Multiplayer agent harness for work.
Add Claude Sonnet 5.5 with mandatory adaptive thinking (#1685)
Regan Bell0d59cb200e56
diff --git a/src/model/pi-models.ts b/src/model/pi-models.tsindex 7f9cd7e22..c5fcce2e9 100644--- a/src/model/pi-models.ts+++ b/src/model/pi-models.ts@@ -167,6 +167,23 @@ export const MODEL_REGISTRY: readonly ModelEntry[] = [},},{ id: "claude-opus-4-8", name: "Claude Opus 4.8", fastMode: true, webui: true, base: true },+ {+ id: "claude-sonnet-5-5",+ name: "Claude Sonnet 5.5",+ fastMode: false,+ webui: true,+ base: true,+ clone: {+ template: "claude-opus-4-8",+ thinkingLevelMap: { off: null },+ input: 2,+ output: 10,+ cacheRead: 0.2,+ cacheWrite: 2.5,+ contextWindow: 1_000_000,+ maxTokens: 128_000,+ },+ },{ id: "claude-sonnet-5", name: "Claude Sonnet 5", fastMode: false, webui: true, base: true },{ id: "claude-haiku-4-5", name: "Claude Haiku 4.5", fastMode: false, webui: true, base: true, auxiliary: true },{diff --git a/test/model-credential-route.test.ts b/test/model-credential-route.test.tsindex 7a4894287..397d8887a 100644--- a/test/model-credential-route.test.ts+++ b/test/model-credential-route.test.ts@@ -65,6 +65,7 @@ test("admin model credentials are encrypted, write-only, live, and removable", a{ id: "claude-fable-5", name: "Claude Fable 5", provider: "anthropic" },{ id: "claude-opus-5", name: "Claude Opus 5", provider: "anthropic" },{ id: "claude-opus-4-8", name: "Claude Opus 4.8", provider: "anthropic" },+ { id: "claude-sonnet-5-5", name: "Claude Sonnet 5.5", provider: "anthropic" },{ id: "claude-sonnet-5", name: "Claude Sonnet 5", provider: "anthropic" },{ id: "claude-haiku-4-5", name: "Claude Haiku 4.5", provider: "anthropic" },{ id: "gpt-5.6-sol", name: "GPT-5.6 Sol", provider: "openai" },diff --git a/test/model-registry.test.ts b/test/model-registry.test.tsindex b6a0ad186..ff77ef110 100644--- a/test/model-registry.test.ts+++ b/test/model-registry.test.ts@@ -118,6 +118,23 @@ test("Opus 5.5 is selectable with compatible harnesses and credentials, without);});+test("Sonnet 5.5 never turns thinking off, rejects temperature and fast mode, and leaves defaults alone", () => {+ const id = "claude-sonnet-5-5";+ const model = resolveModel(id);+ assert.ok(model);+ assert.deepEqual(model.thinkingLevelMap, { xhigh: "xhigh", max: "max", off: null });+ assert.equal((model.compat as { supportsTemperature?: boolean }).supportsTemperature, false);+ assert.deepEqual(model.cost, { input: 2, output: 10, cacheRead: 0.2, cacheWrite: 2.5, tiers: undefined });+ assert.equal(safeModelMetadata(id)?.label, "Sonnet 5.5");+ assert.ok(DEFAULT_WEBUI_MODEL_IDS.includes(id));+ assert.ok(!FAST_MODE_MODEL_IDS.includes(id));+ for (const harness of ["pi", "claude", "opencode", "mock"]) {+ assert.equal(modelSupportedByHarness(id, harness), true);+ assert.equal(defaultModelForHarness(harness), "claude-opus-5");+ }+ assert.equal(modelSupportedByHarness(id, "codex"), false);+});+test("FAST_MODE_MODEL_IDS derives from the registry — the web-ui client reads this, keeps no copy", () => {assert.deepEqual([...FAST_MODE_MODEL_IDS].sort(),diff --git a/test/native-auto-reasoning.test.ts b/test/native-auto-reasoning.test.tsindex effb9fe46..dbf3ab190 100644--- a/test/native-auto-reasoning.test.ts+++ b/test/native-auto-reasoning.test.ts@@ -111,7 +111,7 @@ test("real Pi AgentSession and Anthropic serializer send Auto without a fixed efheaders: { "content-type": "text/event-stream" },});}) as typeof fetch;- for (const modelId of [adaptiveId, "claude-opus-5-5"])+ for (const modelId of [adaptiveId, "claude-opus-5-5", "claude-sonnet-5-5"])for (const route of ["api-key", "personal-key", "oauth", "gateway"] as const) {await t.test(`${modelId}/${route}`, async () => {const harness = createPiHarness({@@ -128,7 +128,16 @@ test("real Pi AgentSession and Anthropic serializer send Auto without a fixed ef: { apiKey: "sk-offline-test-key" }),});t.after(() => harness.turns.close?.());- for (const effortLevel of ["high", "adaptive", "default", "auto", "adaptive", "low"]) {+ const mandatoryThinking = getRequiredModel(modelId).thinkingLevelMap?.off === null;+ for (const effortLevel of [+ "high",+ "adaptive",+ "default",+ "auto",+ "adaptive",+ "low",+ ...(mandatoryThinking ? ["xhigh", "max", "ultracode", "medium"] : []),+ ]) {sendTool = true;const result = await harness.turns.runTurn({session: { id: `native-auto-${modelId}-${route}` } as HarnessTurnInput["session"],@@ -158,11 +167,12 @@ test("real Pi AgentSession and Anthropic serializer send Auto without a fixed efassert.equal(request.body.max_tokens, getRequiredModel(modelId).maxTokens);if (effortLevel === "adaptive" || effortLevel === "default")assert.equal(request.body.output_config?.effort, undefined);- else assert.equal(request.body.output_config?.effort, effortLevel === "auto" ? "low" : effortLevel);- if (- effortLevel === "default" &&- (route === "gateway" || getRequiredModel(modelId).thinkingLevelMap?.off !== null)- )+ else+ assert.equal(+ request.body.output_config?.effort,+ { auto: "low", ultracode: "max" }[effortLevel] ?? effortLevel,+ );+ if (effortLevel === "default" && (route === "gateway" || !mandatoryThinking))assert.equal(request.body.thinking, undefined);else assert.equal(request.body.thinking?.type, "adaptive");if (route === "gateway") {diff --git a/test/pi-harness-fast-mode.test.ts b/test/pi-harness-fast-mode.test.tsindex 3eacfe70d..8b18b2ce6 100644--- a/test/pi-harness-fast-mode.test.ts+++ b/test/pi-harness-fast-mode.test.ts@@ -105,6 +105,7 @@ test("auto resets a reused Anthropic session to its interactive default", () =>const ASTRA = getRequiredModel("gpt-6-astra", false) as Model<Api>;const OPUS_55 = getRequiredModel("claude-opus-5-5", false);+const SONNET_55 = getRequiredModel("claude-sonnet-5-5", false);const OPUS = getRequiredModel("claude-opus-5", false) as Model<Api>;const ASTRA_TOKENS = { input: 10_000, output: 2_000, cacheRead: 50_000, cacheWrite: 4_000, totalTokens: 66_000 };@@ -132,6 +133,7 @@ const pricingCases: Array<[string, Model<Api>, Partial<Usage>, number]> = [],["Opus 5.5 cache reads", OPUS_55, { cacheRead: 100_000 }, 0.02],["Opus 5.5 1h writes", OPUS_55, { cacheWrite: 4_000, cacheWrite1h: 4_000 }, 0.032],+ ["Sonnet 5.5 1h writes", SONNET_55, { cacheWrite: 4_000, cacheWrite1h: 4_000 }, 0.016],["all 1h writes", OPUS, { cacheWrite: 4_000, cacheWrite1h: 4_000 }, 0.04],["clamped 1h writes", OPUS, { cacheWrite: 4_000, cacheWrite1h: 40_000 }, 0.04],];diff --git a/test/pi-models.test.ts b/test/pi-models.test.tsindex fcdf9f9a3..fb309e06f 100644--- a/test/pi-models.test.ts+++ b/test/pi-models.test.ts@@ -109,6 +109,7 @@ test("the curated catalog contains only current model families", () => {"claude-fable-5","claude-opus-5","claude-opus-4-8",+ "claude-sonnet-5-5","claude-sonnet-5","claude-haiku-4-5","gpt-5.6-sol",@@ -220,6 +221,10 @@ test("context token budget is half of each model's real input room", () => {assert.equal(String(opus55.provider), "anthropic");assert.deepEqual(opus55.cost, { input: 4, output: 20, cacheRead: 0.2, cacheWrite: 5, tiers: undefined });assert.equal(contextTokenBudgetForModel("claude-opus-5-5"), 150_000);+ const sonnet55 = getRequiredModel("claude-sonnet-5-5");+ assert.equal(sonnet55.contextWindow, 1_000_000);+ assert.equal(sonnet55.maxTokens, 128_000);+ assert.deepEqual(sonnet55.cost, { input: 2, output: 10, cacheRead: 0.2, cacheWrite: 2.5, tiers: undefined });assert.equal(getRequiredModel("claude-fable-5").contextWindow, 1_000_000);assert.equal(contextTokenBudgetForModel("claude-fable-5"), 150_000);assert.equal(contextTokenBudgetForModel("gpt-5.6-sol"), 150_000);diff --git a/test/pi-opus-55.test.ts b/test/pi-opus-55.test.tsindex 4cc5d5519..b627c3386 100644--- a/test/pi-opus-55.test.ts+++ b/test/pi-opus-55.test.ts@@ -1,12 +1,16 @@import assert from "node:assert/strict";-import { test } from "node:test";+import { test, type TestContext } from "node:test";import { buildModelRuntime, probeModel } from "../src/harness/pi-harness.ts";-import { getRequiredModel } from "../src/model/pi-models.ts";+import { getRequiredModel, modelSupportsFastMode } from "../src/model/pi-models.ts";const bindingBeta = "thinking-binding-controls-2026-08-01";const context = { messages: [{ role: "user" as const, content: "Reply OK.", timestamp: 0 }] };-test("Opus 5.5 wire requests preserve mandatory thinking, caller hooks and beta headers across Pi entry points", async (t) => {+for (const modelId of ["claude-opus-5-5", "claude-sonnet-5-5"])+ test(`${modelId} wire requests keep mandatory thinking, caller hooks and beta headers across Pi entry points`, (t) =>+ assertMandatoryThinkingWire(t, modelId));++async function assertMandatoryThinkingWire(t: TestContext, modelId: string): Promise<void> {const originalFetch = globalThis.fetch;t.after(() => {globalThis.fetch = originalFetch;@@ -21,7 +25,7 @@ test("Opus 5.5 wire requests preserve mandatory thinking, caller hooks and betaid: "msg_test",type: "message",role: "assistant",- model: "claude-opus-5-5",+ model: modelId,content: [],usage: { input_tokens: 1, output_tokens: 0 },},@@ -36,7 +40,7 @@ test("Opus 5.5 wire requests preserve mandatory thinking, caller hooks and betaheaders: { "content-type": "text/event-stream" },});}) as typeof fetch;- const model = { ...getRequiredModel("claude-opus-5-5", false), headers: { "anthropic-beta": "prior-beta" } };+ const model = { ...getRequiredModel(modelId, false), headers: { "anthropic-beta": "prior-beta" } };const runtime = await buildModelRuntime({ anthropic: "sk-offline-test-key" });for (const effort of [undefined, "low", "xhigh", "max"] as const) {const response = await runtime@@ -65,11 +69,12 @@ test("Opus 5.5 wire requests preserve mandatory thinking, caller hooks and betadisplay: "summarized",block_binding: { prefix_mismatch_behavior: "drop_block" },});- await probeModel(model, { anthropic: "sk-offline-test-key" }, AbortSignal.timeout(10_000), true);- assert.equal(requests.at(-1)!.body.speed, "fast");+ const fast = modelSupportsFastMode(modelId);+ await probeModel(model, { anthropic: "sk-offline-test-key" }, AbortSignal.timeout(10_000), fast);+ assert.equal(requests.at(-1)!.body.speed, fast ? "fast" : undefined);const betas = requests.at(-1)!.headers.get("anthropic-beta")!.split(",");assert.equal(betas.filter((beta) => beta === bindingBeta).length, 1);- assert.ok(betas.includes("fast-mode-2026-02-01"));+ assert.equal(betas.includes("fast-mode-2026-02-01"), fast);assert.deepEqual(model.headers, { "anthropic-beta": "prior-beta" });const gateway = await buildModelRuntime(@@ -94,4 +99,4 @@ test("Opus 5.5 wire requests preserve mandatory thinking, caller hooks and betaconst haiku = requests.at(-1)!;assert.ok(!haiku.headers.get("anthropic-beta")?.includes(bindingBeta));assert.ok(haiku.headers.get("anthropic-beta")?.includes("interleaved-thinking"));-});+}