.agents/references/runstate-schema.md
Use this reference for changes involving RunState serialization, deserialization, approvals, trace state, sandbox state, agent identity, tool output payloads, or any persisted resume data.
RunState is the durable SDK pause/resume boundary. Treat the serialized JSON shape as compatibility-sensitive once a schema version has shipped in a release.
to_json() always emits CURRENT_SCHEMA_VERSION.from_json() must continue reading every version in SUPPORTED_SCHEMA_VERSIONS.SCHEMA_VERSION_SUMMARIES.Bump CURRENT_SCHEMA_VERSION when a serialized RunState snapshot changes in a way that affects resume correctness or would silently lose data when read under an older schema label.
Examples include:
RunState, ModelResponse, ProcessedResponse, interruptions, approvals, tool outputs, sandbox state, trace state, or agent-owned state.Do not rely on current-reader tests alone. Add a regression that rewrites $schemaVersion to an older supported label when appropriate and proves the old label is accepted, rejected, or migrated deliberately.
Serialized state must preserve enough identity to resume without changing behavior:
bare, namespaced, and deferred_top_level.OpenAIServerConversationTracker without replaying acknowledged input.Context serialization is intentionally conservative.
RunContextWrapper.context, trace data, tool outputs, or custom data unless the caller explicitly chose that durability boundary.CURRENT_SCHEMA_VERSION and SCHEMA_VERSION_SUMMARIES when resume compatibility requires it.to_json() output, from_json() restoration, string round-trips, and resumed execution through the public Runner.run(...) or Runner.run_streamed(...) path.src/agents/run_state.pysrc/agents/result.pysrc/agents/run_internal/agent_runner_helpers.pysrc/agents/run_internal/oai_conversation.pysrc/agents/run_internal/run_steps.pysrc/agents/run_internal/tool_execution.pytests/test_run_state.py