Skip to content

Python: Foundry Hosting: preserve standard MCP approval identity across continuation #8418

Open

Description

@Jiahui-Gu

Foundry Hosting drops the standard Responses approval_request_id relationship when converting a provider MCP call into an outbound response. Clients consequently cannot identify which approval authorized that call.

Observed behavior

Reproduced with agent-framework-core 1.17.0, agent-framework-foundry-hosting 1.0.0b260910 and azure-ai-agentserver-responses 2.2.0b1. The same emission paths were also inspected at commit 0ad2e44.

  1. The provider MCP call carries approval_request_id in the original item retained by Content.raw_representation.
  2. _OutputItemTracker._open_mcp_call passes server label, tool name and item ID to the response builder, but omits the approval link.
  3. Hosting generates a new outbound ID for mcp_approval_request and stores that ID with the original approval content for incoming decisions. Copying the provider's original approval ID unchanged would therefore be insufficient when the outbound approval has a different ID.

For example: a provider issues approval A, Hosting exposes approval B, and the client approves B. The provider must receive the decision for A. When its subsequent mcp_call refers to A, the outbound call must refer to the corresponding approval B that the client received. Currently that outbound relationship is lost.

Expected behavior

Preserve the explicit approval relationship through incremental events, terminal snapshots, stored history and continuation. Both incoming decisions and outgoing call references must use the appropriate identities for their side of the transport boundary. Do not reconstruct identity from matching names, arguments or output text.

The relationship is defined by the OpenAI Responses MCP contract.

Related SDK change

Azure/azure-sdk-for-python#49037 adds optional approval_request_id support to the MCP builder and preserves it in added/done/terminal output. Hosting still needs to supply the correct outbound approval identity.

Implementation and validation considerations

Confirm whether Hosting should preserve provider IDs or persist an explicit source-to-outbound mapping, including storage scope, collision handling and replay rules. Follow the function-calling loop specification for approval-resume and history changes.

Cover multiple same-name/same-argument approvals, generated outbound IDs, approve/deny, matching call references, restart/replay, and streaming/non-streaming output. This issue concerns existing standard MCP relationships; it does not propose adding a local-function approval field to the protocol.

