# Long-Horizon Coding Agent Simulator

## PURPOSE
The video's most concrete engineering observation is a wall-clock one: when asked to build
a strategy game, "Claude Opus 5.5's web app diligently works on these for 20 plus minutes"
before delivering a deep game. The same clip describes access friction — a model that was
promised but gated, with "I have waited for 5 days... it didn't work." This SimPy prototype
models both: how many long-horizon coding tasks a lab can actually finish in a workday when
each task burns 20+ minutes of agent wall-clock, and how much throughput is lost when a
model is unavailable or tier-gated.

## WHY THIS MATTERS
Long-horizon agents turn capacity planning into a queueing problem. If every task occupies
an agent slot for 20+ minutes, then agents-per-lab, not model quality, sets your delivery
date. Modelling that in SimPy is how teams stop promising ten features a day to a rig that
can finish eight.

## HOW TO BUILD
1. `pip install -r requirements.txt`.
2. Define an `Agent` process: it takes a task from a SimPy `Store`, samples a duration
   around the observed 20-minute mean, and releases the slot.
3. Model providers as resources with availability windows. A gated model is simply not
   ready until day 5 of the week — tasks routed to it queue up or get rejected.
4. Run N replications with random seeds and log completion counts, p50/p95 task latency,
   and starvation (tasks rejected because no eligible provider).
5. Print a comparison table: gated-vs-available throughput.

```python
import simpy, random
env = simpy.Environment()
agents = simpy.Store(env, capacity=4)
def worker(env, store, log, rng):
    while True:
        task = yield store.get()
        dur = max(5, rng.gauss(22, 6))              # minutes, 20+ observed
        log.append((task, env.now, env.now + dur))
        yield env.timeout(dur)
env.process(worker(env, agents, log, random.Random(seed)))
```

## WHEN TO USE IN PRODUCTION
Use it to size agent fleets, to justify a second provider as failover, or to quantify the
cost of vendor gating before signing a contract. Do NOT use it to predict model quality or
token cost — this is a capacity and availability model, nothing more. Skip it if your tasks
are sub-minute; queueing effects vanish and a simple counter is enough.

## HOW IT HELPS STUDENTS
They learn discrete-event simulation, resource contention, variance in latency, and how to
turn a reviewer's anecdote into a falsifiable capacity claim.

## STARTER CODE
`starter/main.py` runs one week of simulated tasks for two scenarios and prints a summary;
tune `AGENTS`, `MEAN_MINUTES`, and the gated model's `ready_day` under the `# TODO` markers.
