See what your AI agent is thinking
Add one decorator and unlock debugging superpowers. No more black box AI.
How @xray works
Examples
Basic Usage
Add the @xray decorator to see inside the agent's mind. Access agent name, task, and iteration count.
Execution Trace
Call xray.trace() to see the complete execution flow of your agent. Perfect for understanding multi-step processes.
IDE Debug
Set breakpoints in your IDE and inspect the xray context. Access the full agent state including messages and previous tool calls.
What You Can Access
xray context object
xray.agent
The Agent instance calling this tool
xray.task
Original request from user
xray.messages
Full conversation history
xray.iteration
Which round of tool calls (1-10)
xray.previous_tools
Tools called before this one
xray.trace()
Visual execution trace
Practical Use Cases
Understand Context
See why a tool was called and what led to it
Adaptive Behavior
Change tool behavior based on execution context
Debug Complex Flows
Get full visibility into multi-step agent processes
Pro Tips
Development Only
Remove @xray in production for best performance
Combine with IDE
Set breakpoints for interactive debugging
Use trace()
Call xray.trace() after runs to see full flow
Check context
Always verify xray.agent exists before using