ai.wire.degrade_tool_media

Degrade, as a journal rewrite. A client that carries only some media kinds inside a tool result (`carries`, by `kind()`) lowers the copy of `j` this returns: every other media block has left its result and, behind a one-line note naming the tool, forms ONE `user` turn after the LAST result of the same assistant turn. The results of one turn stay contiguous (Chat Completions, Converse and Responses all reject a `user` message between two of them), `Text` stays where it was, and a result left with no text keeps the `[audio]`-style placeholder so no client sends an empty result. Lowering stays pure: the caller's journal is untouched and the trace still shows the original events.

Reference version

Signature

function ai.wire.degrade_tool_media(j: ai.Journal, carries: string[]) -> ai.Journal

Degrade, as a journal rewrite. A client that carries only some media kinds inside a tool result (carries, by kind()) lowers the copy of j this returns: every other media block has left its result and, behind a one-line note naming the tool, forms ONE user turn after the LAST result of the same assistant turn. The results of one turn stay contiguous (Chat Completions, Converse and Responses all reject a user message between two of them), Text stays where it was, and a result left with no text keeps the [audio]-style placeholder so no client sends an empty result. Lowering stays pure: the caller's journal is untouched and the trace still shows the original events.

Source:<builtin>/ai/ns_wire/wire.bamlbytes 2067923115