Activity

  1. added
    pythonUsage: [Issues, PRs], Target: Python
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Sep 16, 2026
  2. changed the title [-]Foundry Hosting: preserve standard MCP approval identity across continuation[/-] [+]Python: Foundry Hosting: preserve standard MCP approval identity across continuation[/+] on Sep 16, 2026
  3. he-yufeng commented on Sep 17, 2026

    @he-yufeng
    Contributor

    I traced this end to end on current main (459fe6e) plus the pinned dependency set, and the drop point is exactly where the report says, with one extra boundary constraint worth naming before anyone picks this up.

    Drop point (verified). _OutputItemTracker._open_mcp_call (python/packages/foundry_hosting/agent_framework_foundry_hosting/_responses.py:1547) builds the outbound call through add_output_item_mcp_call(server_label, name, item_id=...). Nothing downstream of that ever sees an approval link.

    The builder cannot carry the link today. In azure-ai-agentserver-responses 2.2.0b1, ResponseEventStream.add_output_item_mcp_call / OutputItemMcpCallBuilder hardcode the emitted item shape to {type: "mcp_call", id, server_label, name, arguments, status} — approval_request_id exists only on the approval response (client decision) path, not on the call path. This matters for fix shape: patching the incremental event dicts in hosting would leave the terminal snapshot stale, because the stream records items internally as they are emitted and assembles response.completed from that record. The report's own requirement (incremental events AND terminal snapshots AND stored history) rules out the dict-patching route.

    Where the correlation data already lives. On approval emission (_responses.py:1404-1421) hosting saves B -> function_approval_request content in approval storage, so the B side is recoverable. The provider's A arrives on the raw provider item; core Content.from_mcp_server_tool_call has no dedicated field for it, but additional_properties is the preservation channel that survives history serialization (raw_representation does not).

    Fix shape I'd propose, two-sided:

    1. azure-ai-agentserver-responses: add_output_item_mcp_call / the builder accept approval_request_id and plumb it into every emitted item (added, arguments done, completed, done), so the internal record and all snapshots stay consistent.
    2. Core: the conversion that turns provider mcp_call items into Content preserves approval_request_id into additional_properties, so history and continuation round-trip it.
    3. Hosting: at approval emission, also record the reverse alias A -> B (the provider id read off the approval content's raw representation); _open_mcp_call resolves the call's provider-side A to the client-side B and passes B outbound.

    Happy to implement the core + hosting side with regression tests. The one decision I need from the team: does the agentserver builder param land first (bump the floor here after), or would you rather hosting construct the mcp_call events without the builder in the meantime? The first keeps one writer for item shape; the second duplicates builder logic in hosting.

  4. added
    reproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflow
    on Sep 18, 2026
  5. github-actions commented on Sep 18, 2026

    @github-actions
    Contributor

    🤖 Automated triage reproduction notes (agent-authored — trust but verify)

    Agent analysis

    The bug reproduces in python/packages/foundry_hosting/agent_framework_foundry_hosting/_responses.py::_OutputItemTracker._open_mcp_call when an MCP call references provider approval A after Hosting emitted and stored client-facing approval B. The outbound mcp_call lacks approval_request_id. Minimal repro: emit a function approval request through the tracker, capture generated ID B, then emit an MCP call whose raw representation references A and assert its outbound item references B.

    • Failing test: python/packages/foundry_hosting/tests/test_responses.py
    • Files examined: python/packages/foundry_hosting/agent_framework_foundry_hosting/_responses.py, python/packages/foundry_hosting/tests/test_responses.py, python/packages/foundry_hosting/tests/test_state_store.py, python/packages/foundry_hosting/pyproject.toml, python/packages/core/agent_framework/_types.py, python/packages/openai/agent_framework_openai/_chat_client.py
    • Tests run: test_output_item_tracker_preserves_outbound_mcp_approval_identity, test_output_item_tracker_emits_native_refusal_events_for_marked_text, hosted MCP replay and approval persistence tests
    • Reported version: 1.0.0b260910
    • Current version: 1.0.0b260910
  6. added
    foundryUsage: [Issues, PRs], Target: all Foundry integrations
    hostingUsage: [Issues, PRs], Target: all hosting related solutions
    and removed
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Sep 18, 2026
  7. eavanvalkenburg commented on Oct 27, 2026

    @eavanvalkenburg
    Member

    /plan Investigate the smallest correct Python hosted MCP approval-identity fix on current main, coordinating with owner Eduard van Valkenburg (@eavanvalkenburg) and volunteer Yufeng He (@he-yufeng) before implementation assignment. This is preservation of the existing standard MCP approval relationship, not a new local-function approval protocol. Hosting currently stores client-facing approval B with the original content but omits approval_request_id when building outbound mcp_call; provider-side A and client-facing B must remain explicitly correlated across continuation. Respect the stable occurrence identity and content metadata contracts from #8886 and docs/specs/004-python-function-calling-loop.md. Define the durable source-to-outbound identity representation, scope, collision/replay handling and restart/serialization behavior; never infer authority from equal names, arguments or output text, and do not depend on nonserialized raw_representation. Azure/azure-sdk-for-python#49037 is still OPEN, not merged or released: verify builder support and the eventual official dependency floor before claiming availability or bumping requirements. Prefer one authoritative SDK item builder and evaluate dependency-first sequencing rather than patching emitted dicts while terminal snapshots remain stale or duplicating the protocol writer. Compare preserving provider IDs with a scoped persisted alias mapping, accounting for generated IDs and incoming approve/deny decisions. Plan fake-provider streaming/nonstreaming tests covering added/done/terminal output, stored history, same-name/same-argument approvals, collision/mismatch rejection, replay, continuation and serialized restart. The .NET counterpart #8873 is merged but does not establish a Python fix; coordinate parity manually. Report minimal production scope, upstream blockers, compatibility/storage choices and focused test commands before implementation. This is nonminor correctness planning, not implementation approval or a ready-for-implementation decision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

foundryUsage: [Issues, PRs], Target: all Foundry integrationshostingUsage: [Issues, PRs], Target: all hosting related solutionspythonUsage: [Issues, PRs], Target: PythonreproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflow

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions