A JavaScript ES6 agent CLI that connects to the Claude API and implements an agent loop with tools.
- Complete request/response logging (console + file)
- Two tools:
ping
andecho
- Multi-turn conversation support
- Interactive and example modes
# Run directly with npx (no installation needed)
npx @imgly/prototype-agent-loop
When prompted, select option 2 for interactive mode and enter:
Please run ping localhost and when you received ping response then run echo with the result
This will demonstrate:
- The agent using the
ping
tool to check localhost - Processing the ping result
- Using the
echo
tool to report the result - Complete logging of all API interactions
- Clone and install:
git clone https://github.com/imgly/prototype-agent-loop.git
cd prototype-agent-loop
npm install
-
API Key Setup (choose one):
- Option A: Set environment variable:
export ANTHROPIC_API_KEY=your-api-key
- Option B: Use 1Password CLI (automatic):
- Make sure you're signed in:
op signin
- The CLI will automatically fetch the key
- Make sure you're signed in:
- Option A: Set environment variable:
-
Run locally:
npm start
# or
node agent-cli.js
All requests and responses are logged to:
- Console (with timestamps)
- Log files in
./logs/
directory
Each session creates a new log file with complete API request/response data, tool calls, and results.
The CLI includes an example prompt that demonstrates multi-turn interaction:
- Pings multiple servers
- Makes decisions based on results
- Provides status summaries
This forces the LLM to use tools across multiple turns to complete the task.