---
sidebar:
  hidden: true
title: roboto.ai.core.content
---
## Module Contents

### AGENT_CONTENT_MODEL_BY_TYPE

```python
roboto.ai.core.content.AGENT_CONTENT_MODEL_BY_TYPE: dict[AgentContentType, type[AgentContent]]
```

`from roboto.ai.agent_thread import AGENT_CONTENT_MODEL_BY_TYPE`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/core/content.py#L270-L277)

Model of each kind of content block other than text, keyed by its `content_type`.

Roboto reads this map when it stores a message's content blocks and when it reads them back, so a kind of block missing from it fails both ways instead of being dropped. `AgentContentType.TEXT` is left out because a text block has no `content_type` field.

### AgentArtifactRecord

```python
class roboto.ai.core.content.AgentArtifactRecord(/, **data: Any)
```

`from roboto.ai.agent_thread import AgentArtifactRecord`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/core/content.py#L82-L103)

Bases: `pydantic.BaseModel`

File a tool produced while it ran.

Carried in `AgentToolResultContent.artifacts`. Holds no URL. To download the file, request `GET /v1/ai/threads/{thread_id}/tool-use/{tool_use_id}/artifacts/{name}`, which returns [`AgentToolArtifactResponse`](/docs/reference/python-sdk/roboto/ai/agent_thread/record#roboto.ai.agent_thread.record.AgentToolArtifactResponse).

**Parameters**

- **data** (`Any`)

**Attributes**

- **AgentArtifactRecord.bytes** (`int`): Size of the file, in bytes.

- **AgentArtifactRecord.content_type** (`str`): Media type the tool reported for the file.

- **AgentArtifactRecord.name** (`str`): Name of the file, as the tool reported it. It can include a directory, such as `plots/a.png`.

- **AgentArtifactRecord.status** (`str`): What became of the file, such as `"uploaded"` (stored, and downloadable) or `"too_large"`.

  Present even when Roboto did not keep the file. Each tool defines its own values.

### AgentClientContextEntry

```python
class roboto.ai.core.content.AgentClientContextEntry(/, **data: Any)
```

`from roboto.ai.agent_thread import AgentClientContextEntry`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/core/content.py#L238-L250)

Bases: `pydantic.BaseModel`

What the caller had open when they sent a message, carried as a block on that message.

Roboto adds it when the caller passes `client_context` to [`start()`](/docs/reference/python-sdk/roboto/ai/agent_thread/agent_thread#roboto.ai.agent_thread.agent_thread.AgentThread.start) or [`send()`](/docs/reference/python-sdk/roboto/ai/agent_thread/agent_thread#roboto.ai.agent_thread.agent_thread.AgentThread.send). It has no `text` field, so text renderers skip it, and Roboto keeps it when it shortens a long thread for the AI model.

**Parameters**

- **data** (`Any`)

**Attributes**

- **AgentClientContextEntry.content_type** (`Literal[AgentContentType]`): Kind of content block, always `AgentContentType.CLIENT_CONTEXT`.
- **AgentClientContextEntry.context** (`roboto.ai.core.context.ClientViewingContext`): What the caller had open, such as datasets, files, and visualizer state.

### AgentCompressionFillerContent

```python
class roboto.ai.core.content.AgentCompressionFillerContent(/, **data: Any)
```

`from roboto.ai.agent_thread import AgentCompressionFillerContent`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/core/content.py#L227-L235)

Bases: `pydantic.BaseModel`

Stand-in for the content of a message Roboto emptied in the copy of a thread it sends to the AI model.

Holds nothing but its kind, and keeps the message's place and sender in that copy. Messages Roboto returns, and the Roboto web app shows, never contain one.

**Parameters**

- **data** (`Any`)

**Attributes**

- **AgentCompressionFillerContent.content_type** (`Literal[AgentContentType]`): Kind of content block, always `AgentContentType.COMPRESSION_FILLER`.

### AgentContent

```python
type roboto.ai.core.content.AgentContent = AgentTextContent | AgentToolUseContent | AgentToolResultContent | AgentErrorContent | AgentDeletedContent | AgentCompressionFillerContent | AgentClientContextEntry
```

`from roboto.ai.agent_thread import AgentContent`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/core/content.py#L253-L261)

Content block of any kind: one of the content block models.

The models are `AgentTextContent`, `AgentToolUseContent`, `AgentToolResultContent`, `AgentErrorContent`, `AgentDeletedContent`, `AgentCompressionFillerContent` and `AgentClientContextEntry`. Each but `AgentTextContent` names its kind in `content_type`.

### AgentContentType

```python
class roboto.ai.core.content.AgentContentType
```

`from roboto.ai.agent_thread import AgentContentType`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/core/content.py#L16-L42)

Bases: `roboto.compat.StrEnum`

Kind of a content block in a message.

**Attributes**

- **AgentContentType.CLIENT_CONTEXT** = `'client_context'`: Viewing context (`AgentClientContextEntry`): what the caller had open when they sent the message.

- **AgentContentType.COMPRESSION_FILLER** = `'compression_filler'`: Stand-ins (`AgentCompressionFillerContent`) for messages left empty in what Roboto sends to the AI model.

  Messages Roboto returns never contain one.

- **AgentContentType.DELETED** = `'deleted'`: Placeholders (`AgentDeletedContent`) for blocks Roboto removed from what it sends to the AI model.

  Messages Roboto returns never contain one.

- **AgentContentType.ERROR** = `'error'`: Errors (`AgentErrorContent`): why generating a message failed or stopped.

- **AgentContentType.TEXT** = `'text'`: Text blocks (`AgentTextContent`), from the caller or from Roboto's AI.

- **AgentContentType.TOOL_RESULT** = `'tool_result'`: Tool results (`AgentToolResultContent`): what a tool returned when it ran.

- **AgentContentType.TOOL_USE** = `'tool_use'`: Tool uses (`AgentToolUseContent`): requests from Roboto's AI to run a tool.

### AgentDeletedContent

```python
class roboto.ai.core.content.AgentDeletedContent(/, **data: Any)
```

`from roboto.ai.agent_thread import AgentDeletedContent`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/core/content.py#L214-L224)

Bases: `pydantic.BaseModel`

Placeholder for a content block Roboto removed from the shortened copy of a thread it sends to the AI model.

Holds nothing but its kind. Roboto shortens a long thread so it fits the AI model's context window, removing blocks the AI model no longer needs, such as filler text or a tool use and its result that later messages make redundant. A message left with only placeholders gets one `AgentCompressionFillerContent` instead, so it keeps its place and sender in the conversation. Messages Roboto returns, and the Roboto web app shows, never contain one.

**Parameters**

- **data** (`Any`)

**Attributes**

- **AgentDeletedContent.content_type** (`Literal[AgentContentType]`): Kind of content block, always `AgentContentType.DELETED`.

### AgentErrorContent

```python
class roboto.ai.core.content.AgentErrorContent(/, **data: Any)
```

`from roboto.ai.agent_thread import AgentErrorContent`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/core/content.py#L202-L211)

Bases: `pydantic.BaseModel`

Error block of a message: why Roboto's AI failed to generate the message, or that it was cancelled.

**Parameters**

- **data** (`Any`)

**Attributes**

- **AgentErrorContent.content_type** (`Literal[AgentContentType]`): Kind of content block, always `AgentContentType.ERROR`.
- **AgentErrorContent.error_code** (`str | None`) = `None`: Code naming the kind of error, such as `"TURN_CANCELLED"`, or `None` if Roboto gave none.
- **AgentErrorContent.error_message** (`str`): Human-readable description of what went wrong.

### AgentTextContent

```python
class roboto.ai.core.content.AgentTextContent(/, **data: Any)
```

`from roboto.ai.agent_thread import AgentTextContent`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/core/content.py#L45-L52)

Bases: `pydantic.BaseModel`

Text block of a message, from the caller or from Roboto's AI.

**Parameters**

- **data** (`Any`)

**Attributes**

- **AgentTextContent.text** (`str`): Text of the block.

### AgentToolResultContent

```python
class roboto.ai.core.content.AgentToolResultContent(/, **data: Any)
```

`from roboto.ai.agent_thread import AgentToolResultContent`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/core/content.py#L106-L148)

Bases: `pydantic.BaseModel`

Tool result block of a message: what a tool returned when it ran for a tool use.

**Parameters**

- **data** (`Any`)

**Attributes**

- **AgentToolResultContent.artifacts** (`list[AgentArtifactRecord] | None`) = `None`: Files the tool produced while it ran, or `None` when the tool's output lists none.

  Roboto reads them from the `outputs` field of the tool's output. Unlike `raw_response`, kept in threads Roboto returns, so a client can offer downloads without fetching each tool result.

- **AgentToolResultContent.content_type** (`Literal[AgentContentType]`): Kind of content block, always `AgentContentType.TOOL_RESULT`.

- **AgentToolResultContent.payload** (`str | dict[str, Any] | list[Any] | None`) = `None`: What the tool returned: text, or a JSON object or array.

  Its form does not depend on the AI model the thread runs on. `None` when the result holds no text or JSON output. A result recorded before Roboto stored this field can hold its output only in `raw_response`; `resolve_payload` reads it from either field.

- **AgentToolResultContent.raw_response** (`dict[str, Any] | None`) = `None`: Deprecated. Result of the tool in the AI model's format, a `toolResult` object.

  Read `payload`, or call `resolve_payload`, instead. Roboto removes this field from threads it returns, after filling `payload` from it when `payload` is empty; only `GET /v1/ai/threads/{thread_id}/tool-use/{tool_use_id}` ([`AgentToolDetailResponse`](/docs/reference/python-sdk/roboto/ai/agent_thread/record#roboto.ai.agent_thread.record.AgentToolDetailResponse)) keeps it.

- **AgentToolResultContent.runtime_ms** (`int`): Wall-clock time the tool took to run, in milliseconds.

- **AgentToolResultContent.status** (`str`): Outcome of the tool run, such as `"success"` or `"error"`.

- **AgentToolResultContent.tool_name** (`str`): Name of the tool that ran.

- **AgentToolResultContent.tool_use_id** (`str`): ID of the tool use this result answers, as `AgentToolUseContent.tool_use_id` gives it.

#### AgentToolResultContent.resolve_payload()

```python
def resolve_payload() -> Optional[Union[str, dict[str, Any], list[Any]]]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/core/content.py#L140-L148)

Return what the tool returned, from `payload`, or from `raw_response` when `payload` is `None`.

**Returns**

- `Optional[Union[str, dict[str, Any], list[Any]]]`: The tool's text or JSON output, or `None` when neither field holds one.

### AgentToolUseContent

```python
class roboto.ai.core.content.AgentToolUseContent(/, **data: Any)
```

`from roboto.ai.agent_thread import AgentToolUseContent`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/core/content.py#L55-L79)

Bases: `pydantic.BaseModel`

Tool use block of a message: a request from Roboto's AI to run a tool.

**Parameters**

- **data** (`Any`)

**Attributes**

- **AgentToolUseContent.answered_by_server** (`bool`) = `False`: Whether Roboto answers this call to a client tool itself, instead of handing it to the caller.

  `True` when Roboto refused the call. Roboto then records an error result for it, so the caller must not run the tool: client tool results submitted with a result for this tool use raise `RobotoInvalidRequestException`. [`run()`](/docs/reference/python-sdk/roboto/ai/agent_thread/agent_thread#roboto.ai.agent_thread.agent_thread.AgentThread.run) skips such tool uses when it runs client tools. Always `False` on a call to a tool Roboto runs.

- **AgentToolUseContent.content_type** (`Literal[AgentContentType]`): Kind of content block, always `AgentContentType.TOOL_USE`.

- **AgentToolUseContent.input** (`dict[str, Any] | None`) = `None`: Input the AI chose for the tool, in a form that does not depend on the AI model the thread runs on.

  `None` on tool uses recorded before Roboto stored it.

- **AgentToolUseContent.raw_request** (`dict[str, Any] | None`) = `None`: Request to run the tool, in the AI model's format.

  Roboto removes it from threads it returns; only `GET /v1/ai/threads/{thread_id}/tool-use/{tool_use_id}` ([`AgentToolDetailResponse`](/docs/reference/python-sdk/roboto/ai/agent_thread/record#roboto.ai.agent_thread.record.AgentToolDetailResponse)) keeps it.

- **AgentToolUseContent.tool_name** (`str`): Name of the tool the AI asks to run.

- **AgentToolUseContent.tool_use_id** (`str`): Unique ID of the tool use, which the tool's result carries as its `tool_use_id`.

### synthesize_tool_result_payload()

```python
def roboto.ai.core.content.synthesize_tool_result_payload(
    raw_response: Optional[dict[str, Any]],
) -> Optional[Union[str, dict[str, Any], list[Any]]]
```

`from roboto.ai.core import synthesize_tool_result_payload`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/core/content.py#L151-L199)

Build a tool result's text or JSON output from its `raw_response`.

Roboto calls this when it records a tool result, and when it returns a result recorded before it stored `AgentToolResultContent.payload`. To read a result's output, use `AgentToolResultContent.resolve_payload` instead.

It reads two forms of `raw_response`:

- A dictionary with a `toolResult` key, whose `content` list holds the output. The first `text` or `json` block in the list is the output.
- A dictionary with no `toolResult` key, which is the tool's output itself and comes back unchanged.

A `json` value of exactly `{"items": [...]}` comes back as the bare list, because Roboto wraps a tool's top-level array that way, which the AI model's format does not accept. A tool that itself returned a dictionary whose only key is `items`, holding a list, therefore also comes back as that list.

**Parameters**

- **raw_response** (`Optional[dict[str, Any]]`): Value of `AgentToolResultContent.raw_response`. `None` returns `None`.

**Returns**

- `Optional[Union[str, dict[str, Any], list[Any]]]`: The tool's text or JSON output, or `None` when `raw_response` is `None` or empty, its `toolResult` is not a dictionary holding a `content` list, or the list holds no text or JSON output.
