switch
A TypeScript framework for building decision-model harnesses that give a model an agent loop over finite choices.
At a Glance
switch framework released under the MIT License; free to use, copy, modify and distribute. Model inference via third-party providers is an external cost.
Engagement
Available On
Listed Nov 2026
About switch
switch is an open-source TypeScript framework by osolmaz for building harnesses around decision models. Your code turns the state of a task into typed questions, such as which next step to take from a short list, and the model picks the answers. The latest listed release is v0.1.1.
What It Is
switch is a harness framework for decision models like TypeSafe's Jev. A decision model answers typed questions with probabilities and writes no text, so it cannot generate the tool calls that a coding agent harness relies on. switch generates the tool calls in code, and the model only picks one from that finite set. You implement a domain, which defines the state of a task and the functions that turn a state into the model's questions and its answers into the next state. Chess is a domain, and so is a rubric judge for evals.
How a Run Works
The domain makes the initial state, and the question function gives the questions for that state. The model reads a view of the state and answers every question. The transition function then makes the next state from the answers. The loop ends when there are no more questions, when a request fails, or at a step limit the domain may set. Questions can be bool, choice or score types, and a picking helper builds a choice question from a list of choices.
Traces, Replay and Examples
Every run writes a trace of states, questions and answers. A replay reads that trace without calling a model, and can fork from a given step so a model continues from there. The run, view and replay commands come from a Commander-based command line helper, and a browser viewer plays runs back step by step. The repository includes a rubric judge that navigates documents to grade rubric items, a chess example, and a WikiRace example.
Setup Path
The package installs from npm and requires Node.js 22.18 or newer. It works with any classifier model that pi-ai lists, and separate entry points cover the core loop, model access, the command line and testing with a fake decider. The examples and viewer are in the repository and run from a pnpm workspace.
Community Discussions
Be the first to start a conversation about switch
Share your experience with switch, ask questions, or help others learn from your insights.
Pricing
Open Source (MIT)
switch framework released under the MIT License; free to use, copy, modify and distribute. Model inference via third-party providers is an external cost.
- MIT License
- Install from npm: @osolmaz/switch
- Requires Node.js 22.18 or newer
- Domain, harness, run, replay and trace tooling
- Examples and viewer live in the repository and are not on npm
Capabilities
Key Features
- Agent loop for finite-choice decision models
- Typed bool, choice and score questions
- Domain state machines with question, transition and view functions
- Picking helper for choice questions
- Trace recording and model-free replay
- Replay forking from a chosen step
- Run, view and replay command line via Commander
- Browser viewer for runs
- Fake decider for tests without model calls
- Example domains: rubric judge, chess, WikiRace
Integrations
Demo Video

