---
sidebar:
  hidden: true
title: roboto.ai.agent_thread.agent_thread_goal_view
---
## Module Contents

### AgentThreadGoalView

```python
class roboto.ai.agent_thread.agent_thread_goal_view.AgentThreadGoalView(
    record: roboto.ai.agent_thread.record.AgentThreadGoalRecord,
    messages: list[roboto.ai.agent_thread.record.AgentMessage],
)
```

`from roboto.ai.agent_thread import AgentThreadGoalView`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/agent_thread/agent_thread_goal_view.py#L27-L190)

Goal declared on a turn of a thread, with the result the AI submitted for it found in the thread's messages.

[`goals`](/docs/reference/python-sdk/roboto/ai/agent_thread/agent_thread#roboto.ai.agent_thread.agent_thread.AgentThread.goals) returns these; you do not build one directly. A view reads its fields from a [`AgentThreadGoalRecord`](/docs/reference/python-sdk/roboto/ai/core/record#roboto.ai.core.record.AgentThreadGoalRecord), and finds the goal's tool use and tool result among the messages of the thread that returned it by the record's `achieve_tool_use_id`. The first read of `achieve_tool_use`, `achieve_tool_result` or `result` searches the messages once for all three.

**Parameters**

- **record** (`roboto.ai.agent_thread.record.AgentThreadGoalRecord`)
- **messages** (`list[roboto.ai.agent_thread.record.AgentMessage]`)

**Properties**

- **AgentThreadGoalView.achieve_tool_result** (`roboto.ai.agent_thread.record.AgentToolResultContent | None`): Tool result that answers `achieve_tool_use`, found in the thread's messages.

  `None` when `achieve_tool_use_id` is `None`, or when the thread's messages hold no result for it. A failed goal whose last attempt errored before Roboto recorded its result has a tool use and no tool result.

- **AgentThreadGoalView.achieve_tool_use** (`roboto.ai.agent_thread.record.AgentToolUseContent | None`): Tool use in which the AI submitted the goal's result, found in the thread's messages.

  `None` when `achieve_tool_use_id` is `None`, or when the thread's messages do not include the tool use, as when the thread was fetched before Roboto recorded it.

- **AgentThreadGoalView.achieve_tool_use_id** (`str | None`): ID of the tool use in which the AI submitted the goal's result.

  [`achieve_tool_use_id`](/docs/reference/python-sdk/roboto/ai/core/record#roboto.ai.core.record.AgentThreadGoalRecord.achieve_tool_use_id) says which attempt it names for each status, and when it is `None`.

- **AgentThreadGoalView.concluded_at** (`datetime.datetime | None`): Time the goal was achieved or failed, or `None` while it is pending.

- **AgentThreadGoalView.created** (`datetime.datetime`): Time the goal was declared.

- **AgentThreadGoalView.goal_data** (`dict[str, Any]`): [`AgentGoal`](/docs/reference/python-sdk/roboto/ai/goals/types#roboto.ai.goals.types.AgentGoal) as a JSON-compatible dictionary.

  `to_agent_goal` builds the typed goal from it.

- **AgentThreadGoalView.goal_type** (`str`): Kind of goal, such as `"dataset_summary"`, which selects the model `goal_data` follows.

- **AgentThreadGoalView.message_sequence_num** (`int`): Index, in the thread's `messages`, of the user message that declared the goal.

- **AgentThreadGoalView.record** (`roboto.ai.agent_thread.record.AgentThreadGoalRecord`): Record of the goal that this instance holds.

- **AgentThreadGoalView.result** (`roboto.ai.goals.results.GoalResult | None`): Result the AI submitted for the goal, built from `achieve_tool_use`.

  It is the [`GoalResult`](/docs/reference/python-sdk/roboto/ai/goals/results#roboto.ai.goals.results.GoalResult) member `goal_type` selects, such as a [`DatasetSummaryGoalResult`](/docs/reference/python-sdk/roboto/ai/goals/results#roboto.ai.goals.results.DatasetSummaryGoalResult) for a `"dataset_summary"` goal. It holds the fields the AI submitted in `achieve_tool_use`, that tool use, `achieve_tool_result`, and the goal's `status`. A pending goal can already have a result from the AI's latest attempt, with [`PENDING`](/docs/reference/python-sdk/roboto/ai/goals/types#roboto.ai.goals.types.AgentGoalStatus.PENDING) as its status, so check `status` before relying on it.

  `None` when `achieve_tool_use` is `None`, or when the submitted fields fail validation against the result model, as fields submitted under an earlier version of the goal's schema can. `achieve_tool_use` still holds those fields.

- **AgentThreadGoalView.status** (`roboto.ai.agent_thread.record.AgentGoalStatus`): Status of the goal.

#### AgentThreadGoalView.to_agent_goal()

```python
def to_agent_goal() -> roboto.ai.goals.types.AgentGoal
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/agent_thread/agent_thread_goal_view.py#L94-L101)

Build the typed goal from `goal_data`.

**Returns**

- `roboto.ai.goals.types.AgentGoal`: The goal as the [`AgentGoal`](/docs/reference/python-sdk/roboto/ai/goals/types#roboto.ai.goals.types.AgentGoal) member `goal_type` selects, such as [`DatasetSummaryAgentGoal`](/docs/reference/python-sdk/roboto/ai/goals/types#roboto.ai.goals.types.DatasetSummaryAgentGoal) for `"dataset_summary"`.
