mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: Fix RUN_FINISHED.interrupt to accumulate all interrupts when multiple tools need approval (#4717)
* Fix flow.interrupts overwrite when multiple tools need approval (#4590) Change flow.interrupts assignment to append so that all interrupt entries accumulate when multiple tools require approval in a single turn. Both _run_common.py and _agent_run.py used assignment (=) which caused each new interrupt to overwrite the previous one. Switching to append() ensures RUN_FINISHED.interrupt contains all pending approvals. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add test for streaming path with multiple confirm_changes interrupts (#4590) Add integration test exercising run_agent_stream with multiple predictive tool calls requiring confirmation. Verifies that flow.interrupts.append() correctly accumulates all interrupt entries and they appear in the RUN_FINISHED event. Also confirms FlowState already declares interrupts field with default_factory=list, addressing the AttributeError concern from review. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Apply pre-commit auto-fixes --------- Co-authored-by: Copilot <copilot@github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot
Copilot
parent
cdb51e6a41
commit
94af83680e
@@ -1015,7 +1015,7 @@ async def run_agent_stream(
|
||||
flow.tool_calls_by_id[confirm_id] = confirm_entry
|
||||
flow.tool_calls_ended.add(confirm_id) # Mark as ended since we emit End event
|
||||
flow.waiting_for_approval = True
|
||||
flow.interrupts = [
|
||||
flow.interrupts.append(
|
||||
{
|
||||
"id": str(confirm_id),
|
||||
"value": {
|
||||
@@ -1027,7 +1027,7 @@ async def run_agent_stream(
|
||||
},
|
||||
},
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
# Close any open message
|
||||
if flow.message_id:
|
||||
|
||||
@@ -320,7 +320,7 @@ def _emit_approval_request(
|
||||
)
|
||||
interrupt_id = func_call_id or content.id
|
||||
if interrupt_id:
|
||||
flow.interrupts = [
|
||||
flow.interrupts.append(
|
||||
{
|
||||
"id": str(interrupt_id),
|
||||
"value": {
|
||||
@@ -332,7 +332,7 @@ def _emit_approval_request(
|
||||
},
|
||||
},
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
if require_confirmation:
|
||||
confirm_id = generate_event_id()
|
||||
|
||||
Reference in New Issue
Block a user