Skip to content

fix(agent): always load the edit tools so coding requests can change files - #3755

Merged
itomek merged 2 commits into
amd:mainfrom
kovtcharov:claude/fix-edit-tools-core
Sep 15, 2026
Merged

itomek merged 2 commits into
amd:mainfrom
kovtcharov:claude/fix-edit-tools-core

Conversation

@kovtcharov

@kovtcharov kovtcharov commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Ask the flagship to fix a bug, rename a function, or add a feature, and most of the time it was not handed a tool that can change a file. It could read the code but not edit it unless the model noticed and fetched the edit tools itself — and the models that picked the wrong bundle looped until the loop guard stopped them.

The edit tools were not missed by semantic selection; they were matched and then ranked out. The flagship leaves 15 slots for non-core tools, 46 others compete every turn, and bundle pull-in raises every member of a bundle to its best member's score, so whole unrelated cohorts — data tables, RAG indexing, clipboard, code index — landed above them. On seven explicit edit prompts the edit tools made the loaded set twice. Scores on these prompts are too close together (edit tools 0.24–0.38, winners 0.35–0.42) to fix by tuning, so write_file and edit_file now join read_file in the always-on set.

Cost, measured the way test_full_tool_bundles measures it: the always-on floor goes from 3,141 to 3,963 tokens (19.2% → 24.2% of the full registry; the guard is 30%). The capped worst case is unchanged at 5,417 tokens, because the cap already bounds it. The always-on block is part of the stable prompt prefix, so providers with prompt caching bill most of it at the cached rate.

Closes #3752

Test plan

  • Selector re-run against this branch — edit tools are in the loaded set on every edit prompt that previously dropped them (numbers in the thread).
  • pytest hub/agents/gaia/python/tests/test_full_tool_bundles.py tests/unit/test_chat_tool_bundles.py tests/unit/test_chat_dynamic_tools.py tests/unit/test_tool_loader_disambiguation.py — full-profile coverage, cap and token-budget guards pass.
  • 6 local failures are pre-existing and unrelated: identical on origin/main, with byte-identical numbers with and without this change — 2 need search_documentation (npx), 4 are doc-profile token pins, and the doc profile is untouched here.
  • gaia eval agent — required by CLAUDE.md for tool-registration changes.
  • Benchmark A/B, the same battery before and after: coding tasks finished with zero file edits in 18/48 runs before and 9/54 after; load_tools calls 165 → 123. The first after-run was confounded by an unrelated history regression (fix(chat): stop replaying tool calls to the model as "None" #3758), so these numbers come from the re-run with that fixed.

…files

Ask the flagship to fix a bug, rename a function or add a feature, and
most of the time it was not handed a tool that can change a file. The
edit tools were matched by semantic selection but ranked out of the 15
dynamic slots: bundle pull-in raises every member of a bundle to its best
member's score, so whole unrelated cohorts (data tables, RAG indexing,
clipboard, code index) outranked them. On seven explicit edit prompts
they made the loaded set twice. Models that then picked the wrong bundle
looped until the loop guard stopped them.

write_file and edit_file now join read_file in the always-on set. The
cost, measured the way the full-profile budget test measures it: the
always-on floor goes from 3,141 to 3,963 tokens (19.2% -> 24.2% of the
full registry, guard 30%); the capped worst case is unchanged at 5,417
because the cap already bounds it.

Closes amd#3752

Co-Authored-By: Claude Opus 5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Request changes — the fix itself is the right call, but two of its own required checks are still unticked and nothing in the test suite pins the new behaviour.

Making the file-edit tools always available is well diagnosed: they weren't being missed, they were being out-scored by unrelated tool groups, and the scores were too close to fix by tuning. The always-on cost increase is measured and stays inside the existing guard.

Three things to settle before merge:

  • The agent evaluation hasn't been run. Project rules require it for any change to which tools the model is handed, and the PR's own test plan leaves that box unchecked. This is the evidence that matters for this change — unit tests confirm the set, only the eval shows the model behaves better.
  • Nothing stops this from silently regressing. The always-on set is just a list; a future trim could drop the edit tools again and every test would still pass. Add one assertion that pins them, next to the ones that already pin the other must-be-always-on tools.
  • Every turn now has two fewer slots for everything else. The total tool budget didn't move, so the crowding this PR fixes for editing gets slightly worse for every other capability, and the guard that keeps room for two full tool groups now passes with one slot to spare instead of three. Either raise the budget or say the trade-off was measured — the A/B benchmark item is also still unchecked.

Real-world evidence

N/A — no evidence bundle was produced for this run, and the changed surface is model tool-selection behaviour, which the CI lane can't exercise. The PR reports an offline selector re-run and passing unit tests, but the one artifact that would show the user-visible effect — the agent eval against the committed baseline — is listed as not yet run. This verdict therefore rests on static review plus the author's reported numbers.

🔍 Technical details

Issues

🟡 Eval not run for a tool-registration change (hub/agents/chat/python/gaia_agent_chat/tool_bundles.py:196)
CLAUDE.md lists "tool registration" among the surfaces that require gaia eval agent against the committed baseline before merge; the PR's test plan has it unchecked. Growing FULL_CORE_TOOLS changes the tools= payload on every flagship call — exactly the class of change unit tests can't score.

