[FEATURE]: How should post-action surface state survive a history replay? (one-shot / ephemeral surfaces)
Summary
After a user acts on a surface, the surface's post-action state lives only in the renderer's local data model. In hosts that rebuild the UI from stored messages, that state is lost on reload. We'd like to know whether there is a recommended pattern for this, or whether it is something A2UI would want to address.
The situation
When a user acts on a surface, the renderer updates it locally right away. Two-way-bound inputs write to the data model immediately (actions.md#L94), and the host can disable the surface or reflect the choice. While the page is open, this works.
But that state is not durable. In a chat host, the only thing persisted is the message stream: the agent's A2UI messages and the renderer's action messages. Local data model writes are not messages, so they never enter the history. On reload, the host replays the stored agent messages and the surface goes back to its pre-action state. An approved tool card is undecided again, a picker shows nothing selected, and a confirm button can become clickable again.
This matters most for one-shot surfaces: surfaces the agent emits once to ask a single question and never updates again. Examples are tool approval, pick one of N, pick a date range, and confirm / cancel. Their post-action state is fully determined by the surface plus the action the user took, yet nothing in the persisted stream records it.
Approaches we've considered
None of these feels clearly right, which is why we're asking.
- The agent echoes the state back. After receiving the
action, the agent sends anupdateDataModelto the bound paths, so the state becomes part of the persisted stream. This works today, but every agent has to implement it. It also has to target the right(surfaceId, path)pairs and order the echo correctly against its next update. Third-party agents often won't do this, and for one-shot surfaces the agent otherwise has no reason to touch the surface again. - The host snapshots the data model at dispatch and replays it. It stores the snapshot next to the action and, on reload, appends a synthetic
updateDataModelafter the agent's messages. This works because data model updates are idempotent path upserts. But it is host-specific, it captures fields the user never submitted, and different hosts rendering the same conversation will disagree. - The host infers the state from the recorded action. It matches the action's resolved
contextagainst the source component'sevent.contextdefinition and inverts{path}bindings intoupdateDataModels. No extra storage is needed. But it only works for absolute path bindings, not for literals,FunctionCallvalues or relative paths inside templates, and it is hard to order correctly against later agent updates. - The
actionmessage records the state it caused. For example, an action could declare the local writes it makes, and the outgoingactionmessage could carry the resolved values, so replaying the log reproduces the state. This makes replay deterministic, but it does not remove the replay step: the host still has to find each stored action and apply it to its surface. It also does not cover state changed without an action (edited but unsubmitted inputs, localfunctionCallactions), and it has no answer for an action the agent later rejects, because the replayed surface would still show it as submitted.
Questions
- Is there a recommended pattern for keeping post-action surface state across a history replay? Or is this considered entirely the host's responsibility (as #2690 suggests for conversation history in general)?
- If the answer is "the agent should echo
updateDataModel", is that something the spec or agent SDK guidance could state explicitly, so that third-party agents know they are expected to do it? - Would the maintainers be open to something at the protocol level for one-shot surfaces? For instance, a way for a component or an action to declare that its submitted state should be recorded, so neither the agent nor the host has to reconstruct it.
- How should this interact with an action the agent rejects after the fact?
Related
- #2014:
userMessageon actions, so actions can be represented in conversation history (merged in #2228). This question is the state-side counterpart of that. - #2690: conversation-history representation; history management was considered out of scope.
- #2712: async data fetching and data-model cells. Any recorded state would need to coexist with computed values.
Source: a2ui-project/a2ui