Skip to content

fix(bash): align tool description with per-call working directory - #44

Merged
Fzkuji merged 1 commit into
mainfrom
fix/bash-cwd-description-43
Sep 16, 2026
Merged

Fzkuji merged 1 commit into
mainfrom
fix/bash-cwd-description-43

Conversation

@Fzkuji

@Fzkuji Fzkuji commented Sep 16, 2026

Copy link
Copy Markdown
Owner

Result

Merged into main as 4bdfca1, after the complete PR CI and Windows install smoke passed. The merge used GitHub's normal PR endpoint with expected head b107fe69591ad3186af086835831f6f81db60fab.

A read-back of main confirms tree b2930cd6b6aec9cabda0c769c4d77a69becee8d5, identical to the tested PR head. Issue #43 is now closed with reason completed.

Fixes #43.

What changed

The report was correct: the Bash description promised working-directory persistence, but the tool deliberately resolves current_worktree_path() and launches a new backend invocation on every call. This PR corrects the model-facing description rather than introducing shared mutable shell state.

  • Each call starts a new shell subprocess in the currently bound agent worktree, or the active backend's default directory when no worktree is bound.
  • cd, exported variables and aliases do not persist between calls.
  • Directory changes must be in the same call as the commands that need them, using syntax supported by the active host shell. Existing absolute-path and quoting guidance remains.
  • Execution, sandbox, permissions, backend selection and timeout behavior are unchanged.

Only two files changed: openprogram/programs/tools/files/bash/prompt.py and the new tests/component/programs/tools/test_bash_cwd.py.

Regression coverage

Five parametrized cases:

  1. Check the description exposed by the actual registered Bash tool and reject the old persistence claim.
  2. Check that every call re-reads the worktree binding, including switching to another worktree and restoring it, starting with either a bound or unbound context (two cases).
  3. Through the real AgentTool, LocalBackend and subprocess runner, verify that standalone cd does not affect subsequent calls, same-call cd handles paths with spaces, exports do not leak, and ordinary local filesystem writes persist. Cover a bound worktree and the backend-default directory (two cases).

The real-shell cases use POSIX syntax and are explicitly skipped on Windows. The description and cwd-routing cases are platform-independent. The shell tests replace only their own sandbox configuration; production sandbox behavior is unchanged.

Completed remote verification

Both workflows completed successfully on the first attempt before merge:

  • CI #2632: all 18 jobs passed, including component/integration/E2E suites, Python 3.11/3.12/3.13 unit suites, coverage, quality/contracts/docs, Web checks/build, Chromium, CLI, Desktop and Windows ARM64 core.
  • Windows install smoke #146: passed.

The component job ran the complete component selection on Ubuntu with Python 3.12.14:

uv run --locked --extra dev python -m pytest -q tests/component
4667 passed, 431 skipped, 1 xfailed

That selection includes the new Bash regression file. Skipped and expected-failing cases are not counted as verified behavior; the quiet suite log does not enumerate individual passing case names.

Local validation was limited to Python AST/syntax, the description assertions with an old-description negative control, and a standard-library shell smoke check. Full project execution results above are from GitHub Actions. Uploaded source files were read back and matched the locally checked Git blob SHAs.

No dependency, protocol, workflow, hook or branch-protection changes. No force push or manual patch-application step was used.

Correct the LLM-facing Bash description: each invocation starts a new shell in the current bound worktree, or the backend default when unbound. Directory changes and shell state do not persist across calls; dependent commands must set their directory in the same invocation using host-compatible syntax.

Keep runtime isolation unchanged. Add registered-description checks, per-call context rebinding/default-cwd coverage, and real LocalBackend POSIX subprocess regressions for cd, exports, paths with spaces and persistent filesystem writes.

Refs #43. Local validation: Python syntax and prompt-contract checks only; full dependency-backed tests are delegated to repository CI.
@Fzkuji
Fzkuji marked this pull request as ready for review September 16, 2026 17:29
@Fzkuji
Fzkuji merged commit 4bdfca1 into main Sep 16, 2026
20 checks passed
@Fzkuji
Fzkuji deleted the fix/bash-cwd-description-43 branch September 16, 2026 17: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.

[Bug]: Bash tool incorrectly claims the working directory persists across calls

1 participant