CLI Tracing Setup
Automatic tracing code generation for your AI agents. The CLI analyzes your codebase and generates the new simplified tracing approach automatically.
Prerequisites: Node.js and a Handit.ai account. The CLI handles all SDK installation and configuration automatically.
Quick Setup
Step 1: Install the CLI
npm install -g @handit.ai/cli
Step 2: Run Setup
handit-cli setup
The CLI will:
- Connect your Handit.ai account
- Analyze your codebase to find agent functions
- Generate tracing code using the new simplified approach
- Configure your API key and environment
What the CLI Generates
The CLI creates tracing code using the new simplified approach:
Configuration Files
Agent Wrapper Code
The CLI generates wrappers for your agent functions using the new simplified approach:
Key point: The CLI only adds tracing to your main agent functions (entry points), not to individual helper functions. Everything inside the traced function gets captured automatically.
Managing Your Setup
Update Configuration
# Re-run setup to update configuration
handit-cli setup
When to re-run setup:
- After adding new agent functions
- When changing your project structure
- If tracing stops working
- To update to latest approach
Verify Setup
✅ Check your dashboard: Go to dashboard.handit.ai - you should see:
- Agent traces appearing when you run your AI
- Complete execution flows captured automatically
- Performance metrics and timing data
Integration Examples
The CLI adapts to different codebase structures:
Class-based Agents
# Your original code (unchanged)
class CustomerAgent:
async def process_request(self, msg):
return await self.handle_request(msg)
# CLI generates traced wrapper
class TracedCustomerAgent(CustomerAgent):
@tracing(agent="customer-agent")
async def process_request(self, msg):
return await super().process_request(msg)
API Endpoints
# FastAPI integration (CLI-generated)
from handit_ai import tracing
@app.post("/chat")
@tracing(agent="chat-api")
async def chat_endpoint(message: str):
return await process_chat(message)
Multiple Agents
# CLI generates separate traced versions
@tracing(agent="customer-service")
async def handle_customer_query(message):
return await process_customer_request(message)
@tracing(agent="technical-support")
async def handle_technical_query(message):
return await process_technical_request(message)
Next Steps
- View your traces in the Dashboard
- Set up Evaluation to assess trace quality
- Configure Autonomous Fixes for continuous improvement
Your AI is now fully observable! The CLI has generated everything needed for your autonomous engineer to monitor your AI and create improvements.
Troubleshooting
CLI setup issues: Ensure Node.js is installed and you have a valid Handit.ai account. Try running handit-cli setup
again.
No traces appearing: Verify your API key is configured correctly and your traced functions are being called.
Performance concerns: The new simplified approach has minimal overhead. Contact support for high-volume optimization.
For more help, visit our Support page or join our Discord community .