🟡 No test pins the new invariant (hub/agents/gaia/python/tests/test_full_tool_bundles.py:111)
test_full_tool_bundles.py already pins load_tools and load_skill as CORE for precisely this reason. Without the equivalent for the edit tools, #3752 reopens silently the next time someone trims CORE for tokens.

    assert "load_skill" in FULL_CORE_TOOLS
    assert "load_skill" in flagship_registry


def test_file_edit_tools_are_core(flagship_registry):
    """Semantic selection cannot rank editing (#3752) — it must be always-on."""
    assert {"write_file", "edit_file"} <= set(FULL_CORE_TOOLS)
    assert {"write_file", "edit_file"} <= set(flagship_registry)

🟡 Dynamic slots drop 15 → 13 without a cap bump (hub/agents/gaia/python/gaia_agent/agent.py:179)
CORE is admitted unconditionally but is not exempt from max_tools for later admissions — tool_loader.py:358 compares len(self._loaded) (CORE included) against the cap. With dynamic_tools_max=26, CORE 11→13 leaves 13 semantic slots instead of 15, tightening the same contention this PR is fixing for every non-editing capability.

It also eats the headroom guard: test_cap_leaves_room_for_two_whole_bundles needs 13 + 6 (rag_query) + 6 (data/web) = 25 against a cap of 26 — one spare slot, down from three. Either bump the cap to 28 to hold the dynamic budget flat (at a higher capped worst case than the 5,417 quoted), or state in the description that 13 slots was the measured choice. The A/B benchmark in the test plan would settle it.

Nits

🟢 Two comments now state the wrong CORE count (hub/agents/gaia/python/gaia_agent/agent.py:172, hub/agents/gaia/python/tests/test_full_tool_bundles.py:39)
Both say "12 CORE … leaves 14"; it's now 13 and 13. (The 12 was already off by one — CORE was 11 — so this is a good moment to correct both.)

    # 13 CORE (FULL_CORE_TOOLS) + 13 dynamic slots. The inherited 14 was sized
#: slots on its own (GaiaAgentConfig.dynamic_tools_max=26 minus 13 CORE leaves 13).

🟢 The paragraph's closing claim is no longer true, and the new sentence runs into the old one (tool_bundles.py:180)
file_edit is {read_file, write_file, edit_file} — all three are now CORE, so that bundle can never contribute a tool and read_file no longer "pulls its whole cohort in". (Keep the bundle: test_full_tool_bundles.py:142 asserts load_tools is the only CORE member outside every bundle.)

# Always-on set (13 tools). Deliberately a smaller share of the registry than
# the doc CORE, because a general-purpose agent has no single reason to exist:
# memory (recall is relevant to every turn), loop control (protocol-level turn
# signalling), the ``load_tools`` escape hatch, ``load_skill`` for proactive
# skill discovery, two universal entry points -- ``read_file`` and
# ``query_documents`` -- that answer "what is in this file / what do my
# documents say" without a round trip, and the two file-edit tools. Editing is
# always on because semantic selection cannot rank it: on explicit edit
# requests the edit tools lost the dynamic slots to unrelated bundles (#3752).
# Everything else, shell and the web included, is a bundle: it arrives when the
# turn asks for it. ``query_documents`` is a bundle member too, so a
# document-shaped turn pulls its whole cohort in with it; the ``file_edit``
# cohort is now entirely CORE.

🟢 PR description carries a "Generated with Claude Code" footer — CLAUDE.md prohibits AI-attribution in any shipped artifact, PR bodies included. Please strip it.

Strengths

  • The diagnosis is the valuable part: distinguishing "never matched" from "matched then out-ranked", with the actual score ranges (0.24–0.38 vs 0.35–0.42) showing why threshold tuning wouldn't have worked, is the kind of evidence that makes a one-line data change reviewable.
  • Cost is quantified against the guard that actually enforces it (3,141 → 3,963, 24.2% against a 30% ceiling) rather than asserted to be small, and the capped worst case is correctly identified as unchanged.
  • The change is minimal and placed where the invariant lives, with the issue number inline — no new machinery for a problem that was a membership question.

A future trim of the always-on tool set could silently drop write_file and
edit_file again, bringing back coding requests that read code but never change
it. A test now fails if either leaves CORE or the flagship registry.

The comments that sized the dynamic-slot budget said 12 CORE / 14 slots; the
real numbers are 13 and 13. The tool_bundles note no longer claims read_file
pulls its cohort in, since the file_edit bundle is now entirely CORE.

Co-Authored-By: Claude Opus 5 <[email protected]>
@kovtcharov

Copy link
Copy Markdown
Contributor Author

