Skip to content

fix(agent): offer the shell when the user asks for it by name - #4728

Merged
kovtcharov-amd merged 3 commits into
amd:mainfrom
kovtcharov:kalin/shell-explicit-request
Oct 5, 2026
Merged

kovtcharov-amd merged 3 commits into
amd:mainfrom
kovtcharov:kalin/shell-explicit-request

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

"Use your shell tool to run pwd" made the flagship guess the directory instead of running the command (gaia_shell/shell_pwd_basic fails 2/2 on main). The shell was never offered. About 90 tools matched the message semantically, the 29-tool cap decided, and run_shell_command lost its slot to file browsers. Now a tool the user names, or a request only the shell can answer (pwd, working directory, "run git status", "in the terminal"), goes into the tool set ahead of semantic ranking.

This brings back a narrow keyword signal, which the tool-loader plan had removed on purpose. It only adds tools and only fires on explicit asks; the plan doc now says why.

Test plan

  • pytest tests/unit/test_chat_tool_requests.py tests/unit/test_tool_loader_selection.py hub/agents/gaia/python/tests/test_full_tool_bundles.py passes. The flagship test fails with the classifier disabled. test_core_and_bundles_cover_the_flagship_registry_exactly and test_optional_tools_are_present_on_a_full_install fail locally only because Playwright isn't installed; they fail on main too.
  • python util/lint.py --black --isort --flake8 is clean
  • With the real embedder, "Use your shell tool to run pwd…" now selects run_shell_command and get_shell_state (before: neither, run_shell_command skipped at the cap)
  • eval_flagship.yml: gaia_shell/shell_pwd_basic passes, and no category regresses against tests/fixtures/eval_baselines/gaia-flagship/ (especially tool_selection and gaia_shell)
🔍 Technical details
  • New REQUESTED tier in ToolLoader.select(requested_tools=...). It is admitted after CORE and ahead of SKILL. It reuses the SKILL admission loop (now _admit_exact), so it follows the same cap, LRU eviction and per-turn protection. Its log key requested is emitted only when non-empty.
  • The classifier is gaia_agent_chat.tool_requests.requested_tools. It matches an underscored registry name written out, or a shell/working-directory phrase. "Terminal" and "bash" count only when they name the place something runs ("in the terminal"), so "the airport terminal" doesn't fire.
  • Real-embedder scores for the turn-1 message: get_shell_state 0.69, run_shell_command 0.40, threshold 0.20, cap 29.

@github-actions github-actions Bot added documentation Documentation changes tests Test changes agents labels Oct 5, 2026
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions. Merge once the flagship eval comes back clean.

When a user asks for the shell outright ("use your shell tool to run pwd") or asks for the working directory, the agent is now always offered the shell. Before, the 29-tool cap could drop it and the agent guessed the directory instead. The new tier slots into the loader's existing cap and eviction rules, and the old SKILL logic moved into a shared helper without changing what it does. I found no correctness bugs.

  • The eval is the real proof, and it's still unchecked. This changes which tools the model sees each turn, so it counts as an LLM-affecting change under the project rules. Dispatch eval_flagship.yml and confirm gaia_shell/shell_pwd_basic passes with no regression in tool_selection or gaia_shell before merging.

Real-world evidence

N/A: no evidence bundle was produced. This changes agent tool selection, so real-inference proof belongs to the flagship eval on the strix-halo lane, which the PR lists as pending. The PR description reports a real-embedder check: the pwd prompt now selects both shell tools. That result wasn't reproduced here. Everything else in this verdict comes from reading the code, and pytest wasn't available on this runner, so I didn't re-run the tests either.

🔍 Technical details

🟡 Important

  • Eval gate pending (hub/agents/chat/python/gaia_agent_chat/agent.py:881): this changes the tool subset sent to the model per turn. The test-plan item for eval_flagship.yml is unchecked. Compare against tests/fixtures/eval_baselines/gaia-flagship/ and list PASS→FAIL and FAIL→PASS separately. That baseline is a single run, so re-run any lone flip before trusting it.

🟢 Minor

  • Stale precedence line (src/gaia/agents/base/tool_loader.py:31-32): the SKILL bullet still says "after CORE … (precedence CORE > SKILL > SEMANTIC)", but REQUESTED now sits between CORE and SKILL.
      tool names via ``select(skill_tools=...)``. Admitted **after CORE and
      REQUESTED, ahead of semantic** (precedence ``CORE > REQUESTED > SKILL >
      SEMANTIC``), cap-bound (NOT
    
  • Some ordinary questions trigger the shell signal (tool_requests.py:22-41): \bcommand[- ]line\b and \bworking\s+directory\b match conceptual questions like "how do I parse command-line args in Python?" or "what does os.getcwd return as the working directory?". Negations like "don't use the shell" match too. The tier only adds tools, so this is low-risk. At the cap, though, each false hit evicts an LRU tool and changes the tool list mid-session. A few negative cases in test_ordinary_requests_ask_for_nothing would pin down the intended boundary.
  • A tool named in a negation counts as a request (tool_requests.py:57): "don't call run_shell_command" still admits it. This is fine as a design choice, but a one-line note in the docstring would stop someone "fixing" it later.

Strengths

  • The SKILL loop moved into _admit_exact without changing behaviour: same dedupe, protection for tools named again, LRU eviction, and skip at the cap. REQUESTED follows the exact same rules.
  • The log payload is unchanged when nothing is requested (requested key only when non-empty), and test_requested_signal_absent_emits_no_key pins that down.
  • The flagship test checks the cap is actually full ("run_shell_command" not in unrelated) before asserting the fix. Without that check, the test could pass without proving anything.
  • The classifier only returns names that exist in the registry, so profiles without shell tools are unaffected. The "terminal"/"bash" place-of-execution rule and its negative cases ("airport terminal", "in a nutshell … bash scripting") are well thought through.

kovtcharov and others added 2 commits October 5, 2026 08:14
"Use your shell tool to run pwd" got an answer guessed from nowhere: about 90
of the flagship's tools cleared the semantic threshold for that message, the
29-tool cap decided, and run_shell_command (score 0.40) was skipped in favour
of file browsers. The agent never had the shell to call.

Tools the user's message explicitly asks for — a tool name written out, or a
request only the shell can answer (pwd, working directory, "run git status",
"in the terminal") — are now admitted ahead of recalled-skill and semantic
candidates, with the same cap and eviction rules as the skill tier.
… test

test_shell_is_offered_when_the_user_asks_for_it built its GaiaAgent
without dynamic_tools=True, so the loader was never constructed and
reset_session() crashed on None in CI.

tests/unit/test_chat_tool_requests.py also needed an entry in
util/test_lane_allowlist.yml's module_skips — it importorskips
gaia_agent_chat, which the generic unit-tests lane doesn't install,
and the lane-coverage gate failed without the allowlist reason.
@kovtcharov-amd
kovtcharov-amd force-pushed the kalin/shell-explicit-request branch from 972a4b2 to bb61208 Compare October 5, 2026 15:24
The allowlist already pointed at test_chat_agent.yml, but the file was
never added to its pytest invocation or path triggers, so
check_test_lane_coverage.py flagged the entry as stale.
@github-actions github-actions Bot added the devops DevOps/infrastructure changes label Oct 5, 2026
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 5, 2026
Merged via the queue into amd:main with commit 22e66b2 Oct 5, 2026
@kovtcharov-amd
kovtcharov-amd deleted the kalin/shell-explicit-request branch October 5, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents devops DevOps/infrastructure changes documentation Documentation changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants