Approximate Labs

Affordance, a browser for models, is open source

Nov 18, 2026 Release

Today we're open-sourcing Affordance. It's a browser for models: you write an agent as an app, and Affordance runs the loop and renders the exact tokens the model reads. The code is on GitHub under the Apache 2.0 license, and the docs and examples are at affordance.rs.

A web browser takes a page's code and its state and draws the page for a person. When the person clicks, the page's code changes the state and the browser draws it again. Most agent harnesses work differently. They build the model's prompt as text with a chat template, a tokenizer then splits that text into tokens, and the harness never sees the tokens the model actually read. Affordance works the way a browser does. An app renders its state straight into tokens, the model acts by calling tools on the page, and the app renders again.

Writing an app feels like writing a web page. The app is a TSX file. Text in it becomes tokens, state lives in components, and a tool is a function the model can call. Layout goes in a style sheet with budgets measured in tokens, so an app can say how much room a long log gets and which part of it to keep.

Because Affordance works on tokens directly, it fits in places a string template can't. We put it inside SGLang in place of the template and tokenizer step, and on long prompts the first token of a reply came back about 24% sooner. In reinforcement learning it gives the trainer exactly the tokens the model wrote, where the usual round trip through a chat template often changes them around tool calls. And for models that ship their own Jinja chat template, Affordance renders that format exactly: we checked 740 models against their official templates and tokenizers, and the tokens match.

The same engine runs very different harnesses. We use the pi coding agent every day with an Affordance app as its core, about 300 lines of TSX in place of roughly 8,000 lines of agent session code. Recursive Language Models and OptMem's tree-based memory are each about a hundred lines. Affordance also powers Multiplet, our fleet framework, which runs over 2,000 agents on a single machine. And because an app's source can be part of its state, an agent can rewrite its own harness while it runs.

Affordance is an early beta, and we're still building it quickly. If you build agents, train models or run inference, we'd like to hear what you try with it and where it breaks.