roboto.ai.core.content
Message-content primitive value types shared across the roboto.ai layer.
These are the leaf building blocks of AgentMessage.content. They live here — below both roboto.ai.core.record and roboto.ai.goals — so the goals layer can reference the raw tool-call blocks (to carry them on a GoalResult) without importing from core.record. That keeps the roboto.ai import graph a DAG: core.content depends only on roboto.ai.core.context (itself a leaf with no roboto.ai imports of its own); goals and core.record both depend down onto core.content.
Module Contents
AGENT_CONTENT_MODEL_BY_TYPE
The model class for each JSON-serialized content type, keyed by discriminator.
Excludes AgentContentType.TEXT, whose payload is persisted as raw text rather than a serialized model. Every other member of AgentContent carries a content_type discriminator and round-trips through model_dump_json / model_validate_json; driving both serialization directions off this one map keeps them symmetric, so a member added to the union without a home here fails loudly instead of being silently dropped on write or reconstructed without its payload on read.
AgentClientContextEntry
Bases: pydantic.BaseModel
The caller’s attached viewing context, carried on their own message.
Replaces a <ctx>{json}</ctx> marker persisted as a separate ROBOTO-role message. That shape made every consumer regex a JSON blob back out of prose it had serialized itself – four parsers across two languages – and relied on the ROBOTO role to keep the marker out of the chat view. It also put the context on a non-USER message, which the compression deletion pass collapses wholesale inside a resolved task’s interior, so the context silently disappeared from compressed history.
As a block on the user’s own message it is a typed field, invisible to text renderers (no text field), and safe from that collapse – USER turns are never dropped.
Parameters
data AnyAttributes
AgentClientContextEntry.content_type
AgentClientContextEntry.context
What the caller had open: attached datasets, files, and visualizer state.
AgentCompressionFillerContent
Bases: pydantic.BaseModel
Filler standing in for a message the compression deletion pass emptied.
Carries no payload. A message reduced to nothing but tombstones keeps this single block instead of an empty content list, so it stays in the Bedrock payload at its original role and turn alternation survives without relocating content. The Bedrock boundary renders it as <Deleted in compression>. Produced only by the compression deletion pass and stored only at the DELETED tier; the verbatim original thread (what the SDK and UI render) never contains one.
Parameters
data AnyAttributes
AgentCompressionFillerContent.content_type
AgentContent
Type alias for all possible content types within agent messages.
AgentContentType
Bases: roboto.compat.StrEnum
Enumeration of different types of content within agent messages.
Defines the various content types that can be included in agent messages.
Attributes
AgentContentType.CLIENT_CONTEXT
What the caller was looking at when they composed the message this block sits on.
Superseded shape: the same payload used to be persisted as a whole ROBOTO-role message whose text was a <ctx>...</ctx> marker (ENG-2185). Readers still accept that form for threads written before this type existed; nothing emits it any more.
AgentContentType.COMPRESSION_FILLER
Stand-in block kept in a message the deletion pass emptied entirely.
A message reduced to nothing but tombstones would break user/assistant alternation if it dropped from the payload. Replacing its content with this single filler keeps the message — and its role — in place. The model sees it as <Deleted in compression>. Only the cross-message deletion pass produces it, so it appears only inside a DELETED-tier compressed variant, never in the verbatim original thread the SDK and UI read.
AgentContentType.DELETED
Tombstone marking a content block elided by compression.
Appears only inside a DELETED-tier compressed variant. Both producers — message-tier compression dropping a pure-filler text run, and the cross-message deletion pass dropping a whole tool exchange — store their output at the DELETED tier, so a message carrying one is always a DELETED-tier variant. Never in the verbatim original thread the SDK and UI read.
AgentDeletedContent
Bases: pydantic.BaseModel
Tombstone for a content block removed by compression.
Carries no payload — its presence records that a block once occupied this slot, and it converts to None at the Bedrock boundary so the block drops from the LLM payload. Produced when compression drops a block — a pure-filler text run at message compression, or a whole redundant tool exchange in the cross-message deletion pass — and stored only at the DELETED tier, so a message carrying one is always a DELETED-tier variant. A message reduced to nothing but tombstones does not drop: it is replaced with a single AgentCompressionFillerContent so it keeps its role and turn. The verbatim original thread (what the SDK and UI render) never contains one.
Parameters
data AnyAttributes
AgentDeletedContent.content_type
AgentErrorContent
Bases: pydantic.BaseModel
Error content within an agent message.
Used when message generation fails due to an error or is cancelled by the user.
Parameters
data AnyAttributes
AgentErrorContent.content_type
AgentErrorContent.error_code
Optional error code for programmatic handling.
AgentErrorContent.error_message
User-friendly error message describing what went wrong.
AgentTextContent
Bases: pydantic.BaseModel
Text content within an agent message.
Parameters
data AnyAttributes
AgentToolResultContent
Bases: pydantic.BaseModel
Tool execution result content within an agent message.
Parameters
data AnyAttributes
AgentToolResultContent.content_type
AgentToolResultContent.payload
What the tool returned: free-form text, or a JSON object or array of structured data.
Independent of any model provider’s wire format (provider-agnostic, like AgentToolUseContent.input). None on results written before this field existed; use resolve_payload() to read old and new results uniformly.
AgentToolResultContent.raw_response
Legacy provider-formatted response envelope (Bedrock toolResult shape).
Kept so results written before payload existed remain readable; deprecated for new readers, who should call resolve_payload() instead of parsing this field.
Populated only where the server-side envelope is in scope: threads read over the API arrive with this field stripped (and, for legacy rows, with payload synthesized from it server-side before the strip), so API/SDK readers should not expect it.
AgentToolResultContent.resolve_payload()
Return what the tool returned, whichever field carries it.
Prefers payload. Results written before that field existed carry only the legacy envelope, from which the equivalent value is reconstructed via synthesize_tool_result_payload().
Returns
The tool’s text or JSON output, or None when neither field carries a recognizable value.
Attributes
AgentToolResultContent.runtime_ms
Wall-clock execution time of the tool in milliseconds.
AgentToolResultContent.tool_use_id
Identifier of the tool invocation this result corresponds to.
AgentToolUseContent
Bases: pydantic.BaseModel
Tool usage request content within an agent message.
Parameters
data AnyAttributes
AgentToolUseContent.content_type
AgentToolUseContent.input
Parsed tool input parameters chosen by the LLM (provider-agnostic).
AgentToolUseContent.raw_request
Raw, unparsed request payload for this tool invocation.
AgentToolUseContent.tool_use_id
Unique identifier for this tool invocation, used to correlate with its result.
synthesize_tool_result_payload()
Reconstruct a tool result’s text or JSON output from its legacy response envelope.
Reads both shapes tool results were persisted with before AgentToolResultContent.payload existed:
- The provider envelope: a
toolResultobject whosecontentlist carries the output as atextorjsonblock, followed at most by image attachments. - A bare output dict with no
toolResultkey at all — the shape client-submitted results and fabricated skill-invocation results persisted, where the dict is the tool’s output and is returned as the payload verbatim.
A json value of the exact single-key form {"items": [...]} — the wrapper applied because the model provider rejected a top-level array — is unwrapped back to the bare array. This unwrap is heuristic: a tool that genuinely returned a single-key {"items": [...]} dict is indistinguishable from the wrapper here and synthesizes as the bare array. Writers that still hold the tool’s true return value should persist AgentToolResultContent.payload directly rather than round- tripping through this function.
Parameters
raw_response Optional[dict[str, Any]]The legacy value, as carried by AgentToolResultContent.raw_response. None is accepted.
Returns
The tool’s text or JSON output, or None when the value is absent, is a malformed envelope, or is an envelope carrying no text or JSON block.