Fan-out and judge

Reviewers answer in parallel, then a judge returns one validated verdict with a reason.

Three reviewer agents get the same proposal at once through parallel_map, which keeps the results in input order. The judge then reads all three reviews and must answer with a verdict from a fixed list and a short reason, checked by json_validate.

What it maps to

Asynchronous tasks: parallel_map with a concurrency limit. Guardrails: the judge output is schema-checked. See the concept map.

Script: fan-out-judge.lms

# Fan-out and judge: reviewers answer in parallel, then a judge picks one verdict with a reason.
import "agentic.lms";
proposal = ARGV.get(0, "Replace the nightly cron jobs with lmscript scripts checked in next to the code.");
seats = ["security reviewer", "operations engineer", "finance lead"];
fn review(seat) {
  return {seat: seat, view: ask(agent(seat, "judge proposals from your seat"), f"Proposal: {proposal}\nGive one risk and one benefit in 2 sentences.")};
}
views = parallel_map(seats, review, 3);
notes = "";
for (v in views) {
  notes = notes + f"[{v.seat}] {v.view}\n";
  println(f"{v.seat}: {v.view}");
}
judge = agent("judge", "weigh the reviews and decide");
schema = {type: "object", required: ["verdict", "reason"], properties: {
  verdict: {type: "string", enum: ["accept", "accept with conditions", "reject"]}, reason: {type: "string", maxLength: 500}}};
decision = ask_json(judge, f"Proposal: {proposal}\nReviews:\n{notes}", schema);
if (decision != null) { println(f"verdict={decision.verdict}: {decision.reason}"); }

It imports the shared helpers from examples/agentic.lms, shown on the recipe index.

Run it

export OLLAMA_API_KEY=...
LLM_MODEL=ollama-cloud/deepseek-v4.1-flash lmscript examples/fan-out-judge.lms

Output (offline mock)

The site check runs this recipe against examples/mock-model.lms, a deterministic stand-in for the model, and compares this output.

security reviewer: Risk: scripts may hold credentials in plain files. Benefit: every job is reviewed like code.
operations engineer: Risk: a failed run needs alerting that cron gave us for free. Benefit: one runner and one log format.
finance lead: Risk: model calls add a small per-run cost. Benefit: fewer hand-maintained jobs.
verdict=accept with conditions: Keep credentials in the environment and add failure alerts before switching off cron.

Live run

Recorded on 2026-11-01 with ollama-cloud/deepseek-v4.1-flash. It made 4 model calls and used 1535 tokens. Live replies differ from run to run.

security reviewer: Risk: Moving nightly execution into repo-checked-in lmscript lets anyone with write access alter privileged scheduled jobs, so require protected branches, mandatory review, and least-privilege credentials. Benefit: scheduling logic becomes versioned and peer-reviewed, improving auditability and reproducibility over opaque server cron entries.
operations engineer: Risk: Moving nightly jobs to checked-in lmscript removes the familiar cron scheduler’s retry, logging, alerting, and runtime ownership, creating operational blind spots unless an equivalent runner is enforced. Benefit: Jobs become versioned, reviewable, and deployable with the code they depend on, reducing drift and making changes reproducible.
finance lead: Risk: Moving nightly jobs into checked-in lmscript increases dependence on engineering discipline and deployment controls, so a missed script update could silently break finance feeds. Benefit: co-locating jobs with code improves version control and auditability, making changes easier to review and reducing untracked cron drift.
verdict=accept with conditions: Enforce protected branches, mandatory review, least-privilege credentials, and an equivalent scheduler/runner with retry, logging, alerting, and ownership before migrating.

Previous: Human checkpoint · Next: Stateful checkpoint

Try it: download examples/fan-out-judge.lms and examples/agentic.lms into an examples/ directory, export the key for your provider, then run the command above. Pass a proposal as the first argument.