Skip to content

feat(one-reason): add explicit Jev routing with LLM compatibility - #12

Merged
yaonyan merged 7 commits into
mainfrom
feat/one-reason-typesafe-jev
Sep 21, 2026
Merged

yaonyan merged 7 commits into
mainfrom
feat/one-reason-typesafe-jev

Conversation

@yaonyan

@yaonyan yaonyan commented Sep 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds optional TypeSafe Jev decision routing to @one-agent/reason while preserving the historical LLM default.

Final behavior

  • Omitted mode or mode: "llm": always uses the existing LLM path.
  • mode: "jev": decision-shaped examples use Jev; free-text examples or unavailable Jev fall back to LLM.
  • auto is not a public mode.
  • Jev credentials configure availability only; they do not change the default mode.
  • ONE_REASON_JEV_ENABLED=0 disables Jev availability.

Example schema mapping

  • boolean -> Jev noul / Gateway boolean
  • number -> Jev score
  • plain strings remain free text and use LLM fallback in Jev mode
  • arrays remain arrays
  • choices must be explicit:
{
  route: {
    $jev: "choice",
    options: ["approve", "manual", "deny"],
  },
}

Score ranges can be declared explicitly:

{
  risk: {
    $jev: "score",
    range: [0, 100],
  },
}

The Jev request uses at most 10 levels and maps the returned score back into the declared range. Invalid ranges and more than 10 custom criteria fail locally before a network request.

Providers

  • TypeSafe: POST {baseURL}/systemone
  • AI Gateway: POST {baseURL}/evaluation-model
  • Provider credentials are independently configurable from the primary LLM.

Verification

  • TypeScript typecheck
  • 40 unit tests
  • package build
  • real TypeSafe Jev smoke test
  • real AI Gateway Jev smoke test
  • real LLM routing smoke test (request reached the provider; OpenRouter returned HTTP 402 due to insufficient credits)
  • local score range/criteria validation tests

Support decision-only Jev evaluation via ONE_REASON_PROVIDER=typesafe|gateway
with OpenAI-style base URL + API key + model config. TypeSafe calls
POST /systemone; Gateway uses the fetchable /evaluation-model surface from
@ai-sdk/gateway (no ai@7 bump). Examples map to noul/choice/score questions.
Jev only handles decision-shaped examples (boolean/choice/score/$jev).
Summary/free-text synthesis auto-falls back to the LLM path when
PROVIDER is typesafe|gateway. Add optional reason(prompt, example, options?)
with mode auto|jev|llm, explicit questions, state, and booleanThreshold.
@yaonyan

yaonyan commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator Author

Hybrid Jev / LLM fallback

Addressed the feedback that summary-style reason() is useless with Jev (Jev only returns noul/choice/score).

Product story: Jev = control-node judgments; summary/synthesis stays on LLM (auto-fallback under typesafe/gateway).

Changes (915f940):

  • reason(prompt, example, options?) with mode: "auto" | "jev" | "llm", optional questions / state / booleanThreshold
  • auto (default): decision-shaped → Jev; free-text/summary → LLM fallback
  • LLM fallback via ONE_REASON_FALLBACK_* or one auth model
  • README documents decision vs summary examples
  • Tests: decision→Jev, summary→fallback, all three modes (35 passing) + typecheck OK

@yaonyan yaonyan changed the title feat(one-reason): TypeSafe Jev support (typesafe + AI Gateway) feat(one-reason): add explicit Jev routing with LLM compatibility Sep 21, 2026
@yaonyan
yaonyan merged commit 3fa5ab0 into main Sep 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant