Skip to content

fix(agentserver): preserve MCP approval request links - #49037

Open
JiahuiGu (Jiahui-Gu) wants to merge 2 commits into
Azure:mainfrom
Jiahui-Gu:fix/mcp-approval-request-link
Open

JiahuiGu (Jiahui-Gu) wants to merge 2 commits into
Azure:mainfrom
Jiahui-Gu:fix/mcp-approval-request-link

Conversation

@Jiahui-Gu

@Jiahui-Gu JiahuiGu (Jiahui-Gu) commented Sep 16, 2026

Copy link
Copy Markdown

Description

MCP call builders currently cannot preserve the standard approval_request_id relationship. Add an optional keyword argument to add_output_item_mcp_call and OutputItemMcpCallBuilder and retain it in added/done items and accumulated terminal response output. Calls without approvals remain unchanged.

This is the AgentServer portion of an end-to-end approval identity issue discovered while validating Inspector. Foundry Hosting also needs to translate or preserve source approval IDs consistently; this change does not claim to fix that producer mapping. The field is defined by the OpenAI Responses MCP contract: https://developers.openai.com/api/docs/guides/tools-connectors-mcp.

33 focused sync/async builder/generator tests pass, including successful and failed calls, terminal output retention, absent links and empty-ID rejection. The optional public API addition is submitted as Draft for design review.

All SDK Contribution checklist:

  • The pull request does not introduce breaking changes.
  • CHANGELOG is updated.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title is clear and informative.
  • The change is contained in one focused commit.

Testing Guidelines

  • Includes test coverage for the change.

B-line scope and dependencies

This is the independent first B-line deliverable. It preserves an existing OpenAI Responses field in both synchronous and asynchronous factories and builders; it introduces no new wire contract. API snapshots and their hash metadata are regenerated with APIView 0.3.31.

It does not depend on microsoft/agent-framework#8418 or Skylight UI changes. Hosting source/wire identity translation is downstream work and remains paused. C-line Inspector E2E proceeds independently and does not require single-card MCP behavior.

@github-actions github-actions Bot added Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. Hosted Agents sdk/agentserver/* labels Sep 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution JiahuiGu (@Jiahui-Gu)! We will review the pull request and get back to you soon.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
7 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
7 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The async API lacks the new parameter, and the committed API snapshot is stale.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds MCP approval-request identity preservation to synchronous response streaming.

Changes:

  • Adds and validates optional approval_request_id.
  • Preserves it across added, done, and terminal output items.
  • Adds focused tests and changelog documentation.
File summaries
File Description
test_mcp_approval_link.py Tests approval-link retention and validation.
CHANGELOG.md Documents the fix.
_event_stream.py Exposes the new synchronous builder argument.
_builders/_tools.py Validates and emits the approval ID.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

name: str,
*,
item_id: str | None = None,
approval_request_id: str | None = None,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in fd2ab09. The async factory accepts and forwards approval_request_id. The same parameterized tests now cover sync/async success and failure, added/done/terminal retention, absent IDs and empty-ID rejection; 33 builder/generator tests pass.

Comment on lines +539 to +540
:keyword approval_request_id: Explicit ID of the approval request for this MCP call.
:keyword type approval_request_id: str | None

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regenerated api.md through APIView 0.3.31 and the repository Export-APIViewMarkdown tool, then generated api.metadata.yml with extract_apiview_metadata.py. It includes sync/async factories and inherited builder signatures. Unrelated model-literal generator churn was excluded; the normalized content hash matches the committed API snapshot. Included in fd2ab09.

Copilot AI review requested due to automatic review settings September 16, 2026 09:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation consistently covers both stream variants, terminal accumulation, validation, tests, and API documentation.

Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

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

Labels

Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. Hosted Agents sdk/agentserver/*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants