Repository navigation
Description
Is your feature request related to a problem? Please describe.
agentscope-extensions-agui already defines AG-UI snapshot types (StateSnapshot / StateDelta / MessagesSnapshot / ActivitySnapshot / ActivityDelta in AguiEvent.java + AguiEventType.java, AguiStateConverter exists) but the core pipeline never emits them. AguiStreamContext has no emit*Snapshot API, AguiAdapterConfig.emitStateEvents is not consumed in the core module, converter/ lacks AguiActivityConverter, and AguiAgentAdapter / AgentEventConverterRegistry (8 converters) never produce MESSAGES/ACTIVITY/STATE_SNAPSHOT on the wire. Emission today only lives in examples/copilotkit (WorkbenchAguiEventConverter / WorkbenchEventMiddleware).
As a result, generic AG-UI frontends cannot recover presentation state on refresh / SSE disconnect / reconnect: no MESSAGES_SNAPSHOT to restore history, no STATE_SNAPSHOT/DELTA to restore shared state, no ACTIVITY_SNAPSHOT/DELTA to restore render activities. The only recovery signal is RUN_FINISHED.outcome.interrupts via AguiResumeCoordinator, which covers HITL resume but not UI projection. This also leaves serverSideMemory=false vs true input-trimming (hasMemory → extractLatestUserMessage) without a snapshot to reconcile client vs server history.
Related: #2911 (history replay re-activates interrupt UI), #2907.
Describe the solution you'd like
Introduce a presentation-state layer decoupled from execution state. Core principle verified against current [email protected]:
AgentStateStorerestores Agent execution state (AgentEvent → AgentState → Agent);AguiSnapshotStorerestores AG-UI presentation state (AguiEvent → AguiThreadSnapshot → Frontend). Both areEvent → Statematerializations, projection relationship, independently closed loops.Adapteronly projectsAgentEvent → AguiEvent;Storeonly materializesAguiEventintoAguiThreadSnapshot.
Architecture
AgentEvent
/ \
/ \
▼ ▼
AgentStateStore AguiAdapter (projection only)
│ │
▼ ▼
AgentState AguiEvent
│ │
▼ ▼
Agent recovery AguiSnapshotStore ─→ AguiThreadSnapshot ─→ Hydrate ─→ Frontend
│ │
│ {messages, state, activity}
│ │
▼ ▼
latest-only covering write per threadId (InMemory, LRU 1000, deep-copy)
AguiSnapshotStoreis a State Store, not an Event Store: API issave(threadId, AguiThreadSnapshot) / get(threadId) / delete / clear, notsave(event). Internal flow isAguiEvent → materialize → AguiThreadSnapshot:MESSAGES_SNAPSHOT → snapshot.messages = …,STATE_SNAPSHOT → snapshot.state = …,ACTIVITY_SNAPSHOT → snapshot.activity = …,STATE_DELTA / ACTIVITY_DELTA → snapshot.state/activity = applyDelta(baseline, delta)viaAguiStateConverter.computeDeltabaseline diff. No event sequence is persisted.Interruptis not part ofAguiThreadSnapshotexecution state. Hydrate replaysRUN_FINISHED(outcome.interrupts)only as presentation-level interrupt metadata so the frontend can re-render the approval UI. Authoritative HITL state remains inAguiResumeCoordinator+ Agent runtime, not in the snapshot.Hydrateis a read-only synthetic AG-UI run, not an Agent re-execution:Frontend refresh → Hydrate → SnapshotStore → Snapshot events → Frontend(neverAgent.call() → LLM).
Hydrate contract (refined)
Hydrate Request = messages == [] && resume == null && snapshotStoreEnabled && snapshot exists
messages==[]alone is not sufficient; the server explicitly classifies the request as Hydrate and returnsRUN_STARTED → [STATE_SNAPSHOT] → [MESSAGES_SNAPSHOT] → [ACTIVITY_SNAPSHOT] → RUN_FINISHED(outcome.interrupts?)without invoking the Agent. Anyresumerequest bypasses hydration and follows the existingAguiResumeCoordinatorpath. Future AG-UIsync/hydrateprotocol semantics should be aligned when available.
Plan
-
New
store/inagentscope-extensions-agui(agentscope-extensions/agentscope-extensions-protocol/agentscope-extensions-agui):AguiThreadSnapshot(messages / state / activity)AguiSnapshotStore(save(threadId, AguiThreadSnapshot) / get(threadId) / delete / clear) +InMemoryAguiSnapshotStore(covering write, baselinestate/activity+STATE_DELTA/ACTIVITY_DELTAmaterialization)AguiActivityConverter(mirrorAguiStateConverterforACTIVITY_SNAPSHOT/DELTA)
-
Wiring
AguiStreamContext: addemitMessagesSnapshot / emitStateSnapshot / emitStateDelta / emitActivitySnapshot / emitActivityDelta(enqueue topendingEventsonly, stays stateless).AguiAgentAdapter.streamWithRuntimeContext: afterconvertAgentEvents → drainEvents, materialize each snapshot event intoAguiThreadSnapshotand callstore.save(threadId, snapshot).DELTAevents apply to the stored baseline.AguiRequestProcessor.process: injectOptional<AguiSnapshotStore>; beforebeginRun, if hydration quadruple holds andstore.get(threadId)is present, returnFlux.fromIterable(hydrateEvents(runId, snapshot))directly (runRUN_STARTEDis always emitted byhydrate_events).
-
Config
AguiAdapterConfig+AguiProperties: newsnapshotStoreEnabled(defaultfalse, opt-in to avoid breaking existing frontends). No coupling toserverSideMemory; hydratable projection isAguiEvent-derived.
-
Docs & examples
- Update
docs/v2/en/integration/protocol/agui.mdmapping table + dual-store responsibility boundary (AgentStateStorevsAguiSnapshotStoretable). - Extend
agentscope-examples/aguito demo refresh/reconnect via empty-message Hydrate.
- Update
Describe alternatives you've considered
- Depend on
com.ag-ui.community:java-core: rejected for this iteration; keep zero external dep, stay onagentscope-extensions-agui. - Emit snapshots directly from
AguiStreamContextwithout a store: rejected;Converterwould become stateful andreconnectwould require full event replay. Store keepsConverterstateless and supports latest-only replay. - Read
AgentState.getContext()to buildMESSAGES_SNAPSHOT: rejected; violates projection boundary (AgentStateis internal runtime state). - Persist event sequence in the store (
save(event)): rejected; store is a State Store, not an Event Store. OnlyAguiThreadSnapshotis persisted.
Additional context
- Validated on
main:AguiEvent.java:45/AguiEventType.java,converter/3 files,AguiStreamContext:373,AguiAgentAdapter:194,Registry:69. - Reference principle: Microsoft
agent-framework-ag-uiHydrate — dualEvent→Statematerializations, latest-onlyInMemorystore, read-only hydration on empty-message request, interrupt replayed as presentation metadata viaRUN_FINISHED.outcome. Referenced at principle/behavior level only, no code copied. - Labels:
enhancement,area/ext/integration,area/ext/spring-boot,area/examples.
Activity
shenghuitian commentedon Sep 1, 2026
请问这部分预计什么时间发布
chcodex commentedon Sep 1, 2026
还在设计阶段
feat(agui): add presentation snapshot store and /connect hydrate (age…
dragondyt commentedon Sep 3, 2026
#2922 这里会不会是重复工作
dragondyt commentedon Sep 3, 2026
设计有没有考虑到多租户,分布式。agui这块状态复用AgentState会不会更好点
CryoThrust commentedon Sep 4, 2026
For the multi-tenant/distributed boundary, the store contract should make ownership explicit rather than relying on a process-local
threadId. A useful SPI could accept a composite key (tenantId, threadId) and an optional version/ETag onsave, with compare-and-set semantics so reconnects from two nodes cannot overwrite a newer snapshot.getshould return an immutable/deep-copied snapshot, and hydrate should carry the snapshot version used to render it. This keeps the in-memory implementation simple while making Redis/MySQL adapters possible without changing the adapter/event model. I agree that reusingAgentStatedirectly would couple a presentation projection to execution internals; the two stores should remain separate, with an explicit mapping only for the messages/state fields that AG-UI exposes.oss-maintainer commentedon Sep 14, 2026
Issue Evaluation
Category:
enhancement| Area:area/ext/integration(AG-UI) | Status: Evaluated — feasibleFeasibility: feasible. Verified on current
main: the AG-UI snapshot/delta event types exist in the protocol model (AguiEvent,AguiEventType), butAguiStreamContextexposes noemit*SnapshotAPIs,AguiAdapterConfig.emitStateEventsis not consumed by the core converters, there is noAguiActivityConverter, and the built-in converters only emit lifecycle/message/tool events. Snapshot emission currently exists only in the copilotkit example; noAguiSnapshotStore/ hydrate layer exists.Scope:
agentscope-extensions-agui(stream context, converter registry, adapter config) plus a persistence/hydrate component.Compatibility: additive; no breaking changes expected if snapshot emission is opt-in via
emitStateEvents.Recommendation: proceed — but the store abstraction (what is snapshotted, TTL, hydrate ordering vs. live events) deserves a short design note before implementation.
Automated evaluation by github-manager-bot
shenghuitian commentedon Oct 14, 2026