Overview
The agent harness wraps any provider harness and adds an agentic loop: it calls the LLM, checks permissions on tool calls, executes approved tools, feeds results back as messages, and loops until the agent provides a final answer or hitsmaxIterations.
Quick Start
Built-in Tools
LLM Gateway provides four core tools:- bash
- read
- patch
- agent
Execute shell commands:The bash tool returns
{ exitCode, stdout, stderr }.The Agentic Loop
The agent harness runs this loop:invoke() → AsyncIterable<HarnessEvent>. The consumer doesn’t know how many LLM calls happened internally.
Permissions
Tool execution is gated by glob-pattern matching:Allow all bash commands
Allow specific command patterns
Deny dangerous operations
One-time approvals
git push auto-approves, subsequent calls require relay approval.
Human-in-the-Loop
When a tool call doesn’t match any permission rule, the agent pauses and yields arelay event:
Custom Tools
Define your own tools:Tool Execution Result
Theexecute function returns:
Permission Derivation
ImplementderivePermission to enable “always allow”:
Tool Context
Tools receive a context object with useful metadata:spawn:
Concurrent Tool Execution
The agent harness executes multiple tool calls concurrently when the LLM requests them in the same turn:Iteration Limits
SetmaxIterations to prevent infinite loops:
Debugging
Enable logging to trace the agentic loop:Next Steps
Multi-Agent
Orchestrate multiple concurrent agents
Human-in-the-Loop
Add permission approval flows
