Double Time: A Budget-Capped Gateway and Swarm for LLM Agents
AI Engineering
What is Double Time?
Double Time is the AI infrastructure I run for my own engineering work. It has three parts: a self-hosted gateway that gives every editor, script, and agent one local endpoint for several model providers, an orchestrator that runs coding tasks behind a human approval gate and hard spend caps, and a swarm runner that sends bulk text work to a low-cost model in parallel. I designed and built all three, and I operate them on one workstation.
This page records what an exploratory run on this stack measured, including the failure counts, and what is still unfinished.
How much does it cost to run 10,000 LLM agent tasks?
In one exploratory run, made with prototype scripts outside the repository and with no budget cap, 10,000 single-message agent tasks cost $1.1154 and finished in 1,101 seconds of wall-clock time. The run was a synthetic conversation study: 1,000 simulated agents each wrote one message per round for 10 rounds, with each agent reading its neighbours’ earlier messages. The model was GLM-5.3-Flash served by DeepInfra, at a concurrency of 200. The run consumed 8,954,804 input tokens and 1,775,892 output tokens.
The figure has a stated limit. It comes from an exploratory run in September 2026, and the scripts for that run are not in version control, so the number is recorded evidence and is not reproducible from the repository today. I treat it as one measurement of what bulk agent work costs on a small model, not as a benchmark.
How often does a low-cost model return invalid structured output?
In that run, 45 of the 10,000 first attempts failed schema validation. Every one was a schema failure. None was a transport error or a rate limit. Retrying recovered 43 of them, and 2 never produced a valid response.
The failures took three shapes, all inside otherwise well-formed JSON: a required key that was absent, a key whose name was corrupted with stray characters, and an object that carried no usable field at all. Checking that the top-level keys exist does not catch the second and third shapes. Restating the required key names as exact literal strings in the instruction reduced the corrupted-key shape on retry.
The run also found a defect in my own analysis. The first tally counted an agent with no parseable response as holding the default answer, which mixed an execution failure into the results as if it were a position. A missing response is now its own state, excluded from every tally, with an assertion that each round’s counts add up to that round’s valid responses.
A separate check compared every quotation the agents claimed against the text they were quoting. Of 19,540 claimed citations, 18,966 matched the source verbatim, which is 97.1%.
How do you cap what an autonomous coding agent can spend?
With limits that are checked in code before every model call, and a gate that a person has to open. When a run starts, the orchestrator writes a specification and stops. Nothing executes until I approve it. From then on, five caps apply: the number of tasks, the number of model calls, the total tokens, the active minutes, and the attempts allowed per task. A breach of any cap stops the run in a capped state. A gateway or model error pauses the run instead of retrying in a loop.
The time cap counts active time, not wall-clock time. An earlier version counted the time a paused run spent waiting for me against its limit.
The swarm runner enforces its budget before submission instead of after. Each task reserves its estimated cost, and the runner stops submitting new tasks once the money spent plus the money reserved reaches the budget.
How does the gateway route between model providers?
The gateway is a LiteLLM proxy running as an ordinary local process. Callers ask for a named route, such as a routine coding worker or an auditor, and the gateway maps that name to a provider and model. A failed call is retried twice. The routine coding route falls back from DeepSeek to an Anthropic model, and that is the only fallback rule in the configuration. The DeepSeek V4 Pro route deliberately joins no fallback group, so a failure there is visible instead of being absorbed by a different model.
The gateway does not run in a container. An earlier Docker-based setup cost the project two outages. A local process started by a script removes that dependency.
The loop runs the real tests, and the auditor fails closed
Inside a run, each task follows the same sequence. An implementer model writes complete files, and they are applied only inside an isolated workspace. The task’s evidence command then runs for real, so a passing result is a test run and not a model’s claim about one. An auditor model reads the output and has to return a structured verdict with an explicit accept value. A reply that cannot be parsed counts as a rejection. Accepted work is snapshotted in git, and a failed attempt restores the last snapshot.
A separate validation exercise ran DeepSeek V4 Pro through the gateway under a reviewing session, across five project types. All 15 attempted tasks passed on the first attempt, for 300,327 counted tokens and a total model cost of about $0.20. The exercise planned 20 tasks, and 5 were not attempted because its token budget closed first.
Later use recorded the limit of that result. A low-cost model passed its own tests and still made edits outside the task’s scope, so a line-by-line review of the diff by a stronger model is a fixed part of the process.
What is not finished?
The synthetic study that produced the cost figure has draft requirements and no approved design, and no code from it has landed. A GPU-hosted model route whose server is down is still in the gateway configuration and is still the orchestrator’s default implementer, and the entry that removes it is a draft. The repository is private, and nothing in it is offered as a product. Its value is as the layer the rest of my work runs on, and as a measured answer to what agent work costs when the limits are enforced by code.