Skip to content

[FEATURE] Decision domain: typed judge decisions through the gateway's /v1/decisions #1342

Description

@edenreich

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 systemone adapter, no systemone_url, no systemone_api_key_env in 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 the CreateDecision(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) and internal/agent/domain/judge.go (ParseJudgeVerdict), not internal/agent/judge.go.
  • judge.gateway_url keeps 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)

  1. Domain. internal/decision/domain: Question (Predicate, Choice, Score with instructions, options or levels), Answer (probability, or choice/probabilities/confidence, or score/probabilities/confidence), and a Decider interface Decide(ctx, model string, evidence Evidence, questions []Question) (Answers, error). Counterfeiter mock registered in the Taskfile mocks:generate line per AGENTS.md.

  2. One adapter, through the gateway. internal/decision/infrastructure/gateway: builds a sdk.CreateDecisionRequest and calls sdk.Client.CreateDecision on the judge's gateway client (the one judgeCompleter already resolves from judge.gateway_url). The provider prefix of judge.model selects the upstream exactly as GenerateContent does. A gateway 400 "The Decisions API is not supported by this provider yet." surfaces as a config error at startup validation when possible, and as judge unavailable at runtime otherwise.

  3. Judge config. judge.yaml gains 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
  4. DecisionJudge implementing JudgeApprover. Evidence is the structured input {"root_request": ..., "latest_request": ..., "tool_call": ...} using the same truncation as today, sent as one input_json item. Questions: one predicate per pending tool call, named by its call id ("Does tool_call serve root_request and latest_request, and is it safe to run unattended?"), plus one choice named risk over benign, destructive, network, secrets, out_of_scope with one-line descriptions each. A whole turn's gated calls go in one request (up to maxJudgeBatchSize, well under the 400-question limit). Verdict: approved iff probability >= min_confidence. Reason is built from the answers (decisions: rejected (p_approve=0.31), risk: destructive) so the agent still gets a reason to adjust on and RequestApproval escalation keeps working. Usage maps input_tokens. The existing JudgeVerdictChatEvent, headless/AG-UI events and TUI flash need no change.

  5. Eval. A checked-in JSONL of 30-50 labeled judge cases (off-list commands, Write/Edit, git push after a bare continue, rm -rf, curl | sh, reading secrets, prompt-injection inside tool arguments). Run against openai/gpt-6-luna through 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. Pick min_confidence from these numbers, not by guess. Rerun when the gateway gains the local System One translator.

  6. Docs. docs/judge-mode.md gains a "Decision-model judge" section: the judge.yaml snippet, the /v1/decisions route and the gateway OPENAI_API_KEY requirement, the label-based reason limitation, the vendor failure modes that apply, and the eval table. Filed as a [DOCS] issue in inference-gateway/docs with the PR.

Acceptance criteria

  • internal/decision/domain defines Question, Answer, Evidence and the Decider interface; the gateway adapter round-trips sdk.CreateDecisionRequest / sdk.Decision against a recorded fixture of a gateway /v1/decisions response and the not-supported 400 (table-driven test).
  • judge.yaml backend: decisions routes the judge through the adapter; backend absent or llm behaves exactly as today (existing judge tests unchanged).
  • Every decision call is a POST {gateway}/v1/decisions through the Go SDK. No proxy path, no vendor URL, no key in the cli config. Config validation rejects backend: decisions without a resolvable provider/model (v1: provider prefix; once the gateway exposes the decisions output 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 yield rejected with a judge unavailable: ... or decisions: rejected (...) reason, honouring on_error.
  • RequestApproval escalation, judge_verdict events, 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-luna and the current LLM judge are in the PR and in the docs; the chosen default min_confidence is justified by them.
  • Docs section as described; no Python, no new runtime, no GPU required.

Out of scope (follow-ups, tracked upstream)

Sources

Activity

  1. added
    enhancement
    on Sep 26, 2026
  2. changed the title [-][FEATURE] Make local GLiNER 2.5 configurable for LLM as a judge[/-] [+][FEATURE] Make local GLiNER2.5 configurable as the judge backend[/+] on Sep 26, 2026
  3. moved this to Todo in 2026on Sep 26, 2026
  4. changed the title [-][FEATURE] Make local GLiNER2.5 configurable as the judge backend[/-] [+][FEATURE] Create a domain for classifiers like JEV, GLiNER2.5 etc[/+] on Oct 2, 2026
  5. added this to 2026 and removed this from 2026on Oct 3, 2026
  6. changed the title [-][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)[/+] on Oct 12, 2026
  7. changed the title [-][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[/+] on Nov 3, 2026
  8. moved this from Todo to QA in 2026on Nov 3, 2026
  9. moved this from QA to Done in 2026on Nov 4, 2026
  10. inference-gateway-releaser commented on Nov 4, 2026

    @inference-gateway-releaser
    Contributor

    🎉 This issue has been resolved in version 0.243.0 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementreleased

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions