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

### AnalysisScope

```python
class roboto.ai.core.context.AnalysisScope(/, **data: Any)
```

`from roboto.ai.agent_thread import AnalysisScope`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/core/context.py#L91-L135)

Bases: `pydantic.BaseModel`

Time window of the data Roboto's AI analyzes in a thread.

Carried in [`analysis_scope`](/docs/reference/python-sdk/roboto/ai/agent_thread/record#roboto.ai.agent_thread.record.StartAgentThreadRequest.analysis_scope), [`analysis_scope`](/docs/reference/python-sdk/roboto/ai/agent_thread/record#roboto.ai.agent_thread.record.SendMessageRequest.analysis_scope), [`analysis_scope`](/docs/reference/python-sdk/roboto/ai/agent/record#roboto.ai.agent.record.LaunchAgentRequest.analysis_scope) and [`analysis_scope`](/docs/reference/python-sdk/roboto/domain/triggers/targets#roboto.domain.triggers.targets.StartAgentTarget.analysis_scope). Roboto passes the scope to each tool the AI calls, and each tool decides whether to apply it. A bound left `None` leaves that end of the window open, so a scope with both bounds `None` limits nothing.

Building it raises `pydantic.ValidationError` when `start_time` is after `end_time`.

**Parameters**

- **data** (`Any`)

**Attributes**

- **AnalysisScope.end_time** (`roboto.time._NanosecondsFromInteger | None`) = `None`: Inclusive end of the window, in nanoseconds since the Unix epoch. `None` leaves the end open.
- **AnalysisScope.start_time** (`roboto.time._NanosecondsFromInteger | None`) = `None`: Inclusive start of the window, in nanoseconds since the Unix epoch. `None` leaves the start open.

#### AnalysisScope.merge()

```python
def merge(override: AnalysisScope) -> AnalysisScope
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/core/context.py#L116-L135)

Build a scope that takes each bound from `override` when it is set, and from this scope otherwise.

Roboto calls this when a user launches an agent, or a trigger starts one, with a scope set. It merges that scope, as `override`, into the scope in the agent's request template, as this scope.

**Parameters**

- **override** (`AnalysisScope`): Scope whose bounds replace this scope's. A bound left `None` keeps this scope's.

**Returns**

- `AnalysisScope`: A new scope. Neither this scope nor `override` changes.

**Raises**

- `pydantic.ValidationError`: The resulting start is after the resulting end, as when `override` sets only a start later than this scope's end.

### ClientViewingContext

```python
class roboto.ai.core.context.ClientViewingContext(/, **data: Any)
```

`from roboto.ai.core import ClientViewingContext`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/core/context.py#L14-L88)

Bases: `pydantic.BaseModel`

What the caller had open in their client, such as the Roboto web app, when they wrote a message to Roboto's AI.

Carried in [`client_context`](/docs/reference/python-sdk/roboto/ai/agent_thread/record#roboto.ai.agent_thread.record.StartAgentThreadRequest.client_context) and [`client_context`](/docs/reference/python-sdk/roboto/ai/agent_thread/record#roboto.ai.agent_thread.record.SendMessageRequest.client_context), and stored on the caller's message as [`context`](/docs/reference/python-sdk/roboto/ai/core/content#roboto.ai.core.content.AgentClientContextEntry.context). It lets the AI resolve references such as "this dataset" or "those files" without the caller naming them. It does not change what the AI may access: the AI still reads each resource through its own tools. Roboto also records each dataset, file and session it names as an [`AgentThreadSubject`](/docs/reference/python-sdk/roboto/ai/agent_thread/record#roboto.ai.agent_thread.record.AgentThreadSubject), so the thread can be found from that resource.

It differs from [`AnalysisScope`](/docs/reference/python-sdk/roboto/ai/core/context#roboto.ai.core.context.AnalysisScope), which limits the data the AI's tools read, and from [`AgentGoal`](/docs/reference/python-sdk/roboto/ai/goals/types#roboto.ai.goals.types.AgentGoal), which states a result the AI must reach in a turn.

**Parameters**

- **data** (`Any`)

**Attributes**

- **ClientViewingContext.collection_ids** (`list[str]`) = `None`: IDs of the collections the caller had open or selected. Defaults to none.

- **ClientViewingContext.dataset_ids** (`list[str]`) = `None`: IDs of the datasets the caller had open or selected. Defaults to none.

- **ClientViewingContext.device_ids** (`list[str]`) = `None`: IDs of the devices the caller had open or selected. Defaults to none.

  Each is the ID the organization gave the device, such as a serial number, so unlike the other IDs here it has no fixed prefix.

- **ClientViewingContext.device_type_ids** (`list[str]`) = `None`: IDs of the device types the caller had open. Defaults to none.

- **ClientViewingContext.display_time_anchor_label** (`str | None`) = `None`: Name the client shows for the time in `display_time_anchor_ns`, or `None` when that field is `None`.

  The name is "Start of workspace" or a chosen timestamp in local time. It lets the AI name the time an offset counts from.

- **ClientViewingContext.display_time_anchor_ns** (`int | None`) = `None`: Time the client shows as zero, in nanoseconds since the Unix epoch, or `None` if it shows absolute times.

  The client sets it while the caller reads timestamps as time elapsed since this time. It lets the AI turn a relative time the caller types, such as "around 65 s", into an absolute time. The AI still reports times back in nanoseconds since the Unix epoch.

- **ClientViewingContext.file_ids** (`list[str]`) = `None`: IDs of the files the caller had open or selected. Defaults to none.

- **ClientViewingContext.misc_context** (`dict[str, Any] | None`) = `None`: Other context from the client that fits none of the other fields, or `None` for none.

- **ClientViewingContext.session_ids** (`list[str]`) = `None`: IDs of the sessions the caller had open. Defaults to none.

- **ClientViewingContext.table_state** (`dict[str, Any] | None`) = `None`: Resource table the caller had open, or `None` if they wrote the message from elsewhere.

  Holds the table's `target` (`datasets`, `files`, ...) and its current `definition`, in the shape a View stores: RoboQL text or filter controls, plus the visible columns, sort and page size. The client sends it whether or not a View is loaded, so the AI can describe filters the caller has not saved, and can save the table as it stands when the caller asks it to save what they are looking at as a View.

- **ClientViewingContext.view_ids** (`list[str]`) = `None`: IDs of the Views applied to the resource table the caller had open. Defaults to none.

  A View is a saved, shareable search over one kind of resource. These IDs let the AI resolve "this View" without the caller naming it.

- **ClientViewingContext.visualizer_state** (`dict[str, Any] | None`) = `None`: State of the visualizer, or `None` if the caller wrote the message from elsewhere.

  The Roboto web app defines its form.
