Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

Claude 5.5-era models: no forced tools, bound thinking, effort, output room, refusals

justrachf36904cc0c82
diff --git a/docs/adr/0219-claude-5-5-era-request-contract.md b/docs/adr/0219-claude-5-5-era-request-contract.md
new file mode 100644
index 00000000..cdf2698e
--- /dev/null
+++ b/docs/adr/0219-claude-5-5-era-request-contract.md
@@ -0,0 +1,78 @@
+# 0219. Claude 5.5-era models: the request contract
+
+Status: accepted 2026-09-30
+
+## Context
+
+Claude Opus 5.5, Sonnet 5.5 and Fable 5.1 change the Messages API contract
+graff relied on:
+
+- **Forced tool use returns a 400.** `tool_choice` `any` or `tool` is
+ rejected. graff forces a tool call under `--strict`, under `--eval`, and
+ after named-work nudges.
+- **Thinking is always on** on Opus 5.5 and Fable 5.1, and `max_tokens`
+ covers thinking plus the answer. graff sent a flat 16K. Anthropic measured
+ that cap ending a large share of agentic attempts on these models, at no
+ saving per solved task.
+- **Replayed thinking is bound to its prefix.** A replayed thinking block is
+ checked against everything before it: `system`, `tools` and the earlier
+ messages. graff edits that prefix mid-session. Tools change when an MCP
+ server joins, and compaction and history repair rewrite earlier messages.
+ Accounts created from 31 August 2026 get a 400 for this by default.
+- **Effort is the only thinking control,** set through
+ `output_config.effort`. Opus 5.5 defaults to `medium`. graff never sent
+ effort to Claude, so `/effort` did nothing there.
+- **A safety refusal** ends with `stop_reason: "refusal"` and a
+ `stop_details.category`.
+
+Separately, graff's retry-without ladder drops a rejected option (a forced
+tool, an effort level, an output format) and retries. It only ran for
+OpenAI-shaped errors, so every Claude error failed the request.
+
+## Decision
+
+- **Per-model rules.** `claude_wire.zig` keys them on family and version
+ (`claude-<family>-<major>[-<minor>]`), so later releases inherit them.
+- **Forced tools.** 5.5-era models run `auto` (soft-strict) and keep their
+ thinking. Older models are forced as before.
+- **Thinking binding.** Fable 5.1, Opus 5.5, Sonnet 5.5 and later get
+ `thinking.block_binding.prefix_mismatch_behavior: "drop_block"`, with
+ `anthropic-beta: thinking-binding-controls-2026-08-01`. A prefix edit then
+ drops the stale thinking instead of failing the request. Older models, which
+ do not run the check, get neither.
+- **Effort.** `output_config.effort` goes to models that take it: Opus 4.5 and
+ later, Sonnet 4.6 and later, Fable, and Mythos. It shares one `output_config`
+ object with a structured-output `format` when there is one. graff's default
+ (`medium`) is left off, so each model keeps its own default. `ultra` maps to
+ `max`.
+- **max_tokens.** 64K on models with a 128K ceiling, and the full 128K at
+ `xhigh`, `max` and `ultra`, as Anthropic advises for agentic work. Other
+ models keep 16K. graff always streams, which responses this size need.
+- **One retry ladder.** Every error shape goes through it: Anthropic JSON
+ errors, streamed error events, and OpenAI envelopes. An effort rejection is
+ recognized before the output-format fallback, since Claude names both
+ inside `output_config`.
+- **Refusals.** A refusal ends the turn with a line naming the category. The
+ refused reply stays out of history, and the turn is never read as an empty
+ reply to re-send.
+- **Defaults and lineup.** The Anthropic default model is `claude-opus-5-5`.
+ The subagent ladder is `claude-opus-5-5` → `claude-sonnet-5-5`, and
+ `claude-sonnet-5-5` is the vision seat. The new lineup has prices and
+ offline catalog rows.
+
+## Consequences
+
+- A dropped thinking block costs the model that earlier reasoning, but the
+ request succeeds.
+- Not done yet:
+ - Keeping thinking instead of dropping it, by freezing `system` and `tools`
+ and using inline tool additions and mid-conversation system messages.
+ - Showing text written between tool calls via the `updates` display.
+ - Pricing 1-hour cache writes at 2× (they are counted at 1.25×).
+ - Tool search with deferred loading.
+ - Task budgets.
+ - An elapsed-time clock.
+ - Keep-alive cache warming.
+ - Server-side refusal fallback.
+ - Fast mode.
+- The request shapes are unit-tested. CI does not call the live API.
diff --git a/docs/adr/README.md b/docs/adr/README.md
index 9e13bfec..272f4e1a 100644
--- a/docs/adr/README.md
+++ b/docs/adr/README.md
@@ -245,6 +245,7 @@ record only when you need the evidence or the edge cases.
| [0216](0216-loop-is-retired.md) | `/loop` is retired: `/goal` is the one autonomous run, and waiting for background work is how every run works (ADR 0215). Typing `/loop` prints a pointer to `/goal` and makes no model call. |
| [0217](0217-follow-ups-supersede-the-streaming-reply.md) | A plain follow-up typed while the root reply streams cuts that stream, drops the uncommitted partial and rebuilds the request with the follow-up (not for compaction, children, started async tools, or GPT-6 WebSocket steer). TUI Enter hands plain text to the running turn; `/btw`, commands and images still wait; ACP is unchanged. |
| [0218](0218-background-jobs-survive-a-crash.md) | A finite root job started in the background writes its output to `.graff/job-output/<id>/` with an exit receipt from its own shell, so it outlives a crashed graff. Loading the session re-attaches this session's unreported jobs under their old ids, reports what ended while graff was down, and sweeps other sessions' stale captures. Foreground commands, servers, subagent jobs and Windows keep pipes. |
+| [0219](0219-claude-5-5-era-request-contract.md) | Claude Opus 5.5, Sonnet 5.5 and Fable 5.1 are never forced to a tool, get `drop_block` thinking binding (with its beta header), take `/effort` as `output_config.effort` (left off at graff's default), and get 64K/128K `max_tokens`. Claude errors take the same retry-without ladder as other providers; a refusal ends the turn outside history. Default model `claude-opus-5-5`, ladder opus-5-5 → sonnet-5-5. |
## When to write one
diff --git a/examples/edge-worker/src/remote.ts b/examples/edge-worker/src/remote.ts
index c8ee80cd..3dea40a0 100644
--- a/examples/edge-worker/src/remote.ts
+++ b/examples/edge-worker/src/remote.ts
@@ -9,7 +9,7 @@
export const HARNESS_VERSION = "0.13";
-export type ModelName = "MiniMax-M2.5" | "MiniMax-M2.7" | "MiniMax-M3" | "accounts/fireworks/models/deepseek-v4-flash" | "accounts/fireworks/models/deepseek-v4-pro" | "accounts/fireworks/models/glm-5p2" | "accounts/fireworks/models/gpt-oss-120b" | "accounts/fireworks/models/kimi-k2p6" | "accounts/fireworks/models/kimi-k2p7-code" | "accounts/fireworks/models/minimax-m3" | "accounts/fireworks/models/qwen3p7-plus" | "alibaba/qwen3.8-27b" | "anthropic/claude-sonnet-4.6" | "claude-fable-5" | "claude-haiku-4-5" | "claude-opus-4-5" | "claude-opus-4-6" | "claude-opus-4-7" | "claude-opus-4-8" | "claude-opus-4.8" | "claude-opus-5" | "claude-sonnet-4-5" | "claude-sonnet-4-6" | "claude-sonnet-4.6" | "claude-sonnet-5" | "deepseek-chat" | "deepseek-reasoner" | "deepseek-v4-flash" | "deepseek-v4-pro" | "fugu" | "fugu-ultra" | "fugu-ultra-20260615" | "gemini-3-flash-preview" | "gemini-3.1-flash-lite" | "gemini-3.1-pro-preview" | "gemini-3.5-flash" | "gemini-3.5-flash-lite" | "gemini-3.6-flash" | "gemini-3.7-flash" | "gemini-3.8-flash" | "gemma-4-26b-a4b-it" | "gemma-4-31b" | "gemma-4-31b-it" | "glm-4.5" | "glm-4.7" | "glm-5" | "glm-5-turbo" | "glm-5.2" | "glm-5.3" | "glm-5.3-flash" | "glm-5v-turbo" | "gpt-5-codex" | "gpt-5.2" | "gpt-5.3-codex-spark" | "gpt-5.4" | "gpt-5.4-mini" | "gpt-5.4-pro" | "gpt-5.5" | "gpt-5.6" | "gpt-5.6-luna" | "gpt-5.6-sol" | "gpt-5.6-terra" | "gpt-6-astra" | "gpt-6-luna" | "gpt-6-sol" | "gpt-oss-120b" | "grok-4.3" | "grok-4.6" | "grok-4.7" | "grok-build" | "k3" | "kilo-auto/small" | "kimi-for-coding" | "kimi-for-coding-highspeed" | "kimi-k2.6" | "kimi-k2.7-code" | "kimi-k3" | "kimi-latest" | "lmstudio" | "mimo-v2-flash" | "mimo-v2.5" | "mimo-v2.5-pro" | "mimo-v2.5-pro-ultraspeed" | "mimo-v2.6-flash" | "mimo-v2.6-pro" | "mimo-v2.6-pro-ultraspeed" | "minimax-m3" | "mistral-medium-latest" | "mlx-community/Qwen3.6-27B-OptiQ-4bit" | "muse-spark-1.2" | "muse-spark-1.2-contributor" | "openai/gpt-oss-120b" | (string & {});
+export type ModelName = "MiniMax-M2.5" | "MiniMax-M2.7" | "MiniMax-M3" | "accounts/fireworks/models/deepseek-v4-flash" | "accounts/fireworks/models/deepseek-v4-pro" | "accounts/fireworks/models/glm-5p2" | "accounts/fireworks/models/gpt-oss-120b" | "accounts/fireworks/models/kimi-k2p6" | "accounts/fireworks/models/kimi-k2p7-code" | "accounts/fireworks/models/minimax-m3" | "accounts/fireworks/models/qwen3p7-plus" | "alibaba/qwen3.8-27b" | "anthropic/claude-sonnet-4.6" | "claude-fable-5" | "claude-fable-5-1" | "claude-haiku-4-5" | "claude-opus-4-5" | "claude-opus-4-6" | "claude-opus-4-7" | "claude-opus-4-8" | "claude-opus-4.8" | "claude-opus-5" | "claude-opus-5-5" | "claude-sonnet-4-5" | "claude-sonnet-4-6" | "claude-sonnet-4.6" | "claude-sonnet-5" | "claude-sonnet-5-5" | "deepseek-chat" | "deepseek-reasoner" | "deepseek-v4-flash" | "deepseek-v4-pro" | "fugu" | "fugu-ultra" | "fugu-ultra-20260615" | "gemini-3-flash-preview" | "gemini-3.1-flash-lite" | "gemini-3.1-pro-preview" | "gemini-3.5-flash" | "gemini-3.5-flash-lite" | "gemini-3.6-flash" | "gemini-3.7-flash" | "gemini-3.8-flash" | "gemma-4-26b-a4b-it" | "gemma-4-31b" | "gemma-4-31b-it" | "glm-4.5" | "glm-4.7" | "glm-5" | "glm-5-turbo" | "glm-5.2" | "glm-5.3" | "glm-5.3-flash" | "glm-5v-turbo" | "gpt-5-codex" | "gpt-5.2" | "gpt-5.3-codex-spark" | "gpt-5.4" | "gpt-5.4-mini" | "gpt-5.4-pro" | "gpt-5.5" | "gpt-5.6" | "gpt-5.6-luna" | "gpt-5.6-sol" | "gpt-5.6-terra" | "gpt-6-astra" | "gpt-6-luna" | "gpt-6-sol" | "gpt-oss-120b" | "grok-4.3" | "grok-4.6" | "grok-4.7" | "grok-build" | "k3" | "kilo-auto/small" | "kimi-for-coding" | "kimi-for-coding-highspeed" | "kimi-k2.6" | "kimi-k2.7-code" | "kimi-k3" | "kimi-latest" | "lmstudio" | "mimo-v2-flash" | "mimo-v2.5" | "mimo-v2.5-pro" | "mimo-v2.5-pro-ultraspeed" | "mimo-v2.6-flash" | "mimo-v2.6-pro" | "mimo-v2.6-pro-ultraspeed" | "minimax-m3" | "mistral-medium-latest" | "mlx-community/Qwen3.6-27B-OptiQ-4bit" | "muse-spark-1.2" | "muse-spark-1.2-contributor" | "openai/gpt-oss-120b" | (string & {});
export type ToolName = "shell" | "read_file" | "edit_file" | "write_file" | "webfetch" | "skill" | "codedb" | "read_tool_result" | "render_html" | "todo_write" | "todo_read" | "eval" | "note_constraint" | "ask_user" | "attempt_completion" | "load_tool_schemas" | "mcp_search_tools" | "mcp_select_tool" | "clock_sleep" | "subagent" | "workflow" | "agent_output" | "agent_message" | "subagent_resume" | "learn_candidate" | "peer_message" | "workspace" | "imagegen" | "rlm";
export type ProviderId = "anthropic" | "codegraff" | "deepseek" | "openai" | "google" | "minimax" | "xiaomi" | "kilo" | "groq" | "cerebras" | "mistral" | "kimi" | "moonshot" | "xai" | "zai" | "meta" | "vercel" | "openrouter" | "fugu" | "fireworks" | "mlx" | "lmstudio" | "codex";
@@ -528,5 +528,5 @@ export async function* runAgentRemote(opts: RunAgentRemoteOptions): AsyncGenerat
}
}
-export const MODELS: ModelName[] = ["MiniMax-M2.5", "MiniMax-M2.7", "MiniMax-M3", "accounts/fireworks/models/deepseek-v4-flash", "accounts/fireworks/models/deepseek-v4-pro", "accounts/fireworks/models/glm-5p2", "accounts/fireworks/models/gpt-oss-120b", "accounts/fireworks/models/kimi-k2p6", "accounts/fireworks/models/kimi-k2p7-code", "accounts/fireworks/models/minimax-m3", "accounts/fireworks/models/qwen3p7-plus", "alibaba/qwen3.8-27b", "anthropic/claude-sonnet-4.6", "claude-fable-5", "claude-haiku-4-5", "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-4.8", "claude-opus-5", "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-sonnet-4.6", "claude-sonnet-5", "deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro", "fugu", "fugu-ultra", "fugu-ultra-20260615", "gemini-3-flash-preview", "gemini-3.1-flash-lite", "gemini-3.1-pro-preview", "gemini-3.5-flash", "gemini-3.5-flash-lite", "gemini-3.6-flash", "gemini-3.7-flash", "gemini-3.8-flash", "gemma-4-26b-a4b-it", "gemma-4-31b", "gemma-4-31b-it", "glm-4.5", "glm-4.7", "glm-5", "glm-5-turbo", "glm-5.2", "glm-5.3", "glm-5.3-flash", "glm-5v-turbo", "gpt-5-codex", "gpt-5.2", "gpt-5.3-codex-spark", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-pro", "gpt-5.5", "gpt-5.6", "gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-6-astra", "gpt-6-luna", "gpt-6-sol", "gpt-oss-120b", "grok-4.3", "grok-4.6", "grok-4.7", "grok-build", "k3", "kilo-auto/small", "kimi-for-coding", "kimi-for-coding-highspeed", "kimi-k2.6", "kimi-k2.7-code", "kimi-k3", "kimi-latest", "lmstudio", "mimo-v2-flash", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2.5-pro-ultraspeed", "mimo-v2.6-flash", "mimo-v2.6-pro", "mimo-v2.6-pro-ultraspeed", "minimax-m3", "mistral-medium-latest", "mlx-community/Qwen3.6-27B-OptiQ-4bit", "muse-spark-1.2", "muse-spark-1.2-contributor", "openai/gpt-oss-120b"];
+export const MODELS: ModelName[] = ["MiniMax-M2.5", "MiniMax-M2.7", "MiniMax-M3", "accounts/fireworks/models/deepseek-v4-flash", "accounts/fireworks/models/deepseek-v4-pro", "accounts/fireworks/models/glm-5p2", "accounts/fireworks/models/gpt-oss-120b", "accounts/fireworks/models/kimi-k2p6", "accounts/fireworks/models/kimi-k2p7-code", "accounts/fireworks/models/minimax-m3", "accounts/fireworks/models/qwen3p7-plus", "alibaba/qwen3.8-27b", "anthropic/claude-sonnet-4.6", "claude-fable-5", "claude-fable-5-1", "claude-haiku-4-5", "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-4.8", "claude-opus-5", "claude-opus-5-5", "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-sonnet-4.6", "claude-sonnet-5", "claude-sonnet-5-5", "deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro", "fugu", "fugu-ultra", "fugu-ultra-20260615", "gemini-3-flash-preview", "gemini-3.1-flash-lite", "gemini-3.1-pro-preview", "gemini-3.5-flash", "gemini-3.5-flash-lite", "gemini-3.6-flash", "gemini-3.7-flash", "gemini-3.8-flash", "gemma-4-26b-a4b-it", "gemma-4-31b", "gemma-4-31b-it", "glm-4.5", "glm-4.7", "glm-5", "glm-5-turbo", "glm-5.2", "glm-5.3", "glm-5.3-flash", "glm-5v-turbo", "gpt-5-codex", "gpt-5.2", "gpt-5.3-codex-spark", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-pro", "gpt-5.5", "gpt-5.6", "gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-6-astra", "gpt-6-luna", "gpt-6-sol", "gpt-oss-120b", "grok-4.3", "grok-4.6", "grok-4.7", "grok-build", "k3", "kilo-auto/small", "kimi-for-coding", "kimi-for-coding-highspeed", "kimi-k2.6", "kimi-k2.7-code", "kimi-k3", "kimi-latest", "lmstudio", "mimo-v2-flash", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2.5-pro-ultraspeed", "mimo-v2.6-flash", "mimo-v2.6-pro", "mimo-v2.6-pro-ultraspeed", "minimax-m3", "mistral-medium-latest", "mlx-community/Qwen3.6-27B-OptiQ-4bit", "muse-spark-1.2", "muse-spark-1.2-contributor", "openai/gpt-oss-120b"];
export const TOOLS: ToolName[] = ["shell", "read_file", "edit_file", "write_file", "webfetch", "skill", "codedb", "read_tool_result", "render_html", "todo_write", "todo_read", "eval", "note_constraint", "ask_user", "attempt_completion", "load_tool_schemas", "mcp_search_tools", "mcp_select_tool", "clock_sleep", "subagent", "workflow", "agent_output", "agent_message", "subagent_resume", "learn_candidate", "peer_message", "workspace", "imagegen", "rlm"];
diff --git a/sdk/py/harness_sdk.py b/sdk/py/harness_sdk.py
index a697ab78..e66425df 100644
--- a/sdk/py/harness_sdk.py
+++ b/sdk/py/harness_sdk.py
@@ -13,7 +13,7 @@ import urllib.error
import urllib.request
from typing import Iterator, List, Literal, Optional, TypedDict, Union
-MODELS = ["MiniMax-M2.5", "MiniMax-M2.7", "MiniMax-M3", "accounts/fireworks/models/deepseek-v4-flash", "accounts/fireworks/models/deepseek-v4-pro", "accounts/fireworks/models/glm-5p2", "accounts/fireworks/models/gpt-oss-120b", "accounts/fireworks/models/kimi-k2p6", "accounts/fireworks/models/kimi-k2p7-code", "accounts/fireworks/models/minimax-m3", "accounts/fireworks/models/qwen3p7-plus", "alibaba/qwen3.8-27b", "anthropic/claude-sonnet-4.6", "claude-fable-5", "claude-haiku-4-5", "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-4.8", "claude-opus-5", "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-sonnet-4.6", "claude-sonnet-5", "deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro", "fugu", "fugu-ultra", "fugu-ultra-20260615", "gemini-3-flash-preview", "gemini-3.1-flash-lite", "gemini-3.1-pro-preview", "gemini-3.5-flash", "gemini-3.5-flash-lite", "gemini-3.6-flash", "gemini-3.7-flash", "gemini-3.8-flash", "gemma-4-26b-a4b-it", "gemma-4-31b", "gemma-4-31b-it", "glm-4.5", "glm-4.7", "glm-5", "glm-5-turbo", "glm-5.2", "glm-5.3", "glm-5.3-flash", "glm-5v-turbo", "gpt-5-codex", "gpt-5.2", "gpt-5.3-codex-spark", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-pro", "gpt-5.5", "gpt-5.6", "gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-6-astra", "gpt-6-luna", "gpt-6-sol", "gpt-oss-120b", "grok-4.3", "grok-4.6", "grok-4.7", "grok-build", "k3", "kilo-auto/small", "kimi-for-coding", "kimi-for-coding-highspeed", "kimi-k2.6", "kimi-k2.7-code", "kimi-k3", "kimi-latest", "lmstudio", "mimo-v2-flash", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2.5-pro-ultraspeed", "mimo-v2.6-flash", "mimo-v2.6-pro", "mimo-v2.6-pro-ultraspeed", "minimax-m3", "mistral-medium-latest", "mlx-community/Qwen3.6-27B-OptiQ-4bit", "muse-spark-1.2", "muse-spark-1.2-contributor", "openai/gpt-oss-120b"]
+MODELS = ["MiniMax-M2.5", "MiniMax-M2.7", "MiniMax-M3", "accounts/fireworks/models/deepseek-v4-flash", "accounts/fireworks/models/deepseek-v4-pro", "accounts/fireworks/models/glm-5p2", "accounts/fireworks/models/gpt-oss-120b", "accounts/fireworks/models/kimi-k2p6", "accounts/fireworks/models/kimi-k2p7-code", "accounts/fireworks/models/minimax-m3", "accounts/fireworks/models/qwen3p7-plus", "alibaba/qwen3.8-27b", "anthropic/claude-sonnet-4.6", "claude-fable-5", "claude-fable-5-1", "claude-haiku-4-5", "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-4.8", "claude-opus-5", "claude-opus-5-5", "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-sonnet-4.6", "claude-sonnet-5", "claude-sonnet-5-5", "deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro", "fugu", "fugu-ultra", "fugu-ultra-20260615", "gemini-3-flash-preview", "gemini-3.1-flash-lite", "gemini-3.1-pro-preview", "gemini-3.5-flash", "gemini-3.5-flash-lite", "gemini-3.6-flash", "gemini-3.7-flash", "gemini-3.8-flash", "gemma-4-26b-a4b-it", "gemma-4-31b", "gemma-4-31b-it", "glm-4.5", "glm-4.7", "glm-5", "glm-5-turbo", "glm-5.2", "glm-5.3", "glm-5.3-flash", "glm-5v-turbo", "gpt-5-codex", "gpt-5.2", "gpt-5.3-codex-spark", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-pro", "gpt-5.5", "gpt-5.6", "gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-6-astra", "gpt-6-luna", "gpt-6-sol", "gpt-oss-120b", "grok-4.3", "grok-4.6", "grok-4.7", "grok-build", "k3", "kilo-auto/small", "kimi-for-coding", "kimi-for-coding-highspeed", "kimi-k2.6", "kimi-k2.7-code", "kimi-k3", "kimi-latest", "lmstudio", "mimo-v2-flash", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2.5-pro-ultraspeed", "mimo-v2.6-flash", "mimo-v2.6-pro", "mimo-v2.6-pro-ultraspeed", "minimax-m3", "mistral-medium-latest", "mlx-community/Qwen3.6-27B-OptiQ-4bit", "muse-spark-1.2", "muse-spark-1.2-contributor", "openai/gpt-oss-120b"]
TOOLS = ["shell", "read_file", "edit_file", "write_file", "webfetch", "skill", "codedb", "read_tool_result", "render_html", "todo_write", "todo_read", "eval", "note_constraint", "ask_user", "attempt_completion", "load_tool_schemas", "mcp_search_tools", "mcp_select_tool", "clock_sleep", "subagent", "workflow", "agent_output", "agent_message", "subagent_resume", "learn_candidate", "peer_message", "workspace", "imagegen", "rlm"]
PROVIDERS = ["anthropic", "codegraff", "deepseek", "openai", "google", "minimax", "xiaomi", "kilo", "groq", "cerebras", "mistral", "kimi", "moonshot", "xai", "zai", "meta", "vercel", "openrouter", "fugu", "fireworks", "mlx", "lmstudio", "codex"]
diff --git a/sdk/ts/harness.ts b/sdk/ts/harness.ts
index 86f2ac23..124348a4 100644
--- a/sdk/ts/harness.ts
+++ b/sdk/ts/harness.ts
@@ -11,7 +11,7 @@ import type { Readable, Writable } from "node:stream";
export const HARNESS_VERSION = "0.13";
-export type ModelName = "MiniMax-M2.5" | "MiniMax-M2.7" | "MiniMax-M3" | "accounts/fireworks/models/deepseek-v4-flash" | "accounts/fireworks/models/deepseek-v4-pro" | "accounts/fireworks/models/glm-5p2" | "accounts/fireworks/models/gpt-oss-120b" | "accounts/fireworks/models/kimi-k2p6" | "accounts/fireworks/models/kimi-k2p7-code" | "accounts/fireworks/models/minimax-m3" | "accounts/fireworks/models/qwen3p7-plus" | "alibaba/qwen3.8-27b" | "anthropic/claude-sonnet-4.6" | "claude-fable-5" | "claude-haiku-4-5" | "claude-opus-4-5" | "claude-opus-4-6" | "claude-opus-4-7" | "claude-opus-4-8" | "claude-opus-4.8" | "claude-opus-5" | "claude-sonnet-4-5" | "claude-sonnet-4-6" | "claude-sonnet-4.6" | "claude-sonnet-5" | "deepseek-chat" | "deepseek-reasoner" | "deepseek-v4-flash" | "deepseek-v4-pro" | "fugu" | "fugu-ultra" | "fugu-ultra-20260615" | "gemini-3-flash-preview" | "gemini-3.1-flash-lite" | "gemini-3.1-pro-preview" | "gemini-3.5-flash" | "gemini-3.5-flash-lite" | "gemini-3.6-flash" | "gemini-3.7-flash" | "gemini-3.8-flash" | "gemma-4-26b-a4b-it" | "gemma-4-31b" | "gemma-4-31b-it" | "glm-4.5" | "glm-4.7" | "glm-5" | "glm-5-turbo" | "glm-5.2" | "glm-5.3" | "glm-5.3-flash" | "glm-5v-turbo" | "gpt-5-codex" | "gpt-5.2" | "gpt-5.3-codex-spark" | "gpt-5.4" | "gpt-5.4-mini" | "gpt-5.4-pro" | "gpt-5.5" | "gpt-5.6" | "gpt-5.6-luna" | "gpt-5.6-sol" | "gpt-5.6-terra" | "gpt-6-astra" | "gpt-6-luna" | "gpt-6-sol" | "gpt-oss-120b" | "grok-4.3" | "grok-4.6" | "grok-4.7" | "grok-build" | "k3" | "kilo-auto/small" | "kimi-for-coding" | "kimi-for-coding-highspeed" | "kimi-k2.6" | "kimi-k2.7-code" | "kimi-k3" | "kimi-latest" | "lmstudio" | "mimo-v2-flash" | "mimo-v2.5" | "mimo-v2.5-pro" | "mimo-v2.5-pro-ultraspeed" | "mimo-v2.6-flash" | "mimo-v2.6-pro" | "mimo-v2.6-pro-ultraspeed" | "minimax-m3" | "mistral-medium-latest" | "mlx-community/Qwen3.6-27B-OptiQ-4bit" | "muse-spark-1.2" | "muse-spark-1.2-contributor" | "openai/gpt-oss-120b" | (string & {});
+export type ModelName = "MiniMax-M2.5" | "MiniMax-M2.7" | "MiniMax-M3" | "accounts/fireworks/models/deepseek-v4-flash" | "accounts/fireworks/models/deepseek-v4-pro" | "accounts/fireworks/models/glm-5p2" | "accounts/fireworks/models/gpt-oss-120b" | "accounts/fireworks/models/kimi-k2p6" | "accounts/fireworks/models/kimi-k2p7-code" | "accounts/fireworks/models/minimax-m3" | "accounts/fireworks/models/qwen3p7-plus" | "alibaba/qwen3.8-27b" | "anthropic/claude-sonnet-4.6" | "claude-fable-5" | "claude-fable-5-1" | "claude-haiku-4-5" | "claude-opus-4-5" | "claude-opus-4-6" | "claude-opus-4-7" | "claude-opus-4-8" | "claude-opus-4.8" | "claude-opus-5" | "claude-opus-5-5" | "claude-sonnet-4-5" | "claude-sonnet-4-6" | "claude-sonnet-4.6" | "claude-sonnet-5" | "claude-sonnet-5-5" | "deepseek-chat" | "deepseek-reasoner" | "deepseek-v4-flash" | "deepseek-v4-pro" | "fugu" | "fugu-ultra" | "fugu-ultra-20260615" | "gemini-3-flash-preview" | "gemini-3.1-flash-lite" | "gemini-3.1-pro-preview" | "gemini-3.5-flash" | "gemini-3.5-flash-lite" | "gemini-3.6-flash" | "gemini-3.7-flash" | "gemini-3.8-flash" | "gemma-4-26b-a4b-it" | "gemma-4-31b" | "gemma-4-31b-it" | "glm-4.5" | "glm-4.7" | "glm-5" | "glm-5-turbo" | "glm-5.2" | "glm-5.3" | "glm-5.3-flash" | "glm-5v-turbo" | "gpt-5-codex" | "gpt-5.2" | "gpt-5.3-codex-spark" | "gpt-5.4" | "gpt-5.4-mini" | "gpt-5.4-pro" | "gpt-5.5" | "gpt-5.6" | "gpt-5.6-luna" | "gpt-5.6-sol" | "gpt-5.6-terra" | "gpt-6-astra" | "gpt-6-luna" | "gpt-6-sol" | "gpt-oss-120b" | "grok-4.3" | "grok-4.6" | "grok-4.7" | "grok-build" | "k3" | "kilo-auto/small" | "kimi-for-coding" | "kimi-for-coding-highspeed" | "kimi-k2.6" | "kimi-k2.7-code" | "kimi-k3" | "kimi-latest" | "lmstudio" | "mimo-v2-flash" | "mimo-v2.5" | "mimo-v2.5-pro" | "mimo-v2.5-pro-ultraspeed" | "mimo-v2.6-flash" | "mimo-v2.6-pro" | "mimo-v2.6-pro-ultraspeed" | "minimax-m3" | "mistral-medium-latest" | "mlx-community/Qwen3.6-27B-OptiQ-4bit" | "muse-spark-1.2" | "muse-spark-1.2-contributor" | "openai/gpt-oss-120b" | (string & {});
export type ToolName = "shell" | "read_file" | "edit_file" | "write_file" | "webfetch" | "skill" | "codedb" | "read_tool_result" | "render_html" | "todo_write" | "todo_read" | "eval" | "note_constraint" | "ask_user" | "attempt_completion" | "load_tool_schemas" | "mcp_search_tools" | "mcp_select_tool" | "clock_sleep" | "subagent" | "workflow" | "agent_output" | "agent_message" | "subagent_resume" | "learn_candidate" | "peer_message" | "workspace" | "imagegen" | "rlm";
export type ProviderId = "anthropic" | "codegraff" | "deepseek" | "openai" | "google" | "minimax" | "xiaomi" | "kilo" | "groq" | "cerebras" | "mistral" | "kimi" | "moonshot" | "xai" | "zai" | "meta" | "vercel" | "openrouter" | "fugu" | "fireworks" | "mlx" | "lmstudio" | "codex";
@@ -681,5 +681,5 @@ export async function* runAgent(opts: RunAgentOptions): AsyncGenerator<Event> {
}
}
-export const MODELS: ModelName[] = ["MiniMax-M2.5", "MiniMax-M2.7", "MiniMax-M3", "accounts/fireworks/models/deepseek-v4-flash", "accounts/fireworks/models/deepseek-v4-pro", "accounts/fireworks/models/glm-5p2", "accounts/fireworks/models/gpt-oss-120b", "accounts/fireworks/models/kimi-k2p6", "accounts/fireworks/models/kimi-k2p7-code", "accounts/fireworks/models/minimax-m3", "accounts/fireworks/models/qwen3p7-plus", "alibaba/qwen3.8-27b", "anthropic/claude-sonnet-4.6", "claude-fable-5", "claude-haiku-4-5", "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-4.8", "claude-opus-5", "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-sonnet-4.6", "claude-sonnet-5", "deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro", "fugu", "fugu-ultra", "fugu-ultra-20260615", "gemini-3-flash-preview", "gemini-3.1-flash-lite", "gemini-3.1-pro-preview", "gemini-3.5-flash", "gemini-3.5-flash-lite", "gemini-3.6-flash", "gemini-3.7-flash", "gemini-3.8-flash", "gemma-4-26b-a4b-it", "gemma-4-31b", "gemma-4-31b-it", "glm-4.5", "glm-4.7", "glm-5", "glm-5-turbo", "glm-5.2", "glm-5.3", "glm-5.3-flash", "glm-5v-turbo", "gpt-5-codex", "gpt-5.2", "gpt-5.3-codex-spark", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-pro", "gpt-5.5", "gpt-5.6", "gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-6-astra", "gpt-6-luna", "gpt-6-sol", "gpt-oss-120b", "grok-4.3", "grok-4.6", "grok-4.7", "grok-build", "k3", "kilo-auto/small", "kimi-for-coding", "kimi-for-coding-highspeed", "kimi-k2.6", "kimi-k2.7-code", "kimi-k3", "kimi-latest", "lmstudio", "mimo-v2-flash", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2.5-pro-ultraspeed", "mimo-v2.6-flash", "mimo-v2.6-pro", "mimo-v2.6-pro-ultraspeed", "minimax-m3", "mistral-medium-latest", "mlx-community/Qwen3.6-27B-OptiQ-4bit", "muse-spark-1.2", "muse-spark-1.2-contributor", "openai/gpt-oss-120b"];
+export const MODELS: ModelName[] = ["MiniMax-M2.5", "MiniMax-M2.7", "MiniMax-M3", "accounts/fireworks/models/deepseek-v4-flash", "accounts/fireworks/models/deepseek-v4-pro", "accounts/fireworks/models/glm-5p2", "accounts/fireworks/models/gpt-oss-120b", "accounts/fireworks/models/kimi-k2p6", "accounts/fireworks/models/kimi-k2p7-code", "accounts/fireworks/models/minimax-m3", "accounts/fireworks/models/qwen3p7-plus", "alibaba/qwen3.8-27b", "anthropic/claude-sonnet-4.6", "claude-fable-5", "claude-fable-5-1", "claude-haiku-4-5", "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-4.8", "claude-opus-5", "claude-opus-5-5", "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-sonnet-4.6", "claude-sonnet-5", "claude-sonnet-5-5", "deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro", "fugu", "fugu-ultra", "fugu-ultra-20260615", "gemini-3-flash-preview", "gemini-3.1-flash-lite", "gemini-3.1-pro-preview", "gemini-3.5-flash", "gemini-3.5-flash-lite", "gemini-3.6-flash", "gemini-3.7-flash", "gemini-3.8-flash", "gemma-4-26b-a4b-it", "gemma-4-31b", "gemma-4-31b-it", "glm-4.5", "glm-4.7", "glm-5", "glm-5-turbo", "glm-5.2", "glm-5.3", "glm-5.3-flash", "glm-5v-turbo", "gpt-5-codex", "gpt-5.2", "gpt-5.3-codex-spark", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-pro", "gpt-5.5", "gpt-5.6", "gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-6-astra", "gpt-6-luna", "gpt-6-sol", "gpt-oss-120b", "grok-4.3", "grok-4.6", "grok-4.7", "grok-build", "k3", "kilo-auto/small", "kimi-for-coding", "kimi-for-coding-highspeed", "kimi-k2.6", "kimi-k2.7-code", "kimi-k3", "kimi-latest", "lmstudio", "mimo-v2-flash", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2.5-pro-ultraspeed", "mimo-v2.6-flash", "mimo-v2.6-pro", "mimo-v2.6-pro-ultraspeed", "minimax-m3", "mistral-medium-latest", "mlx-community/Qwen3.6-27B-OptiQ-4bit", "muse-spark-1.2", "muse-spark-1.2-contributor", "openai/gpt-oss-120b"];
export const TOOLS: ToolName[] = ["shell", "read_file", "edit_file", "write_file", "webfetch", "skill", "codedb", "read_tool_result", "render_html", "todo_write", "todo_read", "eval", "note_constraint", "ask_user", "attempt_completion", "load_tool_schemas", "mcp_search_tools", "mcp_select_tool", "clock_sleep", "subagent", "workflow", "agent_output", "agent_message", "subagent_resume", "learn_candidate", "peer_message", "workspace", "imagegen", "rlm"];
diff --git a/sdk/ts/remote.ts b/sdk/ts/remote.ts
index c8ee80cd..3dea40a0 100644
--- a/sdk/ts/remote.ts
+++ b/sdk/ts/remote.ts
@@ -9,7 +9,7 @@
export const HARNESS_VERSION = "0.13";
-export type ModelName = "MiniMax-M2.5" | "MiniMax-M2.7" | "MiniMax-M3" | "accounts/fireworks/models/deepseek-v4-flash" | "accounts/fireworks/models/deepseek-v4-pro" | "accounts/fireworks/models/glm-5p2" | "accounts/fireworks/models/gpt-oss-120b" | "accounts/fireworks/models/kimi-k2p6" | "accounts/fireworks/models/kimi-k2p7-code" | "accounts/fireworks/models/minimax-m3" | "accounts/fireworks/models/qwen3p7-plus" | "alibaba/qwen3.8-27b" | "anthropic/claude-sonnet-4.6" | "claude-fable-5" | "claude-haiku-4-5" | "claude-opus-4-5" | "claude-opus-4-6" | "claude-opus-4-7" | "claude-opus-4-8" | "claude-opus-4.8" | "claude-opus-5" | "claude-sonnet-4-5" | "claude-sonnet-4-6" | "claude-sonnet-4.6" | "claude-sonnet-5" | "deepseek-chat" | "deepseek-reasoner" | "deepseek-v4-flash" | "deepseek-v4-pro" | "fugu" | "fugu-ultra" | "fugu-ultra-20260615" | "gemini-3-flash-preview" | "gemini-3.1-flash-lite" | "gemini-3.1-pro-preview" | "gemini-3.5-flash" | "gemini-3.5-flash-lite" | "gemini-3.6-flash" | "gemini-3.7-flash" | "gemini-3.8-flash" | "gemma-4-26b-a4b-it" | "gemma-4-31b" | "gemma-4-31b-it" | "glm-4.5" | "glm-4.7" | "glm-5" | "glm-5-turbo" | "glm-5.2" | "glm-5.3" | "glm-5.3-flash" | "glm-5v-turbo" | "gpt-5-codex" | "gpt-5.2" | "gpt-5.3-codex-spark" | "gpt-5.4" | "gpt-5.4-mini" | "gpt-5.4-pro" | "gpt-5.5" | "gpt-5.6" | "gpt-5.6-luna" | "gpt-5.6-sol" | "gpt-5.6-terra" | "gpt-6-astra" | "gpt-6-luna" | "gpt-6-sol" | "gpt-oss-120b" | "grok-4.3" | "grok-4.6" | "grok-4.7" | "grok-build" | "k3" | "kilo-auto/small" | "kimi-for-coding" | "kimi-for-coding-highspeed" | "kimi-k2.6" | "kimi-k2.7-code" | "kimi-k3" | "kimi-latest" | "lmstudio" | "mimo-v2-flash" | "mimo-v2.5" | "mimo-v2.5-pro" | "mimo-v2.5-pro-ultraspeed" | "mimo-v2.6-flash" | "mimo-v2.6-pro" | "mimo-v2.6-pro-ultraspeed" | "minimax-m3" | "mistral-medium-latest" | "mlx-community/Qwen3.6-27B-OptiQ-4bit" | "muse-spark-1.2" | "muse-spark-1.2-contributor" | "openai/gpt-oss-120b" | (string & {});
+export type ModelName = "MiniMax-M2.5" | "MiniMax-M2.7" | "MiniMax-M3" | "accounts/fireworks/models/deepseek-v4-flash" | "accounts/fireworks/models/deepseek-v4-pro" | "accounts/fireworks/models/glm-5p2" | "accounts/fireworks/models/gpt-oss-120b" | "accounts/fireworks/models/kimi-k2p6" | "accounts/fireworks/models/kimi-k2p7-code" | "accounts/fireworks/models/minimax-m3" | "accounts/fireworks/models/qwen3p7-plus" | "alibaba/qwen3.8-27b" | "anthropic/claude-sonnet-4.6" | "claude-fable-5" | "claude-fable-5-1" | "claude-haiku-4-5" | "claude-opus-4-5" | "claude-opus-4-6" | "claude-opus-4-7" | "claude-opus-4-8" | "claude-opus-4.8" | "claude-opus-5" | "claude-opus-5-5" | "claude-sonnet-4-5" | "claude-sonnet-4-6" | "claude-sonnet-4.6" | "claude-sonnet-5" | "claude-sonnet-5-5" | "deepseek-chat" | "deepseek-reasoner" | "deepseek-v4-flash" | "deepseek-v4-pro" | "fugu" | "fugu-ultra" | "fugu-ultra-20260615" | "gemini-3-flash-preview" | "gemini-3.1-flash-lite" | "gemini-3.1-pro-preview" | "gemini-3.5-flash" | "gemini-3.5-flash-lite" | "gemini-3.6-flash" | "gemini-3.7-flash" | "gemini-3.8-flash" | "gemma-4-26b-a4b-it" | "gemma-4-31b" | "gemma-4-31b-it" | "glm-4.5" | "glm-4.7" | "glm-5" | "glm-5-turbo" | "glm-5.2" | "glm-5.3" | "glm-5.3-flash" | "glm-5v-turbo" | "gpt-5-codex" | "gpt-5.2" | "gpt-5.3-codex-spark" | "gpt-5.4" | "gpt-5.4-mini" | "gpt-5.4-pro" | "gpt-5.5" | "gpt-5.6" | "gpt-5.6-luna" | "gpt-5.6-sol" | "gpt-5.6-terra" | "gpt-6-astra" | "gpt-6-luna" | "gpt-6-sol" | "gpt-oss-120b" | "grok-4.3" | "grok-4.6" | "grok-4.7" | "grok-build" | "k3" | "kilo-auto/small" | "kimi-for-coding" | "kimi-for-coding-highspeed" | "kimi-k2.6" | "kimi-k2.7-code" | "kimi-k3" | "kimi-latest" | "lmstudio" | "mimo-v2-flash" | "mimo-v2.5" | "mimo-v2.5-pro" | "mimo-v2.5-pro-ultraspeed" | "mimo-v2.6-flash" | "mimo-v2.6-pro" | "mimo-v2.6-pro-ultraspeed" | "minimax-m3" | "mistral-medium-latest" | "mlx-community/Qwen3.6-27B-OptiQ-4bit" | "muse-spark-1.2" | "muse-spark-1.2-contributor" | "openai/gpt-oss-120b" | (string & {});
export type ToolName = "shell" | "read_file" | "edit_file" | "write_file" | "webfetch" | "skill" | "codedb" | "read_tool_result" | "render_html" | "todo_write" | "todo_read" | "eval" | "note_constraint" | "ask_user" | "attempt_completion" | "load_tool_schemas" | "mcp_search_tools" | "mcp_select_tool" | "clock_sleep" | "subagent" | "workflow" | "agent_output" | "agent_message" | "subagent_resume" | "learn_candidate" | "peer_message" | "workspace" | "imagegen" | "rlm";
export type ProviderId = "anthropic" | "codegraff" | "deepseek" | "openai" | "google" | "minimax" | "xiaomi" | "kilo" | "groq" | "cerebras" | "mistral" | "kimi" | "moonshot" | "xai" | "zai" | "meta" | "vercel" | "openrouter" | "fugu" | "fireworks" | "mlx" | "lmstudio" | "codex";
@@ -528,5 +528,5 @@ export async function* runAgentRemote(opts: RunAgentRemoteOptions): AsyncGenerat
}
}
-export const MODELS: ModelName[] = ["MiniMax-M2.5", "MiniMax-M2.7", "MiniMax-M3", "accounts/fireworks/models/deepseek-v4-flash", "accounts/fireworks/models/deepseek-v4-pro", "accounts/fireworks/models/glm-5p2", "accounts/fireworks/models/gpt-oss-120b", "accounts/fireworks/models/kimi-k2p6", "accounts/fireworks/models/kimi-k2p7-code", "accounts/fireworks/models/minimax-m3", "accounts/fireworks/models/qwen3p7-plus", "alibaba/qwen3.8-27b", "anthropic/claude-sonnet-4.6", "claude-fable-5", "claude-haiku-4-5", "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-4.8", "claude-opus-5", "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-sonnet-4.6", "claude-sonnet-5", "deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro", "fugu", "fugu-ultra", "fugu-ultra-20260615", "gemini-3-flash-preview", "gemini-3.1-flash-lite", "gemini-3.1-pro-preview", "gemini-3.5-flash", "gemini-3.5-flash-lite", "gemini-3.6-flash", "gemini-3.7-flash", "gemini-3.8-flash", "gemma-4-26b-a4b-it", "gemma-4-31b", "gemma-4-31b-it", "glm-4.5", "glm-4.7", "glm-5", "glm-5-turbo", "glm-5.2", "glm-5.3", "glm-5.3-flash", "glm-5v-turbo", "gpt-5-codex", "gpt-5.2", "gpt-5.3-codex-spark", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-pro", "gpt-5.5", "gpt-5.6", "gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-6-astra", "gpt-6-luna", "gpt-6-sol", "gpt-oss-120b", "grok-4.3", "grok-4.6", "grok-4.7", "grok-build", "k3", "kilo-auto/small", "kimi-for-coding", "kimi-for-coding-highspeed", "kimi-k2.6", "kimi-k2.7-code", "kimi-k3", "kimi-latest", "lmstudio", "mimo-v2-flash", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2.5-pro-ultraspeed", "mimo-v2.6-flash", "mimo-v2.6-pro", "mimo-v2.6-pro-ultraspeed", "minimax-m3", "mistral-medium-latest", "mlx-community/Qwen3.6-27B-OptiQ-4bit", "muse-spark-1.2", "muse-spark-1.2-contributor", "openai/gpt-oss-120b"];
+export const MODELS: ModelName[] = ["MiniMax-M2.5", "MiniMax-M2.7", "MiniMax-M3", "accounts/fireworks/models/deepseek-v4-flash", "accounts/fireworks/models/deepseek-v4-pro", "accounts/fireworks/models/glm-5p2", "accounts/fireworks/models/gpt-oss-120b", "accounts/fireworks/models/kimi-k2p6", "accounts/fireworks/models/kimi-k2p7-code", "accounts/fireworks/models/minimax-m3", "accounts/fireworks/models/qwen3p7-plus", "alibaba/qwen3.8-27b", "anthropic/claude-sonnet-4.6", "claude-fable-5", "claude-fable-5-1", "claude-haiku-4-5", "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-4.8", "claude-opus-5", "claude-opus-5-5", "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-sonnet-4.6", "claude-sonnet-5", "claude-sonnet-5-5", "deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro", "fugu", "fugu-ultra", "fugu-ultra-20260615", "gemini-3-flash-preview", "gemini-3.1-flash-lite", "gemini-3.1-pro-preview", "gemini-3.5-flash", "gemini-3.5-flash-lite", "gemini-3.6-flash", "gemini-3.7-flash", "gemini-3.8-flash", "gemma-4-26b-a4b-it", "gemma-4-31b", "gemma-4-31b-it", "glm-4.5", "glm-4.7", "glm-5", "glm-5-turbo", "glm-5.2", "glm-5.3", "glm-5.3-flash", "glm-5v-turbo", "gpt-5-codex", "gpt-5.2", "gpt-5.3-codex-spark", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-pro", "gpt-5.5", "gpt-5.6", "gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-6-astra", "gpt-6-luna", "gpt-6-sol", "gpt-oss-120b", "grok-4.3", "grok-4.6", "grok-4.7", "grok-build", "k3", "kilo-auto/small", "kimi-for-coding", "kimi-for-coding-highspeed", "kimi-k2.6", "kimi-k2.7-code", "kimi-k3", "kimi-latest", "lmstudio", "mimo-v2-flash", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2.5-pro-ultraspeed", "mimo-v2.6-flash", "mimo-v2.6-pro", "mimo-v2.6-pro-ultraspeed", "minimax-m3", "mistral-medium-latest", "mlx-community/Qwen3.6-27B-OptiQ-4bit", "muse-spark-1.2", "muse-spark-1.2-contributor", "openai/gpt-oss-120b"];
export const TOOLS: ToolName[] = ["shell", "read_file", "edit_file", "write_file", "webfetch", "skill", "codedb", "read_tool_result", "render_html", "todo_write", "todo_read", "eval", "note_constraint", "ask_user", "attempt_completion", "load_tool_schemas", "mcp_search_tools", "mcp_select_tool", "clock_sleep", "subagent", "workflow", "agent_output", "agent_message", "subagent_resume", "learn_candidate", "peer_message", "workspace", "imagegen", "rlm"];
diff --git a/src/agent_request.zig b/src/agent_request.zig
index b054e003..f51af1e0 100644
--- a/src/agent_request.zig
+++ b/src/agent_request.zig
@@ -20,7 +20,6 @@ const RetryPlan = http.RetryPlan;
const tools_mod = @import("tools.zig");
const apiErrorMessage = tools_mod.apiErrorMessage;
-const mentionsReasoningEffort = tools_mod.mentionsReasoningEffort;
const telemetry = @import("telemetry.zig");
const tool_spill = @import("tool_spill.zig"); // #409: did the cap preserve the bytes, or destroy them?
const run_budget_mod = @import("run_budget.zig");
@@ -483,6 +482,7 @@ pub fn request(self: *Agent, tools_in: ?[]const u8) !std.json.ObjectMap {
const emsg = if (eo) |e| (if (e.get("message")) |mv| (if (mv == .string) mv.string else "") else "") else "";
const ecode = if (eo) |e| (if (e.get("code")) |cv| (if (cv == .string) cv.string else null) else null) else null;
if (recoverContextOverflow(self, emsg, ecode, &context_retried)) continue; // #193/#203: streamed error event overflow (by code or phrasing) → trim + retry
+ if (policy.retryWithout(self, emsg, &force, &stream_usage)) continue; // ADR 0219: Anthropic errors take the ladder too
if (try policy.afterServerErrorOrParseReject(self, etype, ecode, emsg, &server_retries, &gw_retry)) continue;
if (self.tracer) |tr| tr.api(self.label, self.sub, self.provider.model, ms, body.len, resp_body.len, 0, 0, true);
try sayTypedApiError(self, etype, ecode, emsg, errorRequestId(root));
@@ -532,39 +532,14 @@ pub fn request(self: *Agent, tools_in: ?[]const u8) !std.json.ObjectMap {
const emsg = if (eo) |e| (if (e.get("message")) |mv| (if (mv == .string) mv.string else "") else "") else "";
const ecode = if (eo) |e| (if (e.get("code")) |cv| (if (cv == .string) cv.string else null) else null) else null;
if (recoverContextOverflow(self, emsg, ecode, &context_retried)) continue; // #193/#203: {"type":"error"} overflow (by code or phrasing) → trim + retry
+ if (policy.retryWithout(self, emsg, &force, &stream_usage)) continue; // ADR 0219: Anthropic errors take the ladder too
if (try policy.afterServerErrorOrParseReject(self, etype, ecode, emsg, &server_retries, &gw_retry)) continue;
if (self.tracer) |tr| tr.api(self.label, self.sub, self.provider.model, ms, body.len, resp_body.len, 0, 0, true);
try sayTypedApiError(self, etype, ecode, emsg, errorRequestId(root));
return error.ApiError;
};
if (apiErrorMessage(root)) |msg| {
- if (force and std.mem.indexOf(u8, msg, "tool_choice") != null) {
- force = false; // provider can't force a tool; soft-strict
- continue;
- }
- if (stream_usage and std.mem.indexOf(u8, msg, "stream_options") != null) {
- stream_usage = false; // provider can't report streamed usage
- continue;
- }
- if (!self.cap_new and std.mem.indexOf(u8, msg, "max_completion_tokens") != null) {
- self.cap_new = true; // provider wants the post-deprecation name
- continue;
- }
- // #543: a provider without json_schema structured outputs (deepseek:
- // "This response_format type is unavailable now") must not lose the
- // --output-schema contract — retry in json_object mode with the
- // schema moved into the prompt, on the same ladder as cap_new.
- if (self.output_schema != null and !self.sox_json_object and
- (std.mem.indexOf(u8, msg, "response_format") != null or
- std.mem.indexOf(u8, msg, "output_config") != null))
- {
- self.sox_json_object = true;
- continue;
- }
- if (!self.effort_rejected and mentionsReasoningEffort(msg)) {
- self.effort_rejected = true; // model rejects the effort hint here; drop + retry
- continue;
- }
+ if (policy.retryWithout(self, msg, &force, &stream_usage)) continue;
// #148: a stale login token 401s here with the provider's "API Key
// invalid/expired"; adopt a newer on-disk token or force a refresh
// and retry once (kimi-code's buildAuth(true)). Give up only if the
diff --git a/src/agent_request_body.zig b/src/agent_request_body.zig
index d49f816a..08b9a253 100644
--- a/src/agent_request_body.zig
+++ b/src/agent_request_body.zig
@@ -34,16 +34,21 @@ pub fn buildBody(self: *Agent, tools_in: ?[]const u8, force_tool: bool, stream:
switch (self.provider.kind) {
.anthropic => {
const is_kimi = std.mem.eql(u8, self.provider.id, "kimi");
+ const is_claude = std.mem.eql(u8, self.provider.id, "anthropic");
+ const claude = @import("claude_wire.zig"); // ADR 0219
try s.objectField("max_tokens");
- try s.write(max_tokens);
+ try s.write(if (is_claude) claude.maxTokens(self.provider.model, self.reasoning, max_tokens) else max_tokens);
if (stream) {
try s.objectField("stream");
try s.write(true);
}
+ // A 5.5-era Claude model 400s on forced tool use: it runs auto
+ // (soft-strict) and keeps its thinking.
+ const force = force_tool and !(is_claude and claude.rejectsForcedTools(self.provider.model));
// Kimi's catalog-declared Anthropic transport uses enabled
// thinking plus output_config.effort; Claude uses adaptive.
// Forced tool_choice conflicts with thinking, so skip it then.
- if (!force_tool) {
+ if (!force) {
if (is_kimi) {
if (pricing.kimiSupportsThinking(self.provider.model)) {
try s.objectField("thinking");
@@ -63,8 +68,8 @@ pub fn buildBody(self: *Agent, tools_in: ?[]const u8, force_tool: bool, stream:
// panel then shows nothing. Ask for the summary. Only the real
// Anthropic API knows the field; the other anthropic-format providers
// (minimax) must never see it.
- const thinking_obj: []const u8 = if (std.mem.eql(u8, self.provider.id, "anthropic"))
- "{\"type\":\"adaptive\",\"display\":\"summarized\"}"
+ const thinking_obj: []const u8 = if (is_claude)
+ claude.thinkingObject(self.provider.model)
else
"{\"type\":\"adaptive\"}";
try s.objectField("thinking");
@@ -91,16 +96,24 @@ pub fn buildBody(self: *Agent, tools_in: ?[]const u8, force_tool: bool, stream:
} else {
try s.write(sys);
}
+ // Effort rides output_config, in one object with a structured-output
+ // format when there is one.
+ const effort: ?[]const u8 = if (is_claude and !self.effort_rejected and claude.takesEffort(self.provider.model)) claude.effortWire(self.reasoning) else null;
+ var effort_written = false;
if (tools) |t| {
try s.objectField("tools");
try writeAnthropicTools(&s, self.scratchAlloc(), t, is_kimi);
- if (force_tool) {
+ if (force) {
try s.objectField("tool_choice");
try s.print("{s}", .{"{\"type\":\"any\"}"});
}
} else if (self.output_schema) |schema_json| {
- try @import("agent_request_body_responses.zig").writeAnthropicSchema(&s, self, schema_json);
+ effort_written = try @import("agent_request_body_responses.zig").writeAnthropicSchema(&s, self, schema_json, effort);
}
+ if (effort) |e| if (!effort_written) {
+ try s.objectField("output_config");
+ try s.print("{{\"effort\":\"{s}\"}}", .{e});
+ };
try s.objectField("messages");
// Cache the conversation prefix too (not just system) on the real
// Anthropic API and Kimi's declared Anthropic transport. Kimi also
@@ -338,74 +351,6 @@ test "retained reasoning: openai-chat history replays reasoning_content on the n
try std.testing.expect(std.mem.indexOf(u8, body, "\"tool_calls\"") != null);
}
-test "retained reasoning: anthropic replays thinking+signature inside a multi-step tool turn" {
- var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);
- defer arena_state.deinit();
- const arena = arena_state.allocator();
-
- var messages = std.json.Array.init(arena);
- try messages.append(try testUserMessage(arena, "fix the build"));
-
- // Assistant turn: thinking block (with its signature) followed by tool_use.
- // Anthropic requires the thinking block to be replayed unchanged, in place,
- // when the turn that produced it contained a tool call — editing or dropping
- // it is a signature/ordering 400.
- var thinking_block: std.json.ObjectMap = .empty;
- try thinking_block.put(arena, "type", .{ .string = "thinking" });
- try thinking_block.put(arena, "thinking", .{ .string = "the linker flag is wrong" });
- try thinking_block.put(arena, "signature", .{ .string = "sigabc" });
- var use_block: std.json.ObjectMap = .empty;
- try use_block.put(arena, "type", .{ .string = "tool_use" });
- try use_block.put(arena, "id", .{ .string = "tu_1" });
- try use_block.put(arena, "name", .{ .string = "bash" });
- try use_block.put(arena, "input", .{ .object = .empty });
- var assistant_blocks = std.json.Array.init(arena);
- try assistant_blocks.append(.{ .object = thinking_block });
- try assistant_blocks.append(.{ .object = use_block });
- var assistant: std.json.ObjectMap = .empty;
- try assistant.put(arena, "role", .{ .string = "assistant" });
- try assistant.put(arena, "content", .{ .array = assistant_blocks });
- try messages.append(.{ .object = assistant });
-
- var result_block: std.json.ObjectMap = .empty;
- try result_block.put(arena, "type", .{ .string = "tool_result" });
- try result_block.put(arena, "tool_use_id", .{ .string = "tu_1" });
- try result_block.put(arena, "content", .{ .string = "ok" });
- var result_blocks = std.json.Array.init(arena);
- try result_blocks.append(.{ .object = result_block });
- var result_msg: std.json.ObjectMap = .empty;
- try result_msg.put(arena, "role", .{ .string = "user" });
- try result_msg.put(arena, "content", .{ .array = result_blocks });
- try messages.append(.{ .object = result_msg });
-
- var agent: Agent = .{
- .gpa = std.testing.allocator,
- .arena = arena,
- .io = std.testing.io,
- .client = undefined,
- .provider = .{ .id = "anthropic", .kind = .anthropic, .auth = .x_api_key, .url = "", .api_key = "k", .model = "claude", .context = 1_000_000 },
- .messages = messages,
- .sub = false,
- .label = "",
- .out = null,
- .sys_normal = "system",
- };
- const tools = "[{\"name\":\"bash\",\"description\":\"\",\"input_schema\":{\"type\":\"object\"}}]";
- const body = try agent.buildBody(tools, false, true, true);
- defer std.testing.allocator.free(body);
-
- // Adaptive thinking is what enables interleaved reasoning between tool
- // calls; it needs no beta header on current models. It also opts into a
- // summarized display, since current Claude models default to an empty one.
- try std.testing.expect(std.mem.indexOf(u8, body, "\"thinking\":{\"type\":\"adaptive\",\"display\":\"summarized\"}") != null);
- // The whole block, signature included, survives the cache-breakpoint rewrite.
- try std.testing.expect(std.mem.indexOf(u8, body, "{\"type\":\"thinking\",\"thinking\":\"the linker flag is wrong\",\"signature\":\"sigabc\"}") != null);
- // A cache breakpoint belongs on the trailing tool_result, never on a
- // thinking block (cache_control is not a valid field there).
- try std.testing.expect(std.mem.indexOf(u8, body, "\"signature\":\"sigabc\",\"cache_control\"") == null);
- try std.testing.expect(std.mem.indexOf(u8, body, "\"content\":\"ok\",\"cache_control\":{\"type\":\"ephemeral\"}") != null);
-}
-
test "retained reasoning: codex full resend keeps encrypted reasoning items and requests them" {
var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);
defer arena_state.deinit();
@@ -463,52 +408,6 @@ test "retained reasoning: codex full resend keeps encrypted reasoning items and
try std.testing.expect(std.mem.indexOf(u8, body, key) != null);
}
-test "anthropic asks for summarized thinking; other anthropic-format providers do not" {
- var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);
- defer arena_state.deinit();
- const arena = arena_state.allocator();
-
- var messages = std.json.Array.init(arena);
- try messages.append(try testUserMessage(arena, "hello"));
-
- var agent: Agent = .{
- .gpa = std.testing.allocator,
- .arena = arena,
- .io = std.testing.io,
- .client = undefined,
- .provider = .{ .id = "anthropic", .kind = .anthropic, .auth = .x_api_key, .url = "", .api_key = "k", .model = "claude", .context = 1_000_000 },
- .messages = messages,
- .sub = false,
- .label = "",
- .out = null,
- .sys_normal = "system",
- };
- const tools = "[{\"name\":\"bash\",\"description\":\"\",\"input_schema\":{\"type\":\"object\"}}]";
-
- // a. Real Anthropic, thinking allowed: adaptive thinking opts into a
- // summarized display, since current Claude models default to empty.
- const body_a = try agent.buildBody(tools, false, true, true);
- defer std.testing.allocator.free(body_a);
- try std.testing.expect(std.mem.indexOf(u8, body_a, "\"thinking\":{\"type\":\"adaptive\",\"display\":\"summarized\"}") != null);
-
- // b. Forced tool_choice still suppresses the whole thinking object, exactly
- // as before this change.
- const body_b = try agent.buildBody(tools, true, true, true);
- defer std.testing.allocator.free(body_b);
- try std.testing.expect(std.mem.indexOf(u8, body_b, "\"thinking\"") == null);
- try std.testing.expect(std.mem.indexOf(u8, body_b, "\"tool_choice\":{\"type\":\"any\"}") != null);
-
- // c. Other anthropic-format providers (minimax) reject unknown fields, so
- // they must never see "display" — only the bare adaptive object.
- agent.provider.id = "minimax";
- agent.provider.model = "MiniMax-M3";
- const body_c = try agent.buildBody(tools, false, true, true);
- defer std.testing.allocator.free(body_c);
- try std.testing.expect(std.mem.indexOf(u8, body_c, "\"thinking\":{\"type\":\"adaptive\"}") != null);
- try std.testing.expect(std.mem.indexOf(u8, body_c, "\"display\"") == null);
- try std.testing.expect(std.mem.indexOf(u8, body_c, "\"keep\"") == null); // #323: thinking.keep is Kimi-only
-}
-
test "kimi k2.6 opts into thinking.keep so replayed reasoning is used, not just billed" {
var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);
defer arena_state.deinit();
@@ -597,3 +496,7 @@ test "openai-wire bodies send a sticky prompt_cache_key; children isolate" {
defer std.testing.allocator.free(ob);
try std.testing.expect(std.mem.indexOf(u8, ob, needle) != null);
}
+
+test { // Claude request-shape tests (ADR 0219) live beside this file
+ _ = @import("agent_request_body_claude_tests.zig");
+}
diff --git a/src/agent_request_body_claude_tests.zig b/src/agent_request_body_claude_tests.zig
new file mode 100644
index 00000000..1ba5447c
--- /dev/null
+++ b/src/agent_request_body_claude_tests.zig
@@ -0,0 +1,235 @@
+//! Claude request shapes (ADR 0219), split out of agent_request_body.zig
+//! (600-line cap). The unversioned model id `claude` keeps the pre-5.5
+//! shape; versioned 5.5-era ids get the new contract.
+
+const std = @import("std");
+const Value = std.json.Value;
+const Agent = @import("agent.zig").Agent;
+
+fn testUserMessage(arena: std.mem.Allocator, text: []const u8) !Value {
+ var m: std.json.ObjectMap = .empty;
+ try m.put(arena, "role", .{ .string = "user" });
+ try m.put(arena, "content", .{ .string = text });
+ return .{ .object = m };
+}
+
+fn claudeAgent(arena: std.mem.Allocator, model: []const u8) !Agent {
+ var messages = std.json.Array.init(arena);
+ try messages.append(try testUserMessage(arena, "hello"));
+ return .{
+ .gpa = std.testing.allocator,
+ .arena = arena,
+ .io = std.testing.io,
+ .client = undefined,
+ .provider = .{ .id = "anthropic", .kind = .anthropic, .auth = .x_api_key, .url = "", .api_key = "k", .model = model, .context = 1_000_000 },
+ .messages = messages,
+ .sub = false,
+ .label = "",
+ .out = null,
+ .sys_normal = "system",
+ };
+}
+
+const bash_tools = "[{\"name\":\"bash\",\"description\":\"\",\"input_schema\":{\"type\":\"object\"}}]";
+
+fn has(body: []const u8, needle: []const u8) bool {
+ return std.mem.indexOf(u8, body, needle) != null;
+}
+
+test "a 5.5-era Claude model is never forced to a tool; it keeps and binds its thinking" {
+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer arena_state.deinit();
+ var agent = try claudeAgent(arena_state.allocator(), "claude-opus-5-5");
+ // --strict / --eval / a named-work nudge ask for a forced tool call.
+ const body = try agent.buildBody(bash_tools, true, true, true);
+ defer std.testing.allocator.free(body);
+ try std.testing.expect(!has(body, "\"tool_choice\""));
+ try std.testing.expect(has(body, "\"thinking\":{\"type\":\"adaptive\",\"display\":\"summarized\",\"block_binding\":{\"prefix_mismatch_behavior\":\"drop_block\"}}"));
+ try std.testing.expect(has(body, "\"max_tokens\":64000"));
+}
+
+test "effort rides output_config on Claude, in one object with a structured-output format" {
+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer arena_state.deinit();
+ var agent = try claudeAgent(arena_state.allocator(), "claude-sonnet-5-5");
+
+ // graff's default leaves the model's own effort in place.
+ const plain = try agent.buildBody(bash_tools, false, true, true);
+ defer std.testing.allocator.free(plain);
+ try std.testing.expect(!has(plain, "\"output_config\""));
+
+ agent.reasoning = .high;
+ const high = try agent.buildBody(bash_tools, false, true, true);
+ defer std.testing.allocator.free(high);
+ try std.testing.expect(has(high, "\"output_config\":{\"effort\":\"high\"}"));
+
+ // A formatting turn carries effort and the schema together: two
+ // output_config keys would leave one of them unread.
+ agent.output_schema = "{\"type\":\"object\"}";
+ agent.reasoning = .max;
+ const shaped = try agent.buildBody(null, false, true, true);
+ defer std.testing.allocator.free(shaped);
+ try std.testing.expect(has(shaped, "\"output_config\":{\"effort\":\"max\",\"format\":{\"type\":\"json_schema\",\"schema\":{\"type\":\"object\"}}}"));
+ try std.testing.expectEqual(@as(usize, 1), std.mem.count(u8, shaped, "\"output_config\""));
+ try std.testing.expect(has(shaped, "\"max_tokens\":128000"));
+
+ // A model that rejected the effort hint does not get it again.
+ agent.effort_rejected = true;
+ agent.output_schema = null;
+ const rejected = try agent.buildBody(bash_tools, false, true, true);
+ defer std.testing.allocator.free(rejected);
+ try std.testing.expect(!has(rejected, "\"effort\""));
+}
+
+test "older Claude models keep forced tools, no binding, and graff's default budget" {
+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer arena_state.deinit();
+ var agent = try claudeAgent(arena_state.allocator(), "claude-opus-4-8");
+ const body = try agent.buildBody(bash_tools, true, true, true);
+ defer std.testing.allocator.free(body);
+ try std.testing.expect(has(body, "\"tool_choice\":{\"type\":\"any\"}"));
+ try std.testing.expect(!has(body, "block_binding"));
+ try std.testing.expect(has(body, "\"max_tokens\":16000"));
+ // Haiku takes no effort parameter at all.
+ agent.provider.model = "claude-haiku-4-5";
+ agent.reasoning = .high;
+ const haiku = try agent.buildBody(bash_tools, false, true, true);
+ defer std.testing.allocator.free(haiku);
+ try std.testing.expect(!has(haiku, "\"effort\""));
+}
+
+test "retained reasoning: anthropic replays thinking+signature inside a multi-step tool turn" {
+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer arena_state.deinit();
+ const arena = arena_state.allocator();
+
+ var messages = std.json.Array.init(arena);
+ try messages.append(try testUserMessage(arena, "fix the build"));
+
+ // Assistant turn: thinking block (with its signature) followed by tool_use.
+ // Anthropic requires the thinking block to be replayed unchanged, in place,
+ // when the turn that produced it contained a tool call — editing or dropping
+ // it is a signature/ordering 400.
+ var thinking_block: std.json.ObjectMap = .empty;
+ try thinking_block.put(arena, "type", .{ .string = "thinking" });
+ try thinking_block.put(arena, "thinking", .{ .string = "the linker flag is wrong" });
+ try thinking_block.put(arena, "signature", .{ .string = "sigabc" });
+ var use_block: std.json.ObjectMap = .empty;
+ try use_block.put(arena, "type", .{ .string = "tool_use" });
+ try use_block.put(arena, "id", .{ .string = "tu_1" });
+ try use_block.put(arena, "name", .{ .string = "bash" });
+ try use_block.put(arena, "input", .{ .object = .empty });
+ var assistant_blocks = std.json.Array.init(arena);
+ try assistant_blocks.append(.{ .object = thinking_block });
+ try assistant_blocks.append(.{ .object = use_block });
+ var assistant: std.json.ObjectMap = .empty;
+ try assistant.put(arena, "role", .{ .string = "assistant" });
+ try assistant.put(arena, "content", .{ .array = assistant_blocks });
+ try messages.append(.{ .object = assistant });
+
+ var result_block: std.json.ObjectMap = .empty;
+ try result_block.put(arena, "type", .{ .string = "tool_result" });
+ try result_block.put(arena, "tool_use_id", .{ .string = "tu_1" });
+ try result_block.put(arena, "content", .{ .string = "ok" });
+ var result_blocks = std.json.Array.init(arena);
+ try result_blocks.append(.{ .object = result_block });
+ var result_msg: std.json.ObjectMap = .empty;
+ try result_msg.put(arena, "role", .{ .string = "user" });
+ try result_msg.put(arena, "content", .{ .array = result_blocks });
+ try messages.append(.{ .object = result_msg });
+
+ var agent: Agent = .{
+ .gpa = std.testing.allocator,
+ .arena = arena,
+ .io = std.testing.io,
+ .client = undefined,
+ .provider = .{ .id = "anthropic", .kind = .anthropic, .auth = .x_api_key, .url = "", .api_key = "k", .model = "claude", .context = 1_000_000 },
+ .messages = messages,
+ .sub = false,
+ .label = "",
+ .out = null,
+ .sys_normal = "system",
+ };
+ const tools = "[{\"name\":\"bash\",\"description\":\"\",\"input_schema\":{\"type\":\"object\"}}]";
+ const body = try agent.buildBody(tools, false, true, true);
+ defer std.testing.allocator.free(body);
+
+ // Adaptive thinking is what enables interleaved reasoning between tool
+ // calls; it needs no beta header on current models. It also opts into a
+ // summarized display, since current Claude models default to an empty one.
+ try std.testing.expect(std.mem.indexOf(u8, body, "\"thinking\":{\"type\":\"adaptive\",\"display\":\"summarized\"}") != null);
+ // The whole block, signature included, survives the cache-breakpoint rewrite.
+ try std.testing.expect(std.mem.indexOf(u8, body, "{\"type\":\"thinking\",\"thinking\":\"the linker flag is wrong\",\"signature\":\"sigabc\"}") != null);
+ // A cache breakpoint belongs on the trailing tool_result, never on a
+ // thinking block (cache_control is not a valid field there).
+ try std.testing.expect(std.mem.indexOf(u8, body, "\"signature\":\"sigabc\",\"cache_control\"") == null);
+ try std.testing.expect(std.mem.indexOf(u8, body, "\"content\":\"ok\",\"cache_control\":{\"type\":\"ephemeral\"}") != null);
+}
+
+test "anthropic asks for summarized thinking; other anthropic-format providers do not" {
+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer arena_state.deinit();
+ const arena = arena_state.allocator();
+
+ var messages = std.json.Array.init(arena);
+ try messages.append(try testUserMessage(arena, "hello"));
+
+ var agent: Agent = .{
+ .gpa = std.testing.allocator,
+ .arena = arena,
+ .io = std.testing.io,
+ .client = undefined,
+ .provider = .{ .id = "anthropic", .kind = .anthropic, .auth = .x_api_key, .url = "", .api_key = "k", .model = "claude", .context = 1_000_000 },
+ .messages = messages,
+ .sub = false,
+ .label = "",
+ .out = null,
+ .sys_normal = "system",
+ };
+ const tools = "[{\"name\":\"bash\",\"description\":\"\",\"input_schema\":{\"type\":\"object\"}}]";
+
+ // a. Real Anthropic, thinking allowed: adaptive thinking opts into a
+ // summarized display, since current Claude models default to empty.
+ const body_a = try agent.buildBody(tools, false, true, true);
+ defer std.testing.allocator.free(body_a);
+ try std.testing.expect(std.mem.indexOf(u8, body_a, "\"thinking\":{\"type\":\"adaptive\",\"display\":\"summarized\"}") != null);
+
+ // b. Forced tool_choice still suppresses the whole thinking object, exactly
+ // as before this change.
+ const body_b = try agent.buildBody(tools, true, true, true);
+ defer std.testing.allocator.free(body_b);
+ try std.testing.expect(std.mem.indexOf(u8, body_b, "\"thinking\"") == null);
+ try std.testing.expect(std.mem.indexOf(u8, body_b, "\"tool_choice\":{\"type\":\"any\"}") != null);
+
+ // c. Other anthropic-format providers (minimax) reject unknown fields, so
+ // they must never see "display" — only the bare adaptive object.
+ agent.provider.id = "minimax";
+ agent.provider.model = "MiniMax-M3";
+ const body_c = try agent.buildBody(tools, false, true, true);
+ defer std.testing.allocator.free(body_c);
+ try std.testing.expect(std.mem.indexOf(u8, body_c, "\"thinking\":{\"type\":\"adaptive\"}") != null);
+ try std.testing.expect(std.mem.indexOf(u8, body_c, "\"display\"") == null);
+ try std.testing.expect(std.mem.indexOf(u8, body_c, "\"keep\"") == null); // #323: thinking.keep is Kimi-only
+}
+
+test "Claude's own error text takes the retry-without ladder (ADR 0219)" {
+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer arena_state.deinit();
+ var agent = try claudeAgent(arena_state.allocator(), "claude-opus-5-5");
+ const retryWithout = @import("agent_request_policy.zig").retryWithout;
+ var force = true;
+ var stream_usage = true;
+ // The 400 Opus 5.5 returns for a forced tool: drop the force, retry.
+ try std.testing.expect(retryWithout(&agent, "tool_choice: type \"tool\" and \"any\" are not supported for this model.", &force, &stream_usage));
+ try std.testing.expect(!force);
+ // An effort the model does not take is dropped, not misread as the
+ // structured-output format that shares output_config.
+ agent.output_schema = "{\"type\":\"object\"}";
+ try std.testing.expect(retryWithout(&agent, "output_config.effort: xhigh is not supported for this model", &force, &stream_usage));
+ try std.testing.expect(agent.effort_rejected);
+ try std.testing.expect(!agent.sox_json_object);
+ try std.testing.expect(retryWithout(&agent, "output_config.format: unsupported schema", &force, &stream_usage));
+ try std.testing.expect(agent.sox_json_object);
+ // Anything else is a real failure.
+ try std.testing.expect(!retryWithout(&agent, "messages: at least one message is required", &force, &stream_usage));
+}
diff --git a/src/agent_request_body_responses.zig b/src/agent_request_body_responses.zig
index 143fb612..3fec847a 100644
--- a/src/agent_request_body_responses.zig
+++ b/src/agent_request_body_responses.zig
@@ -230,19 +230,25 @@ pub fn writeStructuredOutputTool(s: *std.json.Stringify, schema_json: []const u8
/// #550: native Anthropic structured outputs on the tools-off formatting
/// turn. Provider id `anthropic` only — minimax / kimi-anthropic keep the
/// structured_output tool, and a learned sox flag falls back to it too.
-pub fn writeAnthropicSchema(s: *std.json.Stringify, self: *const Agent, schema_json: []const u8) !void {
+/// True when it wrote `output_config`, with `effort` inside it (ADR 0219).
+pub fn writeAnthropicSchema(s: *std.json.Stringify, self: *const Agent, schema_json: []const u8, effort: ?[]const u8) !bool {
if (std.mem.eql(u8, self.provider.id, "anthropic") and !self.sox_json_object) {
- try writeAnthropicOutputConfig(s, schema_json);
- return;
+ try writeAnthropicOutputConfig(s, schema_json, effort);
+ return true;
}
try writeAnthropicStructuredTool(s, schema_json);
+ return false;
}
/// kimi-code's anthropic adapter: `output_config.format = {type, schema}`.
/// Formatting turn only (ADR 0001): never attach this to a tools turn.
-pub fn writeAnthropicOutputConfig(s: *std.json.Stringify, schema_json: []const u8) !void {
+pub fn writeAnthropicOutputConfig(s: *std.json.Stringify, schema_json: []const u8, effort: ?[]const u8) !void {
try s.objectField("output_config");
try s.beginObject();
+ if (effort) |e| {
+ try s.objectField("effort");
+ try s.write(e);
+ }
try s.objectField("format");
try s.beginObject();
try s.objectField("type");
diff --git a/src/agent_request_policy.zig b/src/agent_request_policy.zig
index f0f25637..6016dc47 100644
--- a/src/agent_request_policy.zig
+++ b/src/agent_request_policy.zig
@@ -144,6 +144,49 @@ test "refreshLoginKeyBeforeSend (#402): an out-of-band login heals a live sessio
try std.testing.expectEqualStrings("relogin-tok", agent.provider.api_key);
}
+/// A provider rejected a request option graff can drop: drop it and retry.
+/// Every error shape comes here, Anthropic `{"type":"error"}` bodies and
+/// streamed error events as well as OpenAI-style envelopes, so a Claude 400
+/// on a forced tool, an effort level or an output format recovers as any
+/// other provider's does (ADR 0219). Before this, Claude errors skipped it.
+pub fn retryWithout(self: *Agent, msg: []const u8, force: *bool, stream_usage: *bool) bool {
+ const has = struct {
+ fn f(haystack: []const u8, needle: []const u8) bool {
+ return std.mem.indexOf(u8, haystack, needle) != null;
+ }
+ }.f;
+ if (force.* and has(msg, "tool_choice")) {
+ force.* = false; // provider can't force a tool; soft-strict
+ return true;
+ }
+ if (stream_usage.* and has(msg, "stream_options")) {
+ stream_usage.* = false; // provider can't report streamed usage
+ return true;
+ }
+ if (!self.cap_new and has(msg, "max_completion_tokens")) {
+ self.cap_new = true; // provider wants the post-deprecation name
+ return true;
+ }
+ // Before the format check: Claude names effort inside output_config.
+ const effort_word = @import("tools.zig").mentionsReasoningEffort(msg) or
+ (self.provider.kind == .anthropic and has(msg, "effort"));
+ if (!self.effort_rejected and effort_word) {
+ self.effort_rejected = true; // model rejects the effort hint here; drop + retry
+ return true;
+ }
+ // #543: a provider without json_schema structured outputs (deepseek:
+ // "This response_format type is unavailable now") must not lose the
+ // --output-schema contract — retry in json_object mode with the schema
+ // moved into the prompt.
+ if (self.output_schema != null and !self.sox_json_object and
+ (has(msg, "response_format") or has(msg, "output_config")))
+ {
+ self.sox_json_object = true;
+ return true;
+ }
+ return false;
+}
+
/// #148/#402: a login-sourced credential was rejected. Adopt a token an
/// in-session `/login` (or another process) has already written to disk, else
/// spend the refresh grant — then retry the request once with the new bearer.
diff --git a/src/agent_steps.zig b/src/agent_steps.zig
index 3f26d8f1..c5832fa0 100644
--- a/src/agent_steps.zig
+++ b/src/agent_steps.zig
@@ -169,6 +169,15 @@ pub fn stepAnthropic(self: *Agent, root: std.json.ObjectMap) !?[]const u8 {
return error.ApiError;
}
const stop_reason = if (root.get("stop_reason")) |s| (if (s == .string) s.string else "") else "";
+ // ADR 0219: a safety refusal ends the turn, outside history, never retried.
+ if (std.mem.eql(u8, stop_reason, "refusal")) {
+ const refusal = @import("claude_refusal.zig");
+ const cat = refusal.category(root);
+ const line = try refusal.text(self.arena, cat);
+ try self.say("{s}\n", .{line});
+ if (self.tracer) |tr| tr.note("refusal", cat orelse "unspecified");
+ return line;
+ }
var assistant: std.json.ObjectMap = .empty;
try assistant.put(self.arena, "role", .{ .string = "assistant" });
diff --git a/src/anthropic_assemble.zig b/src/anthropic_assemble.zig
index e0339eb2..5940c7d7 100644
--- a/src/anthropic_assemble.zig
+++ b/src/anthropic_assemble.zig
@@ -44,6 +44,7 @@ pub fn assembleAnthropic(self: *Agent, body: []const u8) !?std.json.ObjectMap {
var root: ?std.json.ObjectMap = null;
var blocks: std.ArrayList(BlockAcc) = .empty;
var stop_reason: ?Value = null;
+ var stop_details: ?Value = null; // a refusal's category (ADR 0219)
var usage_delta: ?Value = null;
var saw_block_stop = false;
var it = std.mem.tokenizeScalar(u8, body, '\n');
@@ -82,6 +83,9 @@ pub fn assembleAnthropic(self: *Agent, body: []const u8) !?std.json.ObjectMap {
if (d.object.get("stop_reason")) |sr| if (sr == .string) {
stop_reason = sr;
};
+ if (d.object.get("stop_details")) |sd| if (sd == .object) {
+ stop_details = sd;
+ };
};
if (v.object.get("usage")) |u| if (u == .object) {
usage_delta = u;
@@ -116,6 +120,7 @@ pub fn assembleAnthropic(self: *Agent, body: []const u8) !?std.json.ObjectMap {
}
try r.put(scratch, "content", .{ .array = content });
try r.put(scratch, "stop_reason", stop_reason orelse Value{ .string = "end_turn" });
+ if (stop_details) |sd| try r.put(scratch, "stop_details", sd);
if (stop_reason == null) try r.put(scratch, "incomplete", .{ .bool = true });
if (usage_delta) |ud| {
var usage: std.json.ObjectMap = .empty;
@@ -195,3 +200,13 @@ test "#1218: a stream that ends before message_delta is cut; a finished response
"data: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"tool_use\"}}\n");
try std.testing.expectEqualSlices(tool_call_args.Refusal, &.{ .none, .malformed }, done);
}
+
+test "a refusal keeps its stop_details category (ADR 0219)" {
+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer arena_state.deinit();
+ var agent = testAgent(arena_state.allocator());
+ const root = (try assembleAnthropic(&agent, start_read ++
+ "data: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"refusal\",\"stop_details\":{\"type\":\"refusal\",\"category\":\"cyber\"}}}\n")).?;
+ try std.testing.expectEqualStrings("refusal", root.get("stop_reason").?.string);
+ try std.testing.expectEqualStrings("cyber", @import("claude_refusal.zig").category(root).?);
+}
diff --git a/src/claude_refusal.zig b/src/claude_refusal.zig
new file mode 100644
index 00000000..92f085f5
--- /dev/null
+++ b/src/claude_refusal.zig
@@ -0,0 +1,31 @@
+//! A safety refusal from a Claude model (`stop_reason: "refusal"`, with the
+//! category in `stop_details`). The turn ends there: the refused reply stays
+//! out of history, as Anthropic advises for the turn that drew a refusal
+//! (dropping the end of history is not a prefix edit), and the turn never
+//! reads as an empty reply, which the retry path would send again (ADR 0219).
+
+const std = @import("std");
+
+/// The `stop_details.category` of a response root, if it names one.
+pub fn category(root: std.json.ObjectMap) ?[]const u8 {
+ const d = root.get("stop_details") orelse return null;
+ if (d != .object) return null;
+ const c = d.object.get("category") orelse return null;
+ return if (c == .string and c.string.len > 0) c.string else null;
+}
+
+/// What the turn ends with, for the user and for a parent agent.
+pub fn text(a: std.mem.Allocator, cat: ?[]const u8) ![]u8 {
+ if (cat) |c| return std.fmt.allocPrint(a, "[the model declined this request (safety category: {s}); graff did not retry it. Rephrase the request, or switch models with /model]", .{c});
+ return a.dupe(u8, "[the model declined this request; graff did not retry it. Rephrase the request, or switch models with /model]");
+}
+
+test "the refusal line names the category when there is one" {
+ const a = std.testing.allocator;
+ const with = try text(a, "bio");
+ defer a.free(with);
+ try std.testing.expect(std.mem.indexOf(u8, with, "safety category: bio") != null);
+ const without = try text(a, null);
+ defer a.free(without);
+ try std.testing.expect(std.mem.indexOf(u8, without, "declined") != null);
+}
diff --git a/src/claude_wire.zig b/src/claude_wire.zig
new file mode 100644
index 00000000..42c72023
--- /dev/null
+++ b/src/claude_wire.zig
@@ -0,0 +1,169 @@
+//! Per-model rules for the Claude Messages API (ADR 0219). A Claude model id
+//! is `claude-<family>-<major>[-<minor>][-<date>]`; the rules below turn on
+//! by family and version, so a later release inherits them.
+//!
+//! - Forced tool use: Claude Opus 5.5, Sonnet 5.5 and Fable 5.1 reject
+//! `tool_choice` any/tool with a 400. graff forces only older models.
+//! - Thinking prefix binding: from Fable 5.1 (and Opus 5.5, Sonnet 5.5) a
+//! replayed thinking block is checked against the prefix it was produced
+//! under. graff edits that prefix mid-session (tools change when an MCP
+//! server joins; compaction rewrites history), which new accounts see as a
+//! 400. `drop_block` has the API drop stale blocks instead.
+//! - Effort: `output_config.effort`, on models that take it. graff's default
+//! (medium) is left off so each model keeps its own default.
+//! - max_tokens covers thinking plus text on always-thinking models: 64K, and
+//! the 128K maximum at the top efforts, as Anthropic measured and advises.
+
+const std = @import("std");
+const ReasoningEffort = @import("main.zig").ReasoningEffort;
+
+pub const Family = enum { opus, sonnet, haiku, fable, mythos };
+pub const Version = struct { family: Family, major: u16, minor: u16 };
+
+/// The beta that enables `thinking.block_binding`.
+pub const binding_beta = "thinking-binding-controls-2026-08-01";
+
+/// Parse `claude-opus-5-5`, `claude-sonnet-4-6-20260101`, `claude-fable-5`.
+pub fn version(model: []const u8) ?Version {
+ const rest = if (std.mem.startsWith(u8, model, "claude-")) model["claude-".len..] else return null;
+ var it = std.mem.splitScalar(u8, rest, '-');
+ const family = std.meta.stringToEnum(Family, it.next() orelse return null) orelse return null;
+ const major = std.fmt.parseInt(u16, it.next() orelse return null, 10) catch return null;
+ // A minor is one or two digits; an 8-digit date is not a minor.
+ const minor: u16 = if (it.next()) |part|
+ (if (part.len <= 2) std.fmt.parseInt(u16, part, 10) catch 0 else 0)
+ else
+ 0;
+ return .{ .family = family, .major = major, .minor = minor };
+}
+
+fn atLeast(v: Version, major: u16, minor: u16) bool {
+ return v.major > major or (v.major == major and v.minor >= minor);
+}
+
+/// The 5.5-era contract: no forced tool use, prefix-bound thinking.
+fn fiveFiveEra(model: []const u8) bool {
+ const v = version(model) orelse return false;
+ return switch (v.family) {
+ .opus, .sonnet => atLeast(v, 5, 5),
+ .fable, .mythos => atLeast(v, 5, 1),
+ .haiku => false,
+ };
+}
+
+/// `tool_choice` any/tool returns a 400 on this model.
+pub fn rejectsForcedTools(model: []const u8) bool {
+ return fiveFiveEra(model);
+}
+
+/// The API checks replayed thinking against its prefix on this model.
+/// Mythos 5.1 does not run the check, but takes the field.
+pub fn bindsThinking(model: []const u8) bool {
+ return fiveFiveEra(model);
+}
+
+/// Whether `output_config.effort` is accepted (Opus 4.5 and later, Sonnet
+/// 4.6 and later, every Fable and Mythos; never Haiku).
+pub fn takesEffort(model: []const u8) bool {
+ const v = version(model) orelse return false;
+ return switch (v.family) {
+ .opus => atLeast(v, 4, 5),
+ .sonnet => atLeast(v, 4, 6),
+ .fable, .mythos => true,
+ .haiku => false,
+ };
+}
+
+/// graff's effort on the wire. Null at graff's default: the model keeps its
+/// own (medium on Opus 5.5, high on Opus 5 and Sonnet 5.5), so a session that
+/// never ran /effort does not move. `ultra` asks for the most there is.
+pub fn effortWire(effort: ReasoningEffort) ?[]const u8 {
+ return switch (effort) {
+ .medium, .none => null,
+ .low => "low",
+ .high => "high",
+ .xhigh => "xhigh",
+ .max, .ultra => "max",
+ };
+}
+
+/// Thinking is on by default (Opus and Sonnet 5 and later, Fable, Mythos):
+/// max_tokens is spent on thinking before the answer.
+pub fn thinksByDefault(model: []const u8) bool {
+ const v = version(model) orelse return false;
+ return switch (v.family) {
+ .opus, .sonnet => atLeast(v, 5, 0),
+ .fable, .mythos => true,
+ .haiku => false,
+ };
+}
+
+/// Output budget, thinking included. Anthropic measured a 16K cap ending
+/// about a quarter of Opus 5.5's agentic attempts and 43% of Fable 5.1's, at
+/// no saving per solved task; it recommends 64K for agentic work and the
+/// 128K maximum where a cut-off attempt is costly (the top efforts think
+/// longest). graff always streams, which responses this size need.
+/// Models without a 128K ceiling keep graff's default.
+pub fn maxTokens(model: []const u8, effort: ReasoningEffort, default: u32) u32 {
+ if (!thinksByDefault(model)) return default; // the 128K-output lineup
+ return switch (effort) {
+ .xhigh, .max, .ultra => 128_000,
+ else => @max(default, 64_000),
+ };
+}
+
+/// The `thinking` object for the Anthropic API. The summarized display keeps
+/// the live Thinking panel readable (current models default to an empty
+/// one); binding models also drop stale blocks instead of failing.
+pub fn thinkingObject(model: []const u8) []const u8 {
+ return if (bindsThinking(model))
+ "{\"type\":\"adaptive\",\"display\":\"summarized\",\"block_binding\":{\"prefix_mismatch_behavior\":\"drop_block\"}}"
+ else
+ "{\"type\":\"adaptive\",\"display\":\"summarized\"}";
+}
+
+test "Claude model ids parse by family and version; dates are not minors" {
+ const t = std.testing;
+ try t.expectEqual(Version{ .family = .opus, .major = 5, .minor = 5 }, version("claude-opus-5-5").?);
+ try t.expectEqual(Version{ .family = .opus, .major = 5, .minor = 0 }, version("claude-opus-5").?);
+ try t.expectEqual(Version{ .family = .sonnet, .major = 4, .minor = 6 }, version("claude-sonnet-4-6-20260101").?);
+ try t.expectEqual(Version{ .family = .sonnet, .major = 4, .minor = 0 }, version("claude-sonnet-4-20250514").?);
+ try t.expectEqual(Version{ .family = .fable, .major = 5, .minor = 1 }, version("claude-fable-5-1").?);
+ try t.expect(version("gpt-5.5") == null);
+ try t.expect(version("claude-3-5-sonnet") == null);
+}
+
+test "5.5-era models are never forced to a tool and bind their thinking" {
+ const t = std.testing;
+ for ([_][]const u8{ "claude-opus-5-5", "claude-sonnet-5-5", "claude-fable-5-1", "claude-opus-6" }) |m| {
+ try t.expect(rejectsForcedTools(m));
+ try t.expect(bindsThinking(m));
+ try t.expect(std.mem.indexOf(u8, thinkingObject(m), "\"prefix_mismatch_behavior\":\"drop_block\"") != null);
+ }
+ for ([_][]const u8{ "claude-opus-5", "claude-sonnet-5", "claude-fable-5", "claude-opus-4-8", "claude-haiku-4-5" }) |m| {
+ try t.expect(!rejectsForcedTools(m));
+ try t.expect(!bindsThinking(m));
+ try t.expect(std.mem.indexOf(u8, thinkingObject(m), "block_binding") == null);
+ }
+}
+
+test "effort goes on the wire only where it is taken, and never at graff's default" {
+ const t = std.testing;
+ try t.expect(takesEffort("claude-opus-5-5") and takesEffort("claude-sonnet-5-5") and takesEffort("claude-fable-5-1"));
+ try t.expect(takesEffort("claude-opus-4-5") and takesEffort("claude-sonnet-4-6"));
+ try t.expect(!takesEffort("claude-haiku-4-5") and !takesEffort("claude-sonnet-4-5") and !takesEffort("claude-opus-4-1"));
+ try t.expect(effortWire(.medium) == null);
+ try t.expectEqualStrings("high", effortWire(.high).?);
+ try t.expectEqualStrings("xhigh", effortWire(.xhigh).?);
+ try t.expectEqualStrings("max", effortWire(.ultra).?);
+}
+
+test "max_tokens leaves room for thinking on 128K-output models" {
+ const t = std.testing;
+ try t.expectEqual(@as(u32, 64_000), maxTokens("claude-opus-5-5", .medium, 16_000));
+ try t.expectEqual(@as(u32, 128_000), maxTokens("claude-opus-5-5", .max, 16_000));
+ try t.expectEqual(@as(u32, 128_000), maxTokens("claude-fable-5-1", .xhigh, 16_000));
+ try t.expectEqual(@as(u32, 16_000), maxTokens("claude-haiku-4-5", .max, 16_000));
+ try t.expectEqual(@as(u32, 16_000), maxTokens("claude-opus-4-8", .high, 16_000));
+ try t.expectEqual(@as(u32, 16_000), maxTokens("minimax-m3", .high, 16_000));
+}
diff --git a/src/http_headers.zig b/src/http_headers.zig
index 3b574cf0..6e6e39ac 100644
--- a/src/http_headers.zig
+++ b/src/http_headers.zig
@@ -215,6 +215,13 @@ pub fn providerHeadersWithConv(io: Io, provider: Provider, bearer: []const u8, b
if (provider.kind == .anthropic) {
buf[count] = .{ .name = "anthropic-version", .value = root.anthropic_version };
count += 1;
+ // ADR 0219: the beta that goes with the body's thinking.block_binding,
+ // on the Anthropic API and the models that check it (claude_wire).
+ const claude = @import("claude_wire.zig");
+ if (std.mem.eql(u8, provider.id, "anthropic") and claude.bindsThinking(provider.model)) {
+ buf[count] = .{ .name = "anthropic-beta", .value = claude.binding_beta };
+ count += 1;
+ }
}
if (std.mem.eql(u8, provider.id, "kimi")) {
const identity = kimi_catalog.identityHeaders(buf[count..]);
@@ -571,3 +578,21 @@ test "Kimi chat sends graff identity and kimi-code device headers (#617)" {
if (prefix.len != 0) try std.testing.expect(std.mem.startsWith(u8, model, prefix));
try std.testing.expect(!std.mem.eql(u8, headerValue(headers, "X-Msh-Os-Version").?, @tagName(@import("builtin").os.tag)));
}
+
+test "the thinking-binding beta rides only 5.5-era Claude models on the Anthropic API (ADR 0219)" {
+ const io = std.testing.io;
+ var buf: [12]std.http.Header = undefined;
+ const beta = struct {
+ fn of(headers: []const std.http.Header) ?[]const u8 {
+ for (headers) |h| if (std.mem.eql(u8, h.name, "anthropic-beta")) return h.value;
+ return null;
+ }
+ }.of;
+ var p: Provider = .{ .id = "anthropic", .kind = .anthropic, .auth = .x_api_key, .url = "", .api_key = "k", .model = "claude-opus-5-5", .context = 1_000_000 };
+ try std.testing.expectEqualStrings("thinking-binding-controls-2026-08-01", beta(providerHeaders(io, p, "", &buf)).?);
+ p.model = "claude-opus-5";
+ try std.testing.expect(beta(providerHeaders(io, p, "", &buf)) == null);
+ // An Anthropic-format provider that is not Anthropic never sees it.
+ p = .{ .id = "minimax", .kind = .anthropic, .auth = .x_api_key, .url = "", .api_key = "k", .model = "claude-opus-5-5", .context = 1_000_000 };
+ try std.testing.expect(beta(providerHeaders(io, p, "", &buf)) == null);
+}
diff --git a/src/pricing.zig b/src/pricing.zig
index 68f4f18d..441b8698 100644
--- a/src/pricing.zig
+++ b/src/pricing.zig
@@ -179,11 +179,12 @@ pub const model_table = [_]ModelInfo{
// LM Studio serves whatever model is loaded; "lmstudio" is a routing alias —
// swap for your loaded model id if LM Studio requires an exact match (GET :1234/v1/models).
.{ .provider = "lmstudio", .name = "lmstudio", .context = 200_000 },
- // Anthropic: no-key/offline FALLBACK ONLY. With a key, router_catalog
- // fetches /v1/models and replaces this slice 1:1 with the live list
- // (windows from max_input_tokens) — do not grow or "fix" these rows to
- // track releases; they exist so boot, --schema, and routing work before
- // the first authenticated fetch.
+ // Anthropic: no-key/offline FALLBACK ONLY; with a key, router_catalog swaps
+ // in the live /v1/models list. Rows exist so boot, --schema and routing
+ // (the default, ladder and vision picks) resolve before that fetch.
+ .{ .provider = "anthropic", .name = "claude-opus-5-5", .context = 1_000_000 },
+ .{ .provider = "anthropic", .name = "claude-sonnet-5-5", .context = 1_000_000 },
+ .{ .provider = "anthropic", .name = "claude-fable-5-1", .context = 1_000_000 },
.{ .provider = "anthropic", .name = "claude-opus-5", .context = 1_000_000 },
.{ .provider = "anthropic", .name = "claude-sonnet-5", .context = 1_000_000 },
.{ .provider = "anthropic", .name = "claude-fable-5", .context = 1_000_000 },
diff --git a/src/pricing_table.zig b/src/pricing_table.zig
index 06245f2d..a45cf941 100644
--- a/src/pricing_table.zig
+++ b/src/pricing_table.zig
@@ -23,6 +23,11 @@ pub const rows = [_]ModelPrice{
.{ .name = "gpt-5.3-codex", .in = 1.75, .out = 14, .cache = 0.175 },
.{ .name = "gpt-5.2", .in = 1.75, .out = 14, .cache = 0.175 },
.{ .name = "gpt-5-codex", .in = 1.25, .out = 10, .cache = 0.125 },
+ // Claude 5.5-era lineup (platform.claude.com model pages, read 2026-09-30).
+ // Cache reads are 5% of input on Opus 5.5 and 2.5% on Fable 5.1.
+ .{ .name = "claude-opus-5-5", .in = 4, .out = 20, .cache = 0.2 },
+ .{ .name = "claude-sonnet-5-5", .in = 2, .out = 10, .cache = 0.2 },
+ .{ .name = "claude-fable-5-1", .in = 10, .out = 50, .cache = 0.25 },
.{ .name = "claude-fable-5", .in = 10, .out = 50, .cache = 1 }, // pricier than opus-5; unpriced it read as a cheap rung
.{ .name = "claude-opus-5", .in = 5, .out = 25, .cache = 0.5 },
.{ .name = "claude-sonnet-5", .in = 2, .out = 10, .cache = 0.2 }, // introductory, $3/$15 from 2026-09-01
diff --git a/src/provider.zig b/src/provider.zig
index 13fcd8ab..29b67312 100644
--- a/src/provider.zig
+++ b/src/provider.zig
@@ -76,7 +76,7 @@ pub const provider_specs = [_]ProviderSpec{
// Anthropic publishes its live model list at /v1/models (same x-api-key +
// anthropic-version auth as Messages), so new Claude releases appear
// without a rebuild; the baked pricing.zig rows stay the offline fallback.
- .{ .id = "anthropic", .display_name = "Anthropic", .kind = .anthropic, .auth = .x_api_key, .url = "https://api.anthropic.com/v1/messages", .env_key = "ANTHROPIC_API_KEY", .default_model = "claude-opus-4-8", .catalog = .anthropic, .models_url = "https://api.anthropic.com/v1/models?limit=1000" },
+ .{ .id = "anthropic", .display_name = "Anthropic", .kind = .anthropic, .auth = .x_api_key, .url = "https://api.anthropic.com/v1/messages", .env_key = "ANTHROPIC_API_KEY", .default_model = "claude-opus-5-5", .catalog = .anthropic, .models_url = "https://api.anthropic.com/v1/models?limit=1000" },
.{ .id = "codegraff", .display_name = "Codegraff", .kind = .openai, .auth = .bearer, .url = "https://gateway.codegraff.com/v1/chat/completions", .env_key = "CODEGRAFF_API_KEY", .default_model = "mimo-v2.6-pro", .login = .codegraff_device, .catalog = .openai, .models_url = "https://gateway.codegraff.com/v1/models", .takes_effort = true },
.{ .id = "deepseek", .display_name = "DeepSeek", .kind = .openai, .auth = .bearer, .url = "https://api.deepseek.com/chat/completions", .env_key = "DEEPSEEK_API_KEY", .default_model = "deepseek-v4-pro", .takes_effort = true },
.{ .id = "openai", .display_name = "OpenAI", .kind = .responses, .auth = .bearer, .url = "https://api.openai.com/v1/responses", .env_key = "OPENAI_API_KEY", .default_model = "gpt-5.6" },
diff --git a/src/rlm_query.zig b/src/rlm_query.zig
index 57858a92..77ae45b6 100644
--- a/src/rlm_query.zig
+++ b/src/rlm_query.zig
@@ -95,8 +95,16 @@ pub fn buildBody(gpa: Allocator, provider: Provider, prompt: []const u8) ![]u8 {
try s.write(prompt);
},
.anthropic => {
+ // ADR 0219: a Claude model that thinks by default spends max_tokens
+ // on thinking first; 256 left no answer. Room, and little thinking.
+ const claude = @import("claude_wire.zig");
+ const thinks = std.mem.eql(u8, provider.id, "anthropic") and claude.thinksByDefault(provider.model);
try s.objectField("max_tokens");
- try s.write(max_out_tokens);
+ try s.write(if (thinks) @as(u32, 4096) else max_out_tokens);
+ if (thinks and claude.takesEffort(provider.model)) {
+ try s.objectField("output_config");
+ try s.print("{{\"effort\":\"low\"}}", .{});
+ }
try s.objectField("messages");
try s.beginArray();
try s.beginObject();
@@ -179,3 +187,19 @@ test "llm_query cannot bypass exhausted aggregate model budget" {
try std.testing.expect(std.mem.indexOf(u8, out.text, "RunBudgetExhausted") != null);
try std.testing.expectEqual(@as(u64, 1), budget.used());
}
+
+test "llm_query gives a thinking Claude model room to answer, at low effort (ADR 0219)" {
+ const gpa = std.testing.allocator;
+ var p = sampleProvider(.anthropic);
+ p.id = "anthropic";
+ p.model = "claude-opus-5-5";
+ const body = try buildBody(gpa, p, "one word");
+ defer gpa.free(body);
+ try std.testing.expect(std.mem.indexOf(u8, body, "\"max_tokens\":4096") != null);
+ try std.testing.expect(std.mem.indexOf(u8, body, "\"output_config\":{\"effort\":\"low\"}") != null);
+ p.model = "claude-haiku-4-5"; // no default thinking: the small budget stands
+ const small = try buildBody(gpa, p, "one word");
+ defer gpa.free(small);
+ try std.testing.expect(std.mem.indexOf(u8, small, "\"max_tokens\":256") != null);
+ try std.testing.expect(std.mem.indexOf(u8, small, "output_config") == null);
+}
diff --git a/src/subagent_pin_tests.zig b/src/subagent_pin_tests.zig
index 270681ad..b222e02f 100644
--- a/src/subagent_pin_tests.zig
+++ b/src/subagent_pin_tests.zig
@@ -200,17 +200,17 @@ test "graceful fallback: every unhonorable pin keeps the session default, never
try std.testing.expectEqual(pin_mod.Outcome.no_rung, pin_mod.forSpawn(deepseek, obj(a, "{\"tier\":\"mid\"}"), true).outcome);
const opus: Provider = .{ .id = "anthropic", .kind = .anthropic, .auth = .x_api_key, .url = "", .api_key = "k", .model = "claude-opus-5", .context = 1_000_000 };
try std.testing.expectEqual(pin_mod.Outcome.no_rung, pin_mod.forSpawn(opus, obj(a, "{\"tier\":\"mid\"}"), true).outcome);
- try std.testing.expectEqualStrings("claude-sonnet-5", pin_mod.forSpawn(opus, obj(a, "{\"tier\":\"small\"}"), true).provider.?.model);
+ try std.testing.expectEqualStrings("claude-sonnet-5-5", pin_mod.forSpawn(opus, obj(a, "{\"tier\":\"small\"}"), true).provider.?.model);
}
test "cost ceiling: a tier rung may descend price but never raise it" {
var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);
defer arena_state.deinit();
const a = arena_state.allocator();
- // anthropic's compiled ladder: frontier claude-opus-5 ($5/25), small
- // claude-sonnet-5 ($2/10). Descending is fine…
+ // anthropic's compiled ladder: frontier claude-opus-5-5 ($4/20), small
+ // claude-sonnet-5-5 ($2/10). Descending from an opus root is fine…
const opus: Provider = .{ .id = "anthropic", .kind = .anthropic, .auth = .x_api_key, .url = "", .api_key = "k", .model = "claude-opus-5", .context = 1_000_000 };
- try std.testing.expectEqualStrings("claude-sonnet-5", pin_mod.forSpawn(opus, obj(a, "{\"tier\":\"small\"}"), true).provider.?.model);
+ try std.testing.expectEqualStrings("claude-sonnet-5-5", pin_mod.forSpawn(opus, obj(a, "{\"tier\":\"small\"}"), true).provider.?.model);
// …but a sonnet-5 root asking for the frontier rung would RAISE cost —
// blocked with a reason, spawn keeps the session default. Naming the
// model explicitly still escalates: that is the visible, consented path.
diff --git a/src/subagent_selection.zig b/src/subagent_selection.zig
index ed8d92e0..501922c7 100644
--- a/src/subagent_selection.zig
+++ b/src/subagent_selection.zig
@@ -202,11 +202,12 @@ test "defaultLadderModel: descends one rung per provider, bottom rung inherits"
// openai: same shape, sibling names
try std.testing.expectEqualStrings("gpt-5.6-terra", defaultLadderModel(mk("openai", "gpt-5.6")).?);
try std.testing.expect(defaultLadderModel(mk("openai", "gpt-6-astra")) == null);
- // anthropic: opus-5 -> sonnet-5 -> (bottom). #471 dropped the opus-4-8 and
- // sonnet-4-6 rungs: every opus generation bills the same $5/$25 per MTok,
- // so descending within the family is not a cheaper seat at all.
- try std.testing.expectEqualStrings("claude-sonnet-5", defaultLadderModel(mk("anthropic", "claude-opus-5")).?);
- try std.testing.expect(defaultLadderModel(mk("anthropic", "claude-sonnet-5")) == null);
+ // anthropic: opus-5-5 -> sonnet-5-5 -> (bottom) (ADR 0219). #471: a rung
+ // must be a cheaper seat, so older opus generations are not rungs, and a
+ // root still on one is off-ladder and inherits.
+ try std.testing.expectEqualStrings("claude-sonnet-5-5", defaultLadderModel(mk("anthropic", "claude-opus-5-5")).?);
+ try std.testing.expect(defaultLadderModel(mk("anthropic", "claude-sonnet-5-5")) == null);
+ try std.testing.expect(defaultLadderModel(mk("anthropic", "claude-opus-5")) == null);
try std.testing.expect(defaultLadderModel(mk("anthropic", "claude-opus-4-8")) == null);
// deepseek / codegraff: pro (the session default) descends to flash;
// a flash root is already the cheap seat and inherits.
@@ -234,10 +235,10 @@ test "default ladder: resolves the mid sibling when no flags are given" {
const astra_root = try keys.providerById("codex", "gpt-6-astra");
try std.testing.expect(resolveSubagentProvider(keys, astra_root, null, null, false, false) == null);
- const anthropic_root = try keys.providerById("anthropic", "claude-opus-5");
+ const anthropic_root = try keys.providerById("anthropic", "claude-opus-5-5");
const anthropic_worker = resolveSubagentProvider(keys, anthropic_root, null, null, false, false).?;
try std.testing.expectEqualStrings("anthropic", anthropic_worker.id);
- try std.testing.expectEqualStrings("claude-sonnet-5", anthropic_worker.model);
+ try std.testing.expectEqualStrings("claude-sonnet-5-5", anthropic_worker.model);
}
test "default ladder: bottom-rung and off-ladder roots inherit (resolve to null)" {
diff --git a/src/subagent_tier_ladder.zig b/src/subagent_tier_ladder.zig
index 13ce8414..c17aba7b 100644
--- a/src/subagent_tier_ladder.zig
+++ b/src/subagent_tier_ladder.zig
@@ -64,12 +64,10 @@ pub const TierLadder = struct {
pub const ladders = [_]TierLadder{
.{ .provider = "codex", .frontier = "gpt-6-astra", .mid = "gpt-5.6-terra", .small = "gpt-5.6-luna" },
.{ .provider = "openai", .frontier = "gpt-5.6", .mid = "gpt-5.6-terra", .small = "gpt-5.6-luna" },
- // #471: opus-5 and sonnet-5 are the current lineup, and the rungs below
- // frontier must be cheaper SEATS. Every opus generation bills the same
- // $5/$25 per MTok, so "descend from opus-5 to opus-4-8" saves nothing —
- // it is the same seat, one generation older. sonnet-5 at $2/$10 is the
- // real cheap rung, 2.5x under opus on both halves of the bill.
- .{ .provider = "anthropic", .frontier = "claude-opus-5", .small = "claude-sonnet-5" },
+ // #471: the rungs below frontier must be cheaper SEATS. opus-5-5 ($4/$20)
+ // and sonnet-5-5 ($2/$10) are the current lineup (ADR 0219); descending to
+ // an older opus saves nothing, and sonnet-5-5 halves both halves of the bill.
+ .{ .provider = "anthropic", .frontier = "claude-opus-5-5", .small = "claude-sonnet-5-5" },
// Flash is the cheaper DeepSeek seat ($0.14/$0.28 vs pro $1.1/$2.2) and
// still outclasses luna. Pro stays the frontier name a codegraff/direct
// session actually starts on; small descends to flash instead of hopping
@@ -235,9 +233,9 @@ test "#471 a derived ladder offering no real descent yields to the compiled row"
};
bench.g_ladders = &derived;
const l = forProvider("anthropic").?;
- try std.testing.expectEqualStrings("claude-opus-5", l.frontier);
+ try std.testing.expectEqualStrings("claude-opus-5-5", l.frontier); // the compiled row, whole
try std.testing.expect(l.mid == null);
- try std.testing.expectEqualStrings("claude-sonnet-5", l.small.?); // from the compiled row
+ try std.testing.expectEqualStrings("claude-sonnet-5-5", l.small.?); // from the compiled row
// A derived ladder that DOES name a genuinely cheaper seat still wins:
// measured data outranks the hand-picked default, which is the whole
diff --git a/src/vision_ask_tests.zig b/src/vision_ask_tests.zig
index 040661b6..7e3647d9 100644
--- a/src/vision_ask_tests.zig
+++ b/src/vision_ask_tests.zig
@@ -185,17 +185,16 @@ test "#380 fast fail: no vision-capable model anywhere refuses the spawn, action
// Saying "none is reachable" there would be a lie, so it is a distinct
// message that names the model and how to authorize it.
withKeys(&keys, &.{"anthropic"});
- // #471 moved anthropic's cheap rung from haiku-4-5 to sonnet-5, so the
- // vision seat is sonnet-5 ($2/$10) rather than haiku ($1/$5): still 2.5x
- // under opus, and now a genuinely cheaper SEAT than the frontier instead
- // of an equally-priced older opus.
+ // #471 moved anthropic's cheap rung from haiku-4-5 to sonnet, so the
+ // vision seat is sonnet-5-5 ($2/$10, ADR 0219) rather than haiku ($1/$5):
+ // half of opus-5-5 on both halves, a genuinely cheaper SEAT.
const cheap: Provider = .{ .id = "anthropic", .kind = .anthropic, .auth = .x_api_key, .url = "", .api_key = "k", .model = "claude-sonnet-5", .context = 200_000 };
try std.testing.expectEqualStrings("", va.blockedByCost(cheap)); // sonnet-5 IS the cheap vision rung — affordable, so not this case
const priced_out: Provider = .{ .id = "anthropic", .kind = .anthropic, .auth = .x_api_key, .url = "", .api_key = "k", .model = "deepseek-v4-flash", .context = 200_000 };
- try std.testing.expectEqualStrings("claude-sonnet-5", va.blockedByCost(priced_out));
- const cost_msg = try va.blockMessage(std.testing.allocator, .{ .path = "a.png", .blocked = true, .pricier = "claude-sonnet-5" });
+ try std.testing.expectEqualStrings("claude-sonnet-5-5", va.blockedByCost(priced_out));
+ const cost_msg = try va.blockMessage(std.testing.allocator, .{ .path = "a.png", .blocked = true, .pricier = "claude-sonnet-5-5" });
defer std.testing.allocator.free(cost_msg);
- try std.testing.expect(std.mem.indexOf(u8, cost_msg, "model:\"claude-sonnet-5\"") != null); // how to authorize it
+ try std.testing.expect(std.mem.indexOf(u8, cost_msg, "model:\"claude-sonnet-5-5\"") != null); // how to authorize it
try std.testing.expect(std.mem.indexOf(u8, cost_msg, "escalate") != null); // and why it was not taken
try std.testing.expect(!std.mem.eql(u8, cost_msg, msg));
}
@@ -204,7 +203,7 @@ test "#380 candidate search: sub-first, then provider-local under the cost ceili
// Ladder rungs bottom-up, so a re-route descends price rather than seizing
// the frontier model.
try std.testing.expectEqualStrings("gpt-5.6-luna", va.visionModelFor("codex").?);
- try std.testing.expectEqualStrings("claude-sonnet-5", va.visionModelFor("anthropic").?);
+ try std.testing.expectEqualStrings("claude-sonnet-5-5", va.visionModelFor("anthropic").?);
try std.testing.expect(va.visionModelFor("deepseek") == null); // no vision model at any rung
const saved = bench.g_keys;
@@ -223,12 +222,12 @@ test "#380 candidate search: sub-first, then provider-local under the cost ceili
try std.testing.expectEqualStrings("gpt-5.6-luna", seat.model);
// An anthropic base with no sub logged in resolves provider-locally, and
- // only because sonnet-5 is CHEAPER than the opus it replaces.
+ // only because sonnet-5-5 is CHEAPER than the opus it replaces.
withKeys(&keys, &.{"anthropic"});
const opus_root: Provider = .{ .id = "anthropic", .kind = .anthropic, .auth = .x_api_key, .url = "", .api_key = "k", .model = "claude-opus-5", .context = 1_000_000 };
const local = va.visionSeat(opus_root).?;
try std.testing.expectEqualStrings("anthropic", local.id);
- try std.testing.expectEqualStrings("claude-sonnet-5", local.model);
+ try std.testing.expectEqualStrings("claude-sonnet-5-5", local.model);
}
test "#380 honesty flag: each disclaimer spelling is caught, ordinary reports are not" {