Tool Execution & Results

Master invocation patterns, result handling, and error management for reliable AI agents

Result Handling: From Data to Intelligence

A tool returns dataโ€”but an agent needs intelligence. Result handling is the art of transforming raw responses into actionable information the agent can reason about and act upon.

This process involves parsing, validation, extraction, and formattingโ€”each step critical to agent reliability.

Interactive: Result Parsing Pipeline

Watch how raw tool output transforms into agent-ready data

Receive Response
Raw bytes from tool execution
HTTP 200 OK Content-Type: application/json{'{'status':'success','data':{...}}}

Result Format Comparison

Unprocessed tool response
{
  "status": "success",
  "timestamp": "2024-01-15T10:30:00Z",
  "data": {
    "temperature": 22,
    "humidity": 65,
    "conditions": "partly cloudy",
    "forecast": [...]
  },
  "metadata": {
    "source": "weather-api",
    "cached": false
  }
}
Complexity:
Low
Best Usage:
Developer debugging, full access
Agent-Ready Output
It's 22ยฐC and partly cloudy in Tokyo.

Result Handling Best Practices

โœ…
Always Validate
Check response schema, types, and required fields before use
๐Ÿ”
Extract Essentials
Pull only what the agent needsโ€”avoid passing bloated objects
๐Ÿท๏ธ
Add Metadata
Include source, timestamp, confidence for traceability
๐Ÿ“
Normalize Format
Standardize structure across different tools for consistency
๐Ÿ›ก๏ธ
Handle Nulls
Gracefully manage missing, null, or undefined values
๐Ÿ“
Log Raw Results
Keep original responses for debugging and auditing