Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions python/packages/ag-ui/agent_framework_ag_ui/_agent_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,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": {
Expand All @@ -933,7 +933,7 @@ async def run_agent_stream(
},
},
}
]
)

# Close any open message
if flow.message_id:
Expand Down
4 changes: 2 additions & 2 deletions python/packages/ag-ui/agent_framework_ag_ui/_run_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -332,7 +332,7 @@ def _emit_approval_request(
},
},
}
]
)

if require_confirmation:
confirm_id = generate_event_id()
Expand Down
21 changes: 21 additions & 0 deletions python/packages/ag-ui/tests/ag_ui/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,27 @@ def test_emit_approval_request_populates_interrupt_metadata():
assert flow.interrupts[0]["value"]["type"] == "function_approval_request"


def test_emit_approval_request_accumulates_multiple_interrupts():
"""Multiple approval requests in the same turn should accumulate in flow.interrupts."""
flow = FlowState(message_id="msg-1")

for i in range(1, 4):
function_call = Content.from_function_call(
call_id=f"call_{i}",
name=f"tool_{i}",
arguments={"arg": f"value_{i}"},
)
approval_content = Content.from_function_approval_request(
id=f"approval_{i}",
function_call=function_call,
)
_emit_approval_request(approval_content, flow)

assert len(flow.interrupts) == 3
interrupt_ids = {intr["id"] for intr in flow.interrupts}
assert interrupt_ids == {"call_1", "call_2", "call_3"}


def test_resume_to_tool_messages_from_interrupts_payload():
"""Resume payload interrupt responses map to tool messages."""
resume = {
Expand Down
Loading