Skip to content

fix(bash): honor cwd for backgrounded shell commands - #2900

Open
Fnine59 wants to merge 1 commit into
MoonshotAI:mainfrom
Fnine59:contrib/kimi-bash-cwd-2890
Open

fix(bash): honor cwd for backgrounded shell commands#2900
Fnine59 wants to merge 1 commit into
MoonshotAI:mainfrom
Fnine59:contrib/kimi-bash-cwd-2890

Conversation

@Fnine59

@Fnine59 Fnine59 commented Aug 13, 2026

Copy link
Copy Markdown

Related Issue

Resolve #2890

Problem

The Bash tool prepends cd <cwd> && to the user's shell script. If the first user command is backgrounded with &, Bash backgrounds that entire AND-list, including cd, so later lines silently run in the process's original directory.

What changed

Pass cwd through the process execution boundary in both engine implementations and leave the bash -c input as the user's command. Bash also receives the requested path as its logical PWD, preserving symlinked workspace paths; on Windows the process receives a native cwd while Git Bash receives the corresponding POSIX-style PWD. Relative cwd values continue to resolve from the session working directory using the target platform's path rules.

Added a regression test that backgrounds the first command and verifies the following line remains in the requested directory, a real symlink-workspace test with a stale inherited PWD, and spawn-boundary assertions for both implementations.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 09967cf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 155432823d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/agent-core/src/tools/builtin/shell/bash.ts Outdated
Comment thread packages/agent-core-v2/src/agent/tools/os/bash/bashTool.ts Outdated
@Fnine59
Fnine59 force-pushed the contrib/kimi-bash-cwd-2890 branch from 1554328 to d31244f Compare August 13, 2026 19:07
@Fnine59
Fnine59 force-pushed the contrib/kimi-bash-cwd-2890 branch from d31244f to 09967cf Compare August 14, 2026 02:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bash tool cwd is silently ignored when the command starts with cmd &

1 participant