Repository navigation
Python: preserve mixed-pause recovery invariants - #8518
RongJie G (CorgiBoyG) wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Cross-turn equal-result correlation can remain permanently pending, and malformed restored error counters can weaken the configured failure limit.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds reliable recovery for mixed approval/Host pause batches after provider invalidation.
Changes:
- Persists and replays provider outboxes and invocation budgets.
- Improves Host-result correlation and conflict handling.
- Adds specifications, guidance, and regression coverage.
File summaries
| File | Description |
|---|---|
python/packages/core/agent_framework/_tools.py |
Implements outbox recovery, budget restoration, and correlation logic. |
python/packages/core/tests/core/test_function_invocation_logic.py |
Adds recovery and correlation tests. |
python/packages/core/AGENTS.md |
Documents the outbox invariant. |
docs/specs/004-python-function-calling-loop.md |
Updates function-loop requirements. |
docs/decisions/0041-handle-provider-invalidated-responses.md |
Records the invalidation recovery decision. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
cbb86a0 to
01b024f
Compare
|
Copilot review |
|
Closing this PR after full review because it combines two independent recovery problems and the provider-outbox portion needs revised input and streaming-delivery semantics. Please create two new PRs: one narrowly addressing #8573, and a separate draft addressing #8574. Reuse the relevant code and regression tests from this branch, but keep Host correlation separate from the durable outbox protocol; stack the outbox PR only if the correlation fix is a genuine prerequisite. |
Motivation & Context
A mixed batch containing approval-required and Host-owned calls can finish local execution before the provider accepts the result-delivery request. If that request is invalidated, clearing the completed batch immediately loses the only replayable copy even though the approved local tool has already run.
PR #8449 bounded stateless pause-response ownership to user turns and rejected direct conflicting occurrence-identified Host results. This change builds on that merged work and closes the remaining #8436 gaps: stateful identified/id-less correlation, handling of extra Host replays, and recovery when provider result delivery is invalidated.
Description & Review Guide
What are the major changes?
call_idis reused.What is the impact of these changes?
call_idbatches no longer remain pending or forward contradictory/orphaned Host results.What do you want reviewers to focus on?
Related Issue
Fixes #8436
Built on #8449, which has already been merged.
Validation
Run from
python/:uv run pytest packages/core/tests -quv run pytest packages/ag-ui/tests -q(1367 passed, 14 skipped)uv run pytest packages/declarative/tests -quv run pytest packages/foundry_hosting/tests -quv run ruff check packages/core/agent_framework/_tools.py packages/core/tests/core/test_function_invocation_logic.pyuv run ruff format --check packages/core/agent_framework/_tools.py packages/core/tests/core/test_function_invocation_logic.pyuv run pyright packages/openai packages/core/agent_framework packages/core/tests/core/test_function_invocation_logic.py(0 errors, 0 warnings)git diff --checkContribution 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.