Repository navigation
fix(skills): a loaded skill brings the tools it declares - #3903
kovtcharov wants to merge 3 commits into
Conversation
Loading a skill left its declared tools out of the prompt, so every skill-driven task spent an extra round trip on load_tools (e.g. load_skill github-triage followed by load_tools shell) before it could act. The loaded skills' tools_required now feed the tool loader's SKILL signal, ahead of recalled-procedure tools and deduped. A shell:execute:<binary> grant also admits run_shell_command. Unloading a skill drops its contribution, and admission stays cap-bound. Fixes amd#3901
Verdict: Approve with suggestions — but hold the merge until the eval runsThis makes a loaded skill's declared tools show up in the prompt immediately, so the model stops burning a round trip on Two things to settle before merge:
Smaller: one user-facing doc still describes Real-world evidenceN/A — no evidence bundle was produced for this run, and this environment has no pytest available, so I could not re-run the suite myself. The verdict rests on static review plus the test results reported in the PR description. Since the change only alters which tools reach the prompt (no new CLI/API/UI surface), the meaningful proof here is the pending agent eval plus a short transcript of loading a skill and having the next turn use its tools without a 🔍 Technical detailsIssues🟡 Loaded-skill tools are admitted every turn, independent of the skill-body filter (
The asymmetry is the design question: skill bodies are re-selected per turn ( 🟡 Agent eval required before merge — CLAUDE.md lists "tool registration … the JSON tool schema sent to Lemonade" as eval-gated, and this changes the per-turn tool set for every skill-driven task. Already tracked as the unchecked test-plan item; calling it out so it isn't lost. 🟢 Doc drift ( 🟢 "The tools it declares" is narrower than it reads — a skill that provides tools via 🟢 Strengths
|
…stop rotating A loaded skill's tools used to take dynamic tool slots every turn, even on turns its instructions were hidden, and a skill needing more tools than the free slots swapped its own tools in and out each turn. Now only skills whose body renders this turn feed the tool loader (the body filter runs first so it is current), and a requested tool that is already loaded is held for the turn instead of being evicted by the next pick. The shell-tool check reads the skill's live binary grant rather than re-parsing its permissions every turn.
|
A skill's tools now take slots only on turns its instructions are in the prompt. A skill that needs more tools than the free slots keeps the same ones each turn instead of rotating them. The doc and docstring fixes are in, and the eval runs in the self-hosted CI job once a maintainer pushes the branch to amd/gaia. 🔍 Technical detailsAll in
|
|
Heads-up for merge order: #3765 deletes |
|
Merged Heads-up for whoever merges second: this PR edits 🔍 Technical detailsMerge commit only — no hand resolution. Net vs main: 11 files, +261/−22. Tests on the merge result: |
Replicates amd#3903 (kovtcharov/gaia fork, push access blocked) onto a branch this session can push to. Loading a skill used to leave the tools it declares out of the prompt, so the model had to spend an extra round trip on `load_tools` before doing anything. In a 168-run benchmark, `load_skill github-triage` was followed by a manual `load_tools shell` in almost every run (45 calls), and some runs failed before they got there. Now a skill's declared tools are admitted on every turn its instructions are in the prompt. That includes the shell tool whenever the skill grants a CLI such as `gh`, even if the skill forgot to list it. A skill whose instructions are hidden this turn, or that was unloaded, holds no tool slots. Admission stays under the loader's existing tool cap. A skill that needs more tools than the free slots keeps the same ones each turn instead of rotating them. Tools from procedures recalled from memory still flow in unchanged, after the active skills' tools. Fixes amd#3901 Three things changed during conflict resolution against current main, all forced by amd#3765 landing first: - amd#3765 deleted `tests/unit/test_skill_discovery_integration.py`, which is where the original PR's turn-ordering test lived. It is re-homed into `tests/unit/test_chat_dynamic_tools.py` and now expects `["bodies", "tools"]` — amd#3765 also removed the proactive per-turn skill discovery step the old assertion named. - Main runs the tool filter before the skill-body filter; this PR needs the reverse, because the tool filter admits the `tools_required` of whichever skills are active this turn. The two calls are swapped. - Main independently landed the loader-side half of this fix (a still-named skill tool is held rather than evicted). Main's version is kept — it also reports the tool on every turn it is named, which its own test asserts — and the duplicate the merge produced is dropped. The loader change here is now documentation plus one added regression test. No other content changes. ## Test plan - [x] `pytest tests/unit/test_chat_dynamic_tools.py tests/unit/test_tool_loader_selection.py tests/unit/test_chat_tool_bundles.py tests/unit/test_skill_loader.py` — 105 passed. New tests load the real `github-triage` skill and check the shell tool is admitted, the unload path, a skill hidden by the body filter, a grant-only skill, cap enforcement, and ordering and dedup with recalled procedures. - [x] `pytest tests/unit/test_skill_sets.py tests/unit/test_starter_skills.py tests/unit/test_skill_binary_grants.py tests/unit/test_agent_lazy_skill_prompt.py tests/unit/test_adaptive_skills.py tests/unit/test_skills_consume.py` — 817 passed, 15 skipped. - [x] `pytest tests/unit/test_memory_mixin.py hub/agents/gaia/python/tests/test_skill_prompt_budget.py` — 315 passed. - [x] The re-homed ordering test was mutation-checked: reversing the two calls in `_process_query_impl` makes it fail. - [x] `python util/lint.py --black --isort` clean. - [ ] Agent eval (`gaia eval agent`): this changes which tools reach the prompt, so it needs an eval before merge. Runs in the self-hosted CI job now that the branch is on amd/gaia. --------- Co-authored-by: Kalin Ovtcharov <[email protected]> Co-authored-by: Ovtcharov <[email protected]>
|
Replicated as #4369 — fork push access (kovtcharov/gaia) was revoked mid-review, so this PR could no longer be refreshed against main. #3765 landed first, so three things changed: the ordering test moved out of the deleted |
amd#4021) When the agent loaded a skill partway through a turn, the skill's instructions reached the prompt but its tools didn't reach the tool list until the next turn. After loading github-triage, whose recipe is "run every GitHub command through `run_shell_command`", the agent had no shell tool. It ran `gh` through `run_python` instead, in all 3 benchmark tasks that loaded the skill (9 calls). For a user, that means an approval prompt for every GitHub read, where the skill's grant needs none. Loading a skill now makes its tools callable on the very next step. ## Test plan - [ ] `python -m pytest tests/unit/test_skill_tools_same_turn.py` passes. On main the two reproducing tests fail. - [ ] Agents without a per-turn tool subset are unchanged (`test_no_tool_subset_stays_no_tool_subset`). - [ ] A required tool the agent doesn't have is not added (`test_a_required_tool_this_agent_lacks_is_not_invented`). <details> <summary>🔍 Technical details</summary> `Agent.load_skill` now adds the skill's `tools_required` and its own namespaced tools to an active `_active_tool_filter`. It goes through `_apply_tool_filter`, the same path the `load_tools` escape hatch uses mid-turn, so both render paths pick it up on the next model call. This covers a fresh load and a reload of an already-loaded skill. amd#3903 admits active skills' `tools_required` at the next turn's selection. This PR covers the turn the skill was loaded in, and the two compose. The helper is module-level because five test stubs borrow `Agent.load_skill` onto plain classes. </details> --------- Co-authored-by: Kalin Ovtcharov <[email protected]> Co-authored-by: Kalin Ovtcharov <[email protected]>
Loading a skill used to leave the tools it declares out of the prompt, so the model had to spend an extra round trip on
load_toolsbefore doing anything. In a 168-run benchmark,load_skill github-triagewas followed by a manualload_tools shellin almost every run (45 calls), and some runs failed before they got there. Now a skill's declared tools are admitted on every turn its instructions are in the prompt. That includes the shell tool whenever the skill grants a CLI such asgh, even if the skill forgot to list it. A skill whose instructions are hidden this turn, or that was unloaded, holds no tool slots.Admission stays under the loader's existing tool cap. A skill that needs more tools than the free slots keeps the same ones each turn instead of rotating them. Tools from procedures recalled from memory still flow in unchanged, after the active skills' tools.
Fixes #3901
Test plan
pytest tests/unit/test_chat_dynamic_tools.py: new tests load the realgithub-triageskill and check the shell tool is admitted, the unload path, a skill hidden by the body filter, a grant-only skill, cap enforcement, and ordering and dedup with recalled procedurespytest tests/unit/test_tool_loader_selection.py tests/unit/test_chat_tool_bundles.py tests/unit/test_skill_loader.py tests/unit/test_skill_sets.py tests/unit/test_starter_skills.py tests/unit/test_skill_binary_grants.py tests/unit/test_agent_lazy_skill_prompt.py tests/unit/test_memory_mixin.py tests/unit/test_skills_consume.py tests/unit/test_skill_discovery_integration.pyall pass, including an over-cap skill request that stays stable across turnsgaia eval agent): runs in the self-hosted CI job once the branch is pushed to amd/gaia. This changes which tools reach the prompt, so it needs an eval before merge.