Response Structure
Therun.result object contains:
The Answer Field
Theanswer field contains the agent’s final response as a string:
- Without structured output: A natural language string
- With structured output: A JSON-encoded string matching your schema
Accessing Structured Answers
When usinganswerFormat, the API sends answer as a JSON-encoded string. Both SDKs decode it for you and expose the native value on run.result.parsed_answer (Python) / run.result.parsedAnswer (TypeScript). answer stays as the raw string if you need it. The SDKs do not validate the decoded value against your schema — validate yourself with Pydantic or Zod if you want a typed instance.
Understanding the Reasoning Field
Thereasoning field provides visibility into how the agent arrived at its answer. Each task in the array represents a step in the reasoning process.
Task Structure
Example Reasoning Trace
Extracting Tool Call Information
Loop through the reasoning to extract tool usage:Usage Information
Theusage field provides metrics about the run:
input_tokens, output_tokens, duration_ms) on the Usage pydantic model.
Tracking Costs
Use the usage information to track costs:Related
Runs
Understanding run lifecycle
Structured Output
Define response schemas
Error Handling
Handle errors gracefully