Repository navigation
Description
Summary
Add a decision domain to the cli: typed decisions (predicate, choice, score) with native probabilities, answered by the inference gateway's POST /v1/decisions endpoint, and make the tool-approval judge (approval_behaviour: judge / auto-with-judge) its first consumer.
All decision calls go through the inference gateway. The gateway relays the OpenAI Decisions API natively as of inference-gateway/inference-gateway#827 (schemas v1.7.0), and the Go SDK exposes it as CreateDecision (inference-gateway/sdk#241). The cli never calls /proxy/:provider/*, a vendor endpoint, or a sidecar. Which upstream answers a decision (OpenAI gpt-6-luna today, Ollama / llama.cpp System One models later) is a gateway concern, selected by the provider/model prefix exactly like chat completions. No Python sidecar, no new model runtime, no GPU, no new credentials in the cli.
This supersedes the previous revision of this issue, which proposed a systemone HTTP adapter reaching Ollama and llama.cpp through the gateway's raw proxy, plus a direct URL and key for hosted TypeSafe jev. The research below still holds and is kept as the evidence for why native probabilities beat a verbalized verdict. The transport changed: one typed endpoint on the gateway instead of per-backend wiring in the cli.
Findings (verified against vendor docs and code on 2026-10-12)
The decision wire format is already a de facto standard, and the gateway now speaks it. OpenAI's Decisions API takes {model, input, questions} where input is a string or an ordered list of message and tool items and each question is predicate (yes/no, answered as a probability), choice (value + description options) or score (2-10 ordered levels). The response is {answers, usage}; a choice answer carries choice, probabilities and confidence, a score answer the probability-weighted score plus probabilities and confidence, a predicate answer a single probability. Up to 400 questions are evaluated independently against the same evidence, so adding questions barely changes latency. TypeSafe's POST /v1/systemone (noul / choice / score over a state) is the same model with different field names, which is what makes a gateway-side translator for the local backends a bounded follow-up rather than a redesign.
Decision backends that exist today, checked in their READMEs/source:
| Backend | Where it runs | Models | Reachable through /v1/decisions |
|---|---|---|---|
| OpenAI Decisions API | hosted | gpt-6-luna |
Yes, today (#827) |
| Ollama >= 0.35.0 (local) and ollama.com (cloud) | POST /v1/systemone on both, bearer key for cloud |
nimble, tev1, clef, clef-flash, clef:cloud (clef judges images) |
Follow-up: gateway translator on /v1/decisions for the ollama and ollama_cloud providers (see out of scope) |
llama.cpp llama-server |
local, /v1/systemone |
openjev, laya (ModernBERT-large 421M), clef, pplx-decider, vllm-decision2, vllm-d3, lfm2-d1, lfm2-d1-omni |
Follow-up: gateway translator. GET /v1/models advertises output_modalities: ["decisions"], so the gateway can detect a native decision model without probing |
| TypeSafe jev (hosted) | api.typesafe.ai | jev-latest |
Follow-up: a typesafe gateway provider. $0.042 per million input tokens, 64k context, 80 rps |
| SGLang | GPU server | Clef, PPLX-Decider, Qwen decision LoRAs | GPU only, out of scope for "lightweight" |
| jeff, openjev-sglang, simple-jev, openJev-verdict | self-hosted | GLiFormer 400M and assorted open models | Same System One shape, references only |
Ollama already ships a decision API, in the System One shape. POST /v1/systemone takes {model, state, questions, images?} where questions is an object keyed by name, each with type (choice with 2-26 criteria options, noul with true/false criteria, score with 2-10 ordered criteria), and answers come back keyed by name with choice + probabilities + confidence, a noul probability, or a weighted score, plus usage.input_tokens. Same endpoint and key on ollama.com for :cloud models. The mapping to the OpenAI shape is mechanical: input -> state, predicate -> noul, the questions list -> an object keyed by name, choices[].value/description -> the criteria map, levels[].description -> the criteria array. The gateway's JSON relay helper already carries a per-provider translator hook (jsonProxy.translators in api/routes.go), so Ollama support is a translator entry on the decisions handler, not a new route. Source: https://docs.ollama.com/capabilities/decision
No model metadata says "decision model" yet. models.dev lists gpt-6-luna with output: ["text"] and no type; its type vocabulary (chat, embedding, image, realtime, reranking, speech, transcription, video) has no decision value, and the gateway's modelsdev:sync keeps only pricing, context window, modalities, release date and status anyway. The gateway only knows, per provider, whether a decisions endpoint exists. llama.cpp's /v1/models already advertises output_modalities: ["decisions"], so the fix is to adopt that word: add decisions to the Modality enum in schemas, set it on openai/gpt-6-luna through models.overrides.json, and let the Ollama and llama.cpp transformers pass the native value through. Then /v1/models?include=modalities tells the cli which models the judge may use. Until that lands, cli validation goes by provider prefix.
Why native probabilities matter for decision making. The current judge asks a generative model to write {"decision": ..., "reason": ...} and ParseJudgeVerdict (internal/agent/domain/judge.go) keeps only the two literals. There is no confidence to threshold on, and reasoning models burn max_tokens before answering, which is why DefaultJudgeMaxTokens is 2048. JevBench calls these two objects native (the model's own distribution) and verbalized (an instruction model writing probabilities under a JSON schema) and scores them separately. A decisions backend gives the judge a real p(approve) and a confidence, so min_confidence fail-closed semantics are meaningful instead of parsed prose.
What these models are bad at (vendor's own list, Jev 1.13, reviewed 2026-10-02). Literal reading, math and counting, date comparison, indirection (many hops), large state full of irrelevant detail, adversarial content, contradictory instructions and criteria, option-order sensitivity, and generation. TypeSafe also states jev is not a drop-in model for a coding agent. It is for routing, scoring, guardrails and "does this statement hold for this record" checks inside the app, which is exactly the judge's job. Consequences for the design: keep the evidence small (the three judge fields, truncated as today), spell out the criteria for every option, and expect the "does git push serve a bare continue" cases to be the weak spot. JevBench has a dedicated judge tier (answer-adequacy judgements, 146 items) and a hard tier where even jev scores 72-74% and the small encoders sit at 35-39%, so the eval below is not optional.
Where GLiNER2.5 fits now. GLiNER2 has no System One server and no ONNX/Go path. JevBench ran it through its own adapter: gliner2.5-small 62.1 (#21), gliner2.5-multi 63.1 (#19), versus jev 75.3 (#2) on the same scale. The fastino/GLiNER2.5-Decide checkpoints are classification specialists tuned for intent/routing. If it is ever wanted, it is a gateway provider or translator target, consumed by the cli through the same /v1/decisions call. Not v1, and never a cli-side shim.
Corrections to the previous revision
- No
systemoneadapter, nosystemone_url, nosystemone_api_key_envin the cli. Credentials and upstream URLs stay in the gateway, as for every other model call. - The Go SDK already carries the types:
CreateDecisionRequest,DecisionQuestion,Decision, and theCreateDecision(ctx, provider, request)method. The cli domain wraps them; it does not redefine the wire format. - The judge lives in
internal/agent/loop/judge.go(JudgeApprover,LLMJudge,userIntents) andinternal/agent/domain/judge.go(ParseJudgeVerdict), notinternal/agent/judge.go. judge.gateway_urlkeeps its current meaning: the judge's decision calls may go to a different gateway than the driver, using the same API key and timeout.
Proposal (v1)
-
Domain.
internal/decision/domain:Question(Predicate,Choice,Scorewith instructions, options or levels),Answer(probability, or choice/probabilities/confidence, or score/probabilities/confidence), and aDeciderinterfaceDecide(ctx, model string, evidence Evidence, questions []Question) (Answers, error). Counterfeiter mock registered in the Taskfilemocks:generateline per AGENTS.md. -
One adapter, through the gateway.
internal/decision/infrastructure/gateway: builds asdk.CreateDecisionRequestand callssdk.Client.CreateDecisionon the judge's gateway client (the onejudgeCompleteralready resolves fromjudge.gateway_url). The provider prefix ofjudge.modelselects the upstream exactly asGenerateContentdoes. A gateway400 "The Decisions API is not supported by this provider yet."surfaces as a config error at startup validation when possible, and asjudge unavailableat runtime otherwise. -
Judge config.
judge.yamlgains a backend switch, defaults unchanged:backend: decisions # llm (default) | decisions model: openai/gpt-6-luna # provider/model routed by the gateway's /v1/decisions gateway_url: "" # unchanged: a different gateway for the judge, same key and timeout min_confidence: 0.7 # approve only when p(approve) >= this; below is rejected (fail-closed) on_error: deny
-
DecisionJudgeimplementingJudgeApprover. Evidence is the structured input{"root_request": ..., "latest_request": ..., "tool_call": ...}using the same truncation as today, sent as oneinput_jsonitem. Questions: onepredicateper pending tool call, named by its call id ("Doestool_callserveroot_requestandlatest_request, and is it safe to run unattended?"), plus onechoicenamedriskoverbenign,destructive,network,secrets,out_of_scopewith one-line descriptions each. A whole turn's gated calls go in one request (up tomaxJudgeBatchSize, well under the 400-question limit). Verdict: approved iffprobability >= min_confidence.Reasonis built from the answers (decisions: rejected (p_approve=0.31), risk: destructive) so the agent still gets a reason to adjust on andRequestApprovalescalation keeps working.Usagemapsinput_tokens. The existingJudgeVerdictChatEvent, headless/AG-UI events and TUI flash need no change. -
Eval. A checked-in JSONL of 30-50 labeled judge cases (off-list commands, Write/Edit,
git pushafter a barecontinue,rm -rf,curl | sh, reading secrets, prompt-injection inside tool arguments). Run againstopenai/gpt-6-lunathrough the gateway and the current LLM judge on the same model the offline example uses. Report accuracy, false-approve count, p50/p95 latency and tokens per decision. Pickmin_confidencefrom these numbers, not by guess. Rerun when the gateway gains the local System One translator. -
Docs.
docs/judge-mode.mdgains a "Decision-model judge" section: thejudge.yamlsnippet, the/v1/decisionsroute and the gatewayOPENAI_API_KEYrequirement, the label-basedreasonlimitation, the vendor failure modes that apply, and the eval table. Filed as a[DOCS]issue ininference-gateway/docswith the PR.
Acceptance criteria
-
internal/decision/domaindefinesQuestion,Answer,Evidenceand theDeciderinterface; the gateway adapter round-tripssdk.CreateDecisionRequest/sdk.Decisionagainst a recorded fixture of a gateway/v1/decisionsresponse and the not-supported 400 (table-driven test). -
judge.yamlbackend: decisionsroutes the judge through the adapter;backendabsent orllmbehaves exactly as today (existing judge tests unchanged). - Every decision call is a
POST {gateway}/v1/decisionsthrough the Go SDK. No proxy path, no vendor URL, no key in the cli config. Config validation rejectsbackend: decisionswithout a resolvableprovider/model(v1: provider prefix; once the gateway exposes thedecisionsoutput modality, the model's modalities from/v1/models?include=modalities). - Fail-closed:
probability < min_confidence, a non-2xx response, a timeout or a malformed answer all yieldrejectedwith ajudge unavailable: ...ordecisions: rejected (...)reason, honouringon_error. -
RequestApprovalescalation,judge_verdictevents, usage accounting and the TUI mode indicator work unchanged with the new backend. - Eval JSONL and a results table (accuracy, false approves, p50/p95, tokens) for
openai/gpt-6-lunaand the current LLM judge are in the PR and in the docs; the chosen defaultmin_confidenceis justified by them. - Docs section as described; no Python, no new runtime, no GPU required.
Out of scope (follow-ups, tracked upstream)
- [FEATURE] Add a decisions output modality to the Modality enum schemas#300:
decisionsvalue in theModalityenum. - [FEATURE] Mark decision models with the decisions output modality and reject the rest at /v1/decisions inference-gateway#829: mark
openai/gpt-6-lunawith the modality and reject other models at/v1/decisionswith the gateway's own 400. Once released, cli validation switches from provider prefix to/v1/models?include=modalities. - [FEATURE] Translate /v1/decisions to the Ollama and llama.cpp System One decision API inference-gateway#830: a gateway-side translator so
/v1/decisionsreaches Ollama (local and ollama.com cloud) and llama.cppPOST /v1/systemone(predicate->noul,input->state, questions list -> object keyed by name) via the existingjsonProxy.translatorshook. The cli needs no change when it lands:judge.model: ollama/nimbleorollama_cloud/clef:cloud. - A
typesafegateway provider so hosted jev goes through the same endpoint with key injection. - Cascade: decisions first, LLM judge when
confidenceis low. Second consumer of the decision domain beyond the judge (routing, heartbeat triage, answer adequacy). - GLiNER2.5-Decide as a gateway provider or translator target.
- LoRA fine-tune on the eval set.
- Decision models for browser or computer-use action selection.
Sources
- Gateway endpoint: [FEATURE] Implement the decisions API from OpenAI inference-gateway#816, [FEATURE] Ship built-in skills with the CLI (seed-if-absent) with a tmux starter skill #827 (
POST /v1/decisions,api/routes.goDecisionsHandler); schemas v1.7.0CreateDecisionRequest/DecisionQuestion/Decision - Go SDK: feat(client): add CreateDecision for the OpenAI Decisions API (schemas v1.7.0) sdk#241 (
CreateDecision,examples/decisions) - OpenAI Decisions guide: https://developers.openai.com/api/docs/guides/decisions
- TypeSafe API reference, models/limits/failure modes, coding-agent guidance: https://docs.typesafe.ai (docs repo
typesafe-docs/typesafeai:docs/09-api-reference.md,docs/12-models.md,docs/01-introduction.md) - Ollama decision API (System One, local and cloud): https://docs.ollama.com/capabilities/decision
- models.dev api.json (no decision type or modality as of 2026-11-03): https://models.dev/api.json
- llama.cpp server System One endpoint: https://github.com/ggml-org/llama.cpp/blob/master/tools/server/README.md ("TypeSafe-compatible API Endpoints")
- SGLang decision models: https://docs.sglang.io/docs/supported-models/decision_models
- JevBench (judge tier, native vs verbalized): https://github.com/fstandhartinger/jevbench (README,
docs/v1.2-additions.md) - jeff: https://github.com/logan-markewich/jeff (README,
bench/RESULTS.md) - GLiNER2 / GLiNER2.5 / Decide checkpoints: https://github.com/fastino-ai/GLiNER2
- cli judge:
internal/agent/loop/judge.go,internal/agent/domain/judge.go,config/judge.go,docs/judge-mode.md,examples/working-offline/README.md
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
[-][FEATURE] Make local GLiNER 2.5 configurable for LLM as a judge[/-][+][FEATURE] Make local GLiNER2.5 configurable as the judge backend[/+][-][FEATURE] Make local GLiNER2.5 configurable as the judge backend[/-][+][FEATURE] Create a domain for classifiers like JEV, GLiNER2.5 etc[/+][-][FEATURE] Create a domain for classifiers like JEV, GLiNER2.5 etc[/-][+][FEATURE] Classifier domain: System One decision backend for the judge (jev, Ollama/llama.cpp decision models, GLiNER2.5)[/+][-][FEATURE] Classifier domain: System One decision backend for the judge (jev, Ollama/llama.cpp decision models, GLiNER2.5)[/-][+][FEATURE] Decision domain: typed judge decisions through the gateway's /v1/decisions[/+]inference-gateway-releaser commentedon Nov 4, 2026
🎉 This issue has been resolved in version 0.243.0 🎉
The release is available on:
Your semantic-release bot 📦🚀