Skip to content

fix(agui): suppress resolved historical interrupts on connect replay (#2911) - #2922

Open
chang6666 wants to merge 3 commits into
agentscope-ai:mainfrom
chang6666:fix/2911-copilotkit-replay-interrupt
Open

fix(agui): suppress resolved historical interrupts on connect replay (#2911)#2922
chang6666 wants to merge 3 commits into
agentscope-ai:mainfrom
chang6666:fix/2911-copilotkit-replay-interrupt

Conversation

@chang6666

@chang6666 chang6666 commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Fix #2911

Connect replay (/agent/{agentId}/connect) re-projects stored AgentEvents through the same converters, so historical RequireUserConfirmEvents that a later run already resolved were converted back into RunFinishedInterruptOutcome, re-activating the frontend interrupt form and leaving the suspended tool rendered as Running instead of Done.

Changes

  • replay() post-processes projected AG-UI events via suppressResolvedInterrupts(...).
  • Only the last run's interrupt outcome is preserved (an unresolved interrupt at thread end stays restorable after reload); interrupt outcomes of all earlier runs are replaced with null, which serializes as a normal successful run.
  • The last run is detected from the final event's run id of any kind, so a still-running continuation run also suppresses a resolved historical interrupt.
  • Dangling suspended tool calls of suppressed runs (TOOL_CALL_START without TOOL_CALL_RESULT) are closed with a synthetic TOOL_CALL_RESULT before that run's RUN_FINISHED, so the frontend renders the tool as completed instead of stuck running.
  • First unit test for the module (AgentEventAguiReplayerTest, 11 cases): suppression, last-run-only preservation, success-outcome passthrough, serialization, in-flight continuation, and dangling-tool closure edge cases.

Verification

  • mvn -pl agentscope-examples/agentscope-copilotkit test (JDK 17, -Dfrontend.skip=true): 11/11 pass
  • spotless:check and git diff --check clean

@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@jujn

jujn commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

cc @dragondyt

…ntscope-ai#2920)

Framework-level presentation-state store so reconnecting clients rebuild
the visible conversation without re-running the agent; collapses the agentscope-ai#2911
copilotkit workaround into the data model (only the trailing unresolved
interrupt is ever retained, so a resolved historical interrupt cannot
reappear on reconnect).

- store/: AguiJsonPatch (RFC 6902 applier), AguiThreadSnapshot,
  AguiSnapshotStore + InMemoryAguiSnapshotStore, AguiSnapshotAccumulator
  (absorbs resolved-interrupt suppression + dangling-tool synthesis),
  SnapshotRecordingEnricher (last observer, flush safety net),
  AguiSnapshotHydrator (read-only replay; empty -> 3-frame handshake)
- AguiActivityConverter + shared AguiJsonDiff helper (mirrors state converter)
- AguiAdapterConfig snapshot-store-enabled/snapshotStore (default off);
  AguiRequestProcessor.hydrate(), clearPendingInterrupts at beginRun,
  flush in doFinally
- starters: gated AguiSnapshotStore bean + POST {path-prefix}/connect route
  (WebFlux RouterFunction + MVC conditional AguiConnectController)
- copilotkit: migrate /connect to framework hydrator, delete
  suppressResolvedInterrupts/danglingToolCalls + obsolete test, enable store
- docs (en/zh): Presentation Snapshot Store section + YAML sample
- tests: store package, activity converter, config/processor/starter wiring
  and an end-to-end process-records -> hydrate-replays case
@dragondyt

Copy link
Copy Markdown
Contributor

The #2911 reconnect bug is clear, but this PR now includes two different changes.
The first two commits fix replay in CopilotKit. 263f14b adds a framework snapshot store, /connect hydrate, activity converter, starter wiring, and docs — that's a feature, not part of the bugfix.
Please keep this PR focused on #2911 and move the snapshot-store / hydrate work to a separate branch and PR. That will be much easier to review and land independently.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]:agentscope-copilotkit中connect历史消息重放时重复激活前端中断UI

3 participants