Skip to content

fix(agent): emit external execution lifecycle events#2331

Open
vowor wants to merge 4 commits into
agentscope-ai:mainfrom
vowor:codex/fix-external-execution-events
Open

fix(agent): emit external execution lifecycle events#2331
vowor wants to merge 4 commits into
agentscope-ai:mainfrom
vowor:codex/fix-external-execution-events

Conversation

@vowor

@vowor vowor commented Jul 21, 2026

Copy link
Copy Markdown

AgentScope-Java Version

2.0.1-SNAPSHOT

Summary

  • emit RequireExternalExecutionEvent with the pending ToolUseBlocks when a tool suspends for external execution
  • emit ExternalExecutionResultEvent only after supplied tool results pass Core validation and are appended to state
  • preserve the originating assistant reply ID across same-instance and persisted-state resume
  • prevent AG-UI from publishing the suspended placeholder as TOOL_CALL_RESULT
  • finish suspended AG-UI runs with a RunFinishedInterruptOutcome

Root cause

Core registered the external-execution event types but did not emit them from the native streamEvents() lifecycle. The AG-UI adapter therefore handled the coarse suspended ToolResultBlock like a completed tool result and exposed [Awaiting external execution] as a terminal result. CopilotKit interpreted that message as an already-completed frontend tool call and skipped its HITL handler.

Impact

External frontend tools now produce a stable interrupt boundary instead of a terminal placeholder result. Clients can execute the pending tool and resume with the matching result, including after rebuilding the agent from the same persisted (userId, sessionId) state.

Validation

  • repository-wide mvn test
  • repository-wide mvn spotless:check
  • regression coverage for same-instance resume, persisted-state resume, duplicate and mismatched result rejection, exactly-once request/result events, and AG-UI interrupt mapping

Fixes #2024

@CLAassistant

CLAassistant commented Jul 21, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@vowor
vowor marked this pull request as ready for review July 21, 2026 06:27
@vowor

vowor commented Jul 23, 2026

Copy link
Copy Markdown
Author

Hi @oss-maintainer has been ready for review for a few days. Could you please take a look when you have a chance? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants