Repository navigation
fix(agent): offer the shell whenever the session works in a code repository - #4376
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.
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.
Skill audit
✅ All audited skills cleared the tier they claim. Per-finding detail is withheld here on purpose. Read it in the Security > Code scanning tab, or download the |
Verdict: Approve with suggestions — conditional on the agent evalWhen the session's project resolves to a code repository, the flagship now gets the shell on every turn instead of only when the request happens to sound like one, and the project map stops advertising a shell the turn didn't actually offer. The mechanism is clean: it reuses the root the map already resolved, it's decided once at build time so the prompt prefix stays cache-stable, and the base class default keeps every other agent byte-identical. The one thing blocking a clean merge is not in the code. This changes the tool schema the model receives, which the project requires an agent eval run for, and that run is still outstanding — the author says so plainly and shows the eval is blocked by an unrelated, pre-existing import error in the MCP bridge that also exists on Two smaller things worth a follow-up:
Real-world evidenceAn evidence bundle ran and is substantive. It boots the flagship sidecar from this branch: while the identical request against a plain directory produced zero What it does not show, and says so: the actual 🔍 Technical details🟢 The workspace CORE tool eats a dynamic slot the budget comment still promises
Either grow the cap with the workspace set: def _resolve_dynamic_tools_max(self) -> int:
raw = os.getenv("GAIA_DYNAMIC_TOOLS_MAX")
if raw is None:
return int(self.config.dynamic_tools_max) + len(self._workspace_core_tools())
...or leave the number and amend the comment to say the dynamic share is 13 outside a repository and 12 inside one. (If you take the first option, note 🟢
|
Resolves the changelog conflict between this branch's "shell, always on inside a code repository" entry and main's "sleep, always on" entry by keeping both as separate bullets.
|
Rebased onto main (the branch had drifted into a real conflict) and picked up the two review nits while resolving it — merge is clean now, but the eval gate is still open.
On the eval: Full tool suite ( |
One conflict: main's #4376 added `_workspace_core_tools` at the same anchor where #4114 added `_profile_registers_tools`. Unrelated methods, both kept. Re-verified rather than assumed after the merge: the generator still derives 94 tools (CORE 16 + 24 bundles), fast prefill is still 2,860, and the default moved 17,652 -> 17,620, which the guide and CHANGELOG now say. main's 4a0a069 raised the tool-description budget to 500 chars, so the read_tool_output overage this branch inherited is gone — `util/lint.py --all` is now fully green.
…profile pins #4038's docstring trim dropped "call it directly as a tool instead" from run_python's no-tool-access warning, leaving only what NOT to do without the actionable alternative -- restored within the same char budget. Also refreshes test_tool_loader_token_budget.py's doc-profile pins: the tool count drifted from 39 to 44 (and char/token counts with it) as today's merges (#3122, #4021, #3335, #3791, #4376, and others) each added or exposed a doc-profile tool. Re-measured all five values fresh rather than estimating.
Merging main's independent amd#4376 (shell offered whenever the session works in a repo) reintroduced an older, simpler copy of this method right after the one this branch already had -- Python keeps only the second definition, so it silently overrode the version that also puts delegate_task and the session-findings ledger tool in core when delegation is on. hub/agents/gaia/python/tests/test_delegate_wiring.py caught it (delegate_task/session_findings missing from tool_loader._core).
Replicates #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_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.
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:
_shell_tool_offered()reads_active_tool_filterand falls back to the registry.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
python -m pytest hub/agents/gaia/python/tests/test_shell_in_code_repos.py tests/unit/test_project_map.py -q— 91 passedpython -m pytest hub/agents/gaia/python/tests/ -q— 507 passed, 0 failedpython -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 cleanmaincheckoutpython util/lint.py --black --isortcleangaia eval agent --category tool_selection— could not run here, see belowImportant
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_readPASS 9.8/10). But the eval only runs against this checkout ifPYTHONPATHis pinned to it — otherwise the installedgaiaresolves to an unrelated worktree and measures the wrong code. With the path correctly pinned, every scenario returnsINFRA_ERRORbecause the eval's MCP bridge cannot start:src/gaia/mcp/servers/agent_ui_mcp.py:282doesfrom mcp.server import MCPServer, but the installedmcppackage exportsServer, notMCPServer. That file is untouched by this PR and the same import is on currentmain, so the eval is blocked by a pre-existing incompatibility, not by this change.