Skip to content

fix(serve): send only the model's tool arguments in needs_confirmation - #5645

Merged
kovtcharov-amd merged 3 commits into
amd:mainfrom
kovtcharov:fix/5361-confirmation-args-contract
Oct 23, 2026
Merged

kovtcharov-amd merged 3 commits into
amd:mainfrom
kovtcharov:fix/5361-confirmation-args-contract

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

A client that approves or denies tool calls by policy saw arguments in needs_confirmation that the model never sent. GAIA folded in its own fields: the folder a shell command runs in, a risk note, and an internal scratch marker. So a rule could match on GAIA's additions instead of on what the model asked to do. Now args is exactly the model's call. GAIA's display extras move to a new optional prompt_context object, and the Agent UI still shows them on the approval card.

Closes #5361

  • Contract: args, args_truncated and prompt_context are now documented the same way in the OpenAPI file, README, SPEC, SKILL, CHANGELOG and the SSE contract spec. The spec's needs_confirmation schema had also been missing several existing fields.
  • This sits in the unreleased contract 2.19, where args was introduced, so there's no separate version bump.

Test plan

  • Translator, relay, permission, shell-prompt, chat/ui, OpenAPI-artifact and server-query suites: 3054 pass
  • Real model, flagship /v1/gaia/query on a local Lemonade (Qwen3.6), git log -1 --output=gitlog.txt: on main, args carried working_directory and _risk_note. On this branch, args is {"command": "git log -1 --output=gitlog.txt"} and the folder and note are in prompt_context.
  • util/lint.py --black --isort --flake8 --pylint passes

A policy client auto-approving gated calls on needs_confirmation `args`
was matching on fields the model never sent: the agent's risk note, its
scratch-folder marker, and the folder it fills in for a shell call. `args`
is now exactly the call's arguments as the model sent them.

- The agent notes the model's arguments on the handler before it asks, and
  the permission_request carries them as `call_args`; the translator emits
  those as `args`. A prompt the agent raises itself (path access) drops only
  the prompt-only keys.
- The folder and risk note move to a new `prompt_context` object, and the
  Agent UI relay folds them back into the card's args, so a relayed prompt
  still shows them.
- The flagship OpenAPI now documents the /query stream, and README, SPEC,
  SKILL, CHANGELOG and the SSE contract spec describe `args`,
  `args_truncated` and `prompt_context` the same way. Lands in the
  unreleased contract 2.19, so no version bump.

Closes amd#5361
… call

A gated write or code call whose prompt matched the model's arguments carried its whole content twice in the Agent UI's permission event. call_args is now sent only when the prompt shows more than the model sent; the translator already falls back to args when it is absent.
@github-actions github-actions Bot added documentation Documentation changes tests Test changes agents labels Oct 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

A client that approves tool calls by policy now sees only what the model actually sent in a confirmation's args. Before this, GAIA mixed in its own fields: the folder a shell call runs in, a risk note, and a scratch marker. Those now arrive in a separate prompt_context object. The Agent UI still shows the folder and risk note, because the relay puts them back for the approval card. Every bundled doc (README, SPEC, SKILL, CHANGELOG, OpenAPI, SSE spec) describes this the same way.

Nothing blocks merge. One small gap: when the agent asks for confirmation without recording what the model sent, a folder GAIA added can still end up in args. Today's main path always records it, so this is narrow. A test that pins that case would stop it from regressing.

Real-world evidence

N/A here: no evidence-bundle.md was produced for this run, and pytest isn't installed on the review runner, so I couldn't run the suites. This verdict rests on reading the code. The PR description reports a real-model /v1/gaia/query run on a local Lemonade (Qwen3.6): on main, args carried working_directory and _risk_note; on this branch, args is {"command": "git log -1 --output=gitlog.txt"} and the folder and note are in prompt_context. That run used the right surface for this change (the HTTP SSE route), and I'm relaying it from the description, not from a run of my own.

🔍 Technical details

Issues

🟢 A host-added folder can still reach args when the call wasn't noted (src/gaia/ui/sse_translation.py:530-538)
_model_call_args falls back to args minus PROMPT_ONLY_ARGS, and that set doesn't include working_directory. If a permission_request arrives without call_args, a folder GAIA added stays in args. folder != call_args.get("working_directory") is then false, so prompt_context doesn't get it either. That happens when a prompt is raised by a path that doesn't call note_call_args, or when an older emitter sends it. In _execute_tool the call is always noted first, so only other confirm paths are exposed. A one-line test that sends a permission_request with a host folder and no call_args would document the intended behaviour, whichever way you want it.

🟢 Name the consumer of call_args in the sidecar emitter docstring (src/gaia/ui/sse_handler.py:1694-1702)
call_args is a new internal key on the source permission_request. Its only reader is CanonicalTranslator._on_permission_request. Naming that in the docstring would stop someone from treating it as a UI-facing field later.

Checked and fine

  • Stale-note risk: note_call_args runs right before confirm_tool_execution, which consumes it at the top. It's also keyed by tool name, so a nested confirm for a different tool can't pick it up (covered by test_a_noted_call_is_used_once_and_only_for_its_tool).
  • The relay drops SCRATCH_ARG on the way back to the UI card. Nothing in src/gaia/ui or the webui reads _scratch_dir, and always_scope already carries the grant decision. No regression there.
  • call_args is sent only when it differs from the prompt args, so large code payloads aren't duplicated on the wire (test_a_noted_call_matching_the_prompt_is_not_sent_twice).
  • The OpenAPI /query response now says text/event-stream with an example, not an empty application/json schema. That fix stands on its own merits.

Strengths

  • The model's arguments are recorded where the call is gated, not rebuilt afterwards. That keeps args exact even when a host's confirmation_args_for_call adds keys.
  • The tests cover the full path: agent → handler → translator (test_the_wire_args_are_only_what_the_model_sent), and the relay round-trip back to the UI card.
  • All six doc surfaces were updated together, and the SSE spec's needs_confirmation schema gained fields that were already on the wire but missing from the spec.

A prompt that arrives without call_args keeps working_directory in args. Only the agent's tool-execution path adds a folder, and it always records the model's call first, so any other folder is the model's own. The docstrings now say so and name the translator as call_args' only reader.
@kovtcharov

Copy link
Copy Markdown
Contributor Author

Good catch to pin. A prompt that arrives without the recorded call now has a test that keeps its folder in args. That's the intended behaviour, because the only code that adds a folder always records the model's call first. In every other case, a folder in a prompt is one the model actually sent, so stripping it would hide part of the real call.

🔍 Technical details
  • working_directory is injected only by confirmation_args_for_call, which runs inside Agent._execute_tool right after note_call_args. The governance reviewer and _engineering_consent pass the model's args to confirm_tool_execution unchanged. The path-access prompt is GAIA-raised and has no folder.
  • Pinned by test_without_a_noted_call_the_folder_is_the_models. _model_call_args now documents why the fallback strips only PROMPT_ONLY_ARGS.
  • The note_call_args docstring names CanonicalTranslator as the only reader of call_args, per the second suggestion.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 23, 2026
Merged via the queue into amd:main with commit 7805046 Oct 23, 2026
45 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the fix/5361-confirmation-args-contract branch October 23, 2026 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents documentation Documentation changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(serve): include the tool call's arguments in needs_confirmation

2 participants