Skip to content

Python: fix(python): preserve replayed approval calls#7326

Closed
HUAN2022A wants to merge 1 commit into
microsoft:mainfrom
HUAN2022A:fix/replayed-approval-call-id
Closed

Python: fix(python): preserve replayed approval calls#7326
HUAN2022A wants to merge 1 commit into
microsoft:mainfrom
HUAN2022A:fix/replayed-approval-call-id

Conversation

@HUAN2022A

Copy link
Copy Markdown

Motivation & Context

Fixes #7304. A completed function call can share a call_id with a later replayed approval request. The previous global deduplication treated the earlier result as answering every occurrence of that id, which restored the request as a third orphaned function call.

Description & Review Guide

  • What are the major changes? Track pending function calls in message order while replacing approval content, and add a regression test for a completed call followed by a replayed call with the same id.
  • What is the impact of these changes? Approval replay no longer produces an unmatched duplicate function call when call ids are reused.
  • What do you want reviewers to focus on? The ordering behavior for reused call ids and the existing placeholder-result handling.

Related Issue

Fixes #7304

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.

Copilot AI review requested due to automatic review settings July 26, 2026 12:10
@HUAN2022A
HUAN2022A temporarily deployed to github-app-auth July 26, 2026 12:10 — with GitHub Actions Inactive
@HUAN2022A
HUAN2022A temporarily deployed to github-app-auth July 26, 2026 12:10 — with GitHub Actions Inactive
@HUAN2022A
HUAN2022A temporarily deployed to github-app-auth July 26, 2026 12:10 — with GitHub Actions Inactive
@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Jul 26, 2026
@HUAN2022A
HUAN2022A temporarily deployed to github-app-auth July 26, 2026 12:10 — with GitHub Actions Inactive
@github-actions github-actions Bot changed the title fix(python): preserve replayed approval calls Python: fix(python): preserve replayed approval calls Jul 26, 2026

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 a Python transcript-rewrite edge case in approval replay handling where a previously completed tool call can reuse a call_id and cause _replace_approval_contents_with_results to incorrectly restore an extra orphaned function_call. The update makes pending-call tracking order-aware so that call-id reuse after completion doesn’t confuse deduplication.

Changes:

  • Update _replace_approval_contents_with_results to track pending call_ids in message order by adding on function_call and removing on non-placeholder function_result.
  • Add a regression test covering a completed call followed by a replayed call + approval request reusing the same call_id.

Reviewed changes

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

File Description
python/packages/core/agent_framework/_tools.py Changes dedup logic to preserve replayed approval calls when call_id is reused after a prior completion.
python/packages/core/tests/core/test_function_invocation_logic.py Adds regression test for the “completed call + replayed approval with same call_id” scenario.

@HUAN2022A

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@eavanvalkenburg

Copy link
Copy Markdown
Member

Thank you @HUAN2022A for investigating the reused-call-id replay case and proposing the ordered pending-call fix. Draft PR #7345 incorporates that scenario and extends it to multiple completed/replayed rounds, placeholders, rejected calls, and exactly-once replay. Closing this PR as superseded so the review can continue on the consolidated change.

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

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: Approval request restores a third function_call when a completed call and a replayed approval pair share one call_id

3 participants