Skip to main content

Module history

Module history 

Source
Expand description

Recovering a previously rendered surface from conversation history.

intent = "update" is only useful if the agent knows what it is updating. The surface it rendered a few turns ago is not stored anywhere — it went out over the transport and the renderer holds it. What the agent does still have is the conversation, and the operations it emitted are in there.

find_prior_surface walks the messages newest-first, finds the most recently rendered surface, and replays every operation for that surface in order to reconstruct its components, data model, and catalogId. That reconstruction becomes the “here is what is on screen now” section of the next generation prompt.

§Where the operations are found

Two encodings are recognized, because both occur in practice: the A2UI_OPERATIONS_KEY transport envelope, and raw <a2ui-json> blocks in an assistant turn. A message may also be the envelope itself rather than text containing one.

A generation that failed is deliberately none of those — see wrap_error_envelope — so it contributes no operations and cannot be recovered as a surface that was never on screen.

Structs§

HistoryMessage
One entry of conversation history, oldest first in a slice.
PriorSurface
A surface reconstructed from history.

Functions§

find_prior_surface
Finds the most recently rendered surface in the conversation.
find_prior_surface_by_id
find_prior_surface restricted to one surfaceId.
next_surface_id
A surface id that will not collide with anything already in history.