fix: preserve public built-in tool declarations in Responses metadata #451
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.47) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.47 · 498 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.372
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #451"
general
weight: 0.35
franciscojavierarceo
summary
fixes #442.
built-in tools are lowered to function schemas before inference, and the model server echoes those schemas back. the public metadata snapshot was only supplied when tool search was active, or when the request declared a shell or async tool. a request declaring
web_search_previewtherefore got this back in its lifecycle snapshots:{"type": "function", "name": "web_search"}
cassettes/parallel_tool_calls/parallel-mixed-gateway-Qwen-Qwen3.5-35B-A3B-FP8-streaming.yamlhas it onresponse.createdandresponse.in_progress, and the nonstreaming sibling carried no declarations at all.three changes:
executor/upstream.rs: always pass the request's public declarations towith_response_metadata. the tool search branch stays first because that path replacesrequest.toolswith the private list. sanitization stays insidewith_response_metadata, so mcp headers and discovered tools still never reach clients.executor/translate/tool_search.rs: insert the declarations when a lifecycle snapshot has notoolskey, instead of leaving the[]default thatcomplete_response_fieldssupplies.cassettes/web_search/web-search-gateway--streaming.yamlandcassettes/images/responses/image-tool-image-gateway-.yamlare recorded turns whose terminal frame has notoolskey even though the request declared tools.executor/translate/context.rs: same fortool_choice, so a gateway default cannot be reported for a client that asked for something else.inference is unchanged. upstream requests still carry the lowered function schemas, and the declarations are reported as the typed public values the client sent rather than openai's normalized defaults.
the gateway relaxes a forced selector to
autobefore the round that answers a tool result (engine/agent_turn.rs:357), so which round is authoritative for a single public response is left to #434.test plan
four new tests, each failing without the change it covers:
cargo test -p agentic-server-core --lib builtin_tool_declarations_stay_public_in_stream_and_json_metadatacoversresponse.created, a terminal frame with both keys missing, and the nonstreaming payload.cargo test -p agentic-server-core --test web_search_tool_test builtin_tool_declarationscovers the streaming lifecycle with the lowered echo, json plus stored retrieval, and a model server that omits the keys.i reverted each production hunk on its own to confirm the tests are load bearing:
| reverted | failing tests |
| --- | --- |
| snapshot gate in
upstream.rs| all four || declaration insert in
translate/tool_search.rs| the omitted-frame test, which returns[]|| selector insert in
translate/context.rs| the unit test, which returnsauto|also ran
cargo fmt -- --check,cargo clippy --workspace --all-targets -- -D warnings,cargo test --workspace(2423 passed), andpre-commit run --all-filesincluding the production file-size check.recording gap
the committed gateway web-search and parallel-tool captures were recorded before this change, so their
response.created/response.completedframes still carry the loweredweb_searchschema. they are kept unchanged as evidence of the original behavior, and the new assertions run against synthetic upstream frames plus replays of those captures.re-recording them so the parity harness asserts the new wire shape needs a live vllm deployment and a working search provider, which this environment does not have. the path for whoever can run it:
crates/agentic-server-core/tests/cassettes/record_web_search_cassettes.shcrates/agentic-server-core/tests/cassettes/record_parallel_tool_call_cassettes.shwithPARALLEL_RECORD_SET=gatewayonce re-recorded,
parallel_tool_calls_test.rsandweb_search_tool_test.rscompare the public declarations inresponse.created,response.completedand the final response against the openai reference directly.