View Work
All tinkering

Agent Orchestration

Running 100K agent sessions at once: async execution, risk-based approval lanes, and sending each step to the cheapest model that can handle it.

Agent Orchestration architecture diagram

The problem

When a user asks an agent to "cancel my subscription and refund this month", the agent makes several LLM calls and three writes: a Stripe refund, a record update and a confirmation email. Any of those can time out or get retried. Run 100,000 sessions like that at once, and duplicate refunds, stuck sessions, a growing LLM bill and unchecked writes to production become everyday problems.

The solution

The design rests on one rule: the agent proposes actions, and something else decides whether they run. Requests go through an event stream instead of being handled inline. An orchestrator that keeps no state in memory plans each step, so any instance can pick up any session. Every tool call passes a guardrail engine that runs it now, waits for a human, or holds it.

Core capabilities

Async from the start

Each action is written to the database before anything runs, and work moves through Kafka in order per session. A slow tool or a timed-out LLM call can't block the rest of the system.

Model routing by cost

A router checks how complex each step is first. Roughly 80% go to small models like Haiku or Llama, 15% to GPT-4o mini and 5% to GPT-4o, which is around 10x cheaper with little quality loss.

Fast lane, slow lane

Read-only actions like search, retrieval and analysis run immediately. Writes, emails, payments and deletes wait for a human to approve them.

Quarantine for unclear cases

High-risk or ambiguous actions are held, not executed. The user sees the proposed action with the agent's reasoning and can approve, change or reject it.

No duplicate writes

Every action carries a unique key that's checked against an execution log before it runs, so a retry after a crash or timeout never performs the same write twice.

Why this matters

An agent is basically an unreliable client with access to your most dangerous APIs. Treat it like one and the rest follows: timeouts become safe retries, risky writes wait for a person, and you can look up what any single action cost.