# How Moji works

Moji is control infrastructure for AI agent swarms in production. Moji scopes each agent to a step, checks every output as the step completes and recovers the failed step with the rest of the work intact.

This is the Markdown copy of https://mojisystems.com/agents, written for engineers, researchers and the coding agents that work with them. Every figure below is illustrative.

Moji answers for control, cost, latency, reliability and quality in one product.

- Your swarm file sets every step, agent and check.
- Moji prices every step before your agents start.
- Moji keeps slow steps from holding up the job.
- Moji redoes a failed step and keeps the rest.
- Your own checks judge every output.

## Control

Agents make their own choices inside a step. Moji moves the job between steps only by the rules in your swarm file, which name the agent for each step, what counts as done and what happens when a step fails.

- Your swarm is a file in your own repository, so every change to it goes through your review.
- Moji can split a step between agents by weight, for example half to Claude and half to Codex.
- Parallel steps run side by side, and a merge step combines their results.
- A job keeps the version of the swarm it started on, and Moji can rewind it to any step it passed.
- You can try a new version of a swarm on recent jobs before it goes live.

```yaml
- id: implement
  from: [backlog]
  to: implemented
  lanes:
    - {agent: claude, weight: 50}
    - {agent: codex,  weight: 50}
  retry: {max_attempts: 2}

- id: test
  from: [implemented]
  to: tested
  performer: {kind: ci, workflow: test.yml}

- id: review
  from: [tested]
  to: reviewed
  parallel:
    branches: [claude, codex]
    merge: claude
  gate:
    when: "result.metrics.score >= 70"
    on_reject: {to: implemented, reason: "fix review comments"}
```

## Monitoring, runtime and budget in one system

Moji keeps each job's state, cost, checks and attempts with the job at every step. Because the job carries its own state, Moji can send the job back for a fix or redo one failed step without losing the rest of the work.

Example: a job reaches Reviewed, the review scores it 64 against a gate of 70, and the job goes back to Implemented with the review comments. The second attempt scores 82, and Moji releases the job inside its $9.20 budget.

## Cost

Moji prices each step from jobs it has measured and adds the step prices into a budget for the whole job. You commit that budget before the job starts, and the report shows how many jobs finished inside it.

- Moji counts each step's reported usage against the budget and starts no step that would cross it. Steps already running finish, and new work waits until you raise the budget.
- Moji prices split, parallel and looping steps too, and estimates a new swarm from model list prices until it has measured jobs.
- Moji counts every call down to the cached token at your contracted rates, including steps that call no model, such as CI.
- Each swarm also has a daily budget, such as $60 a night for a security swarm, and every job's spend counts toward it.
- Each step has a time limit in your swarm file, and Moji treats a step that runs past it as a failed step.
- Moji checks its figures against your providers' daily bills and shows what retries cost for each swarm and each day.

| Step | Median | 95th percentile |
|---|---|---|
| Implement | $2.10 | $3.40 |
| Test | $0.20 | $0.30 |
| Review, two agents | $3.10 | $4.60 |
| Merge | $0.10 | $0.20 |
| Whole job | $5.50 | $8.50 |

The committed budget is $9.20 a job.

Further reading: [Inference is part of the job cost](https://mojisystems.com/blog/inference-is-the-new-cost-of-goods) and [The bill should follow the work](https://mojisystems.com/blog/the-shape-of-the-ai-bill).

## Reliability

Moji checks each step's output as soon as the step finishes. Moji retries a failed step in place or sends it to the repair step your swarm names, and work that depends on it waits until the fix passes.

- If a worker machine stops during a step, Moji hands that step to another worker and keeps every earlier step.
- If Moji itself restarts, every job resumes from its last finished step, because Moji records each change on disk as it happens.
- When Moji cannot tell whether a step already changed something outside Moji, such as a deployed service, Moji pauses the job for a named person.
- Moji sorts every failure into a kind, such as a rate limit, an expired login, a used-up quota, a flaky test or a real bug.
- After a timeout, Moji shows the last saved state and its checks and walks you through the recovery.
- Moji warns you before a worker with an expired Claude or Codex login takes a job.

Example: Implement passed ($2.31), Test failed on two tests ($0.18), Implement passed on attempt 2 ($0.84), Test passed ($0.17), Review passed with a score of 82 ($1.92). The retry added $1.01, and the job kept everything it had done before the failure.

## Quality

Checks live in your repository beside the swarm, as rules on a step's result, a score from a separate reviewing agent, files that must exist, your own CI tests or a named person's approval. Moji records every verdict with the step and the attempt that produced it.

- Every swarm starts with a person approving its work.
- You switch on Autopilot once the report shows the swarm meeting your thresholds, and Moji records every automatic approval.

The report tracks four measures for each swarm: first-pass yield (jobs finished correctly with no human help), exception rate (jobs that needed a person, and at which step), cycle time at the 95th percentile, and budget reliability (jobs delivered inside their budget).

## Latency

Moji runs independent steps side by side, and a failure costs you one step's time because Moji redoes only that step. Moji also keeps the evidence, so your team can hand agents more work sooner.

- The report shows how long jobs take at the 95th percentile, where slow jobs show up.
- When every agent is busy, Moji suggests how many more agents would clear the queue and when it would clear.
- Moji can start work on its own when a queue runs low, with a cooldown you set.

## The record

Moji writes each step's result, attempts, cost and approvals to an append-only event log, with the names of the files each agent read and the tools it used. You can replay the day to any moment, search who did what and export it.

- Moji sends the same traces into your own tools through OpenTelemetry.
- You watch an agent's progress live while its step runs.
- Moji records the person and the tool behind every change to a swarm.

## Where Moji runs

Moji runs on your own machine or private network, inside your security boundary, so your SOC 2 and vendor reviews stay simple. Moji does not hold its own SOC 2 report yet. Your agents work under their own Claude or Codex logins, you enter no model key in Moji, and Moji gives agents no GitHub or cloud credentials.

## How Moji fits

Moji makes the decisions while the job runs. Your gateway, tracing tools and agents each see one call or one session. Moji sees the whole job, so it can stop a job at its budget and redo one failed step with the rest intact. You keep your agents and tools, and Moji sends its traces into them through OpenTelemetry.

| Kind of tool | Priced before it starts | Checked at every step | One failed step redone, the rest kept | Sent back when a check fails | Stops new work at the budget |
|---|---|---|---|---|---|
| Gateways and routers | No | No | No | No | Yes |
| Tracing and evals | No | In part | No | No | No |
| Durable workflow engines | No | No | Yes | In part | No |
| Agent platforms | No | In part | No | No | In part |
| Moji | Yes | Yes | Yes | Yes | Yes |

**How does Moji work with a durable workflow engine?** A durable workflow engine replays code you write against its SDK, so a job survives a crash. Moji runs the Claude Code and Codex agents you already use from a swarm file in your repository, and Moji also prices each job, checks each output and stops new work at your budget.

**Do I keep my tracing and eval tools?** Yes. Moji sends every step to them as OpenTelemetry traces, and Moji acts on the job while it runs.

**How is this different from a gateway or a model router?** A gateway or model router works at the request boundary and may choose a model for one call. Moji works across the whole multi-step job, and it keeps the job’s budget, checks, recovery state and record together while the job runs.

**How is this different from an agent platform?** An agent platform hosts agents you build on it, and permissions what an agent may use and spend before it acts. Moji runs the agents you already use on your own machines and controls the work while it moves. Moji checks every step, fixes failures in place and keeps the job within its budget.

**How is this different from a provider's own agent platform?** Provider harnesses run one lab's agents on one lab's models. Moji runs Claude and Codex agents side by side under your own logins, with the same checks, recovery and budget across both.

**How is this different from an open-source agent harness?** A harness runs one person's agents in one session. Moji runs many agents across many workflows for a team, with checks on every step, recovery in place, a spending cap and one record for each job. Your agents keep their own harness, and Moji runs the workflow around them.

## Getting access

Moji is currently invite only. The "Join the swarm" button on the site opens https://mojisystems.com/contact, which asks for a work email. If the email is already invited, the page goes straight to describing the first swarm, and we send back the swarm and its budget to approve. Any other email is a request for an invite. You can also email team@mojisystems.com with one piece of agent work you want to hand off.
