AgentResult¶
Result from agent execution, wrapping pydantic-ai's RunResult.
Quick Example¶
from mamba_agents import Agent
agent = Agent("gpt-4o")
result = await agent.run("What is 2 + 2?")
# Access output
print(result.output) # "4"
# Access usage
usage = result.usage()
print(f"Tokens: {usage.total_tokens}")
# Access messages
new_msgs = result.new_messages()
all_msgs = result.all_messages()
Properties and Methods¶
| Member | Type | Description |
|---|---|---|
output |
OutputT | The typed output from the agent |
data |
OutputT | Alias for output |
usage() |
TokenUsage | Token usage for this run |
new_messages() |
list | Messages from this run only |
all_messages() |
list | Complete message history |
API Reference¶
AgentResult
dataclass
¶
Wrapper for agent run results with additional metadata.
Provides convenient access to the result output, message history, and usage statistics.
| ATTRIBUTE | DESCRIPTION |
|---|---|
_result |
The underlying pydantic-ai RunResult.
TYPE:
|
output
property
¶
Get the final output from the agent run.
| RETURNS | DESCRIPTION |
|---|---|
T
|
The typed output from the agent. |
data
property
¶
Alias for output (for backwards compatibility).
| RETURNS | DESCRIPTION |
|---|---|
T
|
The typed output from the agent. |
usage
¶
Get token usage statistics for this run.
| RETURNS | DESCRIPTION |
|---|---|
Usage
|
Usage statistics including input/output tokens. |
new_messages
¶
Get new messages generated during this run.
| RETURNS | DESCRIPTION |
|---|---|
list[Any]
|
List of messages from this run (for message history). |
all_messages
¶
Get all messages including history.
| RETURNS | DESCRIPTION |
|---|---|
list[Any]
|
Complete message history including new messages. |