Skip to content

Python: Preserve approval decisions under OpenAI continuation - #7407

Open
eavanvalkenburg wants to merge 1 commit into
microsoft:mainfrom
eavanvalkenburg:python-openai-approval-continuation
Open

Python: Preserve approval decisions under OpenAI continuation#7407
eavanvalkenburg wants to merge 1 commit into
microsoft:mainfrom
eavanvalkenburg:python-openai-approval-continuation

Conversation

@eavanvalkenburg

Copy link
Copy Markdown
Member

Motivation & Context

OpenAI service-side continuation already stores the approval request, but the current serializer drops the new
approval response as well. The service therefore never receives the user's approved or rejected decision.

Description & Review Guide

  • What are the major changes?
    • Continue omitting the already stored function_approval_request.
    • Always serialize the current function_approval_response as mcp_approval_response.
    • Cover approved and rejected decisions with and without service-side storage.
  • What is the impact of these changes?
    • Approval-paused OpenAI Responses runs can resume under previous_response_id or conversation continuation.
    • Stored server-issued request items are still not duplicated.
    • Stateless behavior remains unchanged.
  • What do you want reviewers to focus on?
    • The request-versus-response storage boundary.
    • Approved/rejected payload parity.

Related Issue

Fixes #7125

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 1ee1d250-d1e2-4c6f-8c36-aae0d94fe7a1
Copilot AI review requested due to automatic review settings July 29, 2026 20:10
@agent-framework-automation agent-framework-automation Bot added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python labels Jul 29, 2026
@eavanvalkenburg
eavanvalkenburg marked this pull request as ready for review July 29, 2026 20:12

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.

Pull request overview

This PR fixes OpenAI Responses API continuation under service-side storage by ensuring the user’s tool-approval decision is not dropped during serialization, so approval-paused runs can reliably resume with previous_response_id / conversation_id.

Changes:

  • Update the OpenAI chat client serializer to skip only stored function_approval_request items under service-side storage, while still serializing function_approval_response as mcp_approval_response.
  • Expand unit test coverage to validate both approved and rejected decisions under storage-on vs storage-off behavior.
  • Document the request/response storage boundary and update the function-calling loop spec to reflect the covered scenario.

Reviewed changes

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

File Description
python/packages/openai/agent_framework_openai/_chat_client.py Stops stripping function_approval_response under service-side storage, preserving approval decisions for continuation.
python/packages/openai/tests/openai/test_openai_chat_client.py Adds parameterized test coverage ensuring approval responses are kept (approved/rejected) while requests are omitted under storage.
python/packages/openai/AGENTS.md Documents how approval request vs response behave under service-side continuation and warns about manual history replay.
docs/specs/004-python-function-calling-loop.md Updates required invariants/coverage lists to include service-side approval decision behavior and its regression test.

@github-actions

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/openai/agent_framework_openai
   _chat_client.py137011791%312, 325, 675–679, 687–690, 696–700, 750–757, 759–761, 768–770, 828, 836, 859, 1076, 1135, 1137, 1139, 1141, 1207, 1221, 1301, 1311, 1316, 1359, 1471–1472, 1487, 1760, 1867, 1872–1873, 1956, 1966, 1993, 1999, 2009, 2015, 2020, 2026, 2031–2032, 2112, 2156, 2159–2162, 2176, 2186–2187, 2199, 2241, 2306, 2323, 2326, 2353–2355, 2394, 2411, 2414, 2476, 2483, 2520–2521, 2556, 2594–2595, 2613–2614, 2786–2787, 2805, 2891–2899, 3077, 3092, 3142, 3152–3154, 3181–3183, 3193–3194, 3200, 3215, 3348–3349
TOTAL45842447490% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
9460 34 💤 0 ❌ 0 🔥 1m 58s ⏱️


All clients follow the Raw + Full-Featured pattern (e.g., `RawOpenAIChatClient` + `OpenAIChatClient`).

For Responses API continuation with service-side storage, a prior `function_approval_request` is server-issued and

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.

nit: this is a bit confusing since OpenAI never issues function approval requests. It only has one approval request type for mcp.

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

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: function_approval_response is dropped from the request under service-side storage, so an approval-paused run never resumes

3 participants