Pushed 6b106a0 with the missing pin and the corrected counts. The dynamic-slot trade-off is intentional and was measured: the cap stays at 26.

  • Regression pin: a new test fails if write_file or edit_file leaves the always-on set or the flagship registry, so a later trim can't quietly bring The flagship agent usually can't edit files on a coding request: edit tools lose tool selection #3752 back.
  • Two fewer slots for everything else: kept on purpose. Running the same benchmark battery before and after, coding tasks that ended with zero file edits dropped from 18/48 to 9/54. load_tools calls also dropped, from 165 to 123. Fewer tool fetches means the smaller dynamic budget didn't push the model into fetching more. The two-whole-bundles guard still passes, with one slot to spare.
  • Stale counts: fixed. CORE is 13 and leaves 13 dynamic slots. The bundles note no longer says read_file pulls its cohort in.
  • Agent eval: not run. This machine can't run gaia eval agent because the judge needs the claude CLI, which isn't installed here. The A/B above is the evidence for how the model behaves. A maintainer with judge access should run the eval before merge.

The "Generated with Claude Code" footer stays: the tooling that opened this PR requires it, which conflicts with CLAUDE.md, so a maintainer should decide whether to strip it.

🔍 Technical details
  • test_file_edit_tools_are_core sits next to the load_tools/load_skill pins in hub/agents/gaia/python/tests/test_full_tool_bundles.py.
  • len(FULL_CORE_TOOLS) == 13 (checked directly). The comments in gaia_agent/agent.py and at MAX_BUNDLE_MEMBERS now say 13 CORE + 13 dynamic slots. The tool_bundles.py paragraph takes your suggested wording, and its overlong line is re-wrapped. The file_edit bundle stays, so test_core_is_subset_of_bundle_union still holds.
  • test_cap_leaves_room_for_two_whole_bundles: 13 + 6 + 6 = 25 ≤ 26, passes.
  • pytest hub/agents/gaia/python/tests/test_full_tool_bundles.py tests/unit/test_chat_tool_bundles.py tests/unit/test_chat_dynamic_tools.py tests/unit/test_tool_loader_disambiguation.py: 64 passed, 2 failed. Both failures are the search_documentation (npx) failures that already happen on main.
  • The A/B numbers come from the re-run after fix(chat): stop replaying tool calls to the model as "None" #3758 was fixed, as the test plan notes.

@kovtcharov

Copy link
Copy Markdown
Contributor Author

The agent eval gate has now run on this PR, together with the other open agent fixes (#3751, #3755, #3758, #3765, #3791) merged onto one branch: no regressions. Every category passes the same scenarios as the unchanged base commit, and no scenario flipped between pass and fail.

🔍 Technical details

Both legs ran on the same machine with local Gemma-4-E4B-it-GGUF at 65536 ctx and the same judge. Base is 70de0502, where these branches left main; the batch is that commit plus the PRs at their current heads.

Category Base Batch Avg score
tool_selection 4/5 4/5 8.4 → 8.8
rag_quality 7/8 7/8 9.4 → 9.4
context_retention 4/4 4/4 9.6 → 9.6
  • Against the committed baseline gemma-4-e4b-d71cd914: known_path_read goes FAIL → PASS, with no regressions.
  • data_vs_recall_disambiguation fails on both legs. Over three runs each the base averages 5.4 and the batch 5.2, and both sometimes answer from RAG chunks instead of calling analyze_data_file. It is a model miss that predates these changes.
  • csv_analysis is INFRA_ERROR on both legs: the scenario still requests the removed data agent, so no turn reaches the model. Pre-existing and unrelated.

@itomek

itomek commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

Ran the unit-test guards this PR's CI never got to. Because it's a fork PR, GitHub queued 23 checks here where a same-repo PR gets 34 — and none of them were Unit Tests, so the drift guard for the file this PR actually changes never executed.

Merged into current main (no conflict) and ran them locally:

pytest tests/unit/test_chat_tool_bundles.py               ->  5 passed
pytest hub/agents/gaia/python/tests/test_full_tool_bundles.py -> 13 passed

Both green, including the regression pin you added. Merging — this is milestone 59's Phase 1A gate and it was the last thing holding it.

🔍 How the gap was spotted

gh pr checks 3755 | grep -ci "unit test" returns 0; the same command on a same-repo PR merged an hour earlier returns 7. gh run list --branch claude/fix-edit-tools-core shows no Unit Tests workflow was ever queued — not even action_required, so there was nothing to approve. Missing set also included CodeQL (all languages), Email Agent Unit Tests, Example Agents Unit Tests, and the Windows integration jobs.

Worth knowing for future fork PRs: mergeStateStatus: CLEAN and a clean gh pr checks are both true while the jobs that matter simply never ran.

@itomek
itomek added this pull request to the merge queue Sep 15, 2026
Merged via the queue into amd:main with commit 1921e1c Sep 15, 2026
23 checks passed
kovtcharov-amd pushed a commit that referenced this pull request Sep 15, 2026
- Rebased onto current main (245 commits since v0.23.0, up from 230).
- Added a What's New bullet for #3331 (read-only email triage on the
  flagship agent).
- Added 3 Bug Fixes bullets for #3755 (edit tools always loaded),
  #3754 (large tool-arg truncation), #3767 (actionable cloud-billing
  error instead of a bare retry prompt).
- Regenerated the Full Changelog against the new range.
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.

The flagship agent usually can't edit files on a coding request: edit tools lose tool selection

2 participants