Run a Fleet of AI Coding Agents: From Browser Chatbots to Orca, t3code, and MCP Gateways
Originally published on tamiz.pro. The browser chatbot era of AI-assisted development is over. Asking a single model in a chat pane to "fix the bug" and then copy-pasting its patch into your editor was always a bottlene
Originally published on tamiz.pro.
The browser chatbot era of AI-assisted development is over. Asking a single model in a chat pane to "fix the bug" and then copy-pasting its patch into your editor was always a bottleneck: one context window, one serialized thought process, zero awareness of your actual repository state. The teams shipping fastest today don't run one agent β they run a fleet of them, each scoped to a task, sharing the same toolchain, and coordinated by an orchestrator that knows which agent owns which file. This tutorial walks you through building exactly that: a local fleet built from Orca (the orchestrator), t3code (the executor CLI), and a Model Context Protocol (MCP) gateway that gives every agent the same tools, context, and safety rails.
- 1. Why a Fleet, Not a Single Agent
- 2. Architecture Overview
- 3. Prerequisites
- 4. Step 1 β Stand Up the MCP Gateway
- 5. Step 2 β Configure t3code as the Executor
- 6. Step 3 β Define the Orca Orchestration Plan
- 7. Step 4 β Wire the Fleet Together
- 8. Step 5 β Task Routing and Parallel Execution
- 9. Step 6 β Observability and Safety Rails
- 10. Edge Cases and Production Best Practices
- Frequently Asked Questions
1. Why a Fleet, Not a Single Agent
A single coding agent, no matter how capable, is constrained by three hard limits:
- Context exhaustion. One agent's context window fills up fast when it's responsible for a whole feature. It loses track of earlier decisions and starts making contradictory edits.
- Serial execution. One agent can only work on one thing at a time. A refactor, a bug fix, and a test update become a queue, not a pipeline.
- Tool coupling. If the agent's tool access is hardcoded into the model, you can't safely grant different agents different permissions. Everything becomes all-or-nothing.
A fleet solves all three by inverting the control flow. Instead of one agent that does everything, you get many agents that each do one thing, coordinated by an orchestrator that owns the repository state and the task graph. The model becomes a replaceable worker; the toolchain becomes a shared service; and the orchestrator becomes the only thing that touches the filesystem.
That's the architecture we're about to build. It's the same pattern that powers large-scale agent deployments in production CI systems, and you can run it on a single laptop.
2. Architecture Overview
Here's the system we're assembling, in words (no ASCII art needed β the data flow matters more than the boxes):
- You submit a task graph β a list of jobs with dependencies, scopes, and acceptance criteria β to Orca.
- Orca is the orchestrator. It resolves dependencies, assigns each job to a worker, and maintains a lock on the repository so no two agents edit the same file.
- Each worker is a t3code process. t3code is a headless CLI that takes a task description and a working directory, runs the model against the code, and emits a patch + a structured report.
- Every t3code worker connects to the same MCP gateway β a local daemon that exposes tools (file read/write, shell exec, search, git) behind a permission layer. Agents never touch the filesystem directly; they ask the gateway.
- The gateway enforces safety rails: read-only mode for some agents, path allowlists, command denylists, and a rate limiter.
- Results flow back to Orca, which validates them (tests, lints, type checks) before merging or rejecting.
βββββββββββ task graph βββββββββββ spawn ββββββββββββ tools βββββββββββββββ
β You β ββββββββββββββΆ β Orca β βββββββββΆ β t3code #1β ββββββββββΆ β β
βββββββββββ β (orch.) β ββββββββββββ€ β MCP β
β β β t3code #2β ββββββββββΆ β Gateway β
β β ββββββββββββ€ β (tools + β
β β β t3code #Nβ ββββββββββΆ β perms) β
βββββββββββ ββββββββββββ βββββββββββββββ
β β²
β β patches + reports
βΌ β
ββββββββββββ
β git + β
β tests β
ββββββββββββ
The key architectural decision: agents are dumb, the gateway is smart, and Orca is the only writer. This is what makes the fleet safe to run in parallel.
3. Prerequisites
Before you start, make sure you have:
- Node.js 20+ (for Orca and the MCP gateway) and Python 3.11+ (for t3code's model runner, if you use the Python SDK).
- Git installed and a local repository you're comfortable experimenting on β ideally a throwaway branch.
- An LLM API key (OpenAI, Anthropic, or a local model via Ollama). We'll use
ANTHROPIC_API_KEYin examples, but the pattern is provider-agnostic. - Docker (optional, for containerizing workers later).
Install the core CLIs:
# Orca β the orchestrator
npm install -g @orca/orchestrator
# t3code β the executor CLI
npm install -g t3code
# MCP gateway β the tool daemon
npm install -g @mcp/gateway
Verify everything is on the PATH:
orca --version
t3code --version
mcp-gateway --version
4. Step 1 β Stand Up the MCP Gateway
The MCP gateway is the single source of truth for what agents are allowed to do. It exposes a JSON-RPC interface that any MCP client (t3code, Claude Desktop, Cursor, etc.) can connect to. Its job is to wrap filesystem, shell, and git operations behind a permission layer so that a misbehaving agent can't rm -rf your repo or exfiltrate your .env.
Create a config file, gateway.config.json:
{
"port": 8931,
"host": "127.0.0.1",
"tools": {
"read_file": {
"enabled": true,
"allow_paths": ["./src", "./tests", "./package.json", "./tsconfig.json"]
},
"write_file": {
"enabled": true,
"allow_paths": ["./src"],
"max_file_size_kb": 256
},
"edit_file": {
"enabled": true,
"allow_paths": ["./src"],
"require_diff": true
},
"shell_exec": {
"enabled": true,
"allowlist": [
"npm test",
"npm run lint",
"npm run typecheck",
"git status",
"git diff",
"git log --oneline -5"
],
"denylist": ["rm", "sudo", "curl", "wget", "chmod", "git push"]
},
"search": {
"enabled": true,
"max_results": 50
}
},
"rate_limit": {
"requests_per_minute": 120,
"per_tool": {
"shell_exec": 20
}
},
"logging": {
"level": "info",
"file": "./.orca/gateway.log"
}
}
Key things to notice:
-
allow_pathsscopes every file operation to the directories you actually want agents to touch. Agents can read config files but only write insidesrc/. -
shell_execuses a strict allowlist with a denylist as a second layer. The allowlist is the real security boundary; the denylist catches typos and clever variants. -
require_diff: trueforcesedit_fileto send a unified diff, which the gateway applies withpatchβ this prevents agents from doing blind overwrites. - The rate limiter prevents one agent from hammering the shell and starving the others.
Start the gateway:
mcp-gateway start --config ./gateway.config.json
You should see it bind to 127.0.0.1:8931. Test it with a quick MCP handshake:
# List available tools
mcp-gateway tools --endpoint http://127.0.0.1:8931/mcp
You should get back read_file, write_file, edit_file, shell_exec, and search. If you don't, check ./.orca/gateway.log.
5. Step 2 β Configure t3code as the Executor
t3code is the headless worker. It takes a task (a natural-language or structured instruction), a working directory, and a gateway endpoint, and it returns a patch plus a structured report (JSON). It never talks to the model directly for tool calls β it routes them through the MCP gateway.
Create a task file, tasks/fix-login-validation.json:
{
"id": "fix-login-validation",
"description": "Fix the login form so it validates email format before submitting and shows an inline error message.",
"scope": ["./src/components/LoginForm.tsx", "./src/utils/validate.ts"],
"acceptance": [
"npm run lint",
"npm run typecheck",
"npm test -- --runInBand src/components/__tests__/LoginForm.test.tsx"
],
"model": {
"provider": "anthropic",
"model": "claude-sonnet-4-5",
"temperature": 0.2
},
"max_iterations": 8
}
Now run it as a single worker to verify the pipeline works end-to-end:
t3code run \
--task ./tasks/fix-login-validation.json \
--cwd ./my-app \
--gateway http://127.0.0.1:8931/mcp \
--out ./output/fix-login-validation \
--api-key $ANTHROPIC_API_KEY
What happens under the hood:
- t3code reads the task, sets up an MCP client connection to the gateway.
- It sends the task description to the model.
- The model calls
read_fileandsearchon the gateway to understand the code. - The model proposes edits; t3code converts them to a unified diff and sends
edit_fileto the gateway. - The gateway validates the diff against
allow_pathsand applies it. - t3code runs the
acceptancecommands (viashell_execon the gateway) to verify. - If acceptance passes, it writes a report. If not, it feeds the failure back to the model and iterates (up to
max_iterations).
The output directory will contain:
output/fix-login-validation/
βββ patch.diff # the final, applyable patch
βββ report.json # structured result: pass/fail, iterations, tokens, tools used
βββ transcript.md # full agent conversation, for auditing
6. Step 3 β Define the Orca Orchestration Plan
Orca is the brain. It takes a plan file that declares the fleet, the tasks, and their dependencies, then it spawns t3code workers, coordinates them, and merges results. It's the only component that writes to git.
Create orca.plan.yaml:
version: 1
fleet:
max_parallel: 3
worker:
binary: t3code
gateway: http://127.0.0.1:8931/mcp
cwd: ./my-app
api_key_env: ANTHROPIC_API_KEY
repo:
branch: feature/agent-fleet
base: main
merge_strategy: squash
require_clean: true
tasks:
- id: fix-login-validation
depends_on: []
file: ./tasks/fix-login-validation.json
- id: add-login-tests
depends_on: [fix-login-validation]
file: ./tasks/add-login-tests.json
- id: refactor-auth-service
depends_on: [fix-login-validation]
file: ./tasks/refactor-auth-service.json
- id: run-full-suite
depends_on: [add-login-tests, refactor-auth-service]
accept:
- npm test
- npm run lint
- npm run typecheck
This plan declares a dependency graph: fix-login-validation is the root; add-login-tests and refactor-auth-service both depend on it and can run in parallel after it completes; run-full-suite waits for both.
Note the fleet.max_parallel: 3 β that's the concurrency cap. Orca will never spawn more than three t3code processes at once, even if the graph would allow it.
7. Step 4 β Wire the Fleet Together
Now we run the whole thing. Orca handles branch creation, worker spawning, dependency resolution, and merging.
orca run --plan ./orca.plan.yaml
Orca's execution loop, in order:
-
Validate the plan. It checks that all task files exist, that the gateway is reachable, and that the repo is clean (because
require_clean: true). -
Create the feature branch.
git checkout -b feature/agent-fleet(frommain). - Resolve the DAG. It topologically sorts tasks and finds the ready set β tasks with no unmet dependencies.
-
Spawn workers. For each ready task, up to
max_parallel, it spawns at3codeprocess with the task's config. -
Collect results. As each worker finishes, Orca reads its
report.json. Ifpass: true, it marks the task complete and re-evaluates the DAG. Ifpass: false, it marks the task failed and does not run downstream tasks (unlesscontinue_on_erroris set). -
Merge. When all tasks are done, Orca squashes the accumulated patches into a single commit on the feature branch and runs the top-level
acceptcommands. -
Report. It writes a summary to
./.orca/run-summary.jsonand prints a table.
Here's a sample of what Orca prints during a run:
[orca] plan validated: 4 tasks, 3 parallel workers
[orca] branch created: feature/agent-fleet
[orca] ready: fix-login-validation
[orca] spawn worker: fix-login-validation (pid 4123)
[orca] worker done: fix-login-validation (pass, 3 iterations, 1.2k tokens)
[orca] ready: add-login-tests, refactor-auth-service
[orca] spawn worker: add-login-tests (pid 4127)
[orca] spawn worker: refactor-auth-service (pid 4131)
[orca] worker done: add-login-tests (pass, 2 iterations)
[orca] worker done: refactor-auth-service (pass, 5 iterations)
[orca] ready: run-full-suite
[orca] running acceptance: npm test && npm run lint && npm run typecheck
[orca] all tasks passed. merging into feature/agent-fleet
[orca] done: 4/4 tasks passed, 1 commit created
8. Step 5 β Task Routing and Parallel Execution
The simple DAG above is a good start, but real fleets need task routing β the ability to send a task to a specific worker profile based on its nature. You might want a fast worker for small fixes, a deep worker for refactors, and a readonly worker for analysis that never writes.
Extend your Orca plan with worker profiles:
fleet:
profiles:
fast:
model: claude-haiku-4-5
temperature: 0.0
max_iterations: 3
timeout_minutes: 5
tools: [read_file, search, shell_exec]
deep:
model: claude-sonnet-4-5
temperature: 0.2
max_iterations: 12
timeout_minutes: 30
tools: [read_file, write_file, edit_file, search, shell_exec]
readonly:
model: claude-sonnet-4-5
temperature: 0.0
max_iterations: 2
timeout_minutes: 10
tools: [read_file, search]
read_only: true
tasks:
- id: fix-login-validation
profile: fast
file: ./tasks/fix-login-validation.json
- id: refactor-auth-service
profile: deep
file: ./tasks/refactor-auth-service.json
- id: audit-deps
profile: readonly
file: ./tasks/audit-deps.json
Now Orca routes each task to the right profile. The readonly profile is particularly important: it connects to the MCP gateway with a read-only session (the gateway rejects any write_file or edit_file call), so you can run a whole class of agents that literally cannot modify your code.
To enforce read-only at the gateway level, add a session concept to the gateway config:
{
"sessions": {
"readonly": {
"allow": ["read_file", "search"],
"deny": ["write_file", "edit_file", "shell_exec"]
},
"standard": {
"allow": ["read_file", "search", "write_file", "edit_file", "shell_exec"]
}
}
}
And in the t3code task, request a session:
{
"id": "audit-deps",
"description": "Audit for unused dependencies and outdated versions.",
"session": "readonly",
"model": { "provider": "anthropic", "model": "claude-sonnet-4-5" }
}
9. Step 6 β Observability and Safety Rails
A fleet running in parallel is only as good as your ability to see what it's doing and stop it when it goes wrong. Here's the minimum viable observability stack for an Orca fleet.
Structured logging
Orca writes every event to ./.orca/events.jsonl β one JSON object per line. Each event has a task_id, worker_pid, timestamp, event_type, and payload. You can tail it in real time:
tail -f ./.orca/events.jsonl | jq -c 'select(.event_type == "tool_call")'
Metrics
Orca exposes a Prometheus endpoint by default on 127.0.0.1:9090/metrics. Useful gauges:
curl -s http://127.0.0.1:9090/metrics | grep orca_
Key metrics to watch:
-
orca_tasks_in_flightβ current parallel load. -
orca_tasks_failed_totalβ cumulative failures. -
orca_gateway_tool_calls_total{tool="shell_exec"}β how many shell calls agents made. -
orca_worker_iterations_histogramβ how many model iterations tasks needed.
Kill switch
If an agent goes rogue (infinite loop, runaway file edits), you can stop the whole fleet with a single command:
orca stop --plan ./orca.plan.yaml
Orca sends SIGTERM to all workers, and the MCP gateway drops all active sessions. Because the gateway is the only thing that can write, this is a hard stop β no agent can keep writing after the gateway closes.
Safety rail: the patch gate
Before Orca merges any worker's patch, it runs a pre-merge gate. You can define custom gate commands in the plan:
repo:
pre_merge_gates:
- npx prettier --check .
- npx eslint --max-warnings 0 .
- npm run typecheck
If any gate fails, Orca rejects that task's patch and marks the task failed, rather than merging broken code.
10. Edge Cases and Production Best Practices
Running a fleet in production (or even on a busy repo) surfaces edge cases that a single agent never hits. Here's how to handle the big ones.
Concurrent file conflicts
Two agents editing overlapping files is the classic fleet failure. Mitigate it three ways:
-
Scope isolation. Each task's
scopefield tells Orca which files it owns. Orca refuses to schedule two tasks with overlapping scopes simultaneously. - File locking. Orca acquires a lock on each file in a task's scope before spawning the worker, and releases it on completion. If a task's scope is already locked, it waits.
-
Patch application. Even if a conflict slips through, Orca applies patches with
git apply --3wayand falls back togit mergetoolif there's a real conflict, marking the task asneeds_reviewrather than silently overwriting.
Context window exhaustion on long tasks
The deep profile with max_iterations: 12 will eventually blow the context window. Handle it with checkpointing: t3code writes a snapshot of the conversation to output/<task-id>/checkpoint.json after every iteration. If the context fills up, t3code starts a fresh conversation with a compressed summary of the prior state. Enable it per-task:
{
"id": "refactor-auth-service",
"checkpoint": {
"enabled": true,
"interval": 2,
"compress": true
}
}
Model failures and retries
LLM APIs are flaky. Orca has built-in retry with exponential backoff:
fleet:
retry:
max_attempts: 3
backoff_ms: 2000
backoff_multiplier: 2
retry_on: ["rate_limit", "timeout", "server_error"]
Dockerizing workers for isolation
For real production safety, run each t3code worker in a container with a read-only filesystem and only the repo mounted at a specific path. A minimal Dockerfile:
FROM node:20-slim
RUN npm install -g t3code
WORKDIR /workspace
COPY . /workspace
CMD ["t3code", "run", "--task", "/tasks/task.json", "--cwd", "/workspace", "--gateway", "http://gateway:8931/mcp"]
Then point Orca's worker config at a container runtime instead of a local binary:
fleet:
worker:
runtime: docker
image: my-agent-worker:latest
network: host
mounts:
- ./my-app:/workspace
Don't let agents push
This is the most important rule: the MCP gateway's shell_exec denylist must always contain git push. Agents can commit locally, but only Orca (or your CI) should ever push to a remote. This prevents an agent from accidentally pushing broken code or, worse, pushing to main.
If you want to take this further and see how these patterns scale to full CI pipelines and release automation, check out Tamiz's Insights for deeper coverage of agent-driven development workflows.
Frequently Asked Questions
Why use an MCP gateway instead of giving each agent direct filesystem access?
Because the gateway is the security boundary and the audit trail. When agents call tools directly, you have no central place to enforce permissions, rate limits, or path allowlists β and no way to log every tool call. The gateway gives you one choke point where you can say "this agent can only read, that agent can only write to src/, nobody can run rm". It's the difference between a fleet you can trust and a fleet you're praying about.
Can I mix different model providers in one fleet?
Yes. Each task's model.provider field is independent, so you can have one worker on Anthropic, one on OpenAI, and one on a local Ollama model, all in the same plan. The MCP gateway and Orca don't care which provider a worker uses β they only see the tool calls and the resulting patch. This is useful for cost optimization: route simple tasks to a cheap fast model and complex refactors to a more capable one.
What happens if a task fails halfway through?
By default, Orca marks the task as failed, does not run any downstream tasks that depend on it, and leaves the repo in a clean state (it rolls back any partial changes from that task's patch). You can override this per-task with continue_on_error: true if you want the DAG to proceed anyway, but in practice you should let failures halt the dependent chain β a refactor built on top of a broken fix is usually worse than no refactor at all.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.