Overview
LLM Gateway supports human-in-the-loop (HITL) permission approval through relay events. When an agent attempts a tool call that doesn’t match the allowlist, it pauses and yields arelay event. The consumer can then prompt the user for approval, and the agent resumes based on the response.
How It Works
Permission checking follows this flow:Permission Check
The agent harness checks each tool call against the permission rules:
- Match in
deny: Tool call rejected immediately - Match in
allowlist: Tool executes automatically - Match in
allowOnce: Tool executes, permission consumed - No match: Relay event emitted, agent pauses
CLI Example
Simple command-line approval flow:Server-Side with Orchestrator
In a server context, relay resolution happens over HTTP:- Server
- Client
The server strips
respond callbacks and exposes POST /chat/relay/:relayId:Always Allow
When a user approves withalways: true, the orchestrator:
- Calls the tool’s
derivePermission()to generate a reusable permission pattern - Adds the pattern to the shared allowlist
- All future matching calls auto-approve (no more relays)
Permission Derivation
Tools define how to generalize a specific call:ls /tmp→ always allowls **git push origin main→ always allowgit **rm file.txt→ always allowrm **
Web UI Example
React component with relay approval:Deny with Reason
Provide feedback when denying:Pre-Approvals
Set up common permissions ahead of time:Dangerous Operations
Explicitly deny dangerous patterns:Timeout Handling
Implement timeouts for relay approvals:Next Steps
Client Rendering
Build UIs that render agent events
Multi-Agent
Orchestrate concurrent agents with shared permissions
