showcase/integrations/spring-ai/qa/shared-state-read-write.md
/api/health)OPENAI_API_KEY is set on the Spring backendpreferences = { name, tone, language, interests } object
and writes it into agent state via agent.setState({ preferences, notes }).SharedStateReadWriteController runs a per-request LocalAgent
subclass that reads preferences off the AG-UI envelope and injects them
into the system prompt every turn.set_notes(notes: List<String>), that
mutates state.notes and emits a STATE_SNAPSHOT event so the
useAgent({ updates: [OnStateChanged] }) hook re-renders the page./demos/shared-state-read-write.data-testid="preferences-card" and
data-testid="notes-card".data-testid="pref-state-json")
shows the seeded defaults: { name: "", tone: "casual", language: "English", interests: [] }.data-testid="pref-name".data-testid="pref-tone".data-testid="pref-language".set_notes (visible briefly in the chat
stream) and that the Notes card shows two list items shortly after.data-testid="notes-list" is present and contains two
data-testid="note-item" entries.data-testid="notes-clear-button" in the Notes card.data-testid="notes-empty" appears.set_notes calls within 1 second after the tool
result event lands (driven by the STATE_SNAPSHOT emission).