Python: Prevent orphaned local approval responses - #7462
Merged
Evan Mattson (moonbox3) merged 2 commits intoAug 4, 2026
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0efaca91-a0a7-46f4-9b81-022385607fe4
Eduard van Valkenburg (eavanvalkenburg)
temporarily deployed
to
github-app-auth
July 31, 2026 14:41 — with
GitHub Actions
Inactive
Eduard van Valkenburg (eavanvalkenburg)
temporarily deployed
to
github-app-auth
July 31, 2026 14:41 — with
GitHub Actions
Inactive
Eduard van Valkenburg (eavanvalkenburg)
temporarily deployed
to
github-app-auth
July 31, 2026 14:41 — with
GitHub Actions
Inactive
Copilot started reviewing on behalf of
Eduard van Valkenburg (eavanvalkenburg)
July 31, 2026 14:41
View session
Copilot stopped reviewing on behalf of
Eduard van Valkenburg (eavanvalkenburg) due to an error
July 31, 2026 14:42
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates OpenAI chat message preparation to distinguish hosted vs local function-approval controls so only hosted approvals are serialized to MCP items (and local approvals remain in-process).
Changes:
- Gate serialization of
function_approval_request/function_approval_responseon whether the approval is “hosted”. - Add regression test ensuring local approval controls are dropped for both storage and stateless requests.
- Update docs/specs to clarify hosted vs local approval behavior and adjust related tests to include hosted markers.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| python/packages/openai/agent_framework_openai/_chat_client.py | Filters approval request/response contents based on hosted-approval detection during message preparation. |
| python/packages/openai/tests/openai/test_openai_chat_client.py | Updates existing tests to mark hosted approvals and adds a new test to ensure local approvals are omitted. |
| python/packages/openai/AGENTS.md | Clarifies hosted vs local approval serialization rules for service-side storage continuation. |
| docs/specs/004-python-function-calling-loop.md | Updates spec table entries to reflect hosted-only serialization and omission of local approvals. |
Contributor
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0efaca91-a0a7-46f4-9b81-022385607fe4
Eduard van Valkenburg (eavanvalkenburg)
temporarily deployed
to
github-app-auth
July 31, 2026 14:50 — with
GitHub Actions
Inactive
Eduard van Valkenburg (eavanvalkenburg)
marked this pull request as ready for review
July 31, 2026 14:58
Eduard van Valkenburg (eavanvalkenburg)
temporarily deployed
to
github-app-auth
July 31, 2026 14:58 — with
GitHub Actions
Inactive
Evan Mattson (moonbox3)
approved these changes
Aug 2, 2026
Evan Mattson (moonbox3)
enabled auto-merge
August 4, 2026 00:52
Giles Odigwe (giles17)
approved these changes
Aug 4, 2026
Tatsuro Shibamura (shibayan)
added a commit
to polymind-inc/agent-framework-js
that referenced
this pull request
Aug 6, 2026
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation & Context
Issue #7125 correctly identified that service-side continuation dropped the current hosted approval response. PR #7407 preserved that response, but the unconditional serializer now emits local
FunctionToolapprovals as MCP approval responses. Because no matching MCP approval request exists for local tools, the provider rejects the request as an orphaned approval and consumes the pending approval.Description & Review Guide
Related Issue
Fixes #7125
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.