Get BaseAgent running in 5 minutes
Before starting, ensure you have:
- Python 3.9+ installed
- An LLM API key (Chutes, OpenRouter, or Anthropic)
- BaseAgent installed (see Installation)
Choose your provider and set the environment variable:
# For Chutes AI (recommended)
export CHUTES_API_TOKEN="your-token-from-chutes.ai"
# OR for OpenRouter
export OPENROUTER_API_KEY="sk-or-v1-..."Navigate to the BaseAgent directory and run:
python3 agent.py --instruction "Create a file called hello.txt with the content 'Hello, World!'"You'll see JSONL events as the agent works:
{"type": "thread.started", "thread_id": "sess_1234567890"}
{"type": "turn.started"}
{"type": "item.started", "item": {"type": "command_execution", "command": "write_file"}}
{"type": "item.completed", "item": {"type": "command_execution", "status": "completed"}}
{"type": "turn.completed", "usage": {"input_tokens": 5000, "output_tokens": 200}}And the file hello.txt will be created:
cat hello.txt
# Output: Hello, World!python3 agent.py --instruction "Explore this repository and describe its structure"python3 agent.py --instruction "Find all Python files and show me the main entry point"python3 agent.py --instruction "Create a Python script that prints the Fibonacci sequence up to 100"python3 agent.py --instruction "Add a docstring to all functions in src/core/loop.py"BaseAgent emits JSONL (JSON Lines) format for machine-readable output:
sequenceDiagram
participant User
participant Agent
participant stdout as Output
User->>Agent: --instruction "..."
Agent->>stdout: {"type": "thread.started", ...}
Agent->>stdout: {"type": "turn.started"}
loop Tool Execution
Agent->>stdout: {"type": "item.started", ...}
Agent->>stdout: {"type": "item.completed", ...}
end
Agent->>stdout: {"type": "turn.completed", "usage": {...}}
| Event | Description |
|---|---|
thread.started |
Session begins with unique ID |
turn.started |
Agent begins processing |
item.started |
Tool execution begins |
item.completed |
Tool execution finished |
turn.completed |
Agent finished with usage stats |
turn.failed |
Error occurred |
# Basic usage
python3 agent.py --instruction "Your task description"
# With environment variables inline
CHUTES_API_TOKEN="..." python3 agent.py --instruction "..."
# Redirect output to file
python3 agent.py --instruction "..." > output.jsonl 2>&1Here's what happens when you run a task:
flowchart TB
subgraph Input
Cmd["python3 agent.py --instruction '...'"]
end
subgraph Init["Initialization"]
Parse[Parse Arguments]
Config[Load Configuration]
LLM[Initialize LLM Client]
Tools[Register Tools]
end
subgraph Loop["Agent Loop"]
Context[Manage Context]
Cache[Apply Caching]
Call[Call LLM]
Execute[Execute Tools]
Verify[Self-Verify]
end
subgraph Output
JSONL[Emit JSONL Events]
Done[Task Complete]
end
Cmd --> Parse --> Config --> LLM --> Tools
Tools --> Context --> Cache --> Call
Call --> Execute --> Context
Execute --> Verify --> Done
Context & Call & Execute --> JSONL
# ❌ Too vague
python3 agent.py --instruction "Fix the bug"
# ✅ Specific
python3 agent.py --instruction "Fix the TypeError in src/utils.py line 42 where x is None"# ❌ Missing context
python3 agent.py --instruction "Add tests"
# ✅ With context
python3 agent.py --instruction "Add unit tests for the calculate_total function in src/billing.py"# ✅ Ask for verification
python3 agent.py --instruction "Create a Python script for sorting and verify it works with sample data"The agent starts in the current directory. Ensure you're in the right location:
pwd # Check current directory
ls # List files
cd /path/to/project
python3 /path/to/baseagent/agent.py --instruction "..."If you hit rate limits, the agent will automatically retry with exponential backoff. You can also:
# Set a cost limit
export LLM_COST_LIMIT="5.0"For complex tasks, the agent may iterate many times. Monitor progress through the JSONL output:
python3 agent.py --instruction "..." 2>&1 | grep "item.completed"- Usage Guide - Detailed command-line options
- Configuration - Customize behavior
- Tools Reference - Available tools
- Best Practices - Optimization tips