Repository navigation
Python: [BREAKING] Reject caller-supplied tool execution context in Responses requests - #9661
Conversation
…quests ResponsesHostServer now rejects additional_function_arguments supplied at the top level or in extra_body, including on approval resume, so callers cannot replace host-configured tool context. Developer defaults and prepare_options hooks can still supply trusted values. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🔵 Needs a closer look
The security boundary governing tool context during approval resumes warrants final maintainer review.
2 open issues
What changed in this PR
This PR strengthens the Foundry Responses endpoint’s trust boundary by rejecting caller-supplied tool execution context while preserving developer-controlled configuration.
Changes:
- Rejects
additional_function_argumentsat the request’s top level or insideextra_body, including null values. - Adds regression coverage for streaming, trusted hooks, and approval resumes.
- Documents the breaking behavior and supported ways to supply trusted context.
| File | Description |
|---|---|
python/packages/foundry_hosting/tests/test_responses.py |
Adds HTTP-level context-injection and approval-resume tests. |
python/packages/foundry_hosting/tests/test_request.py |
Tests field rejection and trusted hook configuration. |
python/packages/foundry_hosting/README.md |
Documents the restriction and trusted alternatives. |
python/packages/foundry_hosting/agent_framework_foundry_hosting/_request.py |
Rejects caller-controlled tool context during option translation. |
Review effort: Balanced
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: Findings reported
Scope: full PR (1 commit(s)): e67aef89e000
Model: gpt-5.6-sol
Overview
The change blocks caller-controlled tool context before option hooks, approval consumption, model calls, and tool execution for regular agents and native workflows, with focused coverage for both request locations, response modes, trusted hooks, and approval resume. The remaining gap is the legacy WorkflowAgent Responses path, which bypasses the new validator and can execute a request that the documented endpoint contract says must fail.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
1 verified finding remained after source verification (1 medium) across 1 file. Details are attached to the affected lines below.
Affected areas: python/packages/foundry_hosting/agent_framework_foundry_hosting/_request.py
… module Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… requests Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…rtlib Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ackages' conftest Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Motivation & Context
ResponsesHostServerconverts caller-supplied Responses request fields into Agent Framework run options. Theadditional_function_argumentsoption was not treated as host-controlled, so a caller could supply it as a top-levelfield or inside
extra_body. It was merged over the developer-configureddefault_optionsand becameFunctionInvocationContext.kwargsfor every tool call. Tools and skill resources that read hidden runtime context(for example a tenant or user identifier) could therefore receive caller-chosen values instead of the host's trusted
ones. This also applied when a request resumed a pending tool approval.
The Invocations endpoint already treats this field as agent-controlled. This change applies the same boundary to
the Responses endpoint.
Description & Review Guide
response_run_optionsinagent_framework_foundry_hosting/_request.pynow raises aValueErrorwhen a requestcontains
additional_function_argumentsat the top level or insideextra_body. The existing request-preparationerror handling turns this into a failed response that names the field, before any agent or tool runs. Presence
is rejected even when the value is
null._HOST_CONTROLLED_FIELDS, so a developerprepare_optionshook canstill supply trusted values (for example derived from
request.scope), as canAgent(default_options=...).Agent, function-invocation loop, and tool. They coverthe baseline, both injection locations in streaming and non-streaming mode, hook-supplied trusted context, and
approval resume. The approval test shows that a rejected resume neither runs the tool nor consumes the pending
approval, and that a later legitimate resume runs with the trusted value.
foundry_hostingREADME.additional_function_argumentsthrough the Responses endpoint now fail instead ofoverriding tool context. This is a behavior change for any client that relied on it; trusted values should be set
in agent defaults or a
prepare_optionshook.Agent.run(..., function_invocation_kwargs=...), and the Invocations and nativeworkflow paths are unchanged.
host-controlled fields are silently dropped from Responses requests.
prepare_optionsshould remain able to set this field.ag-ui/agent_framework_ag_ui/_agent_run.py,needs the same boundary. That was not changed or verified here.
Related Issue
Coordinating with maintainers; the issue link will be added here.
AI Assistance
AI assistance details: Implementation, tests, README text, and this PR description were drafted with GitHub Copilot and reviewed by the author.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.