Bad Monkey runs Jev,
in concert with Spring AI.
A customer support desk in which Spring AI drafts the replies, TypeSafe Jev judges them with typed questions, and Bad Monkey's AgentSpaces coordinates the work. It runs as nine small Spring Boot peers on AgentSpaces 0.7.0, after Christian Tzolov's Spring AI and TypeSafe Jev post. We ran it fully live, Claude Haiku drafting and Jev judging, to see what the fleet adds and what it costs.
Three layers,
one desk.
Spring AI reaches the models. TypeSafe Jev does the judging. Bad Monkey's AgentSpaces decides who does what, holds each key on one peer, and keeps the signed record.
Model access
Drafters use an ordinary ChatClient. Its model is FleetChatModel, which sends the prompt through the fleet to the one peer whose AnthropicChatModel holds the key.
The judgment
Judges ask Tzolov's typed questions through TypeSafeClient and get a verdict from his JevJudge. Each answer is typed and carries its confidence. Councillors ask Jev one yes/no question each.
The coordination
Leases, retries, exactly-once billing, votes, running scores and a signed record, all as entries in shared spaces. Every agent is a Spring bean with one annotation.
One judge, many peers.
What do we gain?
Tzolov's post shows why typed questions make a better judge than a prompt and a parsed number. We kept his judge exactly as it is and changed everything around it.
The starting point
In the post, one application does everything:
- A
ChatClientdrafts the reply. JevSelfRefineAdvisorjudges the draft, appends the judge's feedback to the prompt, and asks again.JevGuardrailAdvisorscreens input and output.JevJudgescores each criterion with a typed answer (Noulfor yes/no,Choice,Score) against a threshold.
That works well in one process. The retry lives in the advisor loop, the keys live in one application, and the record lives in its logs.
Our version
Nine Spring Boot peers share one AgentSpaces group:
- a model server, the only peer with the Anthropic key;
- two drafters, with no keys;
- three judges, the only peers with the TypeSafe key;
- two billing clerks;
- a console.
Each step reacts to an entry in a shared space and writes the next one. Tzolov's JevJudge and his triage questions run unchanged.
The benefits we expect
Keys stay on their peers
Drafters reach the model through the fleet, so only one peer holds the Anthropic key, and only the judges hold the TypeSafe key.
Retries survive a crash
A failed draft becomes a new ticket carrying the judge's feedback. Any drafter can take it, and a drafter that dies mid-ticket loses nothing: its lease lapses and the ticket comes back.
Side effects happen once
Billing cases go through a Raft-ordered log. Two clerks race for every case, and only one commits.
A signed record of every decision
Every judgment, reply, ballot and receipt is an entry signed by the agent that wrote it, readable from any peer.
Escalation by vote
A very angry customer goes to a council of three. Each councillor asks Jev one question and casts a signed ballot, and a quorum decides.
What it might cost
More moving parts and more hops per ticket. We measured how long each ticket takes with real models, to see whether a desk would notice.
| # | Criterion | How we observe it |
|---|---|---|
| C1 | Every ticket reaches an outcome | An approved reply (for billing, a receipt), or a recorded give-up after two failed drafts. |
| C2 | A failed draft is retried with the judge's feedback | The retry ticket carries verdict.feedback(), and the ledger shows the next attempt. |
| C3 | A crashed drafter loses no work | The fleet test kills a drafter holding a ticket. The ticket must come back after the 20 s lease and be finished by the other drafter. |
| C4 | Billing happens exactly once | One receipt per billing case, from one clerk, at one commit index. |
| C5 | A very angry customer reaches the council | Three ballots and a recorded decision. |
| C6 | Every record is signed by its agent | Every ledger line ends in its signer and AGENT_ATTESTED. |
| C7 | Keys stay on their peers | The launcher gives the live profiles only to the peers that hold the keys, and the test asserts which peers have which model beans. |
| C8 | Fast enough for a desk | Seconds from submission to each ticket's outcome, with real models. |
| C9 | Nothing regressed on 0.7.0 | The keyless counts match the record from 4 November, on the released 0.7.0 artifacts from Maven Central. |
All nine held.
Fully live in 13.5 s.
Two fully live runs, Haiku drafting and Jev judging, plus the keyless fleet test and demo, all on AgentSpaces 0.7.0.
Spring AI and TypeSafe Jev: Fast, Cheap, Structured Decisions
Christian Tzolov on the Spring blog, 21 September 2026. Start here: it explains typed judgment, JevJudge and the advisors this report builds on.
Every expected benefit showed up in the runs. Crash recovery (C3) is checked by the fleet test.
Three tickets with real models, each settled within 6.7 s. The keyless demo takes 10.1 s.
In run B, Jev failed two first drafts and said why. Haiku's second drafts, prompted with that feedback, both passed.
The Anthropic key lives on the model server only, and the TypeSafe key on the three judges only.
| # | What we saw | Verdict |
|---|---|---|
| C1 | Every ticket in every run ended with a reply, a receipt, or a recorded give-up. | met |
| C2 | Run B: T-1 failed on “no unconfirmed promise” (0.28) and T-3 on “addresses the issue” (0.42). Both retries passed. | met |
| C3 | The fleet test killed a drafter holding T-1. The other drafter finished T-1 after the lease lapsed. | met (fleet test) |
| C4 | Run B: one receipt each for T-1 and T-3, by one clerk, at commits 1 and 3. | met |
| C5 | T-3 scored “Very angry” in every run, and the council voted 3–0 for a person every time. | met |
| C6 | All 13 ledger lines of run B were signed by their agents (AGENT_ATTESTED). | met |
| C7 | The live profiles went only to the key holders, and the test's bean checks pass. | met |
| C8 | Fully live, tickets settled in 4.7 to 6.7 s; the whole run took 13.5 s. | met |
| C9 | Keyless: 4 model requests, 11 Jev requests, 12 signed lines. Same as on 4 November. | met |
JevJudge come from Christian Tzolov's post Spring AI and TypeSafe Jev: Fast, Cheap, Structured Decisions (21 September 2026) and the spring-ai-typesafe project. The post now notes that Spring AI TypeSafe is being archived, its functionality moving into Spring AI 2.1's DecisionModel API. This example still runs on typesafe-spring-ai 0.1.0.
The process: one ticket's path
Each peer is an ordinary Spring Boot application with the AgentSpaces starter on its classpath. They share one group (jev-fleet) and six spaces. An agent is a Spring bean whose method is bound to a space by one annotation. The method's parameter is the entry it reacts to, and its return value is the entry it writes. No peer calls another directly.
Steps 1 and 2 · a ticket arrives, a drafter takes it
Work under a lease
The console writes each customer message into inbox as a Ticket. One of the two drafters takes it under a 20-second lease. If that drafter dies, nothing renews the lease, and the ticket goes back to the inbox for the other drafter. The draft it returns is written to drafts.
public void submit(String ticketId, String customer, String message) {
space(Support.INBOX).write(
new Ticket(ticketId, customer, message, 1, ""),
Lease.of(Duration.ofHours(12)));
}@SpaceTake(space = Support.INBOX, lease = LEASE_SECONDS + "s",
pollTimeout = "300ms", resultSpace = Support.DRAFTS,
resultLease = "12h")
public Draft draft(Ticket ticket) {
String reply = chat.prompt().system(SYSTEM).user(prompt(ticket))
.call().content();
return new Draft(ticket.ticketId(), ticket.customer(),
ticket.message(), reply.strip(), ticket.attempt(), name);
}
static String prompt(Ticket ticket) {
String prompt = "Customer " + ticket.customer() + " wrote: "
+ ticket.message();
if (ticket.attempt() > 1) {
prompt += "\n\nA reviewer rejected the previous draft. Feedback: "
+ ticket.feedback()
+ "\nWrite a new reply that fixes this.";
}
return prompt;
}Step 3 · the model call crosses the fleet
One peer holds the key
The drafter's ChatClient runs on FleetChatModel, which writes the prompt into model-requests. The model-server peer takes it, calls Claude Haiku, and writes the answer back. The drafter accepts an answer only from the peer the model-serve grant names.
The launcher decides which peers get the live profiles, and with them the keys.
switch (name) {
case "model-server" -> {
profiles.add("model-server");
if (haikuLive) {
profiles.add("haiku-live"); // the Anthropic key
}
}
case "drafter-a", "drafter-b" -> profiles.add("drafter");
case "judge-lead", "judge-b", "judge-c" -> {
if (jevLive) {
profiles.add("jev-live"); // the TypeSafe key
}
}
case "console" -> profiles.add("console");
default -> { }
}spring:
config:
activate:
on-profile: model-server
agentspaces:
springai:
model-server:
enabled: true
models: ["${example.haiku-model}"] # claude-haiku-4-5-20251001
lease: 2m
---
spring:
config:
activate:
on-profile: haiku-live
ai:
model:
chat: anthropic
anthropic:
api-key: ${ANTHROPIC_API_KEY}
chat:
model: ${example.haiku-model}
max-tokens: 400
---
spring:
config:
activate:
on-profile: drafter
agentspaces:
springai:
model-client:
enabled: true
model: ${example.haiku-model}
timeout: 15s # shorter than the drafter's 20 s take
---
spring:
config:
activate:
on-profile: jev-live
ai:
typesafe:
api-key: ${TYPESAFE_API_KEY}Step 4 · Jev answers typed questions
Tzolov's judge, unchanged
For each draft, the judge makes two System One requests:
- the post's three triage questions about the customer's message;
- a
JevJudgeverdict on the reply, from three criteria with thresholds.
Each answer is typed and carries its confidence, so there is no number to parse out of text.
Map<String, Question> questions = new LinkedHashMap<>();
questions.put("is_urgent", Noul.of("Does this message convey urgency?"));
questions.put("department", Choice.builder()
.instructions("Which team should handle this?")
.option("billing", "Payments, invoicing, refunds, charges")
.option("technical", "Bugs, outages, integrations")
.option("sales", "Pricing, upgrades, new accounts")
.build());
questions.put("frustration", Score.of("How frustrated is the customer?",
"Calm", "Frustrated", "Very angry"));this.judge = JevJudge.builder(jev)
.noul("addresses_issue", Noul.of(
"Does the answer address the specific problem "
+ "the customer raised?"), 0.7)
.noul("no_unconfirmed_promise", Noul.of(
"Does the answer avoid promising a specific outcome "
+ "the company has not confirmed?"), 0.7)
.score("tone", Score.of("What is the tone of the answer?",
"Curt", "Neutral", "Courteous"), 1.0)
.build();T-1 attempt 1 FAILED no_unconfirmed_promise: scored 0.28, needs at least 0.70 T-3 attempt 1 FAILED addresses_issue: scored 0.42, needs at least 0.70
Step 5 · the verdict becomes entries
The retry is an entry, not a loop
The judge reacts to each draft with @SpaceNotify and returns several entries at once:
- the judgment and a quality sample, always;
- an escalation for a very angry customer;
- for a pass, the reply, plus a billing case for billing tickets;
- for a fail, a new ticket carrying the judge's feedback, which any drafter may take;
- after the second failed attempt, a give-up record.
This replaces JevSelfRefineAdvisor. The feedback text is the same, but the retry no longer depends on one process staying alive.
@SpaceNotify(space = Support.DRAFTS, lease = "12h",
resultSpace = Support.VERDICTS, resultLease = "24h",
produces = {Judgment.class, QualitySample.class, Reply.class,
Escalation.class, GaveUp.class})
public Entries judge(Draft draft) {
SystemOneResponse answers = jev.systemOne(draft.message(), TRIAGE);
JevVerdict verdict = judge.judge(draft.message(), draft.reply());
// ... the judgment and the quality sample go on the ledger ...
if (frustration >= Support.VERY_ANGRY) {
ledger.add(new Escalation(draft.ticketId(), draft.customer(),
draft.message(), frustration));
}
if (verdict.passed()) {
ledger.add(new Reply(draft.ticketId(), draft.customer(),
draft.reply(), draft.attempt(), department));
if ("billing".equals(department)) {
billing.write(new BillingCase(...),
Lease.of(Duration.ofHours(12)));
}
} else if (draft.attempt() < Support.MAX_ATTEMPTS) {
// The retry is an entry: any drafter may take it.
inbox.write(new Ticket(draft.ticketId(), draft.customer(),
draft.message(), draft.attempt() + 1, verdict.feedback()),
Lease.of(Duration.ofHours(12)));
} else {
ledger.add(new GaveUp(draft.ticketId(), draft.customer(),
draft.attempt(), verdict.feedback()));
}
return Entries.of(ledger);
}Step 6 · billing commits once
Two clerks, one commit
Both clerks take billing cases through the space's Raft-ordered log. Each case commits once, so exactly one clerk opens the refund review, and the receipt records the commit index.
@OrderedTake(space = Support.BILLING, lease = "30s",
pollTimeout = "1s", resultSpace = Support.VERDICTS,
resultLease = "24h")
public BillingReceipt settle(BillingCase billingCase) {
return new BillingReceipt(billingCase.ticketId(),
"refund review opened for " + billingCase.customer(),
name, desk.raft().commitIndex());
}Step 7 · the council votes
Three concerns, three ballots
The lead opens a vote with a quorum of three. Each councillor holds one concern and asks Jev one yes/no question about the customer's message, then casts a signed ballot.
public enum Concern {
RETENTION("retention", "Is the customer threatening to leave, "
+ "cancel, or dispute a charge?"),
PERSON("asks_for_person",
"Is the customer asking for a person, or complaining that "
+ "nobody has answered?"),
RISK("risk", "Does the message mention legal action, a bank dispute, "
+ "or harm?");
// ...
}
@Ballot(space = Support.COUNCIL, prefix = PREFIX, lease = "12h")
public String vote(VoteCapability.Proposal proposal) {
// ... read the escalation from verdicts ...
double truth = jev.systemOne(escalation.message(),
Map.of(concern.question, Noul.of(concern.text)))
.noulValue(concern.question);
return truth >= 0.5 ? "human" : "bot";
}Step 8 · quality keeps a running score
A reduce, not a report job
Each judgment writes a quality sample. A @SpaceReduce on the console folds the samples into one accumulator per department: how many were judged, how many passed, and the frustration so far. A new sample updates the score within the lease, and nothing recomputes it from scratch.
@SpaceReduce(space = Support.VERDICTS, name = NAME, key = "department",
lease = "30s", accumulatorLease = "7d")
public DepartmentQuality score(DepartmentQuality current,
QualitySample sample) {
DepartmentQuality soFar = current != null ? current
: new DepartmentQuality(sample.department(), 0, 0, 0.0);
return new DepartmentQuality(soFar.department(), soFar.judged() + 1,
soFar.passed() + (sample.passed() ? 1 : 0),
soFar.frustrationSum() + sample.frustration());
}What ran, and what it showed
Four runs on AgentSpaces 0.7.0, all with the same three customers:
- T-1, Dana: charged twice for one order, wants the duplicate refunded.
- T-2, Luis: a webhook integration stopped firing after last night's update.
- T-3, Priya: third message with no answer; she is cancelling and disputing the charge with her bank.
The keyless runs use two fixtures:
- A scripted Haiku (a Spring AI
ChatModel) that writes a vague first draft for T-1 on purpose, so the retry path runs. - A keyword Jev that replaces only the HTTP call. The real
TypeSafeClientandJevJudgerun on top of it.
The fully live runs use the real models, each key set only on the peers that use it.
# the fleet test: nine peers, a killed drafter, the lease lapse
mvn -q verify
# the demo on the fixtures: three tickets, the signed ledger, the timings
mvn -q compile exec:java
# fully live: Haiku on the model server, Jev on the judges
ANTHROPIC_API_KEY=... TYPESAFE_API_KEY=... mvn -q compile exec:java| Measure | Fleet test (fixtures) | Demo (fixtures) | Fully live, run A | Fully live, run B |
|---|---|---|---|---|
| Nine peers started | 1.8 s | 1.5 s | 1.8 s | 1.7 s |
| T-1 settled | – | 2.3 s · reply, attempt 2 | 5.5 s · given up | 5.2 s · reply, attempt 2 |
| T-2 settled | 0.92 s · inbox to reply | 1.3 s · reply | 3.1 s · reply | 4.7 s · reply |
| T-3 settled | – | 2.4 s · receipt | 7.8 s · given up | 6.7 s · receipt, attempt 2 |
| Model requests | 4 | 4 | 5 | 5 |
| Jev requests | 11 | 11 | not counted | not counted |
| Whole run | 33.2 s · includes the 20 s lease lapse | 10.1 s | 14.6 s | 13.5 s |
| Signed ledger lines | 12 | 12 | 11 | 13 |
Figure 1 · Seconds from submission to each ticket's outcome
The three tickets go in together. A ticket settles when its outcome is written: an approved reply (for T-3 a billing receipt), or the judge giving up after two drafts. Hover or tab to a bar for its value.
Show Figure 1 as a table
| Ticket | Demo, fixtures | Fully live, run A | Fully live, run B |
|---|---|---|---|
| T-1 | 2.3 s (reply, attempt 2) | 5.5 s (given up) | 5.2 s (reply, attempt 2) |
| T-2 | 1.3 s (reply) | 3.1 s (reply) | 4.7 s (reply) |
| T-3 | 2.4 s (billing receipt) | 7.8 s (given up) | 6.7 s (receipt, attempt 2) |
What the fully live runs show
- The retry does what the advisor did. In run B, Jev failed two first drafts and said why. Each retry carried that feedback into Haiku's next prompt, and both second drafts passed. Both billing cases then committed once.
- The same desk can end differently. In run A, a minute earlier, Jev failed both drafts for both billing tickets, so the fleet gave T-1 and T-3 up and only T-2 got a reply. Haiku's drafts change from run to run, and Jev judges each one on its own. Either way, every ticket ended in a recorded outcome.
- Jev reads the customer, not keywords. It rated Dana's double charge “Calm” with urgency 0.37–0.39, and Priya “Very angry” at 1.8. The keyword fixture calls both urgent. In every run, the council sent Priya to a person 3–0.
- The fleet costs little. With real models every ticket settled within 7.8 s, and the whole run took 13.5–14.6 s, against 10.1 s on the fixtures. On the fixtures, where the models answer at once, the same path through the fleet took 1.3–2.4 s per ticket, so most of the live time is the model calls themselves.
judgment T-1 attempt 1: billing (1.00), Calm, FAILED (no_unconfirmed_promise: scored 0.28, needs at least 0.70) judgment T-1 attempt 2: billing (1.00), Calm, PASSED judgment T-2 attempt 1: technical (1.00), Frustrated, PASSED judgment T-3 attempt 1: billing (1.00), Very angry, FAILED (addresses_issue: scored 0.42, needs at least 0.70) judgment T-3 attempt 2: billing (1.00), Very angry, PASSED reply T-1 attempt 2 to billing: I sincerely apologize for the duplicate charge on your order ... council T-3: human {human=3, bot=0} receipt T-1: refund review opened for Dana by billing-a at commit 1 receipt T-3: refund review opened for Priya by billing-a at commit 3 quality billing: 4 judged, 2 passed quality technical: 1 judged, 1 passed every line signed by its agent (AGENT_ATTESTED)
Tests on fixtures, live runs opt-in
- The fleet test (
JevFleetTest, 1/1 pass, 33.3 s) asserts C1 to C7: the retry, the killed drafter's ticket coming back, one billing commit, the council's quorum, which peers hold which model beans, and a signer on every ledger line. - The release: all five AgentSpaces artifacts the example uses are byte-identical to Maven Central's 0.7.0 (SHA-1 compared).
- The live runs print the same ledger and timings as the demo. Their keys were passed in the environment of the one command and never written to a file.
Read it as a demonstration
- Two fully live runs and three tickets. They disagreed on both billing tickets, so a pass rate needs many more runs.
- Crash recovery (C3) was run on the fixtures only. A live run doesn't kill a drafter.
- The demo doesn't count Jev's requests on the live path.
- Claude Haiku 4.5 is this example's choice of drafting model. The post leaves the chat model to the reader.
An open-source baseline.
Evolution makes it governed.
Everything in this example is Apache 2 open source:
- The fleet: AgentSpaces 0.7.0, with spaces, leases, the ordered log, votes, reduces and per-agent signatures.
- The model service: the Spring AI integration, with
FleetChatModel,ModelServer,TakeLeaseAdvisorand themodel-servegrant. - The judge: Tzolov's
JevJudge, unchanged.
That's enough to keep keys on one peer, judge every draft with typed questions, retry without a loop, commit billing once, and vote on escalation.
The baseline stops where the example's own code stops:
- The model server forwards every request, with no budget, routing or content check.
- The council's “human” vote is a record, and nobody is paged.
- The quality scores live in a reduce that someone has to read.
Bad Monkey Evolution is the platform layer for those gaps.
| Concern | Open-source baseline (this example) | Bad Monkey Evolution |
|---|---|---|
| Model keys | One model-server peer holds the Anthropic key, and a grant names it as the only trusted server | A model gateway per group. Keys go into the console's vault, read once at start |
| Which model, at what cost | One model, pinned in application.yml | A routing policy per group (preferred, fallback, forbid, price caps), budgets, and usage records |
| What a model may see and say | Nothing checks prompts or completions | Guardrail checks on every prompt and completion at the gateway |
| Judging a draft | JevJudge on the judge peer; the verdict is a signed entry | The same, plus juries of model-backed reviewers and people for rules that need one |
| Handing off to a person | A 3–0 council vote, recorded on the ledger | A HITL desk: the ask waits for a decider, with a quorum, a deadline, a timeout rule and overdue findings |
| Watching quality | A @SpaceReduce per department, printed by the demo | Desk reports, audit rows and findings the console delivers |
This example ran on the open-source baseline only. Table 3 maps what it builds by hand to the Evolution features that cover the same ground. It isn't a record of running this example on Evolution.
Nine peers, one YAML, no key needed.
The fixtures run the whole desk offline in about 10 seconds. Add an Anthropic key and Haiku drafts the replies; add a TypeSafe key and Jev judges them. For the ideas behind the judge, read Christian Tzolov's Spring AI post.