Repository navigation
fix(agent): offer the shell whenever the session works in a code repository - #4076
kovtcharov wants to merge 2 commits into
Conversation
…sitory Coding tasks in a repository ran without a shell, because the flagship's tool loader admitted run_shell_command only when the request's wording was close to the tool's description. "Skip gfx90a tests on PRs unless labeled" is not, so every grep and sed went through run_python, one command per call. Shell availability now follows the working context: when the session's project root (the one the project map already resolves) is a code repository, run_shell_command joins CORE for the life of the loader. It is fixed at construction, so the offered prefix is stable from the first turn. Outside a repository selection is unchanged, and the shell's approval gate is untouched.
Request changesThis makes the flagship offer The agent eval hasn't been run. This changes the tool schema the model sees, which is exactly the surface the project requires an eval for, and the test plan's eval item is still unchecked. Unit tests prove the tool is offered; they say nothing about whether the model uses it well, or whether the extra always-on tool crowds out something else. Run the tool-selection category against the committed baseline and paste the comparison. The release note promises this for a path nobody has shown it working on. The changelog entry ships in the npm package, where the agent runs as a long-lived background sidecar and the "project" is taken from whatever directory that background process was first started in — not from where the user is working. Started once from a home directory, it never sees a repository, and the shell never turns on. Please confirm with a real terminal-UI session inside a repo that the shell is genuinely offered, or soften the note to describe the case it actually covers. Real-world evidenceN/A — no evidence bundle was produced for this run, so the verdict rests on static review alone. The PR description carries strong before-state measurements (four TheRock CI-fix tasks; 181 of 276 tool calls wrapping a single 🔍 Technical details🟡 ImportantEval required for a tool-schema change (
python -m gaia.ui.server --port 4200 --host 127.0.0.1 # terminal 1
gaia eval agent --category tool_selection # terminal 2, serially
gaia eval agent --compare \
tests/fixtures/eval_baselines/<model>/scorecard_tool_selection.json \
<printed-output-path>/scorecard.jsonNote the always-on set grows from 16 to 17 in a repo, and CORE counts against The daemon path may never resolve a repository root (
🟢 MinorThe project map can still name a tool the loader isn't offering (
Non-repo test depends on the temp directory's ancestry ( The Strengths
|
An explicit project root pointing at a non-repository directory still rendered "run_shell_command accepts: ..." in the project map, because the map asked the tool registry whether the agent owns the shell rather than the per-turn filter whether it was offered. That is the guaranteed failed call has_shell_tool exists to prevent. Also makes the negative shell test deterministic. It asserted "no repository" by chdir-ing into tmp_path and trusting the upward walk to find nothing before $HOME — on a runner whose TMPDIR sits under a checkout the walk finds a repository and the assertion flips. The no-project case now stubs the root; the non-repository case covers both ways a root is supplied. The npm CHANGELOG promised the behaviour without saying which root it follows. A sidecar's working directory is the daemon's, not the user's, so the entry now names GAIA_PROJECT_ROOT the way SKILL.md section 11 already does.
|
Three of the four review findings held up and are fixed on the branch; the fourth is the eval, which I can't run here.
Still outstanding: the agent eval. This change alters which tools the model is offered and what the system prompt says about them, so it needs a 🔍 Technical details
|
|
Replicated as #4376 on a branch we can push to — fork push access (kovtcharov/gaia) was revoked mid-review, so this PR could no longer be refreshed against main. Same content, rebased onto current main (one import conflict: main renamed |
…sitory (amd#4376) Replicates amd#4076 (kovtcharov/gaia fork, push access blocked) onto a branch this session can push to. No content changes beyond conflict resolution against current main. The flagship worked real repositories without a shell. The tool loader showed `run_shell_command` only when a request sounded like a shell request, and coding requests usually don't ("skip gfx90a tests on PRs unless labeled"). On four TheRock CI-fix tasks it never got the shell, and 181 of its 276 tool calls were `run_python` wrapping a single `grep` or `sed`. Claude Code took about 20 shell calls per task; GAIA took 65–96 calls. Now, when the session's project is a code repository, the shell is offered on every turn. Outside a repository nothing changes, and the shell still asks for approval as before. **Why not just make the shell always-on everywhere:** its schema is about 160 tokens on every call, and most flagship sessions (documents, email, chat) have no use for a shell. Tying it to the workspace spends those tokens only where they pay off. It's decided once, when the agent is built, so the prompt prefix stays cache-stable from turn 1. ## Review status carried over The original review raised four findings. Three were fixed on the branch and I verified each is present in this replication: - The project map no longer names a shell the turn didn't offer — `_shell_tool_offered()` reads `_active_tool_filter` and falls back to the registry. - The non-deterministic "no project root" test was split into a stubbed-root case and an explicit-root case. - The npm changelog now names `GAIA_PROJECT_ROOT` / `GaiaAgentConfig(project_root=...)` instead of implying the shell turns itself on in any repository. The fourth — **the agent eval — is still outstanding and remains a pre-merge gate for a maintainer.** See the note below for how far I got. ## Test plan - [x] `python -m pytest hub/agents/gaia/python/tests/test_shell_in_code_repos.py tests/unit/test_project_map.py -q` — 91 passed - [x] `python -m pytest hub/agents/gaia/python/tests/ -q` — 507 passed, 0 failed - [x] `python -m pytest tests/unit/ -k "tool_loader or full_tool_bundles or dynamic_tool or project_map"` — 191 passed, 2 failed; both failures (`test_harness_runs_and_pins_baseline`, `test_token_baseline_when_tiktoken_available`) reproduce identically on a clean `main` checkout - [x] `python util/lint.py --black --isort` clean - [ ] `gaia eval agent --category tool_selection` — **could not run here**, see below > [!IMPORTANT] > **The agent eval still needs to run on maintainer hardware, and this is a tool-schema change, so it is required before merge.** > > I did attempt it rather than skipping it. Lemonade and the Claude judge both work on this machine, and a scenario completes end-to-end (`known_path_read` PASS 9.8/10). But the eval only runs against *this* checkout if `PYTHONPATH` is pinned to it — otherwise the installed `gaia` resolves to an unrelated worktree and measures the wrong code. With the path correctly pinned, every scenario returns `INFRA_ERROR` because the eval's MCP bridge cannot start: `src/gaia/mcp/servers/agent_ui_mcp.py:282` does `from mcp.server import MCPServer`, but the installed `mcp` package exports `Server`, not `MCPServer`. That file is untouched by this PR and the same import is on current `main`, so the eval is blocked by a pre-existing incompatibility, not by this change. --------- Co-authored-by: Kalin Ovtcharov <[email protected]> Co-authored-by: Kalin Ovtcharov <[email protected]>
The flagship worked real repositories without a shell. The tool loader showed
run_shell_commandonly when a request sounded like a shell request, and coding requests usually don't ("skip gfx90a tests on PRs unless labeled"). On four TheRock CI-fix tasks it never got the shell, and 181 of its 276 tool calls wererun_pythonwrapping a singlegreporsed. Claude Code took about 20 shell calls per task; GAIA took 65–96 calls. Now, when the session's project is a code repository, the shell is offered on every turn. Outside a repository nothing changes, and the shell still asks for approval as before.Why not just make the shell always-on everywhere: its schema is about 160 tokens on every call, and most flagship sessions (documents, email, chat) have no use for a shell. Tying it to the workspace spends those tokens only where they pay off. It's decided once, when the agent is built, so the prompt prefix stays cache-stable from turn 1. The project map already tells the model which commands
run_shell_commandaccepts in a repo. Until now that tool often wasn't offered.Test plan
hub/agents/gaia/python/tests/test_shell_in_code_repos.py: with an embedder that matches nothing, a first turn in a.gitworkspace (explicit root or found from cwd) sendsrun_shell_commandin the nativetools=list. A non-repo workspace doesn't. The two repo cases fail onmain.hub/agents/gaia/python/testssuites: no new failures versusmain. The failures that remain also fail onmain: 4 intest_tool_loader_token_budget.py, plus 3 intest_full_tool_bundles.py/test_gaia_agent.pycaused bysearch_documentationbeing absent in this env.gaia eval agent --category tool_selectioncompared against the committed baseline