Repository navigation
Python: [BREAKING] Allowlist caller fields in Foundry Responses hosting - #9661
Darren Cohen (dargilco) wants to merge 15 commits into
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>
…ackages' conftest Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| _NATIVE_FIELDS = frozenset(CreateResponse.__annotations__) | ||
| # Trusted tool-execution context that callers must not supply. Unlike ``_HOST_CONTROLLED_FIELDS``, a developer | ||
| # ``prepare_options`` hook may still set it from trusted host state. | ||
| _CALLER_REJECTED_FIELDS = frozenset({"additional_function_arguments"}) |
There was a problem hiding this comment.
what I miss in this, is the broader discussion on if WE should decide which options get rejected or the creator of the server, I think it should be the latter (which is also how the hosting packages work), because there are good reasons to either allow this to be passed through and handled in your code (maybe the user adds a middleware that unpacks this so that non-openAI responses parameters can be passed through through this mechanism. and in general so that as the creator of the server you can enhance the behavior over the existing protocol without having to go fully into the native mode or skipping FHA altogether.
There was a problem hiding this comment.
Thanks for your comment Eduard van Valkenburg (@eavanvalkenburg)! In the spirit of "secure by default", I'm wondering if additional_function_arguments should be rejected by default, but a hosted agent library setting can allow it for advanced developers where the author "opts-in" by overriding this default. And we clearly document the risk associated with opting in. Let's discuss further.
There was a problem hiding this comment.
yeah, I think in general we can do something like that for all the options, there are also instances where it makes sense to reject, alter or allow through any of the other arguments defined by the OAI responses spec and the developer should have control, and I fully agree with a defensive posture as default. Darren Cohen (@dargilco)
…ing-reject-caller-tool-context

The PR was replaced by this new PR: #10348
Motivation & Context
ResponsesHostServerconverts caller-supplied Responses fields into Agent Framework run options. Previously, fields not explicitly treated as host-controlled could flow through to the agent, includingadditional_function_argumentssupplied at the root or insideextra_body. That option can populateFunctionInvocationContext.kwargsfor tool calls, allowing caller-provided values to override trusted tool context. A field-specific rejection does not protect against other unrecognized or newly added request fields.This change makes the Responses boundary fail closed by default: only explicitly allowed top-level fields and
extra_bodykeys reach the run options. Developers can still opt individual fields in through the existingprepare_optionshook. This PR changes the Responses endpoint; Invocations and direct Agent Framework run APIs are unchanged.Description & Review Guide
extra_bodykeys. The allowlists are exposed as read-onlyfrozensetconstants fromagent_framework_foundry_hosting:null. The same check applies to regular-agent Responses requests, legacyWorkflowAgentrequests, and native workflow requests. A rejected request fails before the agent or workflow runs; a rejected approval resume does not consume the pending approval.extra_bodyuse different lists because they have different roles. Native request fields are translated to Agent Framework option names (includingmax_output_tokenstomax_tokensandparallel_tool_callstoallow_multiple_tool_calls); allowed flattenedextra_bodyvalues overlay translated options. Unlisted-name collision checks prevent an allowed alias from authorizing a separate unlisted caller field.prepare_optionshook can opt an unlisted field into a request by returning it as a run option. Host-controlled fields remain prohibited. This hook is available for regular agents and native workflows, but not legacyWorkflowAgenthosting. Applications opting in caller-derived data must validate it before using it as trusted context.nullvalues, alias collisions, hook opt-ins, and approval resume.instructionsandtoolsare not in the default lists. Applications that need an unlisted field must explicitly handle it throughprepare_optionswhere that hook is supported.modelremains in both default allowlists. This PR does not prevent caller model selection and does not resolve reports specifically about model overrides.Agent.run(..., function_invocation_kwargs=...), and other hosting surfaces are outside this PR's changes.extra_bodymemberships are correct and whether their compatibility impact is intentional.WorkflowAgenthosting are clear and safe.Open Issues
extra_bodyallowlists. Each allowed field is something any caller can control on every request, so the defaults should include only fields that are safe for a caller to set without host validation. Each excluded field is a compatibility cost for clients that send it today. Once a stable release ships, adding fields remains possible, but removing one is a breaking change, so the initial lists should err on the side of being small.modelis the most important example. As implemented,modelremains in both lists, so callers can still choose which model the hosted agent uses, which can affect cost, quotas, capabilities, and safety behavior. Removing it would prevent caller-selected models, but the AgentServer SDK inserts amodelvalue during request normalization (the configured server default or an empty string); any stricter policy must distinguish that SDK-supplied value from a caller-selected model. No decision to disallow models has been made.InvocationsHostServer) needs the same treatment. It currently passes calleroptionstoagent.run(options=...)after checking only a short list of agent-controlled fields, so other options are accepted. That includes agent-specific options such as MCP server definitions, hooks, provider endpoints and credentials, and permission or sandbox settings. A matching default allowlist withprepare_optionsopt-in is likely warranted, in a follow-up PR. It should share the decisions above (membership,model, reject vs. drop) so both endpoints behave consistently. Fields such as MCP servers or providers may also need value-level validation, not just name-level allowlisting, when a host intentionally opts them in.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.