Jev engineering for coding agents
A coding agent is mostly a loop of small decisions — which model, which tool, what to keep in context, are we stuck, is this action safe. Doing each in free-text reasoning is slow, inconsistent, and hard to branch on. Jev turns each into a typed, calibrated call the agent can threshold in ~70–500ms, so the model budget goes to writing code, not re-deriving yes/no answers.
"Jev engineering" for a coding agent means moving the loop's control decisions out of the language model and into a decision model. Claude Code, Codex, Cursor and OpenCode are excellent at writing and reasoning, but between edits they make hundreds of structured judgements: route this to a big or small model, pick the right tool, decide what context to drop, notice they're looping, screen a shell command before running it. Each one is a typed decision — a choice, an ordered score, or a calibrated yes/no — which is exactly what Jev returns. The engineering pattern is the same every time: name the decision, give Jev the state and the question, and branch on the number.
The five decision surfaces in an agent loop
| Surface | Jev primitive | What you branch on |
|---|---|---|
| Model routing | choice | cheap-model vs frontier-model for this step |
| Tool selection | choice | which tool (or none) fits the current sub-task |
| Context compaction | score | keep / summarize / drop each context chunk |
| Loop detection | noul | are we repeating without progress? (p → break) |
| Risk gate | noul + choice | is this action destructive? allow / confirm / block |
1. Model routing
Most agent steps don't need the frontier model. Ask Jev a choice over your model tiers — given the current step, is this trivial (small model), standard (mid), or hard (frontier)? Route on the winning key and you cut cost and latency on the 80% of steps that are boilerplate, while still escalating the genuinely hard ones. Because the choice is calibrated, you can also route on confidence: if the top model-tier probability is low, fall back to the safer (bigger) model rather than guessing.
2. Tool selection
When an agent has a dozen tools, letting the LLM free-associate which to call is where format mistakes and wrong-tool loops come from. A choice question over your tool names — with a "none" option — returns exactly one valid tool key, per-option probabilities included. The agent calls the winner; if "none" wins or confidence is low, it thinks in prose instead of forcing a tool call. This is the single highest-leverage place to add Jev, because a wrong tool call is expensive and slow to recover from.
3. Context compaction
Long agent runs blow the context window. Instead of a heuristic ("keep last N messages"), score each chunk with Jev on a relevance scale — how likely is this needed for the next few steps? Drop the low scores, summarize the middle, keep the high. A calibrated score means the threshold you pick ("keep ≥ 0.6") behaves consistently across runs, so compaction stops silently deleting the one file the agent still needed.
4. Loop detection
Agents get stuck: re-editing the same file, re-running a failing command, apologizing and retrying the same approach. Feed the last few actions to a noul question — "is the agent repeating itself without making progress?" — and when the probability crosses your threshold, break the loop: escalate to a human, switch strategy, or stop. This one gate is the difference between an agent that burns your whole budget spinning and one that notices and asks for help.
5. Risk gate
Before the agent runs a shell command, deletes a file, or pushes, gate it. A noul question — "is this destructive or irreversible?" — plus a choice of allow / confirm / block turns a scary autonomous agent into one that flies through the safe 98% and pauses on the risky 2%. The calibration matters here more than anywhere: a threshold like "confirm if p(destructive) > 0.15" only means something if the number is honest, which is what Jev's RLCD training is for.
A working gate, in code
One call, two typed answers the agent branches on directly — no parsing, no retry-on-bad-JSON:
import { TypeSafe } from "@typesafe-ai/sdk";
const jev = new TypeSafe(); // reads TYPESAFE_API_KEY
const { answers } = await jev.systemOne({
model: "jev-latest",
state: `Agent is about to run: ${command}`,
questions: {
destructive: { type: "noul", instructions: "Is this destructive or irreversible?" },
action: {
type: "choice",
instructions: "Gate this command.",
criteria: { allow: "safe, run it", confirm: "ask the human first", block: "never run" },
},
},
});
if (answers.destructive.noul > 0.15 || answers.action.choice !== "allow") {
await askHuman(command); // pause the 2%
} else {
await run(command); // fly through the 98%
}Why not a second LLM call?
You can make these decisions with another model call, and many agents do. But inside a loop it's the wrong tool: seconds of latency, dollars per million output tokens, and prose you still have to parse and can't fully trust the format of. Jev answers in 70–500ms at about $0.001 a decision (input-token billing, output free) and structurally cannot return an invalid type — a choice is always one of your keys. Across a loop that makes hundreds of these calls, that's the difference between a snappy agent and a slow, expensive one.
Wiring it into your agent
Two ways in. Give the agent the primitives as tools via the open jev-mcp server (works in Claude Code, Codex, Cursor, OpenCode), or call the Decision API directly from your loop with fetch or the SDK. The MCP route lets the agent decide on its own initiative; the direct route lets you hard-wire the gates so they always run. Most agent builders do both — MCP for judgement calls, hard-wired direct calls for the non-negotiable risk gate.
See also: Jev in Claude Code · Agent skill (all clients) · Jev for AI agents · Playground
Related: Jev AI agent · Jev vs an LLM · Jev classifier
Wire a decision into your agent
Run a real typed gate in the browser first — no signup — then grab a jv_live_ key and drop it into your agent loop.