Skip to content

Drop local approval controls from the Responses API input - #12

Merged
shibayan merged 1 commit into
masterfrom
drop-local-approval-controls
Aug 6, 2026
Merged

Drop local approval controls from the Responses API input#12
shibayan merged 1 commit into
masterfrom
drop-local-approval-controls

Conversation

@shibayan

@shibayan shibayan commented Aug 6, 2026

Copy link
Copy Markdown
Member

A local tool's approval is resolved in-process, so the provider never issued a matching MCP approval item. Serializing one produced an orphaned mcp_approval_request (server_label: null) or an mcp_approval_response referencing an id the API never saw. The function-calling loop already strips these before the provider sees them, so the hole was the raw OpenAIChatClient path — and FoundryChatClient, which wraps it.

Both cases in toResponsesInput now gate on isHostedApproval, the same server_label test the loop layer uses. Mirrors the upstream Python fix (microsoft/agent-framework#7462), which also documented the hosted/local boundary in the function-calling-loop spec.

The existing hosted round-trip test built its approval response without server_label on the wrapped call; approvalResponse() copies the request's call verbatim, so a real hosted decision always carries it. The test now uses that shape — the same update the upstream fix applied to its own existing test.

Test plan

  • New cases: a local approval request/response pair serializes to zero input items, in both stateless and service-storage modes; a hosted pair still round-trips as mcp_approval_request / mcp_approval_response.
  • Negative control: with the gate reverted, the new cases fail (measured).
  • pnpm check passes.

🤖 Generated with Claude Code

A local tool's approval is resolved in-process, so the provider never
issued a matching MCP approval item. Serializing one produced an
orphaned mcp_approval_request (server_label: null) or an
mcp_approval_response referencing an id the API never saw. The
function-calling loop already strips these before the provider sees
them, so the hole was the raw OpenAIChatClient path (and
FoundryChatClient, which wraps it).

Both cases in toResponsesInput now gate on isHostedApproval, the same
server_label test the loop layer uses. Mirrors the upstream Python fix
(microsoft/agent-framework#7462).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@shibayan shibayan self-assigned this Aug 6, 2026
@shibayan shibayan added the enhancement Usage: [PRs], Target: new functionality or improvements; issues use the Feature issue type label Aug 6, 2026
@shibayan
shibayan requested a review from Copilot August 6, 2026 07:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a wire-format edge case in the OpenAI Responses API adapter where local (in-process) tool approvals could be serialized as MCP approval items, producing orphaned mcp_approval_request / mcp_approval_response entries that the provider never issued or recognized. The change aligns toResponsesInput with the framework’s existing hosted-vs-local approval boundary (isHostedApproval) and updates tests to reflect the real hosted approval shape.

Changes:

  • Gate function_approval_request and function_approval_response serialization in toResponsesInput on isHostedApproval, preventing local approvals from being emitted as MCP wire items.
  • Add regression tests ensuring local approvals serialize to zero input items in both stateless and service-storage modes, while hosted approvals still round-trip on the wire.
  • Update the hosted approval round-trip test to include server_label on the approval response’s functionCall, matching the behavior of approvalResponse().

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/openai/src/to-openai.ts Filters approval request/response items so only hosted approvals are serialized into Responses API input.
packages/openai/src/to-openai.wire-fallbacks.test.ts Adds coverage for local vs hosted approval serialization boundaries across stateless and service-storage modes.
packages/openai/src/hosted-tools.test.ts Fixes the hosted approval round-trip test fixture to include server_label on the response call.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@shibayan
shibayan merged commit ec6b145 into master Aug 6, 2026
6 checks passed
@shibayan
shibayan deleted the drop-local-approval-controls branch August 6, 2026 07:43
@shibayan shibayan added bug Usage: [PRs], Target: bug fixes and regressions; issues use the Bug issue type openai Usage: [Issues, PRs], Target: packages/openai and removed enhancement Usage: [PRs], Target: new functionality or improvements; issues use the Feature issue type labels Aug 7, 2026
@shibayan shibayan mentioned this pull request Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Usage: [PRs], Target: bug fixes and regressions; issues use the Bug issue type openai Usage: [Issues, PRs], Target: packages/openai

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants