Skip to content

SPEC-025: Small-model reliability

  • Status: Implemented
  • Milestone: v0.15 "Small models and chess opponents"
  • Owners: lead maintainer

1. Purpose

Small local models (3B to 8B, through Ollama or another local server) often lose games because of their replies, not their moves. They write a move in prose, put it under the wrong key, or never send a legal one, and then forfeit. v0.14 measures this (unreadable_reply, illegal_move, recovered, forfeited). This spec makes those models finish games, without making the comparison between models unfair:

  • Constrained output: ask the model server to allow only replies whose action is a legal move.
  • Lenient reading: read a few more reply shapes that are clear but not exactly the JSON asked for, the same way for every model, and say in the log how each reply was read.
  • Model check: one command that shows how reliably a model plays, and which settings help.

What already exists stays: the format_hints wrapper (WRP-014), json_mode (ADP-017), the world's lenient matching of moves (WLD-004), and max_illegal (RUN-009).

2. Terms

Keywords MUST, SHOULD and MAY follow RFC 2119. - Constrained output: structured output where the model server only lets the model write text that matches a JSON Schema (response_format with type json_schema in OpenAI-compatible APIs; Ollama 0.5 and later, llama.cpp, vLLM, OpenAI, Gemini and some OpenRouter models support it). - Reading: how the shared reply parser (ADP-009) found the action in a model's reply. - Lenient reading: one of the readings added by this spec (REL-006): other_key, list and prose. - Variant: one way of running a model in the model check: as configured, with format_hints, or with constrain: true.

3. Requirements

Constrained output

  • REL-001 chat_api and every provider preset (ADP-020) MUST accept constrain: true. The adapter then sends, with each request, a JSON Schema for the reply in the server's structured output form. Other adapters MUST reject constrain: true with a config error that names the field and the adapters that support it. constrain together with json_mode MUST be a config error ("use one: constrain already asks for JSON").
  • REL-002 The reply schema MUST require action. When legal_actions is a list, action MUST be limited to that list (enum); when it is a JSON Schema, action MUST use that schema. The schema MUST include reasoning (a string, listed before action so a model can think before it chooses) and say, both optional. The prompt text MUST NOT change (ADP-003): only the response format does.
  • REL-003 With tool_calls: true, the restriction MUST go in the act tool's parameters instead, and the tool call MUST be required (tool_choice names act).
  • REL-004 run_start MUST record capabilities.constrained: true for a constrained agent, and the competitor key (RPT-002) MUST end with +constrained, so reports never pool constrained and unconstrained runs of one model.
  • REL-005 The run MUST end with a provider error with the new code provider.no_structured_output when the server rejects a constrained agent's request with a 400 or 422 whose message names response_format, json_schema or structured output. Its fix says to remove constrain or update the server (for Ollama, version 0.5 or later).

Lenient reading

  • REL-006 The shared reply parser MUST read, in this order, after the readings it has today (a JSON object with action, a JSON object inside other text, a reply that is only a legal move):
  • other_key: a JSON object without action but with exactly one of the keys move, answer, choice or play, or action in other letter case (Action, ACTION).
  • list: action is a list of one item, the list itself is not a legal action, and its item is.
  • prose: the reply holds no JSON object, legal_actions is a list, and exactly one legal action appears in the text as a whole word (letter case ignored, and for chess, check marks + and # ignored).

Every model adapter MUST use these readings, so every model is read the same way (ADP-003). Scripted agents are not affected. - REL-007 When the reply names more than one legal action in prose, it MUST be unreadable, and the error MUST say which legal actions it named and show a valid reply, for example your reply names both "rock" and "scissors"; reply like {"action": "rock"}. - REL-008 An agent's config MAY set strict_replies: true to turn off the lenient readings (REL-006), for comparisons with runs made before v0.15. - REL-009 The action event of a model agent MUST record read, one of json, tool, text (a JSON object found inside other text), bare (the reply was only the move), other_key, list or prose. - REL-010 The behaviour evaluator (SPEC-021) MUST add the rate lenient_read: actions read with other_key, list or prose, out of actions that record read. Reports show it with the other rates.

Model check

  • REL-011 agentplaykit model check --agent <agent> MUST play short games with the agent (given as in bench run --agent) in three variants: as configured, with the format_hints wrapper, and with constrain: true (only when the adapter supports it; otherwise the output says why it was skipped). By default it plays 2 games per world per variant in tic-tac-toe, rps and chess (max_moves: 10, at_limit: material), against scripted/random, as each side in turn, with fixed seeds, so two checks of one model play the same opening positions. --games, --worlds, --out (default runs/model-check) and --workers MUST be accepted.
  • REL-012 Before playing, it MUST print the number of games and, when the agent has a price, an estimated cost; --budget MUST stop it from starting games beyond that cost (as EXP-005 does for experiments).
  • REL-013 For each variant it MUST print: moves, the share of replies that were readable, the share of moves legal at the first try, lenient readings, forfeits, seconds per move and cost. It MUST then recommend the variant with the fewest forfeits (then the most legal first tries, then the fastest), and print the agent entry for a scenario that uses it. The logs MUST stay in --out, so agentplaykit report and the viewer can read them.
  • REL-014 It MUST exit 0 when at least one variant finished every game without a forfeit. Otherwise it MUST exit 1 and say that the model cannot yet play reliably, with the most common error and what to try (a larger model, or another variant).
  • REL-015 The sloppy model (SCF-007) MUST accept constrain: true: it then makes no format mistakes (constrained output cannot have them), but still repeats and plays badly as configured. It MUST be available as the built-in agent testkit/sloppy, so the model check can be tested, and tried, with no model installed.

4. Acceptance criteria

Requirement Test ID Notes
REL-001..003 REL-001..REL-003 recorded request bodies for chat_api and presets, list and schema moves, chat and no chat, tool mode; config errors
REL-004..005 REL-004, REL-005 run_start and competitor key; a 400 fixture from an old Ollama
REL-006..010 REL-006..REL-010 each reading, its order, ambiguity, strict_replies, the read field and the lenient_read rate
REL-011..015 REL-011..REL-015 model check with sloppy models: the plan, the table, the recommendation and snippet, exit codes, --budget

5. Examples

agentplaykit model check --agent '{use: ollama, config: {model: "qwen2.5:3b"}}'
model check: ollama:qwen2.5:3b, 18 games (3 worlds x 2 games x 3 variants), local, cost $0

variant          moves  readable  legal 1st  lenient  forfeits  s/move
as configured       64      81%        72%        9         2     1.9
+format_hints       71      84%        79%       11         1     2.0
+constrained        58     100%        97%        0         0     2.4

Recommended: constrained (no forfeits). In a scenario:
  - id: x
    use: ollama
    config: {model: "qwen2.5:3b", constrain: true}

Logs: runs/model-check (agentplaykit report runs/model-check)

A reply read leniently, in the log:

{"type": "action", "agent": "x", "step": 3, "action": 4, "read": "prose",
 "reasoning": null}

6. Open questions

  • Anthropic's API has its own structured outputs; the anthropic adapter may support constrain in a later version.
  • For local Hugging Face models (hf), constrained output could instead score each legal move's likelihood and pick the best. Worth a later spec.

7. Change log

  • 2026-12-03: Initial draft.
  • 2026-12-03: Accepted by the lead maintainer. Lenient reading is on by default, with strict_replies to turn it off; constrain for the anthropic and hf adapters is left for a later version. REL-005 applies only to constrained agents, so other bad requests keep provider.bad_request.
  • 2026-12-03: On building: REL-002 always offers say, because a request does not say whether the world allows messages, and the prompt offers say in every world (the bus drops messages a world does not allow); REL-015 names the built-in agent testkit/sloppy.
  • 2026-12-04: Implemented in v0.15.0; every requirement has a test.

Changes to other specs on acceptance

  • SPEC-003, new LOG-027: the optional read field of action events (REL-009), in the run log schema.
  • SPEC-007, new CLI-020: agentplaykit model check (REL-011..014).
  • SPEC-009, ADP-009 and ADP-017: the lenient readings (REL-006..008) and constrain (REL-001..003).
  • SPEC-013, RPT-002: competitor keys end with +constrained (REL-004).
  • SPEC-018, SCF-008: a new mistake, ambiguous (prose that names two legal moves), because prose and wrong_key replies are now read; the sloppy model's constrain (REL-015).
  • SPEC-021, BHV-002: the built-in rate lenient_read (REL-010).
  • SPEC-023: the error code provider.no_structured_output (REL-005).