Dev.to AI πŸ€– Ai πŸ‘ 0 πŸ“– 14 min read

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):

  1. You submit a task graph β€” a list of jobs with dependencies, scopes, and acceptance criteria β€” to Orca.
  2. 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.
  3. 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.
  4. 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.
  5. The gateway enforces safety rails: read-only mode for some agents, path allowlists, command denylists, and a rate limiter.
  6. 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_KEY in 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_paths scopes every file operation to the directories you actually want agents to touch. Agents can read config files but only write inside src/.
  • shell_exec uses 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: true forces edit_file to send a unified diff, which the gateway applies with patch β€” 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:

  1. t3code reads the task, sets up an MCP client connection to the gateway.
  2. It sends the task description to the model.
  3. The model calls read_file and search on the gateway to understand the code.
  4. The model proposes edits; t3code converts them to a unified diff and sends edit_file to the gateway.
  5. The gateway validates the diff against allow_paths and applies it.
  6. t3code runs the acceptance commands (via shell_exec on the gateway) to verify.
  7. 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:

  1. 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).
  2. Create the feature branch. git checkout -b feature/agent-fleet (from main).
  3. Resolve the DAG. It topologically sorts tasks and finds the ready set β€” tasks with no unmet dependencies.
  4. Spawn workers. For each ready task, up to max_parallel, it spawns a t3code process with the task's config.
  5. Collect results. As each worker finishes, Orca reads its report.json. If pass: true, it marks the task complete and re-evaluates the DAG. If pass: false, it marks the task failed and does not run downstream tasks (unless continue_on_error is set).
  6. Merge. When all tasks are done, Orca squashes the accumulated patches into a single commit on the feature branch and runs the top-level accept commands.
  7. Report. It writes a summary to ./.orca/run-summary.json and 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:

  1. Scope isolation. Each task's scope field tells Orca which files it owns. Orca refuses to schedule two tasks with overlapping scopes simultaneously.
  2. 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.
  3. Patch application. Even if a conflict slips through, Orca applies patches with git apply --3way and falls back to git mergetool if there's a real conflict, marking the task as needs_review rather 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.

πŸ“° Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.