inspect_evals_utils.messages¶
Helpers for rendering chat message content as text for scorers.
ChatMessageAssistant.text concatenates only ContentText items, so a
message whose content includes reasoning reads as if the model said nothing of
that part. Scorers that judge model behaviour (refusal judges, blacklist
monitors) need the reasoning too, and need it distinguishable from the visible
response rather than concatenated into it.
Reasoning renders as sibling <reasoning> and <reasoning_summary>
blocks. inspect_ai's own <think> serialization was the alternative, but it
carries signature and base64 internal attributes that exist for
round-tripping and are noise in a judge prompt, so this renders only the parts
a judge reads.
reasoning_to_text
¶
reasoning_to_text(reasoning: ContentReasoning) -> str
Render reasoning content as tagged blocks.
The raw chain and the provider summary are tagged separately, each emitted only when it has content, so providers that redact the raw chain and expose only a summary (OpenAI's o1/o3 among them) still contribute text.
A redacted chain keeps an empty <reasoning redacted="true" /> marker so
a judge can distinguish a withheld chain from a model that did not reason.
message_content_text
¶
message_content_text(message: ChatMessage) -> str
Flatten a message to text, tagging reasoning rather than inlining it.
Content items are rendered in order and joined with newlines. Reasoning becomes tagged blocks, text is passed through unchanged, and any other content type (images, audio, documents) is skipped as having no textual rendering.