Overview
TheRuntime class is the core interface agents use to record their behavior. It captures decisions, outcomes, and problems in a structured format that the Builder LLM can analyze to improve agent performance.
Class: Runtime
Constructor
Path to the storage directory for run data
Run Lifecycle
start_run()
Start a new run for a goal.The ID of the goal being pursued
Human-readable description of the goal
Initial input data for the run
Unique identifier for this run (format:
run_YYYYMMDD_HHMMSS_hash)end_run()
End the current run and save results.Whether the run achieved its goal
Human-readable summary of what happened
Final output of the run
set_node()
Set the current node context for subsequent decisions.ID of the node being executed
Decision Recording
decide()
Record a decision the agent made. This is the primary method for capturing agent behavior.What the agent was trying to accomplish
List of options considered. Each option should have:
id(str): Unique identifierdescription(str): What this option doesaction_type(str): βtool_callβ, βgenerateβ, βdelegateβ, etc.action_params(dict, optional): Parameters for the actionpros(list[str], optional): Why this might be goodcons(list[str], optional): Why this might be badconfidence(float, optional): Agentβs confidence (0-1)
ID of the chosen option
Why the agent chose this option
Which node made this decision (uses current if not set)
Type of decision: TOOL_SELECTION, PARAMETER_CHOICE, PATH_CHOICE, OUTPUT_FORMAT, RETRY_STRATEGY, DELEGATION, TERMINATION, CUSTOM
Active constraints that influenced the decision
Additional context available when deciding
The decision ID (use to record outcome later)
record_outcome()
Record the outcome of a decision after executing the action.ID returned from decide()
Whether the action succeeded
The actual result/output
Error message if failed
Human-readable summary of what happened
What state changed as a result
LLM tokens consumed
Time taken in milliseconds
Problem Reporting
report_problem()
Report a problem that occurred during execution.Problem severity: βcriticalβ, βwarningβ, or βminorβ
What went wrong
Which decision caused this (if known)
Why it went wrong (if known)
What might fix it (if known)
The problem ID
Convenience Methods
decide_and_execute()
Record a decision and immediately execute it.Function to call to execute the action
Tuple of (decision_id, result)
quick_decision()
Record a simple decision with a single action (no alternatives).What the agent is trying to do
What itβs doing
Why
Node making the decision
The decision ID
Properties
current_run
Get the current run object for inspection.The current Run object, or None if no run is active
execution_id
Get the current execution ID for trace correlation.The execution ID (32-character hex string)