MCPcopy
hub / github.com/huggingface/smolagents / RunResult

Class RunResult

src/smolagents/agents.py:196–253  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

194
195@dataclass
196class 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 }

Callers 2

runMethod · 0.85

Calls

no outgoing calls

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…