Agent result handling for SDK.

This module defines the AgentResult class which encapsulates the complete response from an agent’s processing cycle.

## AgentResult

```python
@dataclass
class AgentResult()
```

Defined in: [src/strands/agent/agent\_result.py:20](https://github.com/strands-agents/harness-sdk/blob/main/strands-py/src/strands/agent/agent_result.py#L20)

Represents the last result of invoking an agent with a prompt.

**Attributes**:

-   `stop_reason` - The reason why the agent’s processing stopped.
-   `message` - The last message generated by the agent.
-   `metrics` - Performance metrics collected during processing.
-   `state` - Additional state information from the event loop.
-   `interrupts` - List of interrupts if raised by user.
-   `structured_output` - Parsed structured output when structured\_output\_model was specified.
-   `checkpoint` - Checkpoint captured when the agent paused for durable execution. Populated only when stop\_reason == “checkpoint”. See strands.experimental.checkpoint for usage.

#### context\_size

```python
@property
def context_size() -> int | None
```

Defined in: [src/strands/agent/agent\_result.py:44](https://github.com/strands-agents/harness-sdk/blob/main/strands-py/src/strands/agent/agent_result.py#L44)

Most recent context size in tokens from the last LLM call.

**Returns**:

The input token count from the most recent cycle, or None if no data is available.

#### projected\_context\_size

```python
@property
def projected_context_size() -> int | None
```

Defined in: [src/strands/agent/agent\_result.py:53](https://github.com/strands-agents/harness-sdk/blob/main/strands-py/src/strands/agent/agent_result.py#L53)

Projected context size for the next model call.

**Returns**:

The projected token count (inputTokens + outputTokens), or None if no data is available.

#### \_\_str\_\_

```python
def __str__() -> str
```

Defined in: [src/strands/agent/agent\_result.py:61](https://github.com/strands-agents/harness-sdk/blob/main/strands-py/src/strands/agent/agent_result.py#L61)

Return a string representation of the agent result.

Priority order:

1.  Interrupts (if present) → stringified list of interrupt dicts
2.  Structured output (if present) → JSON string
3.  Text content from message → concatenated text blocks

**Returns**:

String representation based on the priority order above.

#### from\_dict

```python
@classmethod
def from_dict(cls, data: dict[str, Any]) -> "AgentResult"
```

Defined in: [src/strands/agent/agent\_result.py:94](https://github.com/strands-agents/harness-sdk/blob/main/strands-py/src/strands/agent/agent_result.py#L94)

Rehydrate an AgentResult from persisted JSON.

**Arguments**:

-   `data` - Dictionary containing the serialized AgentResult data

**Returns**:

AgentResult instance

**Raises**:

-   `TypeError` - If the data format is invalid

#### to\_dict

```python
def to_dict() -> dict[str, Any]
```

Defined in: [src/strands/agent/agent\_result.py:120](https://github.com/strands-agents/harness-sdk/blob/main/strands-py/src/strands/agent/agent_result.py#L120)

Convert this AgentResult to JSON-serializable dictionary.

**Returns**:

Dictionary containing serialized AgentResult data