From 316f53471b2c20cc6b1b94b8dc514cc03c3cb59b Mon Sep 17 00:00:00 2001 From: Ryan Ward Date: Fri, 18 Sep 2026 21:10:06 -0500 Subject: [PATCH] Clarify persistent shell working directory in agent prompts --- app/src/ai/provider/request_translator.rs | 2 +- app/src/ai/runtime/rig_request.rs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/ai/provider/request_translator.rs b/app/src/ai/provider/request_translator.rs index c415662d..2dec2ad5 100644 --- a/app/src/ai/provider/request_translator.rs +++ b/app/src/ai/provider/request_translator.rs @@ -1718,7 +1718,7 @@ pub fn default_tool_definitions() -> Vec { vec![ ToolDefinition { name: "run_shell_command".to_string(), - description: "Execute a shell command in the user's terminal and return its output. Use for builds, tests, git, package managers, and other shell work. Commands run in the user's actual shell and environment. Set wait_until_complete=false for commands that might run longer than a few seconds; Galaxy will return a command_id that can be monitored with read_shell_command_output.".to_string(), + description: "Execute a shell command in the user's terminal and return its output. Use for builds, tests, git, package managers, and other shell work. Commands run in this conversation's persistent shell and environment, starting in the supplied working directory. Successful cd commands affect subsequent calls in this shell; subshell directory changes do not. Avoid prefixing commands with cd to the directory you are already in, and use pwd only when the current location is uncertain. Set wait_until_complete=false for commands that might run longer than a few seconds; Galaxy will return a command_id that can be monitored with read_shell_command_output.".to_string(), input_schema: serde_json::json!({ "type": "object", "properties": { diff --git a/app/src/ai/runtime/rig_request.rs b/app/src/ai/runtime/rig_request.rs index 6dcd5570..01acccf8 100644 --- a/app/src/ai/runtime/rig_request.rs +++ b/app/src/ai/runtime/rig_request.rs @@ -771,6 +771,9 @@ fn build_system_prompt( prompt.push_str( "## Task Tracking\nUse task tracking only for substantial work with multiple concrete steps, after planning has established those steps or when the user provides an actionable plan. Skip it for simple requests, questions, and exploratory planning. Each task must name a specific change or deliverable with a clear completion condition. Do not create generic workflow items such as 'research the request', 'critique the plan', 'execute the plan', or 'verify the result'. Update tasks only when their actual work is complete; a tool call or model turn alone is not evidence of completion.\n\n", ); + prompt.push_str( + "## Shell Working Directory\nShell commands run in this conversation's persistent terminal session. The supplied working directory is the shell's location when the request was prepared. Start there without a redundant `cd` or `pwd`. Track successful directory changes across tool calls; do not assume later commands reset to the project root. Use `cd` only when the next command needs a different directory, and use `pwd` only when the location is missing or uncertain. A `cd` inside a subshell or separate script does not change the parent shell's directory. Each sub-agent has its own terminal; never assume it shares another agent's directory changes.\n\n", + ); let contexts = inputs.iter().filter_map(AIAgentInput::context).flatten(); let mut environment = Vec::new(); let mut request_time = None;