Using window.openai.setWidgetState for model context
Store specific state data that is added to the model's context on the next user-model interaction.
window.openai.setWidgetState(state)
Inside a ChatGPT app's widget code.
Allows the model to be aware of specific UI state (like user selections or navigation) when it needs to answer questions related to the UI.
Use `window.openai.setWidgetState(state)` within your ChatGPT app's widget to store specific state data. This data is then added to the model's context for subsequent user-model interactions, enabling informed responses.
- 15 lessons learned building ChatGPT Apps ↗OpenAI Developers Blog · OpenAI Developers Blog · Sep 3, 2026 · quoted as shared
First seen on Subvolts Sep 3, 2026. Updated Sep 11, 2026. Spotted a problem? Tell us.
- 15 lessons learned building ChatGPT AppsOpenAI · OpenAI Developers Blog · Sep 3, 2026
The Playbook: reusable how-tos, prompts, configs and tips pulled out of the news.
- HeuristicDefine task completion clearly to avoid premature stoppingExplicitly define what 'done' means for a task to ensure AI models complete the full scope. · 10 min
- Anti-patternBuilding agent infrastructure from scratchAvoid piecing together agent infrastructure; use standardized SDKs and native sandbox support. · 5 min
- Setting tipAgent workspace portability with Manifest abstractionUse the Manifest abstraction to describe agent workspaces for portability across different providers. · 10 min
- ToolOpenAI Agents SDK for building agentsSDK for building agents that can inspect files, run commands, edit code, and work on long-horizon tasks. · 15 min
- Anti-patternOverly specific instructions for advanced AI modelsAvoid detailed itineraries; newer models handle nuance and ambiguity better. · 10 min
- Anti-patternPrompting AI to read all project docs before every editAvoid forcing AI to read extensive documentation before simple edits; use contextual pointers instead. · 10 min
Questions people ask
- Which AI tools does this work with?
- The sources used it with ChatGPT.
- Where did this come from?
- OpenAI Developers Blog (OpenAI Developers Blog). Subvolts collected, normalized and credited it; the link above opens the original.

