Showcase / Benchmark
We replaced chat templates with Affordance in four experiments and measured what each one changed
A language model reads and writes tokens, which are numbers that each stand for a short piece of text. Most agent software builds a model's prompt as a string of text, usually with a chat template: a small program, written in a template language called Jinja, that lays out a conversation in the model's format. A tokenizer then splits the string into tokens.
Experiments
4Replies a template rebuilt differently
11.0%Affordance is an open-source program that builds the exact tokens a model reads from an app, a file written in TSX, the language of React web pages. We ran chat templates and Affordance on the same models and tasks in four experiments, and compared the tokens each one produced.
1. LiquidAI's d1 decision model
LiquidAI's d1 is a model that picks one option from a list. Its prompt is a customer's message, three newlines, then the question. In 699 of 3,080 Banking77 bank-customer messages, d1's tokenizer turned the message's last period and the three newlines into a single token. LiquidAI's own code treats that blank line as the end of the message.
The tokens, and six decision models compared2. Training Qwen3-4B on rebuilt replies
To train an agent, the usual setup saves its conversation as messages and rebuilds the tokens with the chat template. For Qwen3-4B, 208 of 1,886 replies, 11.0%, came back with different tokens. Most lost a blank line before a tool call.
Trained on the rebuilt replies, the model changed how it writes. It wrote that blank line in 52% of its replies before training and in 0% after 70 steps. Trained on its own exact tokens with Affordance, it went from 82% to 99%. The task's reward scored only the answer.
The rebuilt replies also made the model server compute prompts again. A server stores its work on the start of a prompt, so a prompt that starts the same way is served faster. A rebuilt reply changes the prompt, and the stored work stops matching. With the usual setup, 19 model calls had most of their prompt computed again, each right after a rebuilt reply. With Affordance, none did.
The training runs, token by token3. Three models on two model servers
SGLang, a model server, runs the chat template and the tokenizer over the whole conversation on every request. With Affordance building the tokens instead, Qwen3.6-35B-A3B's first token on prompts over 120,000 tokens came after 421 to 422 ms. With stock SGLang it took 552 to 562 ms.
Agent software often sends enable_thinking: false, a chat template setting that turns off a Qwen model's thinking. Sent to gpt-oss-20b, stock vLLM, another model server, rejected every request with an error. Affordance accepted the same requests.
4. SGLang's tool layout
When an agent has tools, SGLang's Jinja template adds "defer_loading": null to each one in the prompt. For two tools that is 12 tokens the agent never wrote.
How Affordance builds the same prompts
An Affordance app lays out the prompt as tokens directly. In these experiments a model's reply stayed in the next prompt as the exact tokens it wrote, which is the keep_replies setting, and each new prompt was the previous one with new tokens at the end. In our latest training run, all 236,207 model calls Affordance exported matched what the server had processed.
The layout still has to match what each model was trained on. We rebuilt 740 models' chat templates as Affordance apps and compared them with the official ones on 712,620 conversations, with 0 differences. For d1, whose prompt really is joined as text and then tokenized, the Affordance app does the same, in one line.