Skip to content

Jev Agents & MCP

Where a decision belongs in an agent loop

A gate, a router, a critic, or a judge? Where a decision model fits in an agent loop, and how to keep the loop from becoming a chain of model calls.
Published
Category
Jev Agents & MCP
Resources cited
8
Reading time
6 min
Tags#agents#routing#gates#tools

An agent loop is a sequence of small commitments: which tool to call, which model to wake, whether a result is good enough, and when to stop. Most of those commitments are made by the same general-purpose model that is already doing the work. A decision model belongs only where that arrangement is wasteful or unsafe, and the placement matters more than the model.

The loop has four decision seams

A useful way to read an agent trace is to mark every point where control could go somewhere else. In practice those points cluster into four seams.

SeamTypical questionWhat the answer controlsCost of a wrong answer
RoutingWhich handler, model, or skill should take this?The next branchWasted work or a misrouted request
GatingMay this action run?ExecutionDamage, data loss, or a leaked secret
SelectionWhich tool or candidate fits?The action spaceA plausible but wrong call
VerificationIs the work actually done?Loop exitPremature completion

The distinction matters because each seam has a different tolerance for latency, a different answer shape, and a different failure mode. A router that is wrong 5% of the time is a quality problem. A gate that is wrong 5% of the time is a security problem.

Put routing where the branch is

The cleanest placement is a branch that already exists in code. Intent routing sends one request containing a Choice over four intents (order status, product question, return, complaint) plus a Score for complexity. Intent confidence below 0.5 goes to a human. order_status goes to deterministic code with no model call at all, while complaints escalate when complexity exceeds level 1 or confidence falls below 0.5. The model does not handle the ticket; it decides which handler does.

Confidence-gated routing makes the second axis explicit. In its voice-banking example, any intent below 0.6 confidence routes to a support agent before an action is considered. check_balance is allowed at 0.6 because the worst case is a wrong read-out. approve_transfer needs more than 0.85, or the user confirms first. The caveat is the important part: confidence is not permission. A high-confidence answer can still be wrong, so irreversible actions keep hard limits in code beside the model.

That is the placement rule in one sentence: put the decision where the consequences change, not at the top of the loop where everything looks like planning.

Gate actions at the last responsible moment

A gate should see the concrete call, not a summary of the plan. jev-guard checks shell commands, file writes, and reads before they run and returns ALLOW, ASK, or DENY. Credential files, workspace escapes, and trusted read-only commands are decided by local fast-path rules in under a millisecond; ambiguous or destructive calls go to TypeSafe's System One model. It works with Claude Code, Codex CLI, and Antigravity, fails safe by asking when the API is unreachable, and has an audit mode that logs what would have been blocked. The README publishes no independent latency or accuracy benchmarks, so the sub-millisecond figure is the project's own framing of its fast path, not a measured guarantee.

The transport deserves the same scrutiny. Jev Agent Tools exposes one ask() call that picks a carrier from the environment (TypeSafe, OpenRouter, Cloudflare, then Vercel AI Gateway) and validates the response before returning it. Failures arrive as typed codes such as answer_id_mismatch, invalid_distribution, or unavailable; verdicts are never thrown. It retries 408, 409, 429, and 5xx up to three attempts, honors Retry-After, and requires exactly the requested answer and criterion IDs with finite probabilities in [0,1]. That is what a gate needs: a typed rejection it can turn into a conservative action, not an exception it has to interpret.

A gate is also not a sandbox. It decides whether a call may proceed; it does not contain the process that makes it. Keep OS-level isolation, filesystem permissions, and network policy underneath.

Batch speculative questions, but pay for them

Once a branch is chosen, some questions are reusable across branches. Speculative fan-out puts a category Choice plus four speculative Score and Noul judgments in one request. The questions run in parallel, so adding them usually has little effect on response time. The ticket example escalates bugs when severity is above 1.5 and reproducibility above 0.6, and flags refunds above 0.7; answers the taken branch does not need are simply ignored.

The cost is input tokens on every call. Fan out on questions several branches can reuse, not on everything a workflow might someday ask. A follow-up request is cheaper than a speculative question that never matters; a reused question is cheaper than a round trip.

Measure at the level you deploy

Placement decisions are easy to demo and hard to validate. AgentDecisionBench is useful because it separates three levels: L1 isolated questions (3,991 items from BFCL v4 and When2Call), L2 open-loop questions over recorded states (3,939 distinct questions, an answer key of 5,314 trajectory occurrences, and 153,621 answers from 39 models), and L3 closed-loop runs where the choice actually drives the agent. The third level is the one that matches production, and it is the one that requires running research code with an agent LLM.

Fast Models, Slow Evidence is the cautionary companion. Across 11 agent decision points and 7,283 base cases plus 6,640 robustness variants, Jev was significantly more accurate on 9 of 11 points, by 10.8 to 46.0 percentage points. But neither model beat chance on zero-shot model routing, the two tied on RAG relevance gating, and Laya changed 30% of its answers when option order was reversed. The paper's self-audit also found that an omitted pre-screen cost turned a reported 23.9% saving into an actual 4.3%, and that gate accuracy had been reported as end-to-end quality (58% versus 98%). The lesson is not that decision models fail; it is that an offline decision score is not the same as a loop-level outcome.

A placement checklist

  • Put the decision where the branch is, and let code own the branch.
  • Gate the concrete call, not the plan, and decide the failure posture before rollout.
  • Use one request for questions that share state; do not fan out on speculation.
  • Keep policy (thresholds, permissions, budgets) in code, not in the question text.
  • Measure at the level you deploy, and keep an escalation path for the cases the model marks uncertain.

The coding-agent page is blunt about the first mistake: there is no model: jev-latest setting for Claude Code or Cursor, because Jev is not a drop-in agent model. Jev with Coding Agents instead routes readers to routing, rubric scoring, and truth checks, and recommends the agent skill for API context. If your integration needs a different planner, you are not placing a decision layer; you are replacing the agent.

The same pattern shows up across the catalog: a small typed question at a seam, policy in code, and a deliberate answer to what happens when the call fails. The agent loop does not need another model in the middle. It needs fewer places where a general-purpose model has to improvise. For the broader integration picture, see Jev in Coding Agents and Decision Gates in Agent Frameworks; for threshold design, Confidence Gates in Production is the next read.

From the Jev directory

The resources behind this article.

Classify intent with a Choice and complexity with a Score, then send each branch to deterministic code, a specialist model, or a person, with a 0.5 intent-confidence floor.
Jev Practices & PatternsDocs#official#patterns#routing
Official
Use the answer to decide what to do and confidence to decide whether to act: the voice-banking example routes below 0.6 to a human and needs 0.85 or more to auto-approve a transfer.
Jev Practices & PatternsDocs#official#patterns#confidence
Official
3GitHub stars
A safety gate for AI coding agents that checks every shell command, file write, and file read before it runs and returns ALLOW, ASK, or DENY: most calls are decided locally in under a millisecond, while ambiguous or destructive ones go to TypeSafe's System One model.
Jev Tools & CLIs#community#catalog-import#logicrw
Node.js 22+ npm package that provides a multi-provider Jev transport layer. One ask() call picks a carrier from the environment, sends typed questions, and validates answers before returning them, giving typed rejections instead of thrown verdicts.
Jev Repos & SDKs#typescript#sdk#routing
Community
Ask everything the system might need in one request, then let code throw away what it does not use. The ticket-triage example sends a category plus four speculative questions in parallel.
Jev Practices & PatternsDocs#official#patterns#batching
Official
The benchmark behind JevAgentHarness's paper on decision models that share control with LLMs: next-tool decisions scored at isolated, open-loop and closed-loop levels, with 3,939 common-state questions and 153,621 answers from 39 models. The L1 question texts are third-party data and are not redistributed. CC BY 4.0.
Jev Benchmarks & EvaluationsDocs#community#evaluation#agents
Community
A paired, self-audited evaluation of an open-weight (Laya) and a hosted (Jev) System-1 decision model on 11 agent decision points: 7,283 base cases plus 6,640 robustness variants. Jev is significantly more accurate on 9 of 11 decision points, by 10.8 to 46.0 points.
Jev Benchmarks & EvaluationsArticle#community#research#arxiv
Guidance on how Jev fits coding agents: it is not a drop-in agent model, so the page routes readers to routing, rubric scoring, and truth checks instead.
Jev Guides & ArticlesDocs#official#docs#coding-agent
Official
Back to all articles

Related Jev articles

Complex work needs a plan before a tool call. How to use typed decisions to route tasks, choose a subagent, and stop decomposition from becoming a prompt.
Jev Agents & MCP#agents#routing#planning
Read article
An agent can send a malformed argument or trust a poisoned result. How to validate both sides with typed decisions and deterministic checks.
Jev Agents & MCP#agents#tools#validation
Read article

From the Jev AI model community

Posts from builders shipping with Jev right now.

Follow @typesafeai