Python: fix(python): preserve replayed approval calls#7326
Conversation
There was a problem hiding this comment.
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_resultsto track pendingcall_ids in message order by adding onfunction_calland removing on non-placeholderfunction_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. |
|
@microsoft-github-policy-service agree |
|
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. |
Motivation & Context
Fixes #7304. A completed function call can share a
call_idwith 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
Related Issue
Fixes #7304
Contribution Checklist