Transcript state and application state
Conversation continuity and per-run application data solve different problems, so design them as separate state channels.
An Agents SDK session represents remembered exchanges for one session identity; it can spare an application from rebuilding prior model input on every turn.
By contrast, RunContextWrapper carries an application-owned object through tools, callbacks, and run hooks. That object remains outside the model payload.
Use the local object for request-scoped dependencies, policy inputs, and helper services. Put only information the model needs to reason over into the turn history or current input.
Conversation continuity methods
Select a single owner for transcript progression before implementing a multi-turn workflow.
- Choose an SDK session when the application wants the SDK to read prior session items and record the items produced by a completed run.
- Choose explicit input assembly when the application needs direct control over which earlier material is carried to the next model call. The SDK documentation identifies result.to_input_list() as one such option.
- Choose an OpenAI-managed continuation identifier when server-side continuation is the intended design; the supplied material identifies conversation_id, previous_response_id, and auto_previous_response_id in that category.
Do not pass a session together with any of those server continuation fields for one run; the documented designs are mutually exclusive at that boundary.
The supplied API reference indicates that creating a Conversation is an available operation, but it does not provide enough detail here to prescribe its request shape or persistence behavior.
Model-call input
Session history is normally combined with the new turn before execution. When that default ordering or filtering is unsuitable, RunConfig.session_input_callback can alter the composed input.
Make the inclusion rule intentional. For example, a support workflow may retain the relevant transcript while keeping an internal account identifier in local context, where tools can use it without exposing it as model-visible text.
Shared policy data can inform tool, MCP-filtering, and handoff callbacks. Those visibility controls are not a substitute for checking authorization against the actual arguments and target resource when an action is requested.
Continue reading: Designing Prompt-Injection Defenses for Tool-Using Assistants.
Recovery, storage, and secrecy
For an interrupted session-backed run, the returned execution state can be supplied again using the original session object, or another object that points to the same session key and storage implementation.
The provided material does not establish locking, transactional guarantees, scaling behavior, or history-size handling for session stores.
Do not place credentials in RunContextWrapper.context when serialized run state could be stored or sent elsewhere.
Continue reading: Troubleshooting Durable Agent Runs: Retries, Checkpoints, and Side Effects.
Architecture checklist
- Classify each datum: transcript content, model input, local dependency, policy signal, or secret.
- Do not pair an SDK session with a server-managed continuation field in the same run.
- Specify how history is selected, trimmed, and merged with the incoming turn.
- Define session identity ownership and the storage model required for restart recovery.
- Enforce authorization at the action boundary, not merely when deciding whether a capability is shown.
- Verify current SDK and API contracts before deployment, particularly for Conversations API behavior and version-specific session details.
Limits of the supplied documentation
The available excerpts contain no dated version information, performance figures, retention terms, or comparative cost data. They also leave the exact Conversations API contract and the operational differences among continuation identifiers unresolved.
What is the recovery contract for the failure window between producing a run result and durably recording the corresponding session items? The session documentation says an interrupted run can be resumed with the same session, but the supplied material does not establish atomicity, locking, or duplicate-prevention semantics for the session store.
A minimal validation should inject a process stop at each boundary: before execution, after a tool-side effect, after result production, and during session write; then resume using a fresh session object pointed at the same session key. For each case, verify the recovered transcript, whether the tool action is repeated, and whether concurrent resumes can advance the same history in conflicting orders. Until those observations are available for the selected store, “restart recovery” should mean an attempted resume path, not proven durable or concurrency-safe progression. The available session guidance lists several storage implementations but does not, in the supplied excerpt, state those guarantees: Sessions documentation.