Skip to content

fix: [5424] return the cwd in the exec tool's response so that the model is not lost after subsequent calls #5667

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 14, 2025

Conversation

chris-garrett
Copy link

@chris-garrett chris-garrett commented Jul 13, 2025

Related GitHub Issue

Closes: #5424

Alternative to Roo generated PR:

#5425

Roo Code Task Context (Optional)

N/A

Description

This PR supplements Eric's work here 1a1432d#diff-52d2e5d95f9e18aa360cbc9e8b3b2577d268fef4333cd19ae420ad16b0be8ffd by making sure the current working directory is in the response. This was his clear intent as stated in the commit message. It's possible this was missed or changed since Mar.

This change allows the model to make the right decision when navigating a project on subsequent tool calls. When this is not in pace the model is lost and will burn turns/tokens/time trying to brute force and then finally discover where the terminal currently is. Using Claude this can take at a minimum 3 extra turns. With lesser models like Devstral 2505 it can take 5+.

Test Procedure

I have a small rust project with a library and a cli. At the root ask:

build the cli project

Then ask

build the lib project

This will create a second terminal. Continue alternating between projects and Roo will just reuse the terminal for that task. For example if I ask run tests in cli when the active terminal is in lib, it will switch to the terminal for cli and run there.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

N/A

Documentation Updates

  • No documentation updates are required.
  • Yes, documentation updates are required. (Please describe what needs to be updated or link to a PR in the docs

Additional Notes

Discord thread https://discord.com/channels/1332146336664915968/1389759053600657468

Get in Touch

GumBoots


Important

Fixes executeCommand to include current working directory in response, ensuring model retains directory context, with tests added for various scenarios.

  • Behavior:
    • Fixes executeCommand in executeCommandTool.ts to include current working directory in response.
    • Ensures model retains directory context across tool calls.
  • Tests:
    • Adds executeCommand.spec.ts to test cwd handling in executeCommand.
    • Tests include scenarios for VSCode and Execa terminals, custom cwd, and command execution states.

This description was created by Ellipsis for 58f7ad1. You can customize this summary. It will automatically update as commits are pushed.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 13, 2025
@chris-garrett chris-garrett marked this pull request as ready for review July 13, 2025 21:08
@chris-garrett chris-garrett requested review from mrubens, cte and jr as code owners July 13, 2025 21:08
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Jul 13, 2025
Copy link
Collaborator

@mrubens mrubens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change makes sense to me. Not sure I 100% follow how much of the terminal getting confused it will solve, but seems like a step in the right direction! Thank you for the contribution and digging in here.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 14, 2025
@mrubens mrubens merged commit a163053 into RooCodeInc:main Jul 14, 2025
28 checks passed
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jul 14, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Jul 14, 2025
@chris-garrett
Copy link
Author

Not sure I 100% follow how much of the terminal getting confused it will solve

Can you explain what you mean? Did I miss something?

fxcl added a commit to tameslabs/Roo-Cline that referenced this pull request Jul 16, 2025
* main:
  fix: Resolve confusing auto-approve checkbox states (RooCodeInc#5602)
  fix: prevent empty mode names from being saved (RooCodeInc#5766) (RooCodeInc#5794)
  Format time in ISO 8601 (RooCodeInc#5793)
  fix: resolve DirectoryScanner memory leak and improve file limit handling (RooCodeInc#5785)
  Fix settings dirty check (RooCodeInc#5779)
  feat: increase Ollama API timeout values and extract as constants (RooCodeInc#5778)
  fix: Exclude Terraform and Terragrunt cache directories from checkpoints (RooCodeInc#4601) (RooCodeInc#5750)
  Move less commonly used provider settings into an advanced dropdown (RooCodeInc#5762)
  feat: Add configurable error & repetition limit with unified control (RooCodeInc#5654) (RooCodeInc#5752)
  list-files must include at least the first-level directory contents (RooCodeInc#5303)
  Update evals repo link (RooCodeInc#5758)
  Feature/vertex ai model name conversion (RooCodeInc#5728)
  fix(litellm): handle baseurl with paths correctly (RooCodeInc#5697)
  Add telemetry for todos (RooCodeInc#5746)
  feat: add undo functionality for enhance prompt feature (fixes RooCodeInc#5741) (RooCodeInc#5742)
  Fix max_tokens limit for moonshotai/kimi-k2-instruct on Groq (RooCodeInc#5740)
  Changeset version bump (RooCodeInc#5735)
  Add changeset for v3.23.12 patch release (RooCodeInc#5734)
  Update the max-token calculation in model-params to use the shared logic (RooCodeInc#5720)
  Changeset version bump (RooCodeInc#5719)
  chore: add changeset for v3.23.11 patch release (RooCodeInc#5718)
  Add Kimi K2 model and better support (RooCodeInc#5717)
  Fix: Remove invalid skip-checkout parameter from GitHub Actions workflows (RooCodeInc#5676)
  feat: add Cmd+Shift+. keyboard shortcut for previous mode switching (RooCodeInc#5695)
  Changeset version bump (RooCodeInc#5708)
  chore: add changeset for v3.23.10 patch release (RooCodeInc#5707)
  Add padding to the index model options (RooCodeInc#5706)
  fix: prioritize built-in model dimensions over custom dimensions (RooCodeInc#5705)
  Update CHANGELOG.md
  Changeset version bump (RooCodeInc#5702)
  chore: add changeset for v3.23.9 patch release (RooCodeInc#5701)
  Tweaks to command timeout error (RooCodeInc#5700)
  Update contributors list (RooCodeInc#5639)
  feat: enable Claude Code provider to run natively on Windows (RooCodeInc#5615)
  feat: Add configurable timeout for command execution (RooCodeInc#5668)
  feat: add gemini-embedding-001 model to code-index service (RooCodeInc#5698)
  fix: resolve vector dimension mismatch error when switching embedding models (RooCodeInc#5616) (RooCodeInc#5617)
  fix: [5424] return the cwd in the exec tool's response so that the model is not lost after subsequent calls (RooCodeInc#5667)
  Changeset version bump (RooCodeInc#5670)
  chore: add changeset for v3.23.8 patch release (RooCodeInc#5669)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Subsequent commands run in wrong directory if llm uses cd <dir>
3 participants