Repository navigation
Description
AgentScope-Java Version
2.1.0-SNAPSHOT, based on upstream/main at c1d482900.
Description
DurableAguiEventAdapter.committed() maps run.started, run.ended, step.started/step.ended, message.completed and tool.call.updated, but drops the committed interaction.requested event through default -> List.of().
When a native tool needs human input, BackendThreadJournal emits a public interaction.requested event with:
{ "id", "requestId", "turnId", "key", "kind", "status": "pending",
"call": { "name", "arguments" }, "automatic" }and parks the Turn in WAITING.
Symptoms
- AG-UI clients never receive
RUN_FINISHEDwith an interrupt outcome, so they cannot render the question card or obtain theinterruptIdrequired for a resume. - The committed order is
run.ended(STOPPED, reason such asTOOL_SUSPENDEDfor a suspended tool, orPERMISSION_ASKINGwhen a permission hook parks the Turn) followed byturn.waiting. A parkedrun.endedis not the terminal AG-UI frame, so withoutturn.waitingthe client has no supported way to end the run at the interrupt and resume from it.
WAITING semantics are correct
WAITING needs no change. The adapter commits TurnStatus.WAITING, DurableRuntime releases the lease, and readyAt() returns -1 when waiting.deadline() == 0. No worker thread or lease is held while waiting. The defect is only the missing terminal AG-UI event.
Multiple pending interactions
A Turn can wait on more than one interaction at the same time: a confirmation plus an external-execution request, for example (UserApiContract asserts pendingInteractions().size() == 2). AG-UI 1.0 requires one terminal event per run and allows the interrupt outcome to carry a non-empty interrupts array, so all pending interactions must be delivered in one RUN_FINISHED.
Proposed fix
- Extend the committed
turn.waitingevent with the Turn's pendinginteractionsarray, so one committed event carries the whole wait set. - Map
turn.waitingto exactly oneRUN_FINISHEDwhoseRunFinishedInterruptOutcome.interruptscontains every pending interaction. Individualinteraction.requestedevents are not terminal and are not mapped on their own. - Treat
STOPPEDparked reasons (suspended,PERMISSION_ASKING,TOOL_SUSPENDED) as non-terminal, and end the parked native Run quietly so no extrarun.endedcompetes withturn.waiting. - Use the Durable interaction id (
data.id = hash(turnId, requestId)) asinterrupt.id;AguiInterrupts.externalExecutionmust not regenerate it because the resume request would not match the pending interaction. UserequestId(the tool call id) asinterrupt.toolCallId. - Close the steps, messages and tool calls the Run opened before the terminal event; reset adapter state per Run; provide the confirmation
responseSchema; map non-suspended stopped Runs to the AG-UI cancelled outcome. - Add regression tests for single and multiple interactions, open-item closing, cancelled Runs, repeated waiting events, and failure after an interrupt.
Verification: mvn -B -ntp -pl agentscope-durable/durable-adapters/durable-adapter-agui test, the Durable runtime/JDBC contract tests, and spotless:check.
Activity