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

### AgentErrorEvent

```python
class roboto.ai.core.event.AgentErrorEvent(/, **data: Any)
```

`from roboto.ai.agent_thread import AgentErrorEvent`

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

Bases: `pydantic.BaseModel`

Event reporting an error in a message, such as when its generation failed or was cancelled.

**Parameters**

- **data** (`Any`)

**Attributes**

- **AgentErrorEvent.error_code** (`str | None`) = `None`: Code identifying the kind of error, for a program to act on, or `None` if the error has none.
- **AgentErrorEvent.error_message** (`str`): Human-readable description of what went wrong.

### AgentEvent

```python
type roboto.ai.core.event.AgentEvent = typing.Union[AgentStartTextEvent, AgentTextDeltaEvent, AgentTextEndEvent, AgentToolUseEvent, AgentToolResultEvent, AgentErrorEvent]
```

`from roboto.ai.agent_thread import AgentEvent`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/core/event.py#L89-L96)

Event of any kind that [`events()`](/docs/reference/python-sdk/roboto/ai/agent_thread/agent_thread#roboto.ai.agent_thread.agent_thread.AgentThread.events) yields.

One of `AgentStartTextEvent`, `AgentTextDeltaEvent`, `AgentTextEndEvent`, `AgentToolUseEvent`, `AgentToolResultEvent` and `AgentErrorEvent`. The SDK builds each event from the content Roboto adds to the thread's messages; the caller's own messages yield none. [`run()`](/docs/reference/python-sdk/roboto/ai/agent_thread/agent_thread#roboto.ai.agent_thread.agent_thread.AgentThread.run) passes each event to its `on_event` function.

### AgentStartTextEvent

```python
class roboto.ai.core.event.AgentStartTextEvent(/, **data: Any)
```

`from roboto.ai.agent_thread import AgentStartTextEvent`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/core/event.py#L13-L18)

Bases: `pydantic.BaseModel`

Event marking the start of a run of text in a message.

`AgentTextDeltaEvent` events carry the run's text, and an `AgentTextEndEvent` ends it. A message yields one run for each stretch of text that no other content interrupts.

**Parameters**

- **data** (`Any`)

### AgentTextDeltaEvent

```python
class roboto.ai.core.event.AgentTextDeltaEvent(/, **data: Any)
```

`from roboto.ai.agent_thread import AgentTextDeltaEvent`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/core/event.py#L21-L25)

Bases: `pydantic.BaseModel`

Event carrying the next piece of a run of text, as Roboto's AI generates it.

**Parameters**

- **data** (`Any`)

**Attributes**

- **AgentTextDeltaEvent.text** (`str`): Next piece of the run's text. Joining the pieces in order gives the run's full text.

### AgentTextEndEvent

```python
class roboto.ai.core.event.AgentTextEndEvent(/, **data: Any)
```

`from roboto.ai.agent_thread import AgentTextEndEvent`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/core/event.py#L28-L33)

Bases: `pydantic.BaseModel`

Event marking the end of a run of text in a message.

Yielded when content other than text, such as a tool use, follows the run in the message, or when generation of the message ends.

**Parameters**

- **data** (`Any`)

### AgentToolResultEvent

```python
class roboto.ai.core.event.AgentToolResultEvent(/, **data: Any)
```

`from roboto.ai.agent_thread import AgentToolResultEvent`

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

Bases: `pydantic.BaseModel`

Event reporting the result of a tool the AI asked to run.

**Parameters**

- **data** (`Any`)

**Attributes**

- **AgentToolResultEvent.name** (`str`): Name of the tool the result is for.

- **AgentToolResultEvent.output** (`dict[str, Any] | None`) = `None`: Unused. Always `None`, since Roboto leaves the tool's raw result out of the threads it returns.

  The SDK copies it from [`raw_response`](/docs/reference/python-sdk/roboto/ai/core/content#roboto.ai.core.content.AgentToolResultContent.raw_response). Read what the tool returned from `payload` on the matching [`AgentToolResultContent`](/docs/reference/python-sdk/roboto/ai/core/content#roboto.ai.core.content.AgentToolResultContent) in [`messages`](/docs/reference/python-sdk/roboto/ai/agent_thread/agent_thread#roboto.ai.agent_thread.agent_thread.AgentThread.messages) instead.

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

- **AgentToolResultEvent.success** (`bool`): Whether the tool succeeded.

- **AgentToolResultEvent.tool_use_id** (`str`): ID of the tool use this result answers, the same as on its `AgentToolUseEvent`.

### AgentToolUseEvent

```python
class roboto.ai.core.event.AgentToolUseEvent(/, **data: Any)
```

`from roboto.ai.agent_thread import AgentToolUseEvent`

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

Bases: `pydantic.BaseModel`

Event reporting that Roboto's AI asked to run a tool.

**Parameters**

- **data** (`Any`)

**Attributes**

- **AgentToolUseEvent.answered_by_server** (`bool`) = `False`: Whether Roboto answers this call to a client tool itself, in which case the caller must not run the tool.

  Always `False` for a tool Roboto runs. See [`answered_by_server`](/docs/reference/python-sdk/roboto/ai/core/content#roboto.ai.core.content.AgentToolUseContent.answered_by_server).

- **AgentToolUseEvent.input** (`dict[str, Any] | None`) = `None`: Input the AI chose for the tool, or `None` if the tool use carries none.

- **AgentToolUseEvent.name** (`str`): Name of the tool the AI asked to run.

- **AgentToolUseEvent.tool_use_id** (`str`): Unique ID of the tool use. The `AgentToolResultEvent` reporting its result carries the same ID.
