Agent loops with external verification took a tokenizer trainer to production
- Source
- liquid.ai
- Publisher
- Liquid AI
- Author
- Liquid AI
- Date

Context
Liquid AI needed a byte-pair encoding tokenizer trainer, the that learns a model's vocabulary of text fragments from a corpus, that could trillions of tokens on a single machine, and the existing libraries were too slow, ran out of memory or could not train at all. In late 2025 it handed the job to two coding agents, Anthropic's Claude Opus 4.5 and OpenAI's Codex with GPT-5.2, according to its account of the experiment. Each got a short specification of outcomes and constraints, access to Liquid's production training data on a 128-core machine with 2 TB of memory, and a check it could not modify: the trained vocabulary had to load in tiktoken and Hugging Face tokenizers, round-trip text, and give identical token IDs in both across languages, numbers, currency, tabs, Windows line endings and source code.
Both agents produced a working trainer within 30 minutes that passed its own unit tests on a few megabytes of text, and neither survived the full dataset. Per-document memory overhead made the trainer run out of memory at roughly 1% of the target corpus, which took two to three days to fix, and parallelizing only part of the work kept every core busy with still unacceptable. Three bugs were caught only by the outside libraries. Tokens were numbered in a way tiktoken reads as a different merge order, so the vocabulary loaded without complaint but encoded text differently than intended. A trained merge could duplicate an existing token, leaving the vocabulary short and shifting every later entry. A quirk in how Rust's regular-expression library parsed one pattern meant the two libraries agreed on everything except numbers. Liquid writes that had it accepted the agents' own test suites, it would have had two implementations that passed their tests and produced quietly different vocabularies.
What closed the gap was a loop: run at full scale, hit a wall, report the symptom, and let the agent diagnose and fix it. Liquid stopped the Codex track after more than five iterations with little progress on throughput, calling that a resourcing decision for one operator with a deadline, with the Claude track further along by then. The Claude Opus 4.5 track finished over a handful of further iterations and ran the full production configuration in a few days, passing the external checks cleanly. The operator never read the code. Liquid released the result as toktoktok under Apache 2.0, and argues that the failed first attempts are not a story about model capability: what got the trainer to production was the loop, with real data and verification the agent could not influence.
- Liquid AI gave Claude Opus 4.5 and Codex with GPT-5.2 a real task: a BPE tokenizer trainer for trillions of tokens on one machine. Both built a working toy trainer within 30 minutes, but neither survived the full production dataset on the first pass.
- The real failures only appeared at full scale or in the external harness: per-document Vec overhead ran out of memory at about 1% of the corpus, non-contiguous ranks made tiktoken encode differently, and Rust's regex crate reparsed a number pattern.
- Correctness was judged by tiktoken and Hugging Face tokenizers, code the agent could not edit. Liquid AI says that is why the operator could skip reading the code, and that trusting the agents' own tests would have yielded two passing trainers with quietly different vocabularies.
- Liquid AI stopped the Codex/GPT-5.2 track after more than five iterations with little throughput progress, calling it a resourcing decision. The Claude Opus 4.5 track fixed the remaining issues in a handful more iterations and ran the full multi-day production job.
- The spec stated outcomes and constraints, not mechanisms, because the model already had the domain background. One line asked to reserve vocabulary for all two- and three-digit numbers, so arithmetic does not depend on which digit pairs happened to be frequent.
- Program — A set of instructions stored so that a computer can run it.
- Process — A running instance of a program, with its own working memory, open files and identity.
- Sandbox — An enforced restriction that confines a process to specified files, network destinations and other resources, applied by the operating system, a container or a virtual machine.
- throughput — How much model output a provider can generate over time, commonly measured in output tokens per second.






