ai.wire.sanitize_for_client
Make one run's journal safe to replay to `client_id`, and return the sanitized copy. Every client should lower `ai.wire.sanitize_for_client(input.journal, self.id())` instead of `input.journal`. The rules, in the order they apply per event:
Signature
Make one run's journal safe to replay to client_id, and return the
sanitized copy. Every client should lower
ai.wire.sanitize_for_client(input.journal, self.id()) instead of
input.journal. The rules, in the order they apply per event:
- An assistant turn from a DIFFERENT
client_idloses itsai.content.Reasoningblocks: one model's thinking is not replayable to another (and providers that check reasoning signatures reject it). - Empty and whitespace-only
ai.content.Textblocks are dropped from assistant turns. - An assistant turn left with no blocks at all is dropped entirely —
the reasoning-only turn that lowers to
content: []and makes Anthropic 400, and the same shape an aborted turn leaves behind. Such a turn never has tool calls, so nothing is orphaned by dropping it. - A tool call with no
ToolCompleted/ToolFailedbefore the next assistant or user message (or before the end of the journal) gets a synthesizedToolFailed { message: "No result provided" }, because most APIs reject a tool call that was never answered.
Journal-only events (RunStarted, ToolRequested, Usage,
FinalProduced) pass through untouched — clients skip them anyway — and,
like the clients' own lowering, they never close an open tool-result group.
Nothing here mutates the journal it is given.
Source:<builtin>/ai/ns_wire/wire.bamlbytes 24570–26506