15. Decide before you generate

Status: partly implemented. The typed openagents.router.v2alpha1 router (RoutePlan, `coax/lib/agent/router/router.coax`, `decide.coax`, `policy.coax`, `native-choice.coax`, `replay-check.coax`, #14056, #14071) passes on cpu (66/66 dev, 30/31 held-out) and routes native OpenAgents Core vs opt-in external delegation in `coder/tui/oa-worker.coax`. Remaining: mobile/web front integration and live multi-door latency benchmarking in openagents/agent/front/.

Premise

Chapter 14 defines the plan. This chapter fills it in: the front asks a decision model a few typed questions about each message and builds the plan from the probabilities it gets back.

Draft

A front has to be right, fast and cheap on every turn, and it has to answer in a form code can act on. A chat model is a poor fit for that job. It is trained to write text that reads well to a person, and nobody reads a router's output.

A decision model takes one state and a set of typed questions, such as yes or no, a choice among named options, or a score. It answers with probabilities. For each message the front asks: which route is this, does a prepared answer fit, does it need more specifics, what is the risk, does the work need a computer, and did the person name an engine? One request answers all of them.

Episode 289 gives the reason this works now when our earlier attempts did not: the models are good enough, and a type-safe decision model makes routing feasible. In the old tree, one request answered every router question in about 170 ms at the median. [Episodes 285](../../docs/transcripts/285.md) to 287 are the work that led there.

Every decision goes through our Decisions API. Since 2026-11-13 (#13473), Google's Gemini Decision 1 answers first, and the model a caller used before is the fallback (the door order; `coax/lib/systemone`). New code never calls one vendor's model directly.

We do not route by matching keywords. A message goes where the typed decision says, and chapter 16 measures how often that is right.

What we build

A plan for what this chapter ships once the draft is approved:

  • The front: one typed request per message, answered through the Decisions API, turned into a plan.
  • A question set pinned by digest, so a result names exactly what was asked.
  • Failover across decision routes, with the route that answered written to the log.

It builds on what exists today:

On the protocol (chapter 65):

RecordSchemaCarriageToday
Decision request and answeropenagents.decision.v1alpha1 SystemOneRequest, SystemOneResponse (`systemone.proto`; spec 16.1)HTTP POST /api/v1/systemone; Nostr kind 25910, encrypted (NIP-DEC)In use on the server: the generated codec psionic/lib/serve-proto.coax. The client writes the JSON by hand in coax/lib/systemone/request.coax. The JSON contract stays the definition, and a fixture to pin it is planned (compliance plan)

The chapter's check

  • Source: the front in openagents/agent/front/, asking the Decisions API through a fake decision service that replays recorded probabilities. The clock is controlled.
  • Trace: for the message hello, the trace prints the pinned question set's digest, each question's probabilities, the chosen route (conversation) and the plan built from it. The log names the door that answered: Gemini Decision 1.
  • Refusal: the first door times out on the controlled clock. The front asks the fallback, and the log names the fallback as the door that answered. A recorded answer for a different question-set digest is refused with refused: question set digest mismatch, and no plan is built.
  • Independent check: the client's hand-written request JSON from coax/lib/systemone/request.coax is read by the generated server codec psionic/lib/serve-proto.coax, a separate implementation of systemone.proto, and the fields match.

Planned paths: openagents/agent/front/.

Sources

Open questions for the owner

  1. Which of our own decision models backs up Gemini Decision 1 for the front at 1.0, and what result would move our own model to the first door?
  2. What does the front do when no decision route answers: plain conversation with no routing, as the old tree did, or a visible error?