Repository navigation
fix(agent): own tool-call markup switches only the session that wrote it - #6272
Conversation
A gateway model that wrote its own tool-call markup once was put on native tool schemas for every later session, through a record in gateway.json. A single DeepSeek reply in its DSML format was enough, so every run after it carried the full schemas (about 12K more tokens per call) and made more model round trips, though DeepSeek otherwise follows the in-text format. - The switch to native calls now lives on the agent and lasts for the rest of that session; nothing is written to gateway.json. Claude-style models that write their own markup from the first reply still switch at once. - The switch is tied to the model that wrote the markup, so changing models mid-session does not carry it over. - gateway.json's own_tool_markup_models is no longer read, and is dropped on the next save, so a machine that already recorded a model recovers.
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 Before this PR, one stray DeepSeek reply in its own tool-call format moved it to native tool schemas for every later session, costing about 12K extra tokens per call. Now the switch lasts only for the session that wrote the markup, and machines carrying the old record recover on their own. The fix is small and well tested, and the evidence below shows it working. One thing to fix before merge:
Real-world evidenceThe evidence stage ran the real An old ( The switch lasts for one session only: The spot-regression checks passed: 🔍 Technical detailsIssues 🟡 CHANGELOG entry for an unrelated, unshipped change ( 🟢 Comment states what isn't there ( Strengths
Eval note: this changes which tool format hosted models get, which is an LLM-affecting path. Per the test plan, the DeepSeek 90-task run and the |
…est (amd#6298) Gateway Claude lost about 8 points on repository work after amd#6272, at 2–3× the cost: GAIA + Opus 5.5 dropped from 84 / 81 to 76 / 71 on 30 tasks under two judges, at $1.49 a task instead of $0.73. Since amd#6272, every gateway session starts on the in-text tool format. Claude follows that format instead of switching to native calls, and on it Claude fabricates tool results in its own reply. Gateway Claude now gets native tool calls from its first request. Other gateway models, such as DeepSeek, are unchanged. **Test plan** - [x] `tests/unit/test_native_tool_policy.py`: `amd.Claude-*` is native from the first request even if a probe recorded otherwise; DeepSeek, local models named after Claude, `amd.Claudeish-*` and `fireworks.claude-*` keep the in-text default. 4 of the new tests fail without the fix. - [x] `tests/unit/agents` plus gateway suites (4617 passed, 56 skipped); black/isort clean - [x] GAIA + Opus 5.5 end to end on 30 repository-work tasks, 2 runs: 79 / 73 and 80 / 78 under the two judges (Claude Code + Opus: 82 / 79), at $0.77 and $0.71 a task and 2.5 min a task, against 76 / 71 at $1.49 and 6.6 min on `main` without the fix - [x] `eval_flagship.yml` smoke passed (local models are untouched) <details> <summary>🔍 Technical details</summary> - On the in-text format, Claude's assistant turns came back as `{"thought": "<tool_response>{…invented file content…}"}`, degenerating into repeated lines. Average assistant message: about 4,100 characters, against about 1,100 when native. - Before amd#6272, a stale `own_tool_markup_models` entry in `gateway.json` happened to keep Claude native. amd#6272 correctly stopped persisting that entry, which exposed the gap. - The check keys on `gateway_claude_upstream_id`, the same test amd#6217 uses to route Claude to the Anthropic route, so the two can't disagree. </details>
…truthfully, add gaia -p --time-limit (amd#6296) When the agent hit its step limit or a loop guard, it stopped without writing the file the user asked for, and sometimes claimed it had. A safety refusal was reported to the model as "the user declined", so it treated GAIA's own limit as the user's decision. After this, a forced stop gets one write-only step for a requested file that doesn't exist yet, and an unwritten file is named in the answer instead of being claimed. Refusals are reported as refusals, a refused delete still guards its target, and `gaia -p --time-limit` lets a headless run wrap up before its deadline. - **Needs a flagship eval before merge.** No system prompt, tool docstring or schema changes, but the model reads new text: the write-before-stop and time-limit prompts, the refusal wording, and a stricter completion gate that can mark more turns incomplete. Run the categories that cover step-cap and loop-guard endings, file deliverables and shell denials. - **`run_python` can now import the project's own code** (`import gaia…` inside a GAIA checkout, and `src/` layouts). Only reaching for an agent tool through `gaia` is still refused. ## Test plan - [x] `pytest tests/unit/agents tests/unit/test_agent*.py` and the touched test files: 5401 passed, 57 skipped - [x] `tests/unit/agents/test_forced_stop_deliverable.py`: 17 passed. The two new tests (existing file gets no rewrite step, instruction not saved to history) each fail with their fix reverted. - [x] Independent review: nothing blocking. Its two medium findings are fixed in the last commit. - [ ] Flagship eval via `eval_flagship.yml`, compared against `tests/fixtures/eval_baselines/gaia-flagship/` <details> <summary>🔍 Technical details</summary> - Rebased onto current main. The one conflict, in `Agent.__init__`, kept both `_own_markup_model` and the time-limit fields. The tool-call markup commit was dropped because it is already on main (amd#6272). - The write step runs only `write_file` / `write_markdown_file` / `write_python_file`, one call per missing file, through `_execute_tool_timed`, so confirmation, policy and read-before-overwrite checks still apply. - A refused redirect or overwrite (`echo x > notes.md`) no longer guards that file unless the refusal names it. This is intentional, and `docs/guides/gaia.mdx` describes it. </details>
Since #6216, a single DeepSeek V4.1 Flash reply in its own tool-call format was enough to put it on native tool schemas permanently, for every later session on that machine. Those sessions then send about 12K more tokens on every call and make more model round trips. The switch to native calls now lasts only for the session where the markup appeared. Nothing is saved, and a machine that already recorded a model recovers on its own.
Test plan
tests/unit/test_native_tool_policy.py, adversarial cases: one stray reply in the model's own format affects only that session; many such sessions are never remembered; an existingown_tool_markup_modelsrecord is ignored and dropped on the next save; changing models mid-session doesn't carry the switch; a session with no model never counts as switched; Claude-style models still switch from their first replytests/unit/agents, gateway and tool-call suites (4844 passed, 56 skipped); black/isort cleanown_tool_markup_modelsis writteneval_flagship.ymlmanual dispatch🔍 Technical details
tools=(first call 22.4K tokens vs. 10.4K on the in-text format)._own_markup_model) and is keyed to the model that wrote the markup.GatewayStateno longer readsown_tool_markup_models, and drops it on the next save.