Subchapter 2.3
references/interactive-state-sync-patterns.mdMarkdown4 KBView on GitHub
Use this reference when building ChatGPT apps with long-lived widget state, repeated interactions, or component-initiated tool calls (for example: games, boards, maps, dashboards, editors, or realtime-ish UIs).
Do not load this file for simple read-only render apps unless state sync behavior is part of the task.
Read this file when the app needs one or more of these patterns:
Return a stable state snapshot in structuredContent and add a monotonic event token for repeated actions that may not change other fields.
Examples:
stateVersionrefreshCountresetCountlastMutationIdUse this when the widget must detect “same shape, new event” updates reliably.
Prefer small, explicit tools that map to user-visible actions or data operations.
This improves model tool selection and reduces malformed calls.
Design handlers to tolerate retries. If a tool is not idempotent, make the side effect explicit and confirm intent in the flow.
Partition payloads intentionally:
structuredContent: concise model-visible state the widget also usescontent: short narration/status text_meta: large maps, caches, or sensitive widget-only hydration dataKeep structuredContent small enough for follow-up reasoning and chaining.
For new scaffolds:
tools/call (portable across hosts)window.openai as a compatibility layer plus optional ChatGPT extensionsThis keeps the app portable while still enabling ChatGPT-specific capabilities when helpful.
For interactive widgets, allow the UI to call data/action tools directly and update the existing widget state instead of forcing a full re-render/remount every time.
This is especially useful for:
When feasible, make the widget usable without ChatGPT during development:
This speeds up front-end iteration and reduces dependence on connector setup for every UI tweak.
Use separate data and render tools when the app has multi-step reasoning or frequent updates.
structuredContentThis reduces unnecessary remounts and gives the model a chance to refine data before rendering.
structuredContentwindow.openai APIs for baseline app behavior