Holds extended information about an agent run. Attributes: output (Any | None): The final output of the agent run, if available. state (Literal["success", "max_steps_error"]): The final state of the agent after the run. steps (list[dict]): The agent's memory, as a list o
| 194 | |
| 195 | @dataclass |
| 196 | class RunResult: |
| 197 | """Holds extended information about an agent run. |
| 198 | |
| 199 | Attributes: |
| 200 | output (Any | None): The final output of the agent run, if available. |
| 201 | state (Literal["success", "max_steps_error"]): The final state of the agent after the run. |
| 202 | steps (list[dict]): The agent's memory, as a list of steps. |
| 203 | token_usage (TokenUsage | None): Count of tokens used during the run. |
| 204 | timing (Timing): Timing details of the agent run: start time, end time, duration. |
| 205 | messages (list[dict]): The agent's memory, as a list of messages. |
| 206 | <Deprecated version="1.22.0"> |
| 207 | Parameter 'messages' is deprecated and will be removed in version 1.25. Please use 'steps' instead. |
| 208 | </Deprecated> |
| 209 | """ |
| 210 | |
| 211 | output: Any | None |
| 212 | state: Literal["success", "max_steps_error"] |
| 213 | steps: list[dict] |
| 214 | token_usage: TokenUsage | None |
| 215 | timing: Timing |
| 216 | |
| 217 | def __init__(self, output=None, state=None, steps=None, token_usage=None, timing=None, messages=None): |
| 218 | # Handle deprecated 'messages' parameter |
| 219 | if messages is not None: |
| 220 | if steps is not None: |
| 221 | raise ValueError("Cannot specify both 'messages' and 'steps' parameters. Use 'steps' instead.") |
| 222 | warnings.warn( |
| 223 | "Parameter 'messages' is deprecated and will be removed in version 1.25. Please use 'steps' instead.", |
| 224 | FutureWarning, |
| 225 | stacklevel=2, |
| 226 | ) |
| 227 | steps = messages |
| 228 | |
| 229 | # Initialize with dataclass fields |
| 230 | self.output = output |
| 231 | self.state = state |
| 232 | self.steps = steps |
| 233 | self.token_usage = token_usage |
| 234 | self.timing = timing |
| 235 | |
| 236 | @property |
| 237 | def messages(self): |
| 238 | """Backward compatibility property that returns steps.""" |
| 239 | warnings.warn( |
| 240 | "Parameter 'messages' is deprecated and will be removed in version 1.25. Please use 'steps' instead.", |
| 241 | FutureWarning, |
| 242 | stacklevel=2, |
| 243 | ) |
| 244 | return self.steps |
| 245 | |
| 246 | def dict(self): |
| 247 | return { |
| 248 | "output": self.output, |
| 249 | "state": self.state, |
| 250 | "steps": self.steps, |
| 251 | "token_usage": self.token_usage.dict() if self.token_usage is not None else None, |
| 252 | "timing": self.timing.dict(), |
| 253 | } |
no outgoing calls
searching dependent graphs…