Chapter 11

Keep Your Own Journal; Use Provider State as an Accelerator

Provider-managed state conveniently continues the dialogue, but it's an accelerator, not a source of truth. For audit, migration, eval replay, and support you must know which user input, tool call, result, and outcome actually passed through the system. So your own event log is mandatory, and provider continuation is an option on top of it.

The continuation methods differ across the three APIs, and it's worth keeping that in view.

Provider · Continuation · Key characteristic

  • OpenAI Responses - previous_response_id or the Conversations API; Responses are stored by default; store: false turns off storage. The current call's instructions are better passed explicitly.
  • Anthropic Messages - The full messages array on the client; The Messages API is stateless; assistant content blocks and tool results must be saved losslessly.
  • Gemini Interactions - previous_interaction_id; Tools, system instruction, and generation config are repeated on every interaction. store: true is the default; with store: false continuation via previous id is unavailable.

The difference isn't cosmetic. OpenAI Responses are stored by default, and store: false turns them off - then it's better to pass instructions explicitly. Anthropic Messages are stateless - keep the whole message array and tool results yourself, losslessly. Google's previous_interaction_id stores history but doesn't carry over tools and system_instruction. Your journal, meanwhile, doesn't depend on the provider and outlives a switch of any of them.

TypeScript
type AgentEvent =
  | { type: "user_input"; text: string; at: string }
  | { type: "model_turn"; provider: string; model: string; at: string }
  | { type: "tool_call"; name: string; argsHash: string; at: string }
  | { type: "tool_result"; name: string; resultHash: string; at: string }
  | { type: "approval"; previewId: string; actorId: string; at: string }
  | { type: "outcome"; status: AgentOutcome["status"]; at: string };

And the rule without which the journal itself becomes a problem.

Don't log everything. Redact personal data and secrets, store hashes for sensitive arguments, set a retention, restrict access. Tracing is useful only when it doesn't itself become a leak.

We know what the agent remembers. It remains to decide how it finishes - and a free-form string won't do here.

Links