From 49d05c93bc9dc64d6186097c1a928c531bc2ec55 Mon Sep 17 00:00:00 2001 From: szdziedzic Date: Thu, 26 Nov 2026 12:51:08 +0100 Subject: [PATCH 01/18] feat: add a per-agent effort option for Claude Code passes An agent's frontmatter can now set `effort: low|medium|high|xhigh|max`. The claude-code engine passes it to the `claude` CLI as `--effort`, only for agents that declare it, so other agents and the review-cache key are unchanged. An invalid value is a setup warning and the agent runs at the CLI default; it never stops a review. An agent whose model runs through OpenCode ignores the option, and the review prints one note that names it. Documented in the README, the config template, and LLP 0006. Co-Authored-By: Claude Opus 5.5 --- README.md | 9 ++++ ...config-schema-loading-routing.explainer.md | 24 ++++++++++ src/__tests__/claude-code.test.ts | 38 ++++++++++++++++ src/__tests__/config-load.test.ts | 33 ++++++++++++++ src/config/load.ts | 44 ++++++++++++++++++- src/config/schema.ts | 9 ++++ src/core/claude-code.ts | 37 +++++++++++++++- src/core/review.ts | 8 ++++ templates/config.jsonc | 2 + 9 files changed, 201 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4f97ea28..2575a23e 100644 --- a/README.md +++ b/README.md @@ -521,6 +521,8 @@ alwaysRun: true # Override the default model. model: anthropic/claude-haiku-4-5 temperature: 0.1 +# How much reasoning each pass spends: low, medium, high, xhigh or max. +effort: high paths: ["packages/ios/**", "**/*.swift"] --- @@ -534,6 +536,13 @@ comment (and in the terminal) with the fix, and `ecr doctor` fails on them: frontmatter below an HTML comment, a byte-order mark or blank lines (all its keys are ignored), and a comment that breaks `alwaysRun`, `model` or `temperature`. +`effort` sets how much reasoning the model spends on that agent's passes. Only +models that run through the Claude Code CLI (`anthropic/…`) read it; for any other +model the review prints a note and ignores it. Leave it out to use the CLI default. +A higher level costs more and takes longer, so set it on the agent that needs depth +(a correctness reviewer that must trace callers), not on every agent. A value that +is not a level is listed under **Review setup**, and the agent runs at the default. + `paths` limits an agent to the changes it covers. It takes a list of repo-relative globs in the routing dialect: `*` stays within a directory, `**` crosses directories, and a leading `**/` also matches files at the repo root. Write the diff --git a/llp/0006-config-schema-loading-routing.explainer.md b/llp/0006-config-schema-loading-routing.explainer.md index 989963cc..37019b2a 100644 --- a/llp/0006-config-schema-loading-routing.explainer.md +++ b/llp/0006-config-schema-loading-routing.explainer.md @@ -217,6 +217,30 @@ is letters, digits and underscores joined by single hyphens. An agent without `m `mention` key, so its shape and review-cache key are unchanged [observed: `load.ts` `parseAgentMention`; `schema.ts` `MENTION_TARGET_RE`]. +## Agent Effort + +An agent file may set `effort: low|medium|high|xhigh|max` in its frontmatter. The need came from an +eval replay on one monorepo: a correctness reviewer on an `anthropic/…` model ended a pass after a +median of 8 turns [observed], and a model-written miss analysis put 20 of 55 problems that human +reviewers raised in the class "needs a logic trace" (eval run `full-v2-tune`, 2026-11-25; the data +is private and not in this repo; no person checked the analysis). Depth is a per-agent need, and it costs time and money, so it is a +per-agent key and not a run-level flag. + +- **Only the claude-code engine reads it.** `startClaudeCode` copies the declared levels into + `ClaudeCodeHandle.efforts`, and `runClaudePrompt` passes `--effort ` for that agent's + passes [observed] (`buildClaudeArgs` `effort`; tests in `src/__tests__/claude-code.test.ts`). The + fixed roles (cross-cutting, verifier, coordinator) have no entry and get no flag. The flag exists + in the pinned `@anthropic-ai/claude-code@2.1.280` [observed] (`claude --help`, 2026-11-25). +- **An OpenCode-routed agent ignores it, with a note.** `agentEffortNote` names those agents once + per run, the same way `claudeTemperatureNote` reports a temperature the CLI cannot take. +- **An invalid level never stops a review.** `parseAgentEffort` returns a setup warning with the + fix and no `effort`, so the agent runs at the default. The value is matched after trim and + lower-case, and a trailing `# comment` makes it invalid like any other text. +- **Absent adds no key.** `LoadedAgent.effort` is set only when declared, so a setup without it + keeps its review-cache key, and a setup that adds or changes it gets a fresh review. +- **`REVIEWER_MODEL` does not clear it.** The override can move an agent to a model that runs + through OpenCode; the note then reports the ignored level. + ## Budgets and Chunking Defaults `budget.totalPassesMinutes` defaults to 55, not the scaffolded workflow's full 90-minute timeout, diff --git a/src/__tests__/claude-code.test.ts b/src/__tests__/claude-code.test.ts index 5c25fae2..aa958bc9 100644 --- a/src/__tests__/claude-code.test.ts +++ b/src/__tests__/claude-code.test.ts @@ -7,6 +7,7 @@ import { describe, expect, it, test } from "bun:test"; import { assertClaudeModels, + agentEffortNote, buildClaudeArgs, buildEngineMap, claudeActivities, @@ -820,6 +821,43 @@ test("claudeTokenCredential: resolution order + oat/api-key classification", () expect(claudeTokenCredential(undefined, {})).toBeUndefined(); }); +test("buildClaudeArgs: passes --effort only when a level is given", () => { + const base = { model: "claude-opus-5", system: "SYS", cwd: "/work/repo" }; + expect(buildClaudeArgs(base)).not.toContain("--effort"); + const args = buildClaudeArgs({ ...base, effort: "high" }); + expect(args[args.indexOf("--effort") + 1]).toBe("high"); +}); + +test("runClaudePrompt: an agent's effort reaches its own passes and no other agent's", async () => { + const body = JSON.stringify({ + type: "result", + subtype: "success", + is_error: false, + result: "ok", + }); + const { bin, argsLog, cleanup } = await sequencedFakeClaude([body]); + try { + const handle = testHandle(bin, { efforts: { reviewer: "xhigh" } }); + await runClaudePrompt(handle, { agent: "reviewer", system: "SYS", text: "hi", title: "t" }); + await runClaudePrompt(handle, { agent: "verifier", system: "SYS", text: "hi", title: "t" }); + const reviewer = (await argsLog(1)).split("\n"); + expect(reviewer[reviewer.indexOf("--effort") + 1]).toBe("xhigh"); + expect((await argsLog(2)).split("\n")).not.toContain("--effort"); + } finally { + await cleanup(); + } +}); + +test("agentEffortNote: names the agents whose effort an OpenCode-routed model ignores", () => { + const config = { + agents: [{ id: "a", effort: "high" }, { id: "b", effort: "low" }, { id: "c" }], + } as unknown as LoadedConfig; + expect(agentEffortNote(config, { a: "claude-code", b: "claude-code", c: "opencode" })).toBeNull(); + const note = agentEffortNote(config, { a: "claude-code", b: "opencode", c: "opencode" }); + expect(note).toContain("was ignored for b "); + expect(note).not.toContain("for a"); +}); + test("claudeTemperatureNote: flags non-default temperatures on CLAUDE-ROUTED passes only", () => { const config = (agentTemp: number, coordTemp: number): LoadedConfig => ({ diff --git a/src/__tests__/config-load.test.ts b/src/__tests__/config-load.test.ts index 9bcc8414..790cce08 100644 --- a/src/__tests__/config-load.test.ts +++ b/src/__tests__/config-load.test.ts @@ -299,6 +299,39 @@ test("loadReviewConfig: `includeSuggestions` loads as a floor, with a deprecatio } }); +test("loadReviewConfig: front-matter `effort` loads onto the agent; no `effort` adds no key", async () => { + const root = await configDirWithAgent("---\neffort: High\n---\nIOS"); + try { + const config = await loadReviewConfig(root); + const ios = config.agents.find((agent) => agent.id === "ios")!; + const plain = config.agents.find((agent) => agent.id === "plain")!; + expect(ios.effort).toBe("high"); + // Absent, not undefined: an agent without `effort` keeps its review-cache key. + expect("effort" in plain).toBe(false); + expect("setupWarnings" in config).toBe(false); + } finally { + await rm(root, { recursive: true, force: true }); + } +}); + +test("loadReviewConfig: an invalid `effort` is a warning, and the agent runs at the default", async () => { + for (const line of ["effort: extreme", "effort:", "effort: high # deep trace"]) { + const root = await configDirWithAgent(`---\n${line}\n---\nIOS`); + try { + const config = await loadReviewConfig(root); + const ios = config.agents.find((agent) => agent.id === "ios")!; + expect("effort" in ios, line).toBe(false); + expect(config.setupWarnings, line).toHaveLength(1); + const [warning] = config.setupWarnings!; + expect(warning).toContain(path.join(CONFIG_DIRNAME, "agents", "ios.md")); + expect(warning).toContain("is not an effort level"); + expect(warning).toContain("low, medium, high, xhigh, max"); + } finally { + await rm(root, { recursive: true, force: true }); + } + } +}); + test("loadReviewConfig: front-matter `mention` loads GitHub logins and teams onto the agent", async () => { const root = await configDirWithAgent( '---\nmention:\n - amandeepmittal\n - "@expo/docs"\n---\nIOS', diff --git a/src/config/load.ts b/src/config/load.ts index 29061b3e..ea000d81 100644 --- a/src/config/load.ts +++ b/src/config/load.ts @@ -6,8 +6,13 @@ import { readdir, readFile } from "node:fs/promises"; import { existsSync } from "node:fs"; import path from "node:path"; -import { DEFAULT_MIN_SEVERITY, ReviewConfigSchema, ScopeReviewConfigSchema } from "./schema.js"; -import type { AuthConfigEntry } from "./schema.js"; +import { + AGENT_EFFORT_LEVELS, + DEFAULT_MIN_SEVERITY, + ReviewConfigSchema, + ScopeReviewConfigSchema, +} from "./schema.js"; +import type { AgentEffort, AuthConfigEntry } from "./schema.js"; import type { LoadedAgent, LoadedConfig, @@ -276,6 +281,13 @@ async function loadConfigDir( if (mentionWarning) { setupWarnings.push(mentionWarning); } + const { effort, warning: effortWarning } = parseAgentEffort( + md, + path.join(label, "agents", file), + ); + if (effortWarning) { + setupWarnings.push(effortWarning); + } agents.push({ id, description: md.data.description ?? "", @@ -288,6 +300,7 @@ async function loadConfigDir( // review-cache key) it had before the key existed. ...(paths ? { paths } : {}), ...(mention ? { mention } : {}), + ...(effort ? { effort } : {}), }); } @@ -640,6 +653,33 @@ function parseAgentPaths( return { paths: md.lists.paths }; } +/** + * The agent's `effort` level, or a setup warning that names the fix. A value that is + * not a level is ignored and the agent runs at the default effort; it never fails + * the load. + */ +// @ref LLP 0006#agent-effort [implements] — an invalid level warns and falls back, it never stops a review +function parseAgentEffort( + md: { data: Record }, + file: string, +): { effort?: AgentEffort; warning?: string } { + const raw = md.data.effort; + if (raw === undefined) { + return {}; + } + const value = raw.trim().toLowerCase(); + const effort = AGENT_EFFORT_LEVELS.find((level) => level === value); + if (effort) { + return { effort }; + } + return { + warning: + `${file}: \`effort: ${raw}\` is not an effort level, so the agent runs at the default ` + + `effort. Fix: write one of ${AGENT_EFFORT_LEVELS.join(", ")} with nothing after it ` + + "(a `# comment` goes on its own line), or remove `effort`.", + }; +} + /** * The agent's `mention` list without leading `@`s, or a setup warning that names the * fix. An entry that is not a login or team is left out with a warning, and the diff --git a/src/config/schema.ts b/src/config/schema.ts index 4af1726c..ceeb5ca4 100644 --- a/src/config/schema.ts +++ b/src/config/schema.ts @@ -585,6 +585,10 @@ export const ScopeReviewConfigSchema = ReviewConfigSchema.omit({ export type RawScopeReviewConfig = z.infer; /** A single agent after prompt files are read and models are resolved. */ +/** The effort levels the `claude` CLI takes for `--effort`. */ +export const AGENT_EFFORT_LEVELS = ["low", "medium", "high", "xhigh", "max"] as const; +export type AgentEffort = (typeof AGENT_EFFORT_LEVELS)[number]; + export interface LoadedAgent { id: string; /** One-line summary from frontmatter, used by the router to pick agents. */ @@ -604,6 +608,11 @@ export interface LoadedAgent { * or chunk that has at least one matching changed file. Absent means every change. */ paths?: string[]; + /** + * Frontmatter `effort`: how much reasoning the model spends on this agent's passes. + * Only the claude-code engine reads it. Absent means the CLI's own default. + */ + effort?: AgentEffort; /** * Frontmatter `mention`: GitHub logins or `org/team` slugs. When the agent asks for a * human review, the review comment mentions them. Absent means the agent mentions diff --git a/src/core/claude-code.ts b/src/core/claude-code.ts index 5d9fb734..bc444029 100644 --- a/src/core/claude-code.ts +++ b/src/core/claude-code.ts @@ -3,7 +3,7 @@ import { tmpdir } from "node:os"; import path from "node:path"; -import type { LoadedConfig, McpServerConfig } from "../config/schema.js"; +import type { AgentEffort, LoadedConfig, McpServerConfig } from "../config/schema.js"; import { checkAuthEntry } from "./auth.js"; import { pathInside, resolveOnPath, run } from "./exec.js"; import { assertMcpServerTokenEnvs, mcpGrantEnvironment, mcpServerGrants } from "./mcp-servers.js"; @@ -45,6 +45,11 @@ export interface ClaudeCodeHandle extends OpencodeHandle { * the read-capable subset to the tree. */ tools: Record; + /** + * agent id → frontmatter `effort`, only for the reviewers that declare one. The fixed + * roles (cross-cutting, verifier, coordinator) have no entry and run at the CLI default. + */ + efforts?: Record; /** Default model for cross-cutting/verifier (config.agents[0].model). */ defaultModel: string; /** Absolute `claude` binary (PATH lookup). */ @@ -331,6 +336,8 @@ export function buildClaudeArgs(opts: { mcpServerTools?: readonly string[]; maxTurns?: number; jsonSchema?: Record; + /** `--effort` level. Absent passes no flag, so the CLI default applies. */ + effort?: AgentEffort; }): string[] { // Permission rules are gitignore-style with forward slashes; a Windows cwd // (`C:\Users\dev\repo`) must be normalized or every rule silently matches @@ -363,6 +370,8 @@ export function buildClaudeArgs(opts: { "--verbose", "--model", opts.model, + // @ref LLP 0006#agent-effort [implements] — the flag is passed only for an agent that declares a level + ...(opts.effort ? ["--effort", opts.effort] : []), "--append-system-prompt", opts.system, ...(opts.jsonSchema ? ["--json-schema", JSON.stringify(opts.jsonSchema)] : []), @@ -773,6 +782,24 @@ export function claudeTemperatureNote( : null; } +/** + * A one-time run note when an agent sets `effort` but its model runs through OpenCode: + * only the `claude` CLI takes an effort level, so the setting has no effect there. + * Returns null when every agent with an `effort` is claude-routed. + */ +export function agentEffortNote( + config: LoadedConfig, + engineOf: Record, +): string | null { + const ignored = config.agents + .filter((agent) => agent.effort && engineOf[agent.id] !== CLAUDE_CODE_ENGINE) + .map((agent) => agent.id); + return ignored.length > 0 + ? `\`effort\` is read only by the claude-code engine and was ignored for ${ignored.join(", ")} ` + + "(the model of each runs through OpenCode)" + : null; +} + /** * Preserve actionable process diagnostics without copying arbitrary stderr into a * public Actions log. A non-empty stream may already contain model/tool content, so @@ -876,6 +903,7 @@ export async function runClaudePrompt( mcpServerTools: [...mcpServerTools.keys()], maxTurns, jsonSchema: args.jsonSchema, + ...(handle.efforts?.[args.agent] ? { effort: handle.efforts[args.agent] } : {}), }), { input: args.text, @@ -1289,6 +1317,12 @@ export async function startClaudeCode( // verifier never reads the disk (mirrors the coordinator's empty list). tools[STACK_VERIFIER_AGENT] = []; tools["coordinator"] = []; + const efforts: Record = {}; + for (const agent of config.agents) { + if (agent.effort) { + efforts[agent.id] = agent.effort; + } + } const defaultModel = config.agents[0]?.model ?? config.coordinator.model; const researchAgents = new Set(config.agents.map((agent) => agent.id)); researchAgents.add(CROSS_CUTTING_AGENT); @@ -1311,6 +1345,7 @@ export async function startClaudeCode( engine: CLAUDE_CODE_ENGINE, models, tools, + ...(Object.keys(efforts).length > 0 ? { efforts } : {}), defaultModel, cliPath, childEnv, diff --git a/src/core/review.ts b/src/core/review.ts index 8a103fce..ff19158d 100644 --- a/src/core/review.ts +++ b/src/core/review.ts @@ -32,6 +32,7 @@ import { import type { OpencodeHandle, TokenUsage } from "./opencode.js"; import type { SessionCapture } from "./session-archive.js"; import { + agentEffortNote, buildEngineMap, claudeTemperatureNote, claudeTokenCredential, @@ -594,6 +595,13 @@ export async function runReview( } } + // `effort` reaches only the `claude` CLI. Say so once when an agent sets it on a model + // that runs through OpenCode, so the setting does not fail silently. + const effortNote = agentEffortNote(config, engineOf); + if (effortNote) { + progress(`Note: ${effortNote}`); + } + // Preflight: a model id an engine can't resolve would otherwise fail EVERY pass // routed to it identically — N indistinguishable coverage gaps, after spending the // run's budget rediscovering the same fixable thing. Throw once, up front, naming diff --git a/templates/config.jsonc b/templates/config.jsonc index e0a895a1..7e009ebe 100644 --- a/templates/config.jsonc +++ b/templates/config.jsonc @@ -14,6 +14,8 @@ // e.g. `---\nmodel: anthropic/claude-opus-5-5\n---`. `paths: ["packages/ios/**"]` // there limits an agent to changes that touch those globs, and `mention: [octocat]` // names the people the review mentions when that agent asks for a human review. + // `effort: high` (low, medium, high, xhigh or max) sets how much an `anthropic/…` + // agent reasons; other models ignore it. // @ref LLP 0009#config-and-prompt-templates [implements] — suggestions off by default, not a schema limit "policy": { From da4d940c78f46394a305ecfb6a92a2b1372d22d6 Mon Sep 17 00:00:00 2001 From: szdziedzic Date: Thu, 26 Nov 2026 13:00:19 +0100 Subject: [PATCH 02/18] fix: keep agent effort off fixed-role passes and skipped agents Review of the first version (PR #118) found four problems: - The efforts were a plain object keyed by pass id, so an agent named `constructor` read the inherited Object constructor as its level. They are now a Map. - A reviewer file named after a fixed role (agents/verifier.md) gave its level to the built-in pass of the same id. buildAgentEfforts now gives fixed-role ids no entry, and the run note says to rename the file. - agentEffortNote named agents the run skipped (no engine entry) as OpenCode-routed. It now names only agents whose engine is OpenCode. - The README example set effort on claude-haiku-4-5, which gets no effort from the CLI. The example now uses Opus 5.5, and the README and LLP 0006 say that the model must support effort. Co-Authored-By: Claude Opus 5.5 --- README.md | 7 +- ...config-schema-loading-routing.explainer.md | 18 ++++- src/__tests__/claude-code.test.ts | 42 +++++++++- src/core/claude-code.ts | 81 ++++++++++++++----- 4 files changed, 123 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 2575a23e..b11e19b2 100644 --- a/README.md +++ b/README.md @@ -519,7 +519,7 @@ description: One line the router uses to decide relevance. # Run even when the router would skip this agent. alwaysRun: true # Override the default model. -model: anthropic/claude-haiku-4-5 +model: anthropic/claude-opus-5-5 temperature: 0.1 # How much reasoning each pass spends: low, medium, high, xhigh or max. effort: high @@ -539,9 +539,14 @@ are ignored), and a comment that breaks `alwaysRun`, `model` or `temperature`. `effort` sets how much reasoning the model spends on that agent's passes. Only models that run through the Claude Code CLI (`anthropic/…`) read it; for any other model the review prints a note and ignores it. Leave it out to use the CLI default. +The model must also support effort: the CLI sends no level to a model without +effort support (Claude Haiku 4.5 is one), and ecr does not check this. A higher level costs more and takes longer, so set it on the agent that needs depth (a correctness reviewer that must trace callers), not on every agent. A value that is not a level is listed under **Review setup**, and the agent runs at the default. +An agent file in `agents/` named after a built-in pass (`verifier.md`, +`cross-cutting.md`, `adjudicator.md`, `stack-verifier.md` or `coordinator.md`) gets +no effort; the review note says to rename it. `paths` limits an agent to the changes it covers. It takes a list of repo-relative globs in the routing dialect: `*` stays within a directory, `**` crosses diff --git a/llp/0006-config-schema-loading-routing.explainer.md b/llp/0006-config-schema-loading-routing.explainer.md index 37019b2a..1d601924 100644 --- a/llp/0006-config-schema-loading-routing.explainer.md +++ b/llp/0006-config-schema-loading-routing.explainer.md @@ -229,10 +229,22 @@ per-agent key and not a run-level flag. - **Only the claude-code engine reads it.** `startClaudeCode` copies the declared levels into `ClaudeCodeHandle.efforts`, and `runClaudePrompt` passes `--effort ` for that agent's passes [observed] (`buildClaudeArgs` `effort`; tests in `src/__tests__/claude-code.test.ts`). The - fixed roles (cross-cutting, verifier, coordinator) have no entry and get no flag. The flag exists - in the pinned `@anthropic-ai/claude-code@2.1.280` [observed] (`claude --help`, 2026-11-25). + fixed roles (cross-cutting, verifier, adjudicator, stack verifier, coordinator) have no entry and + get no flag. The flag exists in the pinned `@anthropic-ai/claude-code@2.1.280` [observed] + (`claude --help`, 2026-11-25). +- **The levels are keyed by pass id, so fixed-role ids are excluded.** Passes are looked up by + agent id, and a reviewer file can share a fixed role's id (`agents/verifier.md`). With an entry, + its level would also reach the built-in pass of that id. `buildAgentEfforts` gives such a + reviewer no entry, and the run note tells the author to rename the file. The levels live in a + `Map`, so an id such as `constructor` cannot read an inherited `Object.prototype` value + (both found in review of the first version, PR #118). - **An OpenCode-routed agent ignores it, with a note.** `agentEffortNote` names those agents once - per run, the same way `claudeTemperatureNote` reports a temperature the CLI cannot take. + per run, the same way `claudeTemperatureNote` reports a temperature the CLI cannot take. It names + only agents whose engine in this run is OpenCode; an agent the run skipped is not named. +- **The model must support effort.** The CLI accepts every level for every model, but a model + without effort support gets none: a request from the pinned CLI to `claude-haiku-4-5` with + `--effort high` carried no effort field, and one to `claude-opus-5-5` did (seen in review of PR + #118 against a local mock endpoint, not re-run here). The engine does not check model support. - **An invalid level never stops a review.** `parseAgentEffort` returns a setup warning with the fix and no `effort`, so the agent runs at the default. The value is matched after trim and lower-case, and a trailing `# comment` makes it invalid like any other text. diff --git a/src/__tests__/claude-code.test.ts b/src/__tests__/claude-code.test.ts index aa958bc9..e1f13078 100644 --- a/src/__tests__/claude-code.test.ts +++ b/src/__tests__/claude-code.test.ts @@ -8,6 +8,7 @@ import { describe, expect, it, test } from "bun:test"; import { assertClaudeModels, agentEffortNote, + buildAgentEfforts, buildClaudeArgs, buildEngineMap, claudeActivities, @@ -837,17 +838,41 @@ test("runClaudePrompt: an agent's effort reaches its own passes and no other age }); const { bin, argsLog, cleanup } = await sequencedFakeClaude([body]); try { - const handle = testHandle(bin, { efforts: { reviewer: "xhigh" } }); + // A real run gives every reviewer its own models/tools entry (buildEngineMap); + // only `efforts` lacks one for an agent that sets no level. + const handle = testHandle(bin, { + models: { reviewer: "anthropic/claude-opus-5", constructor: "anthropic/claude-opus-5" }, + tools: { reviewer: ["read", "grep", "glob"], constructor: ["read", "grep", "glob"] }, + efforts: new Map([["reviewer", "xhigh"]]), + }); await runClaudePrompt(handle, { agent: "reviewer", system: "SYS", text: "hi", title: "t" }); await runClaudePrompt(handle, { agent: "verifier", system: "SYS", text: "hi", title: "t" }); + // An id that names an Object.prototype member must not read an inherited value. + await runClaudePrompt(handle, { agent: "constructor", system: "SYS", text: "hi", title: "t" }); const reviewer = (await argsLog(1)).split("\n"); expect(reviewer[reviewer.indexOf("--effort") + 1]).toBe("xhigh"); expect((await argsLog(2)).split("\n")).not.toContain("--effort"); + expect((await argsLog(3)).split("\n")).not.toContain("--effort"); } finally { await cleanup(); } }); +test("buildAgentEfforts: no entry for a reviewer that shares a fixed role's id", () => { + const config = { + agents: [ + { id: "correctness", effort: "high" }, + { id: "verifier", effort: "max" }, + { id: "cross-cutting", effort: "max" }, + { id: "coordinator", effort: "max" }, + { id: "constructor" }, + ], + } as unknown as LoadedConfig; + const efforts = buildAgentEfforts(config); + expect([...efforts]).toEqual([["correctness", "high"]]); + expect(efforts.get("constructor")).toBeUndefined(); +}); + test("agentEffortNote: names the agents whose effort an OpenCode-routed model ignores", () => { const config = { agents: [{ id: "a", effort: "high" }, { id: "b", effort: "low" }, { id: "c" }], @@ -858,6 +883,21 @@ test("agentEffortNote: names the agents whose effort an OpenCode-routed model ig expect(note).not.toContain("for a"); }); +test("agentEffortNote: an agent this run skipped is not named", () => { + const config = { + agents: [{ id: "a", effort: "high" }, { id: "ios", effort: "high" }], + } as unknown as LoadedConfig; + // `ios` was filtered out by its `paths`, so the run's engine map has no entry for it. + expect(agentEffortNote(config, { a: "claude-code" })).toBeNull(); +}); + +test("agentEffortNote: a reviewer that shares a fixed role's id is told to rename", () => { + const config = { agents: [{ id: "verifier", effort: "max" }] } as unknown as LoadedConfig; + const note = agentEffortNote(config, { verifier: "opencode" }); + expect(note).toContain("was ignored for verifier: the id is also a built-in pass"); + expect(note).not.toContain("runs through OpenCode"); +}); + test("claudeTemperatureNote: flags non-default temperatures on CLAUDE-ROUTED passes only", () => { const config = (agentTemp: number, coordTemp: number): LoadedConfig => ({ diff --git a/src/core/claude-code.ts b/src/core/claude-code.ts index bc444029..4127be28 100644 --- a/src/core/claude-code.ts +++ b/src/core/claude-code.ts @@ -46,10 +46,11 @@ export interface ClaudeCodeHandle extends OpencodeHandle { */ tools: Record; /** - * agent id → frontmatter `effort`, only for the reviewers that declare one. The fixed - * roles (cross-cutting, verifier, coordinator) have no entry and run at the CLI default. + * agent id → frontmatter `effort`, only for the reviewers that declare one + * (buildAgentEfforts). The fixed roles (cross-cutting, verifier, adjudicator, stack + * verifier, coordinator) have no entry and run at the CLI default. */ - efforts?: Record; + efforts?: ReadonlyMap; /** Default model for cross-cutting/verifier (config.agents[0].model). */ defaultModel: string; /** Absolute `claude` binary (PATH lookup). */ @@ -783,21 +784,64 @@ export function claudeTemperatureNote( } /** - * A one-time run note when an agent sets `effort` but its model runs through OpenCode: - * only the `claude` CLI takes an effort level, so the setting has no effect there. - * Returns null when every agent with an `effort` is claude-routed. + * Ids the engine dispatches its fixed passes under. A reviewer file can share one + * (agents/verifier.md); its `effort` must not reach the built-in pass of that id. + */ +const FIXED_ROLE_IDS: ReadonlySet = new Set([ + CROSS_CUTTING_AGENT, + VERIFIER_AGENT, + ADJUDICATOR_AGENT, + STACK_VERIFIER_AGENT, + "coordinator", +]); + +/** + * agent id → frontmatter `effort`, for the reviewers that declare one. A reviewer whose + * id is also a fixed role's id gets no entry: passes are looked up by id, so its level + * would otherwise apply to the built-in pass as well. + */ +// @ref LLP 0006#agent-effort [implements] — the fixed roles always run at the CLI default +export function buildAgentEfforts(config: LoadedConfig): Map { + const efforts = new Map(); + for (const agent of config.agents) { + if (agent.effort && !FIXED_ROLE_IDS.has(agent.id)) { + efforts.set(agent.id, agent.effort); + } + } + return efforts; +} + +/** + * A one-time run note for an `effort` that has no effect: the agent's model runs + * through OpenCode (only the `claude` CLI takes an effort level), or the agent's id is + * also a fixed role's id. An agent this run skipped has no `engineOf` entry and is not + * named. Returns null when every declared `effort` applies. */ export function agentEffortNote( config: LoadedConfig, engineOf: Record, ): string | null { - const ignored = config.agents - .filter((agent) => agent.effort && engineOf[agent.id] !== CLAUDE_CODE_ENGINE) + const declared = config.agents.filter((agent) => agent.effort); + const viaOpencode = declared + .filter((agent) => !FIXED_ROLE_IDS.has(agent.id) && engineOf[agent.id] === "opencode") .map((agent) => agent.id); - return ignored.length > 0 - ? `\`effort\` is read only by the claude-code engine and was ignored for ${ignored.join(", ")} ` + - "(the model of each runs through OpenCode)" - : null; + const fixedRole = declared + .filter((agent) => FIXED_ROLE_IDS.has(agent.id)) + .map((agent) => agent.id); + const notes: string[] = []; + if (viaOpencode.length > 0) { + notes.push( + `\`effort\` is read only by the claude-code engine and was ignored for ${viaOpencode.join(", ")} ` + + "(the model of each runs through OpenCode)", + ); + } + if (fixedRole.length > 0) { + notes.push( + `\`effort\` was ignored for ${fixedRole.join(", ")}: the id is also a built-in pass, which ` + + "runs at the default effort. Fix: rename the agent file", + ); + } + return notes.length > 0 ? notes.join("; ") : null; } /** @@ -885,6 +929,8 @@ export async function runClaudePrompt( }, CLAUDE_HEARTBEAT_MS) : undefined; heartbeat?.unref?.(); + // A Map lookup: an agent id such as `constructor` must not read an inherited value. + const effort = handle.efforts?.get(args.agent); let result; try { result = await run( @@ -903,7 +949,7 @@ export async function runClaudePrompt( mcpServerTools: [...mcpServerTools.keys()], maxTurns, jsonSchema: args.jsonSchema, - ...(handle.efforts?.[args.agent] ? { effort: handle.efforts[args.agent] } : {}), + ...(effort ? { effort } : {}), }), { input: args.text, @@ -1317,12 +1363,7 @@ export async function startClaudeCode( // verifier never reads the disk (mirrors the coordinator's empty list). tools[STACK_VERIFIER_AGENT] = []; tools["coordinator"] = []; - const efforts: Record = {}; - for (const agent of config.agents) { - if (agent.effort) { - efforts[agent.id] = agent.effort; - } - } + const efforts = buildAgentEfforts(config); const defaultModel = config.agents[0]?.model ?? config.coordinator.model; const researchAgents = new Set(config.agents.map((agent) => agent.id)); researchAgents.add(CROSS_CUTTING_AGENT); @@ -1345,7 +1386,7 @@ export async function startClaudeCode( engine: CLAUDE_CODE_ENGINE, models, tools, - ...(Object.keys(efforts).length > 0 ? { efforts } : {}), + ...(efforts.size > 0 ? { efforts } : {}), defaultModel, cliPath, childEnv, From c28e3eb15ea2efc300d7132f33fb8f948d69dced Mon Sep 17 00:00:00 2001 From: szdziedzic Date: Thu, 26 Nov 2026 13:09:46 +0100 Subject: [PATCH 03/18] fix: report ignored effort only for reviewers that run Second review of PR #118: - The effort note ran before the paths filter and the router, so it could name a reviewer that never ran. agentEffortNote now takes the final reviewer list, and runReview calls it after routing. - The fixed-role ids are now the session archive's NON_REVIEWER_AGENTS, so the two lists cannot drift. The test covers all five ids, and the rename test checks the "Fix: rename the agent file" text. - The config template says the model must support effort. - Format the new test with oxfmt (fmt:check failed in CI). Co-Authored-By: Claude Opus 5.5 --- ...config-schema-loading-routing.explainer.md | 8 ++-- src/__tests__/claude-code.test.ts | 38 ++++++++++--------- src/core/claude-code.ts | 26 ++++++------- src/core/review.ts | 15 ++++---- templates/config.jsonc | 3 +- 5 files changed, 47 insertions(+), 43 deletions(-) diff --git a/llp/0006-config-schema-loading-routing.explainer.md b/llp/0006-config-schema-loading-routing.explainer.md index 1d601924..c83e8be3 100644 --- a/llp/0006-config-schema-loading-routing.explainer.md +++ b/llp/0006-config-schema-loading-routing.explainer.md @@ -235,12 +235,14 @@ per-agent key and not a run-level flag. - **The levels are keyed by pass id, so fixed-role ids are excluded.** Passes are looked up by agent id, and a reviewer file can share a fixed role's id (`agents/verifier.md`). With an entry, its level would also reach the built-in pass of that id. `buildAgentEfforts` gives such a - reviewer no entry, and the run note tells the author to rename the file. The levels live in a + reviewer no entry, and the run note tells the author to rename the file. The id set is the + session archive's `NON_REVIEWER_AGENTS`, so the two cannot drift. The levels live in a `Map`, so an id such as `constructor` cannot read an inherited `Object.prototype` value (both found in review of the first version, PR #118). - **An OpenCode-routed agent ignores it, with a note.** `agentEffortNote` names those agents once - per run, the same way `claudeTemperatureNote` reports a temperature the CLI cannot take. It names - only agents whose engine in this run is OpenCode; an agent the run skipped is not named. + per run, the same way `claudeTemperatureNote` reports a temperature the CLI cannot take. + `runReview` builds it from the final reviewer list, after the `paths` filter and the router, so + an agent that does not run in the review is never named. - **The model must support effort.** The CLI accepts every level for every model, but a model without effort support gets none: a request from the pinned CLI to `claude-haiku-4-5` with `--effort high` carried no effort field, and one to `claude-opus-5-5` did (seen in review of PR diff --git a/src/__tests__/claude-code.test.ts b/src/__tests__/claude-code.test.ts index e1f13078..e36654ef 100644 --- a/src/__tests__/claude-code.test.ts +++ b/src/__tests__/claude-code.test.ts @@ -39,7 +39,7 @@ import { import type { OpencodeHandle } from "../core/opencode.js"; import { parseReviewerOutput } from "../core/schema.js"; import { RateLimitWatch } from "../core/throttle.js"; -import type { AuthConfigEntry, LoadedConfig } from "../config/schema.js"; +import type { AuthConfigEntry, LoadedAgent, LoadedConfig } from "../config/schema.js"; const entry = (over: Partial): AuthConfigEntry => ({ provider: "anthropic", @@ -859,12 +859,11 @@ test("runClaudePrompt: an agent's effort reaches its own passes and no other age }); test("buildAgentEfforts: no entry for a reviewer that shares a fixed role's id", () => { + const fixedRoles = ["coordinator", "verifier", "cross-cutting", "adjudicator", "stack-verifier"]; const config = { agents: [ { id: "correctness", effort: "high" }, - { id: "verifier", effort: "max" }, - { id: "cross-cutting", effort: "max" }, - { id: "coordinator", effort: "max" }, + ...fixedRoles.map((id) => ({ id, effort: "max" })), { id: "constructor" }, ], } as unknown as LoadedConfig; @@ -874,27 +873,32 @@ test("buildAgentEfforts: no entry for a reviewer that shares a fixed role's id", }); test("agentEffortNote: names the agents whose effort an OpenCode-routed model ignores", () => { - const config = { - agents: [{ id: "a", effort: "high" }, { id: "b", effort: "low" }, { id: "c" }], - } as unknown as LoadedConfig; - expect(agentEffortNote(config, { a: "claude-code", b: "claude-code", c: "opencode" })).toBeNull(); - const note = agentEffortNote(config, { a: "claude-code", b: "opencode", c: "opencode" }); + const agents = [ + { id: "a", effort: "high" }, + { id: "b", effort: "low" }, + { id: "c" }, + ] as unknown as LoadedAgent[]; + expect(agentEffortNote(agents, { a: "claude-code", b: "claude-code", c: "opencode" })).toBeNull(); + const note = agentEffortNote(agents, { a: "claude-code", b: "opencode", c: "opencode" }); expect(note).toContain("was ignored for b "); expect(note).not.toContain("for a"); }); -test("agentEffortNote: an agent this run skipped is not named", () => { - const config = { - agents: [{ id: "a", effort: "high" }, { id: "ios", effort: "high" }], - } as unknown as LoadedConfig; - // `ios` was filtered out by its `paths`, so the run's engine map has no entry for it. - expect(agentEffortNote(config, { a: "claude-code" })).toBeNull(); +test("agentEffortNote: an agent that does not run in this review is not named", () => { + // The caller passes the reviewers left after the `paths` filter and the router. Here + // `ios` (OpenCode) was routed out and agents/verifier.md was excluded by its paths, + // although the engine map still has entries for both ids. + const selected = [{ id: "alpha", effort: "high" }] as unknown as LoadedAgent[]; + expect( + agentEffortNote(selected, { alpha: "claude-code", ios: "opencode", verifier: "claude-code" }), + ).toBeNull(); }); test("agentEffortNote: a reviewer that shares a fixed role's id is told to rename", () => { - const config = { agents: [{ id: "verifier", effort: "max" }] } as unknown as LoadedConfig; - const note = agentEffortNote(config, { verifier: "opencode" }); + const agents = [{ id: "verifier", effort: "max" }] as unknown as LoadedAgent[]; + const note = agentEffortNote(agents, { verifier: "opencode" }); expect(note).toContain("was ignored for verifier: the id is also a built-in pass"); + expect(note).toContain("Fix: rename the agent file"); expect(note).not.toContain("runs through OpenCode"); }); diff --git a/src/core/claude-code.ts b/src/core/claude-code.ts index 4127be28..236f0408 100644 --- a/src/core/claude-code.ts +++ b/src/core/claude-code.ts @@ -3,7 +3,7 @@ import { tmpdir } from "node:os"; import path from "node:path"; -import type { AgentEffort, LoadedConfig, McpServerConfig } from "../config/schema.js"; +import type { AgentEffort, LoadedAgent, LoadedConfig, McpServerConfig } from "../config/schema.js"; import { checkAuthEntry } from "./auth.js"; import { pathInside, resolveOnPath, run } from "./exec.js"; import { assertMcpServerTokenEnvs, mcpGrantEnvironment, mcpServerGrants } from "./mcp-servers.js"; @@ -19,7 +19,7 @@ import { withTransientRetry, } from "./opencode.js"; import type { OpencodeHandle, PromptResult, TokenUsage } from "./opencode.js"; -import { buildClaudeSessionExport } from "./session-archive.js"; +import { buildClaudeSessionExport, NON_REVIEWER_AGENTS } from "./session-archive.js"; import { RateLimitWatch } from "./throttle.js"; import { CLAUDE_RESEARCH_TOOLS } from "./research.js"; import type { ResearchMcpRuntime } from "./research.js"; @@ -784,16 +784,11 @@ export function claudeTemperatureNote( } /** - * Ids the engine dispatches its fixed passes under. A reviewer file can share one - * (agents/verifier.md); its `effort` must not reach the built-in pass of that id. + * Ids the engine dispatches its fixed passes under (the same set the session archive + * uses). A reviewer file can share one (agents/verifier.md); its `effort` must not + * reach the built-in pass of that id. */ -const FIXED_ROLE_IDS: ReadonlySet = new Set([ - CROSS_CUTTING_AGENT, - VERIFIER_AGENT, - ADJUDICATOR_AGENT, - STACK_VERIFIER_AGENT, - "coordinator", -]); +const FIXED_ROLE_IDS: ReadonlySet = NON_REVIEWER_AGENTS; /** * agent id → frontmatter `effort`, for the reviewers that declare one. A reviewer whose @@ -814,14 +809,15 @@ export function buildAgentEfforts(config: LoadedConfig): Map, ): string | null { - const declared = config.agents.filter((agent) => agent.effort); + const declared = agents.filter((agent) => agent.effort); const viaOpencode = declared .filter((agent) => !FIXED_ROLE_IDS.has(agent.id) && engineOf[agent.id] === "opencode") .map((agent) => agent.id); diff --git a/src/core/review.ts b/src/core/review.ts index ff19158d..867fa2bb 100644 --- a/src/core/review.ts +++ b/src/core/review.ts @@ -595,13 +595,6 @@ export async function runReview( } } - // `effort` reaches only the `claude` CLI. Say so once when an agent sets it on a model - // that runs through OpenCode, so the setting does not fail silently. - const effortNote = agentEffortNote(config, engineOf); - if (effortNote) { - progress(`Note: ${effortNote}`); - } - // Preflight: a model id an engine can't resolve would otherwise fail EVERY pass // routed to it identically — N indistinguishable coverage gaps, after spending the // run's budget rediscovering the same fixable thing. Throw once, up front, naming @@ -722,6 +715,14 @@ export async function runReview( .filter((agent) => !selectedAgents.includes(agent)) .map((agent) => agent.id); + // `effort` reaches only the `claude` CLI, and never a fixed pass. Say so once for an + // agent that runs in this review and whose level has no effect, so the setting does + // not fail silently. After routing, so an agent that does not run is not named. + const effortNote = agentEffortNote(selectedAgents, engineOf); + if (effortNote) { + progress(`Note: ${effortNote}`); + } + // Split the diff into focused chunks so each reviewer call sees a small file // set (better recall than one giant blob), and run all agent×chunk calls // concurrently up to a cap. diff --git a/templates/config.jsonc b/templates/config.jsonc index 7e009ebe..d9e396b0 100644 --- a/templates/config.jsonc +++ b/templates/config.jsonc @@ -15,7 +15,8 @@ // there limits an agent to changes that touch those globs, and `mention: [octocat]` // names the people the review mentions when that agent asks for a human review. // `effort: high` (low, medium, high, xhigh or max) sets how much an `anthropic/…` - // agent reasons; other models ignore it. + // agent reasons, on a model that supports effort (Haiku 4.5 does not); other models + // ignore it. // @ref LLP 0009#config-and-prompt-templates [implements] — suggestions off by default, not a schema limit "policy": { From 9f9f0cd47b944605aa1bd041d0da0e05aff247da Mon Sep 17 00:00:00 2001 From: szdziedzic Date: Thu, 26 Nov 2026 13:22:41 +0100 Subject: [PATCH 04/18] refactor: select reviewers in one tested step that owns the effort note Devin review of c28e3eb: - The rule "build the effort note after routing" had no @ref at its call site, and no test drove runReview's order: a test of agentEffortNote with a pre-filtered list would still pass if runReview built the note before routing. - Move reviewer selection (paths-filtered candidates, the optional router, the effort note) into selectReviewers, which runReview calls. Tests drive it with a stand-in router: a routed-out OpenCode reviewer and a path-excluded agents/verifier.md are not named, and a running OpenCode reviewer is. Building the note from the candidates instead makes the first test fail. Co-Authored-By: Claude Opus 5.5 --- ...config-schema-loading-routing.explainer.md | 4 +- src/__tests__/review-internals.test.ts | 46 ++++++++++- src/core/review.ts | 77 +++++++++++++------ 3 files changed, 99 insertions(+), 28 deletions(-) diff --git a/llp/0006-config-schema-loading-routing.explainer.md b/llp/0006-config-schema-loading-routing.explainer.md index c83e8be3..4d199319 100644 --- a/llp/0006-config-schema-loading-routing.explainer.md +++ b/llp/0006-config-schema-loading-routing.explainer.md @@ -241,8 +241,8 @@ per-agent key and not a run-level flag. (both found in review of the first version, PR #118). - **An OpenCode-routed agent ignores it, with a note.** `agentEffortNote` names those agents once per run, the same way `claudeTemperatureNote` reports a temperature the CLI cannot take. - `runReview` builds it from the final reviewer list, after the `paths` filter and the router, so - an agent that does not run in the review is never named. + `selectReviewers`, which `runReview` calls, builds it from the final reviewer list, after the + `paths` filter and the router, so an agent that does not run in the review is never named. - **The model must support effort.** The CLI accepts every level for every model, but a model without effort support gets none: a request from the pinned CLI to `claude-haiku-4-5` with `--effort high` carried no effort field, and one to `claude-opus-5-5` did (seen in review of PR diff --git a/src/__tests__/review-internals.test.ts b/src/__tests__/review-internals.test.ts index 0d4275cb..88cdf32a 100644 --- a/src/__tests__/review-internals.test.ts +++ b/src/__tests__/review-internals.test.ts @@ -26,6 +26,7 @@ import { attachVerifierRejected, exportReviewSessions, runReview, + selectReviewers, } from "../core/review.js"; import type { AgentSummaryParts, ReviewRunOptions } from "../core/review.js"; import { resolveOpencodeCli } from "../core/opencode.js"; @@ -38,7 +39,7 @@ import { REVIEW_TRACE_BYTES_LIMIT, fingerprintFinding, } from "../core/schema.js"; -import type { LoadedConfig } from "../config/schema.js"; +import type { LoadedAgent, LoadedConfig } from "../config/schema.js"; import type { PatchWorkspaceFile } from "../core/noise.js"; import type { CoordinatorOutput, Finding, Severity } from "../core/schema.js"; @@ -929,3 +930,46 @@ describe("Exporting OpenCode sessions before the review closes", () => { expect(log).toEqual(["session store: export failed: the database is locked"]); }); }); + +describe("selectReviewers: the effort note names only reviewers that run", () => { + const alpha = { id: "alpha", effort: "high" } as unknown as LoadedAgent; + const ios = { id: "ios", effort: "high" } as unknown as LoadedAgent; + const engineOf = { alpha: "claude-code", ios: "opencode", verifier: "claude-code" } as const; + + it("does not name an OpenCode reviewer the router left out", async () => { + const lines: string[] = []; + const result = await selectReviewers({ + candidates: [alpha, ios], + route: async () => ({ agents: [alpha], routed: true }), + engineOf, + progress: (line) => lines.push(line), + }); + expect(result.selectedAgents.map((a) => a.id)).toEqual(["alpha"]); + expect(result.notRouted).toEqual(["ios"]); + expect(lines).toContain("Router selected: alpha"); + expect(lines.some((line) => line.includes("effort"))).toBe(false); + }); + + it("names an OpenCode reviewer that runs", async () => { + const lines: string[] = []; + await selectReviewers({ + candidates: [alpha, ios], + engineOf, + progress: (line) => lines.push(line), + }); + const note = lines.find((line) => line.startsWith("Note: `effort`")); + expect(note).toContain("was ignored for ios "); + }); + + it("does not tell a path-excluded agents/verifier.md to rename", async () => { + // The engine map always has the built-in verifier, but the reviewer file did not + // pass its `paths` filter, so it is not a candidate. + const lines: string[] = []; + await selectReviewers({ + candidates: [alpha], + engineOf, + progress: (line) => lines.push(line), + }); + expect(lines.some((line) => line.includes("effort"))).toBe(false); + }); +}); diff --git a/src/core/review.ts b/src/core/review.ts index 867fa2bb..e01e90c4 100644 --- a/src/core/review.ts +++ b/src/core/review.ts @@ -38,8 +38,9 @@ import { claudeTokenCredential, startClaudeCode, } from "./claude-code.js"; -import type { ClaudeCodeHandle } from "./claude-code.js"; +import type { ClaudeCodeHandle, Engine } from "./claude-code.js"; import { routeAgents } from "./router.js"; +import type { RouteResult } from "./router.js"; import { changedPaths, formatSkippedAgents, @@ -698,30 +699,19 @@ export async function runReview( // Resolve which agents run: an explicit list wins; otherwise route (LLM picks // relevant agents + always-run) when asked, else all. Routing chooses only among // the agents the `paths` filter kept. - let selectedAgents = pathsSelection.agents; - if (!explicitAgents && options.route) { - progress("Routing: selecting relevant agents…"); - const routed = await routeAgents(handle, pathsSelection.agents, workspace.files, (line) => - progress(formatAgentActivity("router", "router", line)), - ); - selectedAgents = routed.agents; - progress( - routed.routed - ? `Router selected: ${selectedAgents.map((a) => a.id).join(", ")}` - : "Router unavailable; running all agents.", - ); - } - const notRouted = pathsSelection.agents - .filter((agent) => !selectedAgents.includes(agent)) - .map((agent) => agent.id); - - // `effort` reaches only the `claude` CLI, and never a fixed pass. Say so once for an - // agent that runs in this review and whose level has no effect, so the setting does - // not fail silently. After routing, so an agent that does not run is not named. - const effortNote = agentEffortNote(selectedAgents, engineOf); - if (effortNote) { - progress(`Note: ${effortNote}`); - } + const { selectedAgents, notRouted } = await selectReviewers({ + candidates: pathsSelection.agents, + ...(!explicitAgents && options.route + ? { + route: () => + routeAgents(handle, pathsSelection.agents, workspace.files, (line) => + progress(formatAgentActivity("router", "router", line)), + ), + } + : {}), + engineOf, + progress, + }); // Split the diff into focused chunks so each reviewer call sees a small file // set (better recall than one giant blob), and run all agent×chunk calls @@ -2369,6 +2359,43 @@ export function decisionAfterGrounding( : previous; } +/** + * Resolve which reviewers run, then report an `effort` that has no effect on them. + * `candidates` are the agents the `paths` filter kept; `route`, when given, picks among + * them (the LLM router in a review, a stand-in in tests). Exported for tests. + */ +export async function selectReviewers(args: { + candidates: LoadedAgent[]; + route?: () => Promise; + engineOf: Record; + progress: (line: string) => void; +}): Promise<{ selectedAgents: LoadedAgent[]; notRouted: string[] }> { + let selectedAgents = args.candidates; + if (args.route) { + args.progress("Routing: selecting relevant agents…"); + const routed = await args.route(); + selectedAgents = routed.agents; + args.progress( + routed.routed + ? `Router selected: ${selectedAgents.map((a) => a.id).join(", ")}` + : "Router unavailable; running all agents.", + ); + } + const notRouted = args.candidates + .filter((agent) => !selectedAgents.includes(agent)) + .map((agent) => agent.id); + + // `effort` reaches only the `claude` CLI, and never a fixed pass. Say so once for an + // agent that runs in this review and whose level has no effect, so the setting does + // not fail silently. + // @ref LLP 0006#agent-effort [implements] — built from the final reviewer list, after the paths filter and the router, so an agent that does not run is never named + const effortNote = agentEffortNote(selectedAgents, args.engineOf); + if (effortNote) { + args.progress(`Note: ${effortNote}`); + } + return { selectedAgents, notRouted }; +} + /** * The coordinator writes its summary before findings are verified/suppressed, so a * post-coordination drop can leave the summary referencing issues no longer shown. From 48d8f54d1003a7156457e8af878c939ea0dc960e Mon Sep 17 00:00:00 2001 From: szdziedzic Date: Thu, 26 Nov 2026 13:29:35 +0100 Subject: [PATCH 05/18] fix: word the effort note as a fact about the setup Astra review of 9f9f0cd: a blocking pre-check or the budget can skip a reviewer after selectReviewers named it, so "effort was ignored for X" could describe a pass that never ran. The note now says "has no effect for X", which is true whether or not X runs, and the doc comment and LLP 0006 no longer claim that an agent that does not run is never named. Co-Authored-By: Claude Opus 5.5 --- ...-config-schema-loading-routing.explainer.md | 6 ++++-- src/__tests__/claude-code.test.ts | 4 ++-- src/__tests__/review-internals.test.ts | 2 +- src/core/claude-code.ts | 18 ++++++++++-------- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/llp/0006-config-schema-loading-routing.explainer.md b/llp/0006-config-schema-loading-routing.explainer.md index 4d199319..99c99e1d 100644 --- a/llp/0006-config-schema-loading-routing.explainer.md +++ b/llp/0006-config-schema-loading-routing.explainer.md @@ -241,8 +241,10 @@ per-agent key and not a run-level flag. (both found in review of the first version, PR #118). - **An OpenCode-routed agent ignores it, with a note.** `agentEffortNote` names those agents once per run, the same way `claudeTemperatureNote` reports a temperature the CLI cannot take. - `selectReviewers`, which `runReview` calls, builds it from the final reviewer list, after the - `paths` filter and the router, so an agent that does not run in the review is never named. + `selectReviewers`, which `runReview` calls, builds it from the selected reviewer list, after the + `paths` filter and the router, so an agent either of them left out is never named. A later step + (a blocking pre-check, the budget) can still skip a named agent, so the note states a fact about + the setup ("has no effect for X"), not about a pass that ran. - **The model must support effort.** The CLI accepts every level for every model, but a model without effort support gets none: a request from the pinned CLI to `claude-haiku-4-5` with `--effort high` carried no effort field, and one to `claude-opus-5-5` did (seen in review of PR diff --git a/src/__tests__/claude-code.test.ts b/src/__tests__/claude-code.test.ts index e36654ef..652202be 100644 --- a/src/__tests__/claude-code.test.ts +++ b/src/__tests__/claude-code.test.ts @@ -880,7 +880,7 @@ test("agentEffortNote: names the agents whose effort an OpenCode-routed model ig ] as unknown as LoadedAgent[]; expect(agentEffortNote(agents, { a: "claude-code", b: "claude-code", c: "opencode" })).toBeNull(); const note = agentEffortNote(agents, { a: "claude-code", b: "opencode", c: "opencode" }); - expect(note).toContain("was ignored for b "); + expect(note).toContain("has no effect for b:"); expect(note).not.toContain("for a"); }); @@ -897,7 +897,7 @@ test("agentEffortNote: an agent that does not run in this review is not named", test("agentEffortNote: a reviewer that shares a fixed role's id is told to rename", () => { const agents = [{ id: "verifier", effort: "max" }] as unknown as LoadedAgent[]; const note = agentEffortNote(agents, { verifier: "opencode" }); - expect(note).toContain("was ignored for verifier: the id is also a built-in pass"); + expect(note).toContain("has no effect for verifier: the id is also a built-in pass"); expect(note).toContain("Fix: rename the agent file"); expect(note).not.toContain("runs through OpenCode"); }); diff --git a/src/__tests__/review-internals.test.ts b/src/__tests__/review-internals.test.ts index 88cdf32a..bca904e4 100644 --- a/src/__tests__/review-internals.test.ts +++ b/src/__tests__/review-internals.test.ts @@ -958,7 +958,7 @@ describe("selectReviewers: the effort note names only reviewers that run", () => progress: (line) => lines.push(line), }); const note = lines.find((line) => line.startsWith("Note: `effort`")); - expect(note).toContain("was ignored for ios "); + expect(note).toContain("has no effect for ios:"); }); it("does not tell a path-excluded agents/verifier.md to rename", async () => { diff --git a/src/core/claude-code.ts b/src/core/claude-code.ts index 236f0408..3d434814 100644 --- a/src/core/claude-code.ts +++ b/src/core/claude-code.ts @@ -807,11 +807,13 @@ export function buildAgentEfforts(config: LoadedConfig): Map 0) { notes.push( - `\`effort\` is read only by the claude-code engine and was ignored for ${viaOpencode.join(", ")} ` + - "(the model of each runs through OpenCode)", + `\`effort\` has no effect for ${viaOpencode.join(", ")}: only the claude-code engine ` + + "reads it, and the model of each runs through OpenCode", ); } if (fixedRole.length > 0) { notes.push( - `\`effort\` was ignored for ${fixedRole.join(", ")}: the id is also a built-in pass, which ` + + `\`effort\` has no effect for ${fixedRole.join(", ")}: the id is also a built-in pass, which ` + "runs at the default effort. Fix: rename the agent file", ); } From 9094fa6a9d11888e5f3b550c5fe36341d960adc8 Mon Sep 17 00:00:00 2001 From: szdziedzic Date: Thu, 26 Nov 2026 13:38:36 +0100 Subject: [PATCH 06/18] fix: warn on effort outside reviewer files, and test selection edges Neon review of 9f9f0cd: - `effort` in coordinator.md or shared.md frontmatter did nothing and said nothing. The loader now adds a setup warning that says to remove it. - The "path-excluded verifier.md" test passed a list without the verifier, so it tested nothing new. Replace it with a routed-out and a routed-in agents/verifier.md, and add the router-fallback branch (routed: false runs every candidate and notes a running OpenCode reviewer). - startClaudeCode: assert the handle has no efforts map without effort, and that fixed-role ids get no entry with it. - agentEffortNote: one test with both reasons in one note. - Move LoadedAgent's doc comment back onto LoadedAgent. Co-Authored-By: Claude Opus 5.5 --- ...config-schema-loading-routing.explainer.md | 2 + src/__tests__/claude-code.test.ts | 20 ++++++++++ src/__tests__/config-load.test.ts | 14 +++++++ src/__tests__/review-internals.test.ts | 39 ++++++++++++++++--- src/config/load.ts | 20 ++++++++-- src/config/schema.ts | 2 +- 6 files changed, 87 insertions(+), 10 deletions(-) diff --git a/llp/0006-config-schema-loading-routing.explainer.md b/llp/0006-config-schema-loading-routing.explainer.md index 99c99e1d..5abe8dfc 100644 --- a/llp/0006-config-schema-loading-routing.explainer.md +++ b/llp/0006-config-schema-loading-routing.explainer.md @@ -249,6 +249,8 @@ per-agent key and not a run-level flag. without effort support gets none: a request from the pinned CLI to `claude-haiku-4-5` with `--effort high` carried no effort field, and one to `claude-opus-5-5` did (seen in review of PR #118 against a local mock endpoint, not re-run here). The engine does not check model support. +- **Only reviewer files take it.** `effort` in `coordinator.md` or `shared.md` frontmatter has no + effect, so the loader adds a setup warning that says to remove it, instead of ignoring it. - **An invalid level never stops a review.** `parseAgentEffort` returns a setup warning with the fix and no `effort`, so the agent runs at the default. The value is matched after trim and lower-case, and a trailing `# comment` makes it invalid like any other text. diff --git a/src/__tests__/claude-code.test.ts b/src/__tests__/claude-code.test.ts index 652202be..5d066a87 100644 --- a/src/__tests__/claude-code.test.ts +++ b/src/__tests__/claude-code.test.ts @@ -894,6 +894,16 @@ test("agentEffortNote: an agent that does not run in this review is not named", ).toBeNull(); }); +test("agentEffortNote: reports both reasons in one note", () => { + const agents = [ + { id: "ios", effort: "high" }, + { id: "verifier", effort: "max" }, + ] as unknown as LoadedAgent[]; + const note = agentEffortNote(agents, { ios: "opencode", verifier: "claude-code" }); + expect(note).toContain("has no effect for ios: only the claude-code engine reads it"); + expect(note).toContain("; `effort` has no effect for verifier: the id is also a built-in pass"); +}); + test("agentEffortNote: a reviewer that shares a fixed role's id is told to rename", () => { const agents = [{ id: "verifier", effort: "max" }] as unknown as LoadedAgent[]; const note = agentEffortNote(agents, { verifier: "opencode" }); @@ -1037,6 +1047,16 @@ test("startClaudeCode: childEnv is an allowlist (forbidden ambient secrets exclu // sk-ant-oat… classifies as oauth ⇒ CLAUDE_CODE_OAUTH_TOKEN, never ANTHROPIC_API_KEY. expect(handle.childEnv.CLAUDE_CODE_OAUTH_TOKEN).toBe(oat); expect(handle.childEnv.ANTHROPIC_API_KEY).toBeUndefined(); + // No agent sets `effort`, so the handle has no efforts map. + expect(handle.efforts).toBeUndefined(); + const withEffort = await startClaudeCode({ + ...config, + agents: [ + { id: "reviewer", model: "anthropic/claude-opus-5", tools: {}, effort: "high" }, + { id: "verifier", model: "anthropic/claude-opus-5", tools: {}, effort: "max" }, + ], + } as unknown as LoadedConfig); + expect([...(withEffort.efforts ?? [])]).toEqual([["reviewer", "high"]]); } finally { for (const [key, value] of Object.entries(saved)) { if (value === undefined) { diff --git a/src/__tests__/config-load.test.ts b/src/__tests__/config-load.test.ts index 790cce08..7eff8fb1 100644 --- a/src/__tests__/config-load.test.ts +++ b/src/__tests__/config-load.test.ts @@ -332,6 +332,20 @@ test("loadReviewConfig: an invalid `effort` is a warning, and the agent runs at } }); +test("loadReviewConfig: `effort` in coordinator.md is a warning, not silently ignored", async () => { + const root = await configDirWithAgent("IOS", "---\neffort: high\n---\nCoordinator prompt."); + try { + const config = await loadReviewConfig(root); + expect(config.setupWarnings).toHaveLength(1); + const [warning] = config.setupWarnings!; + expect(warning).toContain(path.join(CONFIG_DIRNAME, "coordinator.md")); + expect(warning).toContain("is read only in agents/*.md reviewer files"); + expect(warning).toContain("Fix: remove `effort` from this file."); + } finally { + await rm(root, { recursive: true, force: true }); + } +}); + test("loadReviewConfig: front-matter `mention` loads GitHub logins and teams onto the agent", async () => { const root = await configDirWithAgent( '---\nmention:\n - amandeepmittal\n - "@expo/docs"\n---\nIOS', diff --git a/src/__tests__/review-internals.test.ts b/src/__tests__/review-internals.test.ts index bca904e4..5a07de65 100644 --- a/src/__tests__/review-internals.test.ts +++ b/src/__tests__/review-internals.test.ts @@ -961,15 +961,42 @@ describe("selectReviewers: the effort note names only reviewers that run", () => expect(note).toContain("has no effect for ios:"); }); - it("does not tell a path-excluded agents/verifier.md to rename", async () => { - // The engine map always has the built-in verifier, but the reviewer file did not - // pass its `paths` filter, so it is not a candidate. - const lines: string[] = []; + it("does not tell a routed-out agents/verifier.md to rename, but does when it runs", async () => { + const verifier = { id: "verifier", effort: "max" } as unknown as LoadedAgent; + const routedOut: string[] = []; + await selectReviewers({ + candidates: [alpha, verifier], + route: async () => ({ agents: [alpha], routed: true }), + engineOf, + progress: (line) => routedOut.push(line), + }); + expect(routedOut.some((line) => line.includes("effort"))).toBe(false); + + const selected: string[] = []; await selectReviewers({ - candidates: [alpha], + candidates: [alpha, verifier], + route: async () => ({ agents: [alpha, verifier], routed: true }), + engineOf, + progress: (line) => selected.push(line), + }); + expect(selected.find((line) => line.startsWith("Note: `effort`"))).toContain( + "has no effect for verifier: the id is also a built-in pass", + ); + }); + + it("runs every candidate, and names a running OpenCode reviewer, when the router falls back", async () => { + const lines: string[] = []; + const result = await selectReviewers({ + candidates: [alpha, ios], + route: async () => ({ agents: [alpha, ios], routed: false }), engineOf, progress: (line) => lines.push(line), }); - expect(lines.some((line) => line.includes("effort"))).toBe(false); + expect(result.selectedAgents.map((a) => a.id)).toEqual(["alpha", "ios"]); + expect(result.notRouted).toEqual([]); + expect(lines).toContain("Router unavailable; running all agents."); + expect(lines.find((line) => line.startsWith("Note: `effort`"))).toContain( + "has no effect for ios:", + ); }); }); diff --git a/src/config/load.ts b/src/config/load.ts index ea000d81..640b44cd 100644 --- a/src/config/load.ts +++ b/src/config/load.ts @@ -247,14 +247,28 @@ async function loadConfigDir( }; // shared.md is optional; the coordinator is required. - const sharedPromptText = existsSync(path.join(dir, "shared.md")) - ? (await readPrompt("shared.md")).body - : ""; + const sharedMd = existsSync(path.join(dir, "shared.md")) + ? await readPrompt("shared.md") + : undefined; + const sharedPromptText = sharedMd?.body ?? ""; if (!existsSync(path.join(dir, "coordinator.md"))) { throw new Error(`Missing ${CONFIG_DIRNAME}/coordinator.md`); } const coordinatorMd = await readPrompt("coordinator.md"); + // @ref LLP 0006#agent-effort [implements] — only reviewer files take `effort`; say so instead of ignoring it silently + for (const [file, md] of [ + ["shared.md", sharedMd], + ["coordinator.md", coordinatorMd], + ] as const) { + if (md?.data.effort !== undefined) { + setupWarnings.push( + `${path.join(label, file)}: \`effort\` is read only in agents/*.md reviewer files, so it ` + + "has no effect here; the coordinator and the other built-in passes run at the default " + + "effort. Fix: remove `effort` from this file.", + ); + } + } // Every markdown file in agents/ is a reviewer agent (id = filename). const agentsDir = path.join(dir, "agents"); diff --git a/src/config/schema.ts b/src/config/schema.ts index ceeb5ca4..a0486c26 100644 --- a/src/config/schema.ts +++ b/src/config/schema.ts @@ -584,11 +584,11 @@ export const ScopeReviewConfigSchema = ReviewConfigSchema.omit({ }); export type RawScopeReviewConfig = z.infer; -/** A single agent after prompt files are read and models are resolved. */ /** The effort levels the `claude` CLI takes for `--effort`. */ export const AGENT_EFFORT_LEVELS = ["low", "medium", "high", "xhigh", "max"] as const; export type AgentEffort = (typeof AGENT_EFFORT_LEVELS)[number]; +/** A single agent after prompt files are read and models are resolved. */ export interface LoadedAgent { id: string; /** One-line summary from frontmatter, used by the router to pick agents. */ From f06ba081dbdc4a11dd367e82f7c6b349d7a4e10e Mon Sep 17 00:00:00 2001 From: szdziedzic Date: Thu, 26 Nov 2026 13:52:49 +0100 Subject: [PATCH 07/18] fix: give the full fix for a fixed-role reviewer on an OpenCode model MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Astra review of 9094fa6: - A reviewer file named after a built-in pass, on an OpenCode model, was told only to rename the file; after the rename the next run said OpenCode ignores effort. The note now reads the reviewer's own model (the engine map's entry for that id describes the built-in pass) and also says to use an `anthropic/…` model when needed. - The @ref gloss at selectReviewers still said an agent that does not run is never named; a later pre-check or budget limit can skip a named one. Match the LLP wording. Co-Authored-By: Claude Opus 5.5 --- src/__tests__/claude-code.test.ts | 11 +++++++++++ src/core/claude-code.ts | 13 ++++++++++++- src/core/review.ts | 2 +- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/__tests__/claude-code.test.ts b/src/__tests__/claude-code.test.ts index 5d066a87..f3c25f7d 100644 --- a/src/__tests__/claude-code.test.ts +++ b/src/__tests__/claude-code.test.ts @@ -904,6 +904,17 @@ test("agentEffortNote: reports both reasons in one note", () => { expect(note).toContain("; `effort` has no effect for verifier: the id is also a built-in pass"); }); +test("agentEffortNote: a fixed-role reviewer on an OpenCode model is told to change the model too", () => { + const agents = [ + { id: "verifier", effort: "max", model: "openai/gpt-6-astra" }, + { id: "coordinator", effort: "high", model: "anthropic/claude-opus-5-5" }, + ] as unknown as LoadedAgent[]; + // The engine map describes the built-in passes (claude here), not the reviewer files. + const note = agentEffortNote(agents, { verifier: "claude-code", coordinator: "claude-code" }); + expect(note).toContain("Fix: rename the agent file, and give verifier an `anthropic/…` model"); + expect(note).not.toContain("give verifier, coordinator"); +}); + test("agentEffortNote: a reviewer that shares a fixed role's id is told to rename", () => { const agents = [{ id: "verifier", effort: "max" }] as unknown as LoadedAgent[]; const note = agentEffortNote(agents, { verifier: "opencode" }); diff --git a/src/core/claude-code.ts b/src/core/claude-code.ts index 3d434814..508be73c 100644 --- a/src/core/claude-code.ts +++ b/src/core/claude-code.ts @@ -833,10 +833,21 @@ export function agentEffortNote( "reads it, and the model of each runs through OpenCode", ); } + // The engine map's entry for a fixed-role id describes the built-in pass, so read the + // reviewer's own model: after a rename, an OpenCode model would still ignore `effort`. + const fixedRoleViaOpencode = declared + .filter( + (agent) => FIXED_ROLE_IDS.has(agent.id) && engineForModel(agent.model ?? "") === "opencode", + ) + .map((agent) => agent.id); if (fixedRole.length > 0) { notes.push( `\`effort\` has no effect for ${fixedRole.join(", ")}: the id is also a built-in pass, which ` + - "runs at the default effort. Fix: rename the agent file", + "runs at the default effort. Fix: rename the agent file" + + (fixedRoleViaOpencode.length > 0 + ? `, and give ${fixedRoleViaOpencode.join(", ")} an \`anthropic/…\` model, because only ` + + "the claude-code engine reads `effort`" + : ""), ); } return notes.length > 0 ? notes.join("; ") : null; diff --git a/src/core/review.ts b/src/core/review.ts index e01e90c4..93a97166 100644 --- a/src/core/review.ts +++ b/src/core/review.ts @@ -2388,7 +2388,7 @@ export async function selectReviewers(args: { // `effort` reaches only the `claude` CLI, and never a fixed pass. Say so once for an // agent that runs in this review and whose level has no effect, so the setting does // not fail silently. - // @ref LLP 0006#agent-effort [implements] — built from the final reviewer list, after the paths filter and the router, so an agent that does not run is never named + // @ref LLP 0006#agent-effort [implements] — built from the selected reviewer list, after the paths filter and the router, so an agent either of them left out is never named; a later pre-check or budget limit can still skip a named one const effortNote = agentEffortNote(selectedAgents, args.engineOf); if (effortNote) { args.progress(`Note: ${effortNote}`); From c6d4a10ba83ca4f7393b2a6b2198009d07f68374 Mon Sep 17 00:00:00 2001 From: szdziedzic Date: Thu, 26 Nov 2026 13:56:52 +0100 Subject: [PATCH 08/18] fix: align effort comments and warnings with the setup-fact wording Neon review of 9094fa6: - The comment above the selectReviewers @ref still said the note names agents that run; it now says selected reviewers, and the test group title matches. - Test the shared.md branch of the non-reviewer effort warning, next to coordinator.md. - The warning no longer names the coordinator when it fires for shared.md, and the README says that effort in coordinator.md or shared.md is listed under Review setup. Co-Authored-By: Claude Opus 5.5 --- README.md | 2 ++ src/__tests__/config-load.test.ts | 20 ++++++++++++++------ src/__tests__/review-internals.test.ts | 2 +- src/config/load.ts | 4 ++-- src/core/review.ts | 5 ++--- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index b11e19b2..f29c2879 100644 --- a/README.md +++ b/README.md @@ -544,6 +544,8 @@ effort support (Claude Haiku 4.5 is one), and ecr does not check this. A higher level costs more and takes longer, so set it on the agent that needs depth (a correctness reviewer that must trace callers), not on every agent. A value that is not a level is listed under **Review setup**, and the agent runs at the default. +`effort` in `coordinator.md` or `shared.md` is also listed there: only reviewer +files take it. An agent file in `agents/` named after a built-in pass (`verifier.md`, `cross-cutting.md`, `adjudicator.md`, `stack-verifier.md` or `coordinator.md`) gets no effort; the review note says to rename it. diff --git a/src/__tests__/config-load.test.ts b/src/__tests__/config-load.test.ts index 7eff8fb1..83f6ffae 100644 --- a/src/__tests__/config-load.test.ts +++ b/src/__tests__/config-load.test.ts @@ -332,15 +332,23 @@ test("loadReviewConfig: an invalid `effort` is a warning, and the agent runs at } }); -test("loadReviewConfig: `effort` in coordinator.md is a warning, not silently ignored", async () => { +test("loadReviewConfig: `effort` in coordinator.md or shared.md is a warning, not silently ignored", async () => { const root = await configDirWithAgent("IOS", "---\neffort: high\n---\nCoordinator prompt."); try { + await writeFile( + path.join(root, CONFIG_DIRNAME, "shared.md"), + "---\neffort: max\n---\nShared prompt.", + "utf8", + ); const config = await loadReviewConfig(root); - expect(config.setupWarnings).toHaveLength(1); - const [warning] = config.setupWarnings!; - expect(warning).toContain(path.join(CONFIG_DIRNAME, "coordinator.md")); - expect(warning).toContain("is read only in agents/*.md reviewer files"); - expect(warning).toContain("Fix: remove `effort` from this file."); + expect(config.setupWarnings).toHaveLength(2); + for (const file of ["shared.md", "coordinator.md"]) { + const warning = config.setupWarnings!.find((w) => + w.includes(path.join(CONFIG_DIRNAME, file)), + ); + expect(warning, file).toContain("is read only in agents/*.md reviewer files"); + expect(warning, file).toContain("Fix: remove `effort` from this file."); + } } finally { await rm(root, { recursive: true, force: true }); } diff --git a/src/__tests__/review-internals.test.ts b/src/__tests__/review-internals.test.ts index 5a07de65..ab5a2f57 100644 --- a/src/__tests__/review-internals.test.ts +++ b/src/__tests__/review-internals.test.ts @@ -931,7 +931,7 @@ describe("Exporting OpenCode sessions before the review closes", () => { }); }); -describe("selectReviewers: the effort note names only reviewers that run", () => { +describe("selectReviewers: the effort note names only selected reviewers", () => { const alpha = { id: "alpha", effort: "high" } as unknown as LoadedAgent; const ios = { id: "ios", effort: "high" } as unknown as LoadedAgent; const engineOf = { alpha: "claude-code", ios: "opencode", verifier: "claude-code" } as const; diff --git a/src/config/load.ts b/src/config/load.ts index 640b44cd..599482a1 100644 --- a/src/config/load.ts +++ b/src/config/load.ts @@ -264,8 +264,8 @@ async function loadConfigDir( if (md?.data.effort !== undefined) { setupWarnings.push( `${path.join(label, file)}: \`effort\` is read only in agents/*.md reviewer files, so it ` + - "has no effect here; the coordinator and the other built-in passes run at the default " + - "effort. Fix: remove `effort` from this file.", + "has no effect here; the built-in passes run at the default effort. Fix: remove " + + "`effort` from this file.", ); } } diff --git a/src/core/review.ts b/src/core/review.ts index 93a97166..4bba427c 100644 --- a/src/core/review.ts +++ b/src/core/review.ts @@ -2385,9 +2385,8 @@ export async function selectReviewers(args: { .filter((agent) => !selectedAgents.includes(agent)) .map((agent) => agent.id); - // `effort` reaches only the `claude` CLI, and never a fixed pass. Say so once for an - // agent that runs in this review and whose level has no effect, so the setting does - // not fail silently. + // `effort` reaches only the `claude` CLI, and never a fixed pass. Say so once for a + // selected reviewer whose level has no effect, so the setting does not fail silently. // @ref LLP 0006#agent-effort [implements] — built from the selected reviewer list, after the paths filter and the router, so an agent either of them left out is never named; a later pre-check or budget limit can still skip a named one const effortNote = agentEffortNote(selectedAgents, args.engineOf); if (effortNote) { From b6dd1ca3472f8fe667e6b7bdb1ba436d0c04ea12 Mon Sep 17 00:00:00 2001 From: szdziedzic Date: Thu, 26 Nov 2026 14:31:56 +0100 Subject: [PATCH 09/18] fix: no effort on the no-tools fallback, and never echo an invalid value Multi-model review of c6d4a10 (PR comment by Kudo) and Devin: - A timed-out pass is retried with no tools under a short cap (maxToolCalls 0); it still got the agent's level, so an `effort: max` agent could time out again. runClaudePrompt now sends no level there. - The invalid-effort warning repeated the raw value, so a backtick could close the code span in the review comment and a long value went in uncapped. It now names the file and the allowed levels only. - The hidden-frontmatter warning now lists `effort` among ignored keys. - The rename advice for a fixed-role reviewer on an OpenCode model now says that REVIEWER_MODEL, when set, decides the model. - LLP 0006 records the two points left for later: per-agent warnings in routed scopes with enforceAgents (same as `mention`), and the shared reader's unmatched-quote handling. Co-Authored-By: Claude Opus 5.5 --- README.md | 3 ++- ...0006-config-schema-loading-routing.explainer.md | 14 +++++++++++++- src/__tests__/claude-code.test.ts | 12 +++++++++++- src/__tests__/config-load.test.ts | 3 +++ src/config/load.ts | 8 +++++--- src/core/claude-code.ts | 10 +++++++--- 6 files changed, 41 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index f29c2879..a394c2d1 100644 --- a/README.md +++ b/README.md @@ -540,7 +540,8 @@ are ignored), and a comment that breaks `alwaysRun`, `model` or `temperature`. models that run through the Claude Code CLI (`anthropic/…`) read it; for any other model the review prints a note and ignores it. Leave it out to use the CLI default. The model must also support effort: the CLI sends no level to a model without -effort support (Claude Haiku 4.5 is one), and ecr does not check this. +effort support (Claude Haiku 4.5 is one), and ecr does not check this. A model can +also take only some of the levels. A higher level costs more and takes longer, so set it on the agent that needs depth (a correctness reviewer that must trace callers), not on every agent. A value that is not a level is listed under **Review setup**, and the agent runs at the default. diff --git a/llp/0006-config-schema-loading-routing.explainer.md b/llp/0006-config-schema-loading-routing.explainer.md index 5abe8dfc..59eaeab3 100644 --- a/llp/0006-config-schema-loading-routing.explainer.md +++ b/llp/0006-config-schema-loading-routing.explainer.md @@ -251,11 +251,23 @@ per-agent key and not a run-level flag. #118 against a local mock endpoint, not re-run here). The engine does not check model support. - **Only reviewer files take it.** `effort` in `coordinator.md` or `shared.md` frontmatter has no effect, so the loader adds a setup warning that says to remove it, instead of ignoring it. +- **The no-tools fallback pass runs at the default.** A timed-out pass is retried with no tools under + a short cap (`maxToolCalls: 0`); `runClaudePrompt` sends no level for it, because a deep level + under that cap would likely time out again (found in a multi-model review of PR #118, not + measured in a live run). - **An invalid level never stops a review.** `parseAgentEffort` returns a setup warning with the - fix and no `effort`, so the agent runs at the default. The value is matched after trim and + fix and no `effort`, so the agent runs at the default. The warning does not repeat the value: a + backtick in it would close the code span in the review comment, and setup notes are not + length-capped. The value is matched after trim and lower-case, and a trailing `# comment` makes it invalid like any other text. - **Absent adds no key.** `LoadedAgent.effort` is set only when declared, so a setup without it keeps its review-cache key, and a setup that adds or changes it gets a fresh review. +- **Not handled here.** In a routed scope, a root `enforceAgents` entry replaces a same-id scope + agent, but the scope keeps its own setup warnings: an invalid root `effort` shows no warning + there, and an invalid scope `effort` warns about an agent that runs at the root's level. `mention` + warnings behave the same way, so a fix belongs to all per-agent warnings at once. An unmatched + quote (`effort: "max`) loads as `max`, because the shared frontmatter reader strips each quote on + its own for every key. - **`REVIEWER_MODEL` does not clear it.** The override can move an agent to a model that runs through OpenCode; the note then reports the ignored level. diff --git a/src/__tests__/claude-code.test.ts b/src/__tests__/claude-code.test.ts index f3c25f7d..0138a37e 100644 --- a/src/__tests__/claude-code.test.ts +++ b/src/__tests__/claude-code.test.ts @@ -853,6 +853,15 @@ test("runClaudePrompt: an agent's effort reaches its own passes and no other age expect(reviewer[reviewer.indexOf("--effort") + 1]).toBe("xhigh"); expect((await argsLog(2)).split("\n")).not.toContain("--effort"); expect((await argsLog(3)).split("\n")).not.toContain("--effort"); + // The no-tools fallback of a timed-out pass runs at the default effort. + await runClaudePrompt(handle, { + agent: "reviewer", + system: "SYS", + text: "hi", + title: "t", + maxToolCalls: 0, + }); + expect((await argsLog(4)).split("\n")).not.toContain("--effort"); } finally { await cleanup(); } @@ -911,7 +920,8 @@ test("agentEffortNote: a fixed-role reviewer on an OpenCode model is told to cha ] as unknown as LoadedAgent[]; // The engine map describes the built-in passes (claude here), not the reviewer files. const note = agentEffortNote(agents, { verifier: "claude-code", coordinator: "claude-code" }); - expect(note).toContain("Fix: rename the agent file, and give verifier an `anthropic/…` model"); + expect(note).toContain("Fix: rename the agent file, and run verifier on an `anthropic/…` model"); + expect(note).toContain("`REVIEWER_MODEL` when that is set"); expect(note).not.toContain("give verifier, coordinator"); }); diff --git a/src/__tests__/config-load.test.ts b/src/__tests__/config-load.test.ts index 83f6ffae..443d9bd3 100644 --- a/src/__tests__/config-load.test.ts +++ b/src/__tests__/config-load.test.ts @@ -325,6 +325,9 @@ test("loadReviewConfig: an invalid `effort` is a warning, and the agent runs at const [warning] = config.setupWarnings!; expect(warning).toContain(path.join(CONFIG_DIRNAME, "agents", "ios.md")); expect(warning).toContain("is not an effort level"); + // The raw value is never repeated into the review comment. + expect(warning, line).not.toContain("extreme"); + expect(warning, line).not.toContain("deep trace"); expect(warning).toContain("low, medium, high, xhigh, max"); } finally { await rm(root, { recursive: true, force: true }); diff --git a/src/config/load.ts b/src/config/load.ts index 599482a1..fb983fb3 100644 --- a/src/config/load.ts +++ b/src/config/load.ts @@ -688,7 +688,9 @@ function parseAgentEffort( } return { warning: - `${file}: \`effort: ${raw}\` is not an effort level, so the agent runs at the default ` + + // The value is not repeated: a backtick in it would close the code span in the + // review comment, and a long one would go into the comment uncapped. + `${file}: \`effort\` is not an effort level, so the agent runs at the default ` + `effort. Fix: write one of ${AGENT_EFFORT_LEVELS.join(", ")} with nothing after it ` + "(a `# comment` goes on its own line), or remove `effort`.", }; @@ -822,8 +824,8 @@ function frontmatterWarnings( if (hidden) { return [ `${file}: its frontmatter does not start on the first line (${hidden.cause}), so ` + - "every key in it is ignored, including `description`, `alwaysRun`, `model` and " + - `\`paths\`. Fix: ${hidden.fix}.`, + "every key in it is ignored, including `description`, `alwaysRun`, `model`, `paths` " + + `and \`effort\`. Fix: ${hidden.fix}.`, ]; } const warnings: string[] = []; diff --git a/src/core/claude-code.ts b/src/core/claude-code.ts index 508be73c..832e6f14 100644 --- a/src/core/claude-code.ts +++ b/src/core/claude-code.ts @@ -845,8 +845,9 @@ export function agentEffortNote( `\`effort\` has no effect for ${fixedRole.join(", ")}: the id is also a built-in pass, which ` + "runs at the default effort. Fix: rename the agent file" + (fixedRoleViaOpencode.length > 0 - ? `, and give ${fixedRoleViaOpencode.join(", ")} an \`anthropic/…\` model, because only ` + - "the claude-code engine reads `effort`" + ? `, and run ${fixedRoleViaOpencode.join(", ")} on an \`anthropic/…\` model (its ` + + "`model:`, or `REVIEWER_MODEL` when that is set), because only the claude-code " + + "engine reads `effort`" : ""), ); } @@ -939,7 +940,10 @@ export async function runClaudePrompt( : undefined; heartbeat?.unref?.(); // A Map lookup: an agent id such as `constructor` must not read an inherited value. - const effort = handle.efforts?.get(args.agent); + // The no-tools fallback (maxToolCalls 0) retries a timed-out pass under a short cap, so + // it runs at the default effort: a deep level there would likely time out again. + // @ref LLP 0006#agent-effort [implements] — the no-tools fallback pass takes no level + const effort = args.maxToolCalls === 0 ? undefined : handle.efforts?.get(args.agent); let result; try { result = await run( From e0ce4b75183e020be3fedae7956dcad301b79b29 Mon Sep 17 00:00:00 2001 From: szdziedzic Date: Thu, 26 Nov 2026 15:10:08 +0100 Subject: [PATCH 10/18] fix: run the no-tools fallback at the agent's level capped at medium Gemini Neon review of PR #119 (stacked on this one): sending no level on the no-tools fallback uses the provider's default, which can be higher than the agent's own level (an `effort: low` agent could fall back to a higher default). fallbackEffort now returns min(level, medium), and runClaudePrompt passes that for maxToolCalls 0: it never raises the level and still keeps a deep level off a short-capped retry. Co-Authored-By: Claude Opus 5.5 --- llp/0006-config-schema-loading-routing.explainer.md | 10 ++++++---- src/__tests__/claude-code.test.ts | 5 +++-- src/__tests__/config-load.test.ts | 9 +++++++++ src/config/schema.ts | 13 +++++++++++++ src/core/claude-code.ts | 8 ++++---- 5 files changed, 35 insertions(+), 10 deletions(-) diff --git a/llp/0006-config-schema-loading-routing.explainer.md b/llp/0006-config-schema-loading-routing.explainer.md index 59eaeab3..cb502262 100644 --- a/llp/0006-config-schema-loading-routing.explainer.md +++ b/llp/0006-config-schema-loading-routing.explainer.md @@ -251,10 +251,12 @@ per-agent key and not a run-level flag. #118 against a local mock endpoint, not re-run here). The engine does not check model support. - **Only reviewer files take it.** `effort` in `coordinator.md` or `shared.md` frontmatter has no effect, so the loader adds a setup warning that says to remove it, instead of ignoring it. -- **The no-tools fallback pass runs at the default.** A timed-out pass is retried with no tools under - a short cap (`maxToolCalls: 0`); `runClaudePrompt` sends no level for it, because a deep level - under that cap would likely time out again (found in a multi-model review of PR #118, not - measured in a live run). +- **The no-tools fallback pass runs at `min(level, medium)`.** A timed-out pass is retried with no + tools under a short cap (`maxToolCalls: 0`). A deep level there would likely time out again + (found in a multi-model review of PR #118, not measured in a live run), and sending no level + would use the provider's default, which can be higher than the agent's own `low` (OpenCode sends + Gemini `high` by default; found in review of PR #119). So `fallbackEffort` caps the level at + `medium` and never raises it, and `runClaudePrompt` passes that for the fallback. - **An invalid level never stops a review.** `parseAgentEffort` returns a setup warning with the fix and no `effort`, so the agent runs at the default. The warning does not repeat the value: a backtick in it would close the code span in the review comment, and setup notes are not diff --git a/src/__tests__/claude-code.test.ts b/src/__tests__/claude-code.test.ts index 0138a37e..d9ffe6c2 100644 --- a/src/__tests__/claude-code.test.ts +++ b/src/__tests__/claude-code.test.ts @@ -853,7 +853,7 @@ test("runClaudePrompt: an agent's effort reaches its own passes and no other age expect(reviewer[reviewer.indexOf("--effort") + 1]).toBe("xhigh"); expect((await argsLog(2)).split("\n")).not.toContain("--effort"); expect((await argsLog(3)).split("\n")).not.toContain("--effort"); - // The no-tools fallback of a timed-out pass runs at the default effort. + // The no-tools fallback of a timed-out pass runs at the level capped at medium. await runClaudePrompt(handle, { agent: "reviewer", system: "SYS", @@ -861,7 +861,8 @@ test("runClaudePrompt: an agent's effort reaches its own passes and no other age title: "t", maxToolCalls: 0, }); - expect((await argsLog(4)).split("\n")).not.toContain("--effort"); + const fallback = (await argsLog(4)).split("\n"); + expect(fallback[fallback.indexOf("--effort") + 1]).toBe("medium"); } finally { await cleanup(); } diff --git a/src/__tests__/config-load.test.ts b/src/__tests__/config-load.test.ts index 443d9bd3..f25bfdd7 100644 --- a/src/__tests__/config-load.test.ts +++ b/src/__tests__/config-load.test.ts @@ -10,6 +10,7 @@ import { stripJsonComments, stripTrailingCommas, } from "../config/load.js"; +import { fallbackEffort } from "../config/schema.js"; test("parseFrontmatter: parses scalar keys + returns body without frontmatter", () => { const { data, body } = parseFrontmatter("---\nmodel: x\nalwaysRun: true\n---\n# Body\ntext"); @@ -425,3 +426,11 @@ test("loadReviewConfig: reads the PR template comments from the repository root" await rm(root, { recursive: true, force: true }); } }); + +test("fallbackEffort: the agent's level, capped at medium", () => { + expect(fallbackEffort("low")).toBe("low"); + expect(fallbackEffort("medium")).toBe("medium"); + expect(fallbackEffort("high")).toBe("medium"); + expect(fallbackEffort("xhigh")).toBe("medium"); + expect(fallbackEffort("max")).toBe("medium"); +}); diff --git a/src/config/schema.ts b/src/config/schema.ts index a0486c26..01fcb556 100644 --- a/src/config/schema.ts +++ b/src/config/schema.ts @@ -588,6 +588,19 @@ export type RawScopeReviewConfig = z.infer; export const AGENT_EFFORT_LEVELS = ["low", "medium", "high", "xhigh", "max"] as const; export type AgentEffort = (typeof AGENT_EFFORT_LEVELS)[number]; +/** + * The level a no-tools fallback pass runs at: the agent's own level, capped at `medium`. + * The fallback retries a timed-out pass under a short cap, so a deep level would likely + * time out again; sending no level instead would fall back to a provider default that can + * be higher than the agent's own `low`. + */ +// @ref LLP 0006#agent-effort [implements] — the no-tools fallback runs at min(level, medium) +export function fallbackEffort(level: AgentEffort): AgentEffort { + return AGENT_EFFORT_LEVELS.indexOf(level) <= AGENT_EFFORT_LEVELS.indexOf("medium") + ? level + : "medium"; +} + /** A single agent after prompt files are read and models are resolved. */ export interface LoadedAgent { id: string; diff --git a/src/core/claude-code.ts b/src/core/claude-code.ts index 832e6f14..78a0ee25 100644 --- a/src/core/claude-code.ts +++ b/src/core/claude-code.ts @@ -3,6 +3,7 @@ import { tmpdir } from "node:os"; import path from "node:path"; +import { fallbackEffort } from "../config/schema.js"; import type { AgentEffort, LoadedAgent, LoadedConfig, McpServerConfig } from "../config/schema.js"; import { checkAuthEntry } from "./auth.js"; import { pathInside, resolveOnPath, run } from "./exec.js"; @@ -940,10 +941,9 @@ export async function runClaudePrompt( : undefined; heartbeat?.unref?.(); // A Map lookup: an agent id such as `constructor` must not read an inherited value. - // The no-tools fallback (maxToolCalls 0) retries a timed-out pass under a short cap, so - // it runs at the default effort: a deep level there would likely time out again. - // @ref LLP 0006#agent-effort [implements] — the no-tools fallback pass takes no level - const effort = args.maxToolCalls === 0 ? undefined : handle.efforts?.get(args.agent); + // The no-tools fallback (maxToolCalls 0) runs at the agent's level capped at `medium`. + const level = handle.efforts?.get(args.agent); + const effort = level && args.maxToolCalls === 0 ? fallbackEffort(level) : level; let result; try { result = await run( From 2270ed35243a9b57028ea0d8299382570aa944bf Mon Sep 17 00:00:00 2001 From: szdziedzic Date: Thu, 26 Nov 2026 15:42:38 +0100 Subject: [PATCH 11/18] docs: scope the fallback cap to the claude-code engine in LLP 0006 Devin review of e0ce4b7: the fallback paragraph gave OpenCode's Gemini default as its example, so it read as if fallbackEffort applied to OpenCode. This PR has no OpenCode effort; the paragraph now names the CLI's default and says only the claude-code engine applies the cap. Co-Authored-By: Claude Opus 5.5 --- llp/0006-config-schema-loading-routing.explainer.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/llp/0006-config-schema-loading-routing.explainer.md b/llp/0006-config-schema-loading-routing.explainer.md index cb502262..1a9d3c13 100644 --- a/llp/0006-config-schema-loading-routing.explainer.md +++ b/llp/0006-config-schema-loading-routing.explainer.md @@ -251,12 +251,12 @@ per-agent key and not a run-level flag. #118 against a local mock endpoint, not re-run here). The engine does not check model support. - **Only reviewer files take it.** `effort` in `coordinator.md` or `shared.md` frontmatter has no effect, so the loader adds a setup warning that says to remove it, instead of ignoring it. -- **The no-tools fallback pass runs at `min(level, medium)`.** A timed-out pass is retried with no - tools under a short cap (`maxToolCalls: 0`). A deep level there would likely time out again - (found in a multi-model review of PR #118, not measured in a live run), and sending no level - would use the provider's default, which can be higher than the agent's own `low` (OpenCode sends - Gemini `high` by default; found in review of PR #119). So `fallbackEffort` caps the level at - `medium` and never raises it, and `runClaudePrompt` passes that for the fallback. +- **The claude-code no-tools fallback runs at `min(level, medium)`.** A timed-out pass is retried + with no tools under a short cap (`maxToolCalls: 0`). A deep level there would likely time out + again (found in a multi-model review of PR #118, not measured in a live run), and sending no + level would use the CLI's default, which can be higher than the agent's own `low`. So + `fallbackEffort` caps the level at `medium` and never raises it, and `runClaudePrompt` passes + that for the fallback. Only the claude-code engine applies this cap. - **An invalid level never stops a review.** `parseAgentEffort` returns a setup warning with the fix and no `effort`, so the agent runs at the default. The warning does not repeat the value: a backtick in it would close the code span in the review comment, and setup notes are not From d16c574a6504ebbbe6cc9288487a81f038f2be38 Mon Sep 17 00:00:00 2001 From: Szymon Dziedzic Date: Thu, 26 Nov 2026 17:13:19 +0100 Subject: [PATCH 12/18] feat: pass agent effort to OpenAI and Google models through OpenCode (#119) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Why Stacked on #118. After #118, `effort` reaches only `anthropic/…` agents (`--effort` on the Claude Code CLI). An agent on an OpenAI model (for example GPT-6.2 Astra) or a Google model (for example Gemini 4 Neon) gets the run note "`effort` has no effect", although OpenCode can pass a reasoning level to both providers. ## How OpenCode hands unknown agent-config keys to the provider as model options. `buildOpencodeConfig` now adds one per reviewer with `effort`, chosen by `opencodeEffortStyle` from the adapter ecr gives the model's provider: | Model | Agent key | What reaches the API | | --- | --- | --- | | `openai/…`, or an alias with `upstream: "openai"` (built on `@ai-sdk/openai`) | `reasoningEffort: ` | Responses API `reasoning.effort` | | `google/…`, `google-vertex/…` | `thinkingConfig: { thinkingLevel: }`, only for `low`, `medium`, `high` | `thinkingConfig.thinkingLevel`, in place of the model's default | - **Google `xhigh` and `max`:** the pinned Google adapter rejects them inside OpenCode before any request, so ecr sends no level for them and the run note names the agent, its level and the levels that work (`GOOGLE_THINKING_LEVELS`). - **Other aliases** (including `upstream: "google"`, built on the OpenAI-compatible adapter), Meta and other providers get no level and are named in the run note. - **No level on ids the engine or OpenCode also uses:** ecr's fixed roles (`NON_REVIEWER_AGENTS`) and OpenCode 1.19.5's own agents (`OPENCODE_BUILTIN_AGENTS`: build, compaction, explore, general, plan, summary, title). A level on `compaction` reached other reviewers' session compaction. The run note tells the author to rename the file, with the full fix in one note. - **The level is never one the author did not write.** On OpenCode every prompt of a pass, including the no-tools fallback, finalize and corrective, runs at the agent's own level: a model can reject a lower level ecr picks (GPT-5 pro takes only `high`). The claude-code engine keeps #118's `min(level, medium)` fallback. - ecr passes the level as written and does not check which levels a model takes. A provider that rejects a level fails that agent's passes with its own error. README, template and LLP 0006 say so. ## Evidence With the pinned OpenCode 1.19.5 and a local mock endpoint (no real provider call), using the config `buildOpencodeConfig` produces: - `openai/gpt-6.2-astra`: no key → no `reasoning` field; `high`, `xhigh`, `max` → `reasoning.effort` with that value. - `google/gemini-4-neon` and `google-vertex/gemini-4-neon`: no key → `thinkingLevel: "high"`; `low`/`medium` → that level, `includeThoughts: true` kept; `xhigh`/`max` → no request sent. - `app.agents()` lists the seven built-in agents above with `native: true`. Not observed: the ChatGPT/Codex sign-in path, and how a real provider answers each level. ## Review Reviewed in several rounds by GPT-6.2 Astra and Gemini 4 Neon (high effort). An earlier version added a `__fallback-effort` copy agent at `min(level, medium)` for the OpenCode fallback; review showed it could send a level a model rejects and could hijack a built-in pass, so it was removed. Both reviewers approve the final design; their last nits are in `4d4137b` and `24144b9`. ## Test plan - [x] `bun run typecheck`, `bun run lint`, `bun run fmt:check` - [x] `bun run llp:check`: 0 errors - [x] `bun test`: 1186 pass, 0 fail - [x] Tests: `opencodeEffortStyle` per provider and alias; `buildOpencodeConfig` keys for OpenAI and Google, none for Google `xhigh`/`max`, Meta, fixed roles or OpenCode built-in ids; `agentEffortNote` names each case once, with the full fix. --------- --- README.md | 25 +++- ...config-schema-loading-routing.explainer.md | 63 ++++++-- src/__tests__/claude-code.test.ts | 140 ++++++++++++++++-- src/__tests__/opencode.test.ts | 91 +++++++++++- src/__tests__/review-internals.test.ts | 5 + src/config/schema.ts | 5 +- src/core/claude-code.ts | 122 +++++++++++++-- src/core/opencode.ts | 104 ++++++++++++- src/core/review.ts | 12 +- templates/config.jsonc | 7 +- 10 files changed, 517 insertions(+), 57 deletions(-) diff --git a/README.md b/README.md index a394c2d1..784c1ece 100644 --- a/README.md +++ b/README.md @@ -536,12 +536,21 @@ comment (and in the terminal) with the fix, and `ecr doctor` fails on them: frontmatter below an HTML comment, a byte-order mark or blank lines (all its keys are ignored), and a comment that breaks `alwaysRun`, `model` or `temperature`. -`effort` sets how much reasoning the model spends on that agent's passes. Only -models that run through the Claude Code CLI (`anthropic/…`) read it; for any other -model the review prints a note and ignores it. Leave it out to use the CLI default. -The model must also support effort: the CLI sends no level to a model without -effort support (Claude Haiku 4.5 is one), and ecr does not check this. A model can -also take only some of the levels. +`effort` sets how much reasoning the model spends on that agent's passes. ecr +passes it for these models, and for any other model the review prints a note and +ignores it. Leave it out to use the provider's default. + +| Model | How the level is sent | +| --- | --- | +| `anthropic/…` (Claude Code CLI) | `--effort ` | +| `openai/…`, or an alias with `upstream: "openai"` (OpenCode) | `reasoningEffort`, sent as the Responses API `reasoning.effort` | +| `google/…`, `google-vertex/…` (OpenCode) | `thinkingConfig.thinkingLevel`, in place of the model's default (OpenCode sends `high` for Gemini 4 Neon); only `low`, `medium` or `high` (for `xhigh` and `max` ecr sends no level, and the run note says so) | +| `xai/…` (Grok, OpenCode) | `reasoningEffort`, sent as Chat Completions `reasoning_effort` | + +ecr passes the level as written and does not check which levels a model takes. A +model without effort support can drop it (the Claude Code CLI sends no level to +Claude Haiku 4.5), and a provider can reject a level its model does not take, which +fails that agent's passes with the provider's error. A higher level costs more and takes longer, so set it on the agent that needs depth (a correctness reviewer that must trace callers), not on every agent. A value that is not a level is listed under **Review setup**, and the agent runs at the default. @@ -549,7 +558,9 @@ is not a level is listed under **Review setup**, and the agent runs at the defau files take it. An agent file in `agents/` named after a built-in pass (`verifier.md`, `cross-cutting.md`, `adjudicator.md`, `stack-verifier.md` or `coordinator.md`) gets -no effort; the review note says to rename it. +no effort; the review note says to rename it. The same holds, on OpenCode-routed +models, for a file named after one of OpenCode's own agents (`build.md`, +`compaction.md`, `explore.md`, `general.md`, `plan.md`, `summary.md`, `title.md`). `paths` limits an agent to the changes it covers. It takes a list of repo-relative globs in the routing dialect: `*` stays within a directory, `**` crosses diff --git a/llp/0006-config-schema-loading-routing.explainer.md b/llp/0006-config-schema-loading-routing.explainer.md index 1a9d3c13..3ce5feee 100644 --- a/llp/0006-config-schema-loading-routing.explainer.md +++ b/llp/0006-config-schema-loading-routing.explainer.md @@ -226,7 +226,7 @@ reviewers raised in the class "needs a logic trace" (eval run `full-v2-tune`, 20 is private and not in this repo; no person checked the analysis). Depth is a per-agent need, and it costs time and money, so it is a per-agent key and not a run-level flag. -- **Only the claude-code engine reads it.** `startClaudeCode` copies the declared levels into +- **The claude-code engine passes it as a flag.** `startClaudeCode` copies the declared levels into `ClaudeCodeHandle.efforts`, and `runClaudePrompt` passes `--effort ` for that agent's passes [observed] (`buildClaudeArgs` `effort`; tests in `src/__tests__/claude-code.test.ts`). The fixed roles (cross-cutting, verifier, adjudicator, stack verifier, coordinator) have no entry and @@ -239,8 +239,43 @@ per-agent key and not a run-level flag. session archive's `NON_REVIEWER_AGENTS`, so the two cannot drift. The levels live in a `Map`, so an id such as `constructor` cannot read an inherited `Object.prototype` value (both found in review of the first version, PR #118). -- **An OpenCode-routed agent ignores it, with a note.** `agentEffortNote` names those agents once - per run, the same way `claudeTemperatureNote` reports a temperature the CLI cannot take. +- **OpenCode passes it for OpenAI, Google and xAI models.** OpenCode hands unknown agent-config keys to + the provider as model options. `buildOpencodeConfig` adds one per reviewer with `effort`, chosen + by `opencodeEffortStyle` from the adapter ecr gives the model's provider: native `openai` and an + alias with `upstream: "openai"` (built on `@ai-sdk/openai`) get `reasoningEffort`; native + `google` and `google-vertex` get `thinkingConfig.thinkingLevel`; native `xai` (Grok, on + `@ai-sdk/xai`) gets `reasoningEffort`. Any other alias, including + `upstream: "google"` (built on `@ai-sdk/openai-compatible`), gets nothing: a Google key on that + adapter reached a mock endpoint as a top-level `thinkingConfig` on `/chat/completions` (found in + review of PR #119). Observed with the pinned OpenCode 1.19.5 against a local mock + endpoint (2026-11-26) [observed]: with no key, an `openai/gpt-6.2-astra` request carried no + `reasoning` field; `reasoningEffort: "xhigh"` and `"max"` arrived as `reasoning.effort`; a + `google/gemini-4-neon` request carried `thinkingConfig: {includeThoughts: true, thinkingLevel: + "high"}` with no key, and `thinkingLevel: "low"` replaced the `high`; an `xai/grok-4.7` request to + `/chat/completions` carried no level field with no key, and `reasoningEffort` `"low"`, `"high"` and + `"xhigh"` arrived as `reasoning_effort` (asked for in review of PR #118; which levels xAI's API + accepts is not verified). Only reviewer entries get + the key: the fixed roles are written after the reviewer loop, so a reviewer that shares a fixed + role's id cannot give that pass its level. The pinned Google adapter takes `thinkingLevel` + `minimal`, `low`, `medium` and `high`; with `xhigh` or `max` the pass failed inside OpenCode + (an invalid-provider-options error) with no request sent, on `google/…` and `google-vertex/…` + [observed]. OpenCode's model catalog lists more variants for some Gemini models; the limit comes + from the bundled Google SDK's option schema, so re-check it when the OpenCode pins move. So + `GOOGLE_THINKING_LEVELS` is `low`, `medium`, `high`: for the other two ecr sends no + key, the model runs at its default in OpenCode (`high` for Gemini 4 Neon; a `google/gemini-2.5-flash` + request carried no `thinkingLevel`, per review of PR #119), and the run note names the agent, its level + and the levels that work. Not observed: the ChatGPT/Codex sign-in path and a + real provider's response to each level. ecr passes the level as written; a provider that does + not take it fails that agent's passes with its own error. +- **No level on OpenCode's own agent ids.** OpenCode 1.19.5 defines `build`, `compaction`, + `explore`, `general`, `plan`, `summary` and `title` (`app.agents()`, `native: true`, 2026-11-26) [observed]; a + reviewer config with one of these ids replaces that agent, and `compaction`, `summary` and `title` + also run for other sessions. A reviewer level there reached another reviewer's session + compaction (found in review of PR #119), so `buildOpencodeConfig` gives these ids no level + (`OPENCODE_BUILTIN_AGENTS`), and the run note tells the author to rename the file. +- **Any other OpenCode-routed agent ignores it, with a note.** `agentEffortNote` names agents whose + OpenCode provider takes no level (Meta, OpenAI-compatible and others) once per run, the same way + `claudeTemperatureNote` reports a temperature the CLI cannot take. `selectReviewers`, which `runReview` calls, builds it from the selected reviewer list, after the `paths` filter and the router, so an agent either of them left out is never named. A later step (a blocking pre-check, the budget) can still skip a named agent, so the note states a fact about @@ -251,12 +286,18 @@ per-agent key and not a run-level flag. #118 against a local mock endpoint, not re-run here). The engine does not check model support. - **Only reviewer files take it.** `effort` in `coordinator.md` or `shared.md` frontmatter has no effect, so the loader adds a setup warning that says to remove it, instead of ignoring it. -- **The claude-code no-tools fallback runs at `min(level, medium)`.** A timed-out pass is retried - with no tools under a short cap (`maxToolCalls: 0`). A deep level there would likely time out - again (found in a multi-model review of PR #118, not measured in a live run), and sending no - level would use the CLI's default, which can be higher than the agent's own `low`. So - `fallbackEffort` caps the level at `medium` and never raises it, and `runClaudePrompt` passes - that for the fallback. Only the claude-code engine applies this cap. +- **The claude-code no-tools fallback runs at `min(level, medium)`; OpenCode keeps the level.** A + timed-out pass is retried with no tools under a short cap (`maxToolCalls: 0`). A deep level there + would likely time out again (found in a multi-model review of PR #118, not measured in a live + run), and sending no level would use the CLI's default, which can be higher than the agent's own + `low`. So `fallbackEffort` caps the level at `medium` and never raises it, and `runClaudePrompt` + passes that for the fallback. Only the claude-code engine applies this cap. On OpenCode the + fallback, and the finalize and corrective prompts, run at the agent's own level: OpenCode reads + the level from the agent config, and ecr cannot know which lower levels a model takes (GPT-5 pro + takes only `high`, per the provider's docs cited in review of PR #119), so it never sends a level + the author did not write. An earlier version of PR #119 gave each such reviewer a + `__fallback-effort` copy at `min(level, medium)`; review showed it could send a rejected + level, so it was removed. - **An invalid level never stops a review.** `parseAgentEffort` returns a setup warning with the fix and no `effort`, so the agent runs at the default. The warning does not repeat the value: a backtick in it would close the code span in the review comment, and setup notes are not @@ -270,8 +311,8 @@ per-agent key and not a run-level flag. warnings behave the same way, so a fix belongs to all per-agent warnings at once. An unmatched quote (`effort: "max`) loads as `max`, because the shared frontmatter reader strips each quote on its own for every key. -- **`REVIEWER_MODEL` does not clear it.** The override can move an agent to a model that runs - through OpenCode; the note then reports the ignored level. +- **`REVIEWER_MODEL` does not clear it.** The override can move an agent to another provider; the + level then goes to that provider, or the note reports it as ignored. ## Budgets and Chunking Defaults diff --git a/src/__tests__/claude-code.test.ts b/src/__tests__/claude-code.test.ts index d9ffe6c2..e122f285 100644 --- a/src/__tests__/claude-code.test.ts +++ b/src/__tests__/claude-code.test.ts @@ -874,11 +874,16 @@ test("buildAgentEfforts: no entry for a reviewer that shares a fixed role's id", agents: [ { id: "correctness", effort: "high" }, ...fixedRoles.map((id) => ({ id, effort: "max" })), + // An OpenCode built-in id keeps its level on the claude-code engine. + { id: "compaction", effort: "high" }, { id: "constructor" }, ], } as unknown as LoadedConfig; const efforts = buildAgentEfforts(config); - expect([...efforts]).toEqual([["correctness", "high"]]); + expect([...efforts]).toEqual([ + ["correctness", "high"], + ["compaction", "high"], + ]); expect(efforts.get("constructor")).toBeUndefined(); }); @@ -888,8 +893,10 @@ test("agentEffortNote: names the agents whose effort an OpenCode-routed model ig { id: "b", effort: "low" }, { id: "c" }, ] as unknown as LoadedAgent[]; - expect(agentEffortNote(agents, { a: "claude-code", b: "claude-code", c: "opencode" })).toBeNull(); - const note = agentEffortNote(agents, { a: "claude-code", b: "opencode", c: "opencode" }); + expect( + agentEffortNote(agents, { a: "claude-code", b: "claude-code", c: "opencode" }, []), + ).toBeNull(); + const note = agentEffortNote(agents, { a: "claude-code", b: "opencode", c: "opencode" }, []); expect(note).toContain("has no effect for b:"); expect(note).not.toContain("for a"); }); @@ -900,35 +907,144 @@ test("agentEffortNote: an agent that does not run in this review is not named", // although the engine map still has entries for both ids. const selected = [{ id: "alpha", effort: "high" }] as unknown as LoadedAgent[]; expect( - agentEffortNote(selected, { alpha: "claude-code", ios: "opencode", verifier: "claude-code" }), + agentEffortNote( + selected, + { alpha: "claude-code", ios: "opencode", verifier: "claude-code" }, + [], + ), ).toBeNull(); }); +test("agentEffortNote: OpenAI, Google and xAI models take a level through OpenCode; others do not", () => { + const agents = [ + { id: "astra", effort: "high", model: "openai/gpt-6.2-astra" }, + { id: "pro", effort: "high", model: "openai-api/gpt-5.5-pro" }, + { id: "neon", effort: "high", model: "google/gemini-4-neon" }, + { id: "vertex", effort: "high", model: "google-vertex/gemini-4-neon" }, + { id: "grok", effort: "high", model: "xai/grok-4.7" }, + { id: "muse", effort: "high", model: "meta/muse-spark-1.3" }, + ] as unknown as LoadedAgent[]; + const engineOf = { + astra: "opencode", + pro: "opencode", + neon: "opencode", + vertex: "opencode", + grok: "opencode", + muse: "opencode", + } as const; + const auth = [ + { provider: "openai-api", mode: "api-key", tokenEnv: "OPENAI_API_KEY", upstream: "openai" }, + ] as unknown as AuthConfigEntry[]; + const named = (note: string | null) => note?.match(/has no effect for ([^:]+):/)?.[1]; + const note = agentEffortNote(agents, engineOf, auth); + expect(note).toContain( + "the model of each runs through OpenCode on a provider ecr passes no level to (ecr passes one only for `anthropic/…`", + ); + expect(named(note)).toBe("muse"); + // Without the alias's auth entry, `openai-api` is not known to be OpenAI. + expect(named(agentEffortNote(agents, engineOf, []))).toBe("pro, muse"); +}); + +test("agentEffortNote: a Google level the pinned adapter rejects is named with the levels it takes", () => { + const agents = [ + { id: "neon", effort: "xhigh", model: "google/gemini-4-neon" }, + { id: "vertex", effort: "max", model: "google-vertex/gemini-4-neon" }, + { id: "ok", effort: "medium", model: "google/gemini-4-neon" }, + ] as unknown as LoadedAgent[]; + const note = agentEffortNote( + agents, + { neon: "opencode", vertex: "opencode", ok: "opencode" }, + [], + ); + expect(note).toContain("has no effect for neon (xhigh), vertex (max): OpenCode's Google adapter"); + expect(note).toContain("takes only low, medium, high"); + expect(note).toContain("Fix: use one of those levels"); + expect(note).not.toContain("ok ("); +}); + +test("agentEffortNote: a Google-upstream alias takes no level and is named", () => { + const agents = [ + { id: "gem", effort: "high", model: "gemini-api/gemini-4-neon" }, + ] as unknown as LoadedAgent[]; + const auth = [ + { provider: "gemini-api", mode: "api-key", tokenEnv: "GEMINI_KEY_2", upstream: "google" }, + ] as unknown as AuthConfigEntry[]; + expect(agentEffortNote(agents, { gem: "opencode" }, auth)).toContain( + "has no effect for gem: the model of each runs through OpenCode on a provider ecr passes no level to", + ); +}); + +test("agentEffortNote: a fixed-role reviewer on Google xhigh is also told the levels Google takes", () => { + const agents = [ + { id: "verifier", effort: "xhigh", model: "google/gemini-4-neon" }, + ] as unknown as LoadedAgent[]; + const note = agentEffortNote(agents, { verifier: "claude-code" }, []); + expect(note).toContain("Fix: rename the agent file, and give verifier one of low, medium, high"); +}); + +test("agentEffortNote: an OpenCode reviewer named after an OpenCode built-in agent is told to rename", () => { + const agents = [ + { id: "compaction", effort: "xhigh", model: "openai/gpt-6.2-astra" }, + ] as unknown as LoadedAgent[]; + const note = agentEffortNote(agents, { compaction: "opencode" }, []); + expect(note).toContain("has no effect for compaction: the id is also an OpenCode built-in agent"); + expect(note).toContain("Fix: rename the agent file"); + expect(note).not.toContain("runs through OpenCode on a provider"); + // On the claude-code engine the level does apply, so there is no note. + expect(agentEffortNote(agents, { compaction: "claude-code" }, [])).toBeNull(); +}); + +test("agentEffortNote: an OpenCode built-in id on Google max is also told the levels Google takes", () => { + const agents = [ + { id: "compaction", effort: "max", model: "google/gemini-4-neon" }, + { id: "title", effort: "high", model: "meta/muse-spark-1.3" }, + ] as unknown as LoadedAgent[]; + const note = agentEffortNote(agents, { compaction: "opencode", title: "opencode" }, []); + expect(note).toContain( + "has no effect for compaction, title: the id is also an OpenCode built-in agent", + ); + expect(note).toContain("and run title on a model that takes a level"); + expect(note).toContain("and give compaction one of low, medium, high"); + // One note only: the built-in id is not also listed as a plain OpenCode or Google case. + expect(note?.split("has no effect").length).toBe(2); +}); + +test("agentEffortNote: a fixed-role reviewer on OpenAI is told only to rename", () => { + const agents = [ + { id: "verifier", effort: "max", model: "openai/gpt-6.2-astra" }, + ] as unknown as LoadedAgent[]; + const note = agentEffortNote(agents, { verifier: "claude-code" }, []); + expect(note).toContain("Fix: rename the agent file"); + expect(note?.endsWith("Fix: rename the agent file")).toBe(true); +}); + test("agentEffortNote: reports both reasons in one note", () => { const agents = [ { id: "ios", effort: "high" }, { id: "verifier", effort: "max" }, ] as unknown as LoadedAgent[]; - const note = agentEffortNote(agents, { ios: "opencode", verifier: "claude-code" }); - expect(note).toContain("has no effect for ios: only the claude-code engine reads it"); + const note = agentEffortNote(agents, { ios: "opencode", verifier: "claude-code" }, []); + expect(note).toContain("has no effect for ios: the model of each runs through OpenCode"); expect(note).toContain("; `effort` has no effect for verifier: the id is also a built-in pass"); }); -test("agentEffortNote: a fixed-role reviewer on an OpenCode model is told to change the model too", () => { +test("agentEffortNote: a fixed-role reviewer on a model that takes no level is told to change the model too", () => { const agents = [ - { id: "verifier", effort: "max", model: "openai/gpt-6-astra" }, + { id: "verifier", effort: "max", model: "meta/muse-spark-1.3" }, { id: "coordinator", effort: "high", model: "anthropic/claude-opus-5-5" }, ] as unknown as LoadedAgent[]; // The engine map describes the built-in passes (claude here), not the reviewer files. - const note = agentEffortNote(agents, { verifier: "claude-code", coordinator: "claude-code" }); - expect(note).toContain("Fix: rename the agent file, and run verifier on an `anthropic/…` model"); + const note = agentEffortNote(agents, { verifier: "claude-code", coordinator: "claude-code" }, []); + expect(note).toContain( + "Fix: rename the agent file, and run verifier on a model that takes a level", + ); expect(note).toContain("`REVIEWER_MODEL` when that is set"); - expect(note).not.toContain("give verifier, coordinator"); + expect(note).not.toContain("run verifier, coordinator"); }); test("agentEffortNote: a reviewer that shares a fixed role's id is told to rename", () => { const agents = [{ id: "verifier", effort: "max" }] as unknown as LoadedAgent[]; - const note = agentEffortNote(agents, { verifier: "opencode" }); + const note = agentEffortNote(agents, { verifier: "opencode" }, []); expect(note).toContain("has no effect for verifier: the id is also a built-in pass"); expect(note).toContain("Fix: rename the agent file"); expect(note).not.toContain("runs through OpenCode"); diff --git a/src/__tests__/opencode.test.ts b/src/__tests__/opencode.test.ts index 791f1538..65cd47ec 100644 --- a/src/__tests__/opencode.test.ts +++ b/src/__tests__/opencode.test.ts @@ -18,6 +18,10 @@ import { serverStopped, STACK_VERIFIER_AGENT, META_MODEL_API_BASE_URL, + opencodeEffortStyle, + OPENCODE_BUILTIN_AGENTS, + VERIFIER_AGENT, + CROSS_CUTTING_AGENT, } from "../core/opencode.js"; import type { OpencodeHandle } from "../core/opencode.js"; import type { ClaudeCodeHandle } from "../core/claude-code.js"; @@ -58,7 +62,7 @@ test("resolveEngineDispatch: per-agent router picks the right engine and claude /** Minimal LoadedConfig for buildOpencodeConfig tests. */ function configWith(overrides: { - agents?: Array<{ id: string; model: string }>; + agents?: Array<{ id: string; model: string; effort?: string }>; coordinatorModel?: string; auth?: unknown[]; }): LoadedConfig { @@ -689,3 +693,88 @@ describe("Recording an OpenCode pass for the session archive", () => { expect(handle.capture?.count).toBe(0); }, 20_000); }); + +test("opencodeEffortStyle: OpenAI and Google families take a level; others do not", () => { + const alias = [ + { provider: "openai-api", mode: "api-key", tokenEnv: "OPENAI_API_KEY", upstream: "openai" }, + { provider: "claude-api", mode: "api-key", tokenEnv: "ANTHROPIC_KEY_2", upstream: "anthropic" }, + // ecr builds this alias with the OpenAI-compatible adapter, not Google's. + { provider: "gemini-api", mode: "api-key", tokenEnv: "GEMINI_KEY_2", upstream: "google" }, + ] as unknown as LoadedConfig["auth"]; + expect(opencodeEffortStyle("openai/gpt-6.2-astra", [])).toBe("openai"); + expect(opencodeEffortStyle("openai-api/gpt-5.5-pro", alias)).toBe("openai"); + expect(opencodeEffortStyle("openai-api/gpt-5.5-pro", [])).toBeNull(); + expect(opencodeEffortStyle("google/gemini-4-neon", [])).toBe("google"); + expect(opencodeEffortStyle("google-vertex/gemini-4-neon", [])).toBe("google"); + expect(opencodeEffortStyle("claude-api/claude-opus-5-5", alias)).toBeNull(); + expect(opencodeEffortStyle("gemini-api/gemini-4-neon", alias)).toBeNull(); + expect(opencodeEffortStyle("meta/muse-spark-1.3", [])).toBeNull(); + expect(opencodeEffortStyle("gpt-6.2-astra", [])).toBeNull(); + expect(opencodeEffortStyle("xai/grok-4.7", [])).toBe("xai"); +}); + +test("buildOpencodeConfig passes a reviewer's effort as its provider's option, and only a reviewer's", () => { + const opencode = buildOpencodeConfig( + configWith({ + agents: [ + { id: "astra", model: "openai/gpt-6.2-astra", effort: "xhigh" }, + { id: "neon", model: "google/gemini-4-neon", effort: "low" }, + { id: "neon-x", model: "google/gemini-4-neon", effort: "xhigh" }, + { id: "vertex-max", model: "google-vertex/gemini-4-neon", effort: "max" }, + { id: "muse", model: "meta/muse-spark-1.3", effort: "high" }, + { id: "plain", model: "openai/gpt-6.2-astra" }, + { id: "verifier", model: "openai/gpt-6.2-astra", effort: "max" }, + ], + }), + ) as { agent: Record> }; + expect(opencode.agent.astra!.reasoningEffort).toBe("xhigh"); + expect(opencode.agent.astra!.thinkingConfig).toBeUndefined(); + expect(opencode.agent.neon!.thinkingConfig).toEqual({ thinkingLevel: "low" }); + expect(opencode.agent.neon!.reasoningEffort).toBeUndefined(); + // The pinned Google adapter rejects xhigh and max, so they get no key at all. + for (const id of [ + "neon-x", + "vertex-max", + "muse", + "plain", + VERIFIER_AGENT, + CROSS_CUTTING_AGENT, + "coordinator", + ]) { + expect(opencode.agent[id]!.reasoningEffort, id).toBeUndefined(); + expect(opencode.agent[id]!.thinkingConfig, id).toBeUndefined(); + } +}); + +test("buildOpencodeConfig gives no level to a reviewer that shares an OpenCode built-in agent id", () => { + const opencode = buildOpencodeConfig( + configWith({ + agents: [ + { id: "compaction", model: "openai/gpt-6.2-astra", effort: "xhigh" }, + { id: "title", model: "google/gemini-4-neon", effort: "low" }, + { id: "astra", model: "openai/gpt-6.2-astra", effort: "xhigh" }, + ], + }), + ) as { agent: Record> }; + // OpenCode also runs these for other sessions (compaction, titles), so no level there. + expect(opencode.agent.compaction!.reasoningEffort).toBeUndefined(); + expect(opencode.agent.title!.thinkingConfig).toBeUndefined(); + expect(opencode.agent.astra!.reasoningEffort).toBe("xhigh"); + expect([...OPENCODE_BUILTIN_AGENTS].sort()).toEqual([ + "build", + "compaction", + "explore", + "general", + "plan", + "summary", + "title", + ]); +}); + +test("buildOpencodeConfig passes a Grok reviewer's level as reasoningEffort", () => { + const opencode = buildOpencodeConfig( + configWith({ agents: [{ id: "grok", model: "xai/grok-4.7", effort: "xhigh" }] }), + ) as { agent: Record> }; + expect(opencode.agent.grok!.reasoningEffort).toBe("xhigh"); + expect(opencode.agent.grok!.thinkingConfig).toBeUndefined(); +}); diff --git a/src/__tests__/review-internals.test.ts b/src/__tests__/review-internals.test.ts index ab5a2f57..e6113624 100644 --- a/src/__tests__/review-internals.test.ts +++ b/src/__tests__/review-internals.test.ts @@ -942,6 +942,7 @@ describe("selectReviewers: the effort note names only selected reviewers", () => candidates: [alpha, ios], route: async () => ({ agents: [alpha], routed: true }), engineOf, + auth: [], progress: (line) => lines.push(line), }); expect(result.selectedAgents.map((a) => a.id)).toEqual(["alpha"]); @@ -955,6 +956,7 @@ describe("selectReviewers: the effort note names only selected reviewers", () => await selectReviewers({ candidates: [alpha, ios], engineOf, + auth: [], progress: (line) => lines.push(line), }); const note = lines.find((line) => line.startsWith("Note: `effort`")); @@ -968,6 +970,7 @@ describe("selectReviewers: the effort note names only selected reviewers", () => candidates: [alpha, verifier], route: async () => ({ agents: [alpha], routed: true }), engineOf, + auth: [], progress: (line) => routedOut.push(line), }); expect(routedOut.some((line) => line.includes("effort"))).toBe(false); @@ -977,6 +980,7 @@ describe("selectReviewers: the effort note names only selected reviewers", () => candidates: [alpha, verifier], route: async () => ({ agents: [alpha, verifier], routed: true }), engineOf, + auth: [], progress: (line) => selected.push(line), }); expect(selected.find((line) => line.startsWith("Note: `effort`"))).toContain( @@ -990,6 +994,7 @@ describe("selectReviewers: the effort note names only selected reviewers", () => candidates: [alpha, ios], route: async () => ({ agents: [alpha, ios], routed: false }), engineOf, + auth: [], progress: (line) => lines.push(line), }); expect(result.selectedAgents.map((a) => a.id)).toEqual(["alpha", "ios"]); diff --git a/src/config/schema.ts b/src/config/schema.ts index 01fcb556..5a56f5ec 100644 --- a/src/config/schema.ts +++ b/src/config/schema.ts @@ -584,7 +584,7 @@ export const ScopeReviewConfigSchema = ReviewConfigSchema.omit({ }); export type RawScopeReviewConfig = z.infer; -/** The effort levels the `claude` CLI takes for `--effort`. */ +/** The effort levels an agent may set. Each engine maps them (LLP 0006, "Agent Effort"). */ export const AGENT_EFFORT_LEVELS = ["low", "medium", "high", "xhigh", "max"] as const; export type AgentEffort = (typeof AGENT_EFFORT_LEVELS)[number]; @@ -623,7 +623,8 @@ export interface LoadedAgent { paths?: string[]; /** * Frontmatter `effort`: how much reasoning the model spends on this agent's passes. - * Only the claude-code engine reads it. Absent means the CLI's own default. + * The claude-code engine passes it as `--effort`; OpenCode passes it for OpenAI and + * Google models (opencodeEffortStyle). Absent means the provider's own default. */ effort?: AgentEffort; /** diff --git a/src/core/claude-code.ts b/src/core/claude-code.ts index 78a0ee25..1fbfcaf3 100644 --- a/src/core/claude-code.ts +++ b/src/core/claude-code.ts @@ -4,7 +4,13 @@ import { tmpdir } from "node:os"; import path from "node:path"; import { fallbackEffort } from "../config/schema.js"; -import type { AgentEffort, LoadedAgent, LoadedConfig, McpServerConfig } from "../config/schema.js"; +import type { + AgentEffort, + AuthConfigEntry, + LoadedAgent, + LoadedConfig, + McpServerConfig, +} from "../config/schema.js"; import { checkAuthEntry } from "./auth.js"; import { pathInside, resolveOnPath, run } from "./exec.js"; import { assertMcpServerTokenEnvs, mcpGrantEnvironment, mcpServerGrants } from "./mcp-servers.js"; @@ -15,6 +21,9 @@ import { AgentTimeoutError, CLAUDE_CODE_ENGINE, CROSS_CUTTING_AGENT, + GOOGLE_THINKING_LEVELS, + OPENCODE_BUILTIN_AGENTS, + opencodeEffortStyle, STACK_VERIFIER_AGENT, VERIFIER_AGENT, withTransientRetry, @@ -810,51 +819,132 @@ export function buildAgentEfforts(config: LoadedConfig): Map, + auth: readonly AuthConfigEntry[], ): string | null { const declared = agents.filter((agent) => agent.effort); + const takesNoLevel = (model: string): boolean => + engineForModel(model) === "opencode" && opencodeEffortStyle(model, auth) === null; const viaOpencode = declared - .filter((agent) => !FIXED_ROLE_IDS.has(agent.id) && engineOf[agent.id] === "opencode") + .filter( + (agent) => + !FIXED_ROLE_IDS.has(agent.id) && + !OPENCODE_BUILTIN_AGENTS.has(agent.id) && + engineOf[agent.id] === "opencode" && + takesNoLevel(agent.model ?? ""), + ) .map((agent) => agent.id); + // A Google model whose level the pinned adapter rejects gets no level (opencodeEffortOptions). + const googleLevelNotTaken = declared + .filter( + (agent) => + !FIXED_ROLE_IDS.has(agent.id) && + !OPENCODE_BUILTIN_AGENTS.has(agent.id) && + engineOf[agent.id] === "opencode" && + opencodeEffortStyle(agent.model ?? "", auth) === "google" && + agent.effort !== undefined && + !GOOGLE_THINKING_LEVELS.has(agent.effort), + ) + .map((agent) => `${agent.id} (${agent.effort})`); const fixedRole = declared .filter((agent) => FIXED_ROLE_IDS.has(agent.id)) .map((agent) => agent.id); + // buildOpencodeConfig gives an OpenCode built-in agent id no level (other sessions use it). + const opencodeBuiltin = declared + .filter( + (agent) => + !FIXED_ROLE_IDS.has(agent.id) && + OPENCODE_BUILTIN_AGENTS.has(agent.id) && + engineOf[agent.id] === "opencode", + ) + .map((agent) => agent.id); + // After a rename, the model still has to take a level; say so in the same note. + const builtinNoLevel = opencodeBuiltin.filter((id) => + takesNoLevel(declared.find((agent) => agent.id === id)?.model ?? ""), + ); + const builtinGoogleLevel = declared + .filter( + (agent) => + opencodeBuiltin.includes(agent.id) && + opencodeEffortStyle(agent.model ?? "", auth) === "google" && + agent.effort !== undefined && + !GOOGLE_THINKING_LEVELS.has(agent.effort), + ) + .map((agent) => agent.id); const notes: string[] = []; + if (opencodeBuiltin.length > 0) { + notes.push( + `\`effort\` has no effect for ${opencodeBuiltin.join(", ")}: the id is also an OpenCode ` + + "built-in agent, which other sessions use. Fix: rename the agent file" + + (builtinNoLevel.length > 0 + ? `, and run ${builtinNoLevel.join(", ")} on a model that takes a level ` + + `(${EFFORT_PROVIDERS}; its \`model:\`, or \`REVIEWER_MODEL\` when that is set)` + : "") + + (builtinGoogleLevel.length > 0 + ? `, and give ${builtinGoogleLevel.join(", ")} one of ` + + `${[...GOOGLE_THINKING_LEVELS].join(", ")} (OpenCode's Google adapter takes no other)` + : ""), + ); + } if (viaOpencode.length > 0) { notes.push( - `\`effort\` has no effect for ${viaOpencode.join(", ")}: only the claude-code engine ` + - "reads it, and the model of each runs through OpenCode", + `\`effort\` has no effect for ${viaOpencode.join(", ")}: the model of each runs through ` + + `OpenCode on a provider ecr passes no level to (ecr passes one only for ${EFFORT_PROVIDERS})`, + ); + } + if (googleLevelNotTaken.length > 0) { + notes.push( + `\`effort\` has no effect for ${googleLevelNotTaken.join(", ")}: OpenCode's Google adapter ` + + `takes only ${[...GOOGLE_THINKING_LEVELS].join(", ")}, so ecr sends no level and the model ` + + "runs at the model's default in OpenCode. Fix: use one of those levels", ); } // The engine map's entry for a fixed-role id describes the built-in pass, so read the - // reviewer's own model: after a rename, an OpenCode model would still ignore `effort`. - const fixedRoleViaOpencode = declared + // reviewer's own model: after a rename, a model that takes no level still ignores it. + const fixedRoleNoLevel = declared + .filter((agent) => FIXED_ROLE_IDS.has(agent.id) && takesNoLevel(agent.model ?? "")) + .map((agent) => agent.id); + // After a rename, a Google model still drops a level its adapter does not take. + const fixedRoleGoogleLevel = declared .filter( - (agent) => FIXED_ROLE_IDS.has(agent.id) && engineForModel(agent.model ?? "") === "opencode", + (agent) => + FIXED_ROLE_IDS.has(agent.id) && + opencodeEffortStyle(agent.model ?? "", auth) === "google" && + agent.effort !== undefined && + !GOOGLE_THINKING_LEVELS.has(agent.effort), ) .map((agent) => agent.id); if (fixedRole.length > 0) { notes.push( `\`effort\` has no effect for ${fixedRole.join(", ")}: the id is also a built-in pass, which ` + "runs at the default effort. Fix: rename the agent file" + - (fixedRoleViaOpencode.length > 0 - ? `, and run ${fixedRoleViaOpencode.join(", ")} on an \`anthropic/…\` model (its ` + - "`model:`, or `REVIEWER_MODEL` when that is set), because only the claude-code " + - "engine reads `effort`" + (fixedRoleNoLevel.length > 0 + ? `, and run ${fixedRoleNoLevel.join(", ")} on a model that takes a level ` + + `(${EFFORT_PROVIDERS}; its \`model:\`, or \`REVIEWER_MODEL\` when that is set)` + : "") + + (fixedRoleGoogleLevel.length > 0 + ? `, and give ${fixedRoleGoogleLevel.join(", ")} one of ` + + `${[...GOOGLE_THINKING_LEVELS].join(", ")} (OpenCode's Google adapter takes no other)` : ""), ); } return notes.length > 0 ? notes.join("; ") : null; } +/** The model families ecr passes an effort level to, for the run notes. */ +const EFFORT_PROVIDERS = + '`anthropic/…`, `openai/…` (or an `upstream: "openai"` alias), `google/…`, `google-vertex/…` or `xai/…`'; + /** * Preserve actionable process diagnostics without copying arbitrary stderr into a * public Actions log. A non-empty stream may already contain model/tool content, so diff --git a/src/core/opencode.ts b/src/core/opencode.ts index dbaa07f3..2ff0f6a7 100644 --- a/src/core/opencode.ts +++ b/src/core/opencode.ts @@ -5,12 +5,18 @@ import path from "node:path"; import { createOpencode } from "@opencode-ai/sdk"; -import type { LoadedConfig, McpServerConfig } from "../config/schema.js"; +import type { + AgentEffort, + AuthConfigEntry, + LoadedConfig, + McpServerConfig, +} from "../config/schema.js"; // Type-only: erased at compile time, so it creates NO runtime import cycle. The // Claude engine is reached at runtime via dynamic import() in the dispatch // branches below; claude-code.ts statically imports the shared helpers here. import type { ClaudeCodeHandle, Engine } from "./claude-code.js"; import type { SessionCapture } from "./session-archive.js"; +import { NON_REVIEWER_AGENTS } from "./session-archive.js"; import { pathInside, resolveOnPath } from "./exec.js"; import { RateLimitWatch } from "./throttle.js"; import { OPENCODE_RESEARCH_TOOLS, toolMap } from "./tools.js"; @@ -274,6 +280,88 @@ export const ADJUDICATOR_AGENT = "adjudicator"; // that structural, like the coordinator. export const STACK_VERIFIER_AGENT = "stack-verifier"; +/** + * How an OpenCode provider's SDK takes a reasoning level from an agent's config: + * OpenAI's Responses adapter and xAI's adapter read `reasoningEffort`, Google's reads + * `thinkingConfig.thinkingLevel`. + */ +export type OpencodeEffortStyle = "openai" | "google" | "xai"; + +/** + * The effort style for a model id, or null when ecr does not pass a level to that + * provider. Native `openai` gets the OpenAI style, native `google` and `google-vertex` the + * Google style, native `xai` (Grok) the xAI style. An alias (an auth entry with `upstream`) follows the adapter + * `buildOpencodeConfig` creates for it: only `upstream: "openai"` gets `@ai-sdk/openai`, + * so only that alias takes a level. Meta, OpenAI-compatible and other providers get null. + */ +// @ref LLP 0006#agent-effort [implements] — OpenCode-routed effort, per provider adapter +export function opencodeEffortStyle( + model: string, + auth: readonly AuthConfigEntry[], +): OpencodeEffortStyle | null { + const slash = model.indexOf("/"); + if (slash <= 0) { + return null; + } + const provider = model.slice(0, slash); + const alias = auth.find((entry) => entry.provider === provider && entry.upstream); + if (alias) { + return alias.upstream === "openai" ? "openai" : null; + } + if (provider === "openai") { + return "openai"; + } + if (provider === "google" || provider === "google-vertex") { + return "google"; + } + if (provider === "xai") { + return "xai"; + } + return null; +} + +/** + * The levels the pinned OpenCode's Google adapter takes for `thinkingLevel`. With + * OpenCode 1.19.5, `xhigh` and `max` fail locally with an invalid-provider-options error + * and no request is sent (LLP 0006), so ecr sends no level for them. + */ +export const GOOGLE_THINKING_LEVELS: ReadonlySet = new Set(["low", "medium", "high"]); + +/** + * The agent-config keys that carry a reasoning level for an effort style, or null when + * the style's adapter does not take that level. OpenCode passes unknown agent keys to + * the provider as model options; observed with OpenCode 1.19.5 against a mock endpoint + * (LLP 0006): `reasoningEffort` becomes the Responses API's `reasoning.effort` (OpenAI) + * and Chat Completions' `reasoning_effort` (xAI), and `thinkingConfig.thinkingLevel` + * replaces the `high` that OpenCode sends to Gemini 4 Neon. + */ +export function opencodeEffortOptions( + style: OpencodeEffortStyle, + effort: AgentEffort, +): Record | null { + if (style === "openai" || style === "xai") { + return { reasoningEffort: effort }; + } + return GOOGLE_THINKING_LEVELS.has(effort) ? { thinkingConfig: { thinkingLevel: effort } } : null; +} + +/** + * The agents OpenCode 1.19.5 defines itself (`app.agents()` with `native: true`, + * observed 2026-11-26). `compaction`, `summary` and `title` run for every session, so a + * reviewer that shares one of these ids must not give it a level (LLP 0006). Re-check when + * the OpenCode pins move. + */ +// @ref LLP 0006#agent-effort [implements] — no level on OpenCode's own agent ids, which other sessions use +export const OPENCODE_BUILTIN_AGENTS: ReadonlySet = new Set([ + "build", + "compaction", + "explore", + "general", + "plan", + "summary", + "title", +]); + /** Build the inline OpenCode config (agents + coordinator) from a repo config. */ export function buildOpencodeConfig( config: LoadedConfig, @@ -282,11 +370,25 @@ export function buildOpencodeConfig( ): Record { const agent: Record = {}; for (const reviewer of config.agents) { + // No level for an id the engine or OpenCode also uses: ecr's fixed roles replace the + // entry after this loop, and an OpenCode built-in agent (compaction, title, …) also + // runs for other sessions, so a level there would reach them. + const effortStyle = + reviewer.effort && + !NON_REVIEWER_AGENTS.has(reviewer.id) && + !OPENCODE_BUILTIN_AGENTS.has(reviewer.id) + ? opencodeEffortStyle(reviewer.model, config.auth) + : null; + const effortOptions = + reviewer.effort && effortStyle ? opencodeEffortOptions(effortStyle, reviewer.effort) : null; agent[reviewer.id] = { description: `${reviewer.id} reviewer`, mode: "all", model: reviewer.model, temperature: reviewer.temperature, + // Only reviewers: the fixed roles below are written after this loop, so a reviewer + // that shares a fixed role's id cannot give that pass its level. + ...effortOptions, prompt: `You are the ${reviewer.id} code reviewer. Follow the user message exactly and return only the requested JSON.`, tools: { ...reviewer.tools, diff --git a/src/core/review.ts b/src/core/review.ts index 4bba427c..ba44e106 100644 --- a/src/core/review.ts +++ b/src/core/review.ts @@ -1,7 +1,7 @@ // @ref LLP 0002#pipeline-stages [implements] — the mode-agnostic pipeline core owning budgets, coverage, and logging import path from "node:path"; -import type { LoadedAgent, LoadedConfig } from "../config/schema.js"; +import type { AuthConfigEntry, LoadedAgent, LoadedConfig } from "../config/schema.js"; import type { PreparedReadRoot, ReviewSource, @@ -710,6 +710,7 @@ export async function runReview( } : {}), engineOf, + auth: config.auth, progress, }); @@ -2368,6 +2369,8 @@ export async function selectReviewers(args: { candidates: LoadedAgent[]; route?: () => Promise; engineOf: Record; + /** The run's credentials: a provider alias takes its upstream's effort support. */ + auth: readonly AuthConfigEntry[]; progress: (line: string) => void; }): Promise<{ selectedAgents: LoadedAgent[]; notRouted: string[] }> { let selectedAgents = args.candidates; @@ -2385,10 +2388,11 @@ export async function selectReviewers(args: { .filter((agent) => !selectedAgents.includes(agent)) .map((agent) => agent.id); - // `effort` reaches only the `claude` CLI, and never a fixed pass. Say so once for a - // selected reviewer whose level has no effect, so the setting does not fail silently. + // `effort` reaches the `claude` CLI and OpenCode's OpenAI and Google adapters, and never + // a fixed pass. Say so once for a selected reviewer whose level has no effect, so the + // setting does not fail silently. // @ref LLP 0006#agent-effort [implements] — built from the selected reviewer list, after the paths filter and the router, so an agent either of them left out is never named; a later pre-check or budget limit can still skip a named one - const effortNote = agentEffortNote(selectedAgents, args.engineOf); + const effortNote = agentEffortNote(selectedAgents, args.engineOf, args.auth); if (effortNote) { args.progress(`Note: ${effortNote}`); } diff --git a/templates/config.jsonc b/templates/config.jsonc index d9e396b0..dd901c0b 100644 --- a/templates/config.jsonc +++ b/templates/config.jsonc @@ -14,9 +14,10 @@ // e.g. `---\nmodel: anthropic/claude-opus-5-5\n---`. `paths: ["packages/ios/**"]` // there limits an agent to changes that touch those globs, and `mention: [octocat]` // names the people the review mentions when that agent asks for a human review. - // `effort: high` (low, medium, high, xhigh or max) sets how much an `anthropic/…` - // agent reasons, on a model that supports effort (Haiku 4.5 does not); other models - // ignore it. + // `effort: high` (low, medium, high, xhigh or max) sets how much an agent reasons on + // `anthropic/…`, `openai/…` (or an `upstream: "openai"` alias), `google/…`, + // `google-vertex/…` or `xai/…` models; Google takes only low, medium or high. Other models ignore + // it, and so does a model without effort support (Claude Haiku 4.5). README: "effort". // @ref LLP 0009#config-and-prompt-templates [implements] — suggestions off by default, not a schema limit "policy": { From abdfeb4a36f9ef2a7e0c2d08db3366b7d4f2e8ca Mon Sep 17 00:00:00 2001 From: szdziedzic Date: Thu, 26 Nov 2026 17:56:20 +0100 Subject: [PATCH 13/18] docs: both xAI wire formats; a provider can reject an unsupported level Astra review of d16c574 (approve with comments): - OpenCode reaches xAI two ways: with an inline key the level went to /chat/completions as `reasoning_effort`, with XAI_API_KEY set to /responses as `reasoning.effort`. The README, the source comment and LLP 0006 now name both. LLP 0006 also records that `max` and a non-reasoning Grok model get the field, and that xAI documents `low` to `xhigh` for Grok 4.7 (per that review, not re-run here). - The config template said a model without effort support ignores the level; a provider can also reject it, which fails that agent's passes. Co-Authored-By: Claude Opus 5.5 --- README.md | 2 +- llp/0006-config-schema-loading-routing.explainer.md | 7 +++++-- src/core/opencode.ts | 3 ++- templates/config.jsonc | 5 +++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 784c1ece..65f00470 100644 --- a/README.md +++ b/README.md @@ -545,7 +545,7 @@ ignores it. Leave it out to use the provider's default. | `anthropic/…` (Claude Code CLI) | `--effort ` | | `openai/…`, or an alias with `upstream: "openai"` (OpenCode) | `reasoningEffort`, sent as the Responses API `reasoning.effort` | | `google/…`, `google-vertex/…` (OpenCode) | `thinkingConfig.thinkingLevel`, in place of the model's default (OpenCode sends `high` for Gemini 4 Neon); only `low`, `medium` or `high` (for `xhigh` and `max` ecr sends no level, and the run note says so) | -| `xai/…` (Grok, OpenCode) | `reasoningEffort`, sent as Chat Completions `reasoning_effort` | +| `xai/…` (Grok, OpenCode) | `reasoningEffort`, sent as Chat Completions `reasoning_effort` or Responses API `reasoning.effort`, depending on how OpenCode reaches xAI | ecr passes the level as written and does not check which levels a model takes. A model without effort support can drop it (the Claude Code CLI sends no level to diff --git a/llp/0006-config-schema-loading-routing.explainer.md b/llp/0006-config-schema-loading-routing.explainer.md index 3ce5feee..57be2028 100644 --- a/llp/0006-config-schema-loading-routing.explainer.md +++ b/llp/0006-config-schema-loading-routing.explainer.md @@ -253,8 +253,11 @@ per-agent key and not a run-level flag. `google/gemini-4-neon` request carried `thinkingConfig: {includeThoughts: true, thinkingLevel: "high"}` with no key, and `thinkingLevel: "low"` replaced the `high`; an `xai/grok-4.7` request to `/chat/completions` carried no level field with no key, and `reasoningEffort` `"low"`, `"high"` and - `"xhigh"` arrived as `reasoning_effort` (asked for in review of PR #118; which levels xAI's API - accepts is not verified). Only reviewer entries get + `"xhigh"` arrived as `reasoning_effort` (asked for in review of PR #118). With `XAI_API_KEY` set + in the environment instead of an inline key, the same model went to `/responses` with the level in + `reasoning.effort`; `"max"` and a non-reasoning Grok model got the field too (both seen in review + of PR #118, not re-run here). Which levels xAI's API accepts is not verified; per that review, + xAI documents `low` to `xhigh` for Grok 4.7, without `max`. Only reviewer entries get the key: the fixed roles are written after the reviewer loop, so a reviewer that shares a fixed role's id cannot give that pass its level. The pinned Google adapter takes `thinkingLevel` `minimal`, `low`, `medium` and `high`; with `xhigh` or `max` the pass failed inside OpenCode diff --git a/src/core/opencode.ts b/src/core/opencode.ts index 2ff0f6a7..f1a46b74 100644 --- a/src/core/opencode.ts +++ b/src/core/opencode.ts @@ -332,7 +332,8 @@ export const GOOGLE_THINKING_LEVELS: ReadonlySet = new Set(["low", * the style's adapter does not take that level. OpenCode passes unknown agent keys to * the provider as model options; observed with OpenCode 1.19.5 against a mock endpoint * (LLP 0006): `reasoningEffort` becomes the Responses API's `reasoning.effort` (OpenAI) - * and Chat Completions' `reasoning_effort` (xAI), and `thinkingConfig.thinkingLevel` + * and, for xAI, Chat Completions' `reasoning_effort` or the Responses API's `reasoning.effort` + * (OpenCode picks the endpoint), and `thinkingConfig.thinkingLevel` * replaces the `high` that OpenCode sends to Gemini 4 Neon. */ export function opencodeEffortOptions( diff --git a/templates/config.jsonc b/templates/config.jsonc index dd901c0b..0d024185 100644 --- a/templates/config.jsonc +++ b/templates/config.jsonc @@ -16,8 +16,9 @@ // names the people the review mentions when that agent asks for a human review. // `effort: high` (low, medium, high, xhigh or max) sets how much an agent reasons on // `anthropic/…`, `openai/…` (or an `upstream: "openai"` alias), `google/…`, - // `google-vertex/…` or `xai/…` models; Google takes only low, medium or high. Other models ignore - // it, and so does a model without effort support (Claude Haiku 4.5). README: "effort". + // `google-vertex/…` or `xai/…` models; Google takes only low, medium or high. Other + // providers get no level. A model can ignore a level it does not support (Claude Haiku + // 4.5) or its provider can reject it, which fails that agent's passes. README: "effort". // @ref LLP 0009#config-and-prompt-templates [implements] — suggestions off by default, not a schema limit "policy": { From 0ae90a4c616b4dae710896ca4160f9f75a580192 Mon Sep 17 00:00:00 2001 From: szdziedzic Date: Thu, 26 Nov 2026 18:06:29 +0100 Subject: [PATCH 14/18] fix: no level for Gemini 2.5; guard OpenCode levels against global variants Devin review of abdfeb4: - Gemini 2.5 and older take a thinking budget, not a level (OpenCode itself uses thinkingBudget for them), so a thinkingLevel would fail the request. opencodeEffortStyle gives gemini-1/gemini-2 ids a `google-budget` style that sends nothing, and the run note says so. - OpenCode merges the developer's global config under ecr's and applies an agent's model variant after its options. With a global same-named agent at variant `high`, an inline reasoningEffort "low" went out as "high"; with `variant: ""` it went out as "low" (OpenAI and Gemini 4 Neon, OpenCode 1.19.5, mock endpoint). ecr now sets `variant: ""` whenever it sends a level; agents without `effort` are unchanged. Gemini Neon review of d16c574: tests now cover an `upstream: "xai"` alias and the provider list in the note, and the LoadedAgent doc names xAI. Neon saw xAI requests only on /responses; Astra and the author saw /chat/completions with an inline key and /responses with XAI_API_KEY, so the docs keep both and LLP 0006 says the endpoint depends on the setup. Co-Authored-By: Claude Opus 5.5 --- README.md | 4 +-- ...config-schema-loading-routing.explainer.md | 14 +++++++-- src/__tests__/claude-code.test.ts | 12 ++++++++ src/__tests__/opencode.test.ts | 30 ++++++++++++++++++- src/config/schema.ts | 5 ++-- src/core/claude-code.ts | 28 +++++++++++++++-- src/core/opencode.ts | 16 +++++++--- 7 files changed, 95 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 65f00470..0df4a484 100644 --- a/README.md +++ b/README.md @@ -544,10 +544,10 @@ ignores it. Leave it out to use the provider's default. | --- | --- | | `anthropic/…` (Claude Code CLI) | `--effort ` | | `openai/…`, or an alias with `upstream: "openai"` (OpenCode) | `reasoningEffort`, sent as the Responses API `reasoning.effort` | -| `google/…`, `google-vertex/…` (OpenCode) | `thinkingConfig.thinkingLevel`, in place of the model's default (OpenCode sends `high` for Gemini 4 Neon); only `low`, `medium` or `high` (for `xhigh` and `max` ecr sends no level, and the run note says so) | +| `google/…`, `google-vertex/…` (OpenCode) | `thinkingConfig.thinkingLevel`, in place of the model's default (OpenCode sends `high` for Gemini 4 Neon); only `low`, `medium` or `high` (for `xhigh` and `max` ecr sends no level, and the run note says so). Gemini 2.5 and older take a thinking budget, not a level, so ecr sends them none and the run note says so | | `xai/…` (Grok, OpenCode) | `reasoningEffort`, sent as Chat Completions `reasoning_effort` or Responses API `reasoning.effort`, depending on how OpenCode reaches xAI | -ecr passes the level as written and does not check which levels a model takes. A +ecr passes the level as written and does not check which levels a model takes. When it sends a level through OpenCode it also sets the agent's `variant` to `""`, so a variant on a same-named agent in your global OpenCode config cannot replace it. A model without effort support can drop it (the Claude Code CLI sends no level to Claude Haiku 4.5), and a provider can reject a level its model does not take, which fails that agent's passes with the provider's error. diff --git a/llp/0006-config-schema-loading-routing.explainer.md b/llp/0006-config-schema-loading-routing.explainer.md index 57be2028..f253ddbd 100644 --- a/llp/0006-config-schema-loading-routing.explainer.md +++ b/llp/0006-config-schema-loading-routing.explainer.md @@ -256,10 +256,20 @@ per-agent key and not a run-level flag. `"xhigh"` arrived as `reasoning_effort` (asked for in review of PR #118). With `XAI_API_KEY` set in the environment instead of an inline key, the same model went to `/responses` with the level in `reasoning.effort`; `"max"` and a non-reasoning Grok model got the field too (both seen in review - of PR #118, not re-run here). Which levels xAI's API accepts is not verified; per that review, + of PR #118, not re-run here; a second review saw only `/responses`, so the endpoint depends on + the setup). Which levels xAI's API accepts is not verified; per that review, xAI documents `low` to `xhigh` for Grok 4.7, without `max`. Only reviewer entries get the key: the fixed roles are written after the reviewer loop, so a reviewer that shares a fixed - role's id cannot give that pass its level. The pinned Google adapter takes `thinkingLevel` + role's id cannot give that pass its level. Gemini 2.5 and older take a thinking budget, not a + level (OpenCode uses `thinkingBudget` for them; found in review of PR #118), so + `opencodeEffortStyle` gives `gemini-1…`/`gemini-2…` ids the `google-budget` style, which sends + nothing, and the run note says so (unit-tested; a `google/gemini-2.5-flash` probe sent no request + even without a level, so this was not observed on the wire). When ecr sends a level it also sets + the agent's `variant` to `""`: OpenCode merges the developer's global config under ecr's and applies + an agent's model variant after its options, and with a global same-named agent at variant `high`, + an inline `reasoningEffort: "low"` went out as `"high"`; with `variant: ""` it went out as `"low"` + (OpenAI and Gemini 4 Neon, OpenCode 1.19.5, mock endpoint, 2026-11-26) [observed]. An agent without + `effort` keeps OpenCode's variant behavior. The pinned Google adapter takes `thinkingLevel` `minimal`, `low`, `medium` and `high`; with `xhigh` or `max` the pass failed inside OpenCode (an invalid-provider-options error) with no request sent, on `google/…` and `google-vertex/…` [observed]. OpenCode's model catalog lists more variants for some Gemini models; the limit comes diff --git a/src/__tests__/claude-code.test.ts b/src/__tests__/claude-code.test.ts index e122f285..cbc181f8 100644 --- a/src/__tests__/claude-code.test.ts +++ b/src/__tests__/claude-code.test.ts @@ -940,11 +940,23 @@ test("agentEffortNote: OpenAI, Google and xAI models take a level through OpenCo expect(note).toContain( "the model of each runs through OpenCode on a provider ecr passes no level to (ecr passes one only for `anthropic/…`", ); + expect(note).toContain("`google-vertex/…` or `xai/…`)"); expect(named(note)).toBe("muse"); // Without the alias's auth entry, `openai-api` is not known to be OpenAI. expect(named(agentEffortNote(agents, engineOf, []))).toBe("pro, muse"); }); +test("agentEffortNote: a Gemini 2.5 reviewer is told it takes a budget, once", () => { + const agents = [ + { id: "flash", effort: "high", model: "google-vertex/gemini-2.5-flash" }, + ] as unknown as LoadedAgent[]; + const note = agentEffortNote(agents, { flash: "opencode" }, []); + expect(note).toContain( + "has no effect for flash: Gemini 2.5 and older models take a thinking budget", + ); + expect(note?.split("has no effect").length).toBe(2); +}); + test("agentEffortNote: a Google level the pinned adapter rejects is named with the levels it takes", () => { const agents = [ { id: "neon", effort: "xhigh", model: "google/gemini-4-neon" }, diff --git a/src/__tests__/opencode.test.ts b/src/__tests__/opencode.test.ts index 65cd47ec..5568cb5a 100644 --- a/src/__tests__/opencode.test.ts +++ b/src/__tests__/opencode.test.ts @@ -694,12 +694,14 @@ describe("Recording an OpenCode pass for the session archive", () => { }, 20_000); }); -test("opencodeEffortStyle: OpenAI and Google families take a level; others do not", () => { +test("opencodeEffortStyle: OpenAI, Google and xAI families take a level; others do not", () => { const alias = [ { provider: "openai-api", mode: "api-key", tokenEnv: "OPENAI_API_KEY", upstream: "openai" }, { provider: "claude-api", mode: "api-key", tokenEnv: "ANTHROPIC_KEY_2", upstream: "anthropic" }, // ecr builds this alias with the OpenAI-compatible adapter, not Google's. { provider: "gemini-api", mode: "api-key", tokenEnv: "GEMINI_KEY_2", upstream: "google" }, + // Also OpenAI-compatible, not xAI's adapter. + { provider: "xai-api", mode: "api-key", tokenEnv: "XAI_KEY_2", upstream: "xai" }, ] as unknown as LoadedConfig["auth"]; expect(opencodeEffortStyle("openai/gpt-6.2-astra", [])).toBe("openai"); expect(opencodeEffortStyle("openai-api/gpt-5.5-pro", alias)).toBe("openai"); @@ -708,9 +710,15 @@ test("opencodeEffortStyle: OpenAI and Google families take a level; others do no expect(opencodeEffortStyle("google-vertex/gemini-4-neon", [])).toBe("google"); expect(opencodeEffortStyle("claude-api/claude-opus-5-5", alias)).toBeNull(); expect(opencodeEffortStyle("gemini-api/gemini-4-neon", alias)).toBeNull(); + expect(opencodeEffortStyle("xai-api/grok-4.7", alias)).toBeNull(); expect(opencodeEffortStyle("meta/muse-spark-1.3", [])).toBeNull(); expect(opencodeEffortStyle("gpt-6.2-astra", [])).toBeNull(); expect(opencodeEffortStyle("xai/grok-4.7", [])).toBe("xai"); + // Gemini 2.5 and older take a thinking budget, not a level. + expect(opencodeEffortStyle("google/gemini-2.5-flash", [])).toBe("google-budget"); + expect(opencodeEffortStyle("google-vertex/gemini-2.5-pro", [])).toBe("google-budget"); + expect(opencodeEffortStyle("google/gemini-1.5-pro", [])).toBe("google-budget"); + expect(opencodeEffortStyle("google/gemini-3-pro", [])).toBe("google"); }); test("buildOpencodeConfig passes a reviewer's effort as its provider's option, and only a reviewer's", () => { @@ -778,3 +786,23 @@ test("buildOpencodeConfig passes a Grok reviewer's level as reasoningEffort", () expect(opencode.agent.grok!.reasoningEffort).toBe("xhigh"); expect(opencode.agent.grok!.thinkingConfig).toBeUndefined(); }); + +test('buildOpencodeConfig: no level for Gemini 2.5; `variant: ""` guards every level it sends', () => { + const opencode = buildOpencodeConfig( + configWith({ + agents: [ + { id: "flash", model: "google-vertex/gemini-2.5-flash", effort: "high" }, + { id: "neon", model: "google/gemini-4-neon", effort: "low" }, + { id: "astra", model: "openai/gpt-6.2-astra", effort: "xhigh" }, + { id: "plain", model: "openai/gpt-6.2-astra" }, + ], + }), + ) as { agent: Record> }; + expect(opencode.agent.flash!.thinkingConfig).toBeUndefined(); + expect("variant" in opencode.agent.flash!).toBe(false); + // A global OpenCode agent of the same name with a variant would otherwise replace the level. + expect(opencode.agent.neon!.variant).toBe(""); + expect(opencode.agent.astra!.variant).toBe(""); + // An agent without effort keeps OpenCode's own variant behavior. + expect("variant" in opencode.agent.plain!).toBe(false); +}); diff --git a/src/config/schema.ts b/src/config/schema.ts index 5a56f5ec..971d2d3b 100644 --- a/src/config/schema.ts +++ b/src/config/schema.ts @@ -623,8 +623,9 @@ export interface LoadedAgent { paths?: string[]; /** * Frontmatter `effort`: how much reasoning the model spends on this agent's passes. - * The claude-code engine passes it as `--effort`; OpenCode passes it for OpenAI and - * Google models (opencodeEffortStyle). Absent means the provider's own default. + * The claude-code engine passes it as `--effort`; OpenCode passes it for OpenAI, Google + * (Gemini 3 and later) and xAI models (opencodeEffortStyle). Absent means the provider's + * own default. */ effort?: AgentEffort; /** diff --git a/src/core/claude-code.ts b/src/core/claude-code.ts index 1fbfcaf3..d542ec92 100644 --- a/src/core/claude-code.ts +++ b/src/core/claude-code.ts @@ -833,15 +833,20 @@ export function agentEffortNote( auth: readonly AuthConfigEntry[], ): string | null { const declared = agents.filter((agent) => agent.effort); - const takesNoLevel = (model: string): boolean => - engineForModel(model) === "opencode" && opencodeEffortStyle(model, auth) === null; + const takesNoLevel = (model: string): boolean => { + if (engineForModel(model) !== "opencode") { + return false; + } + const style = opencodeEffortStyle(model, auth); + return style === null || style === "google-budget"; + }; const viaOpencode = declared .filter( (agent) => !FIXED_ROLE_IDS.has(agent.id) && !OPENCODE_BUILTIN_AGENTS.has(agent.id) && engineOf[agent.id] === "opencode" && - takesNoLevel(agent.model ?? ""), + opencodeEffortStyle(agent.model ?? "", auth) === null, ) .map((agent) => agent.id); // A Google model whose level the pinned adapter rejects gets no level (opencodeEffortOptions). @@ -856,6 +861,16 @@ export function agentEffortNote( !GOOGLE_THINKING_LEVELS.has(agent.effort), ) .map((agent) => `${agent.id} (${agent.effort})`); + // Gemini 2.5 and older take a thinking budget, not a level (opencodeEffortStyle). + const googleBudget = declared + .filter( + (agent) => + !FIXED_ROLE_IDS.has(agent.id) && + !OPENCODE_BUILTIN_AGENTS.has(agent.id) && + engineOf[agent.id] === "opencode" && + opencodeEffortStyle(agent.model ?? "", auth) === "google-budget", + ) + .map((agent) => agent.id); const fixedRole = declared .filter((agent) => FIXED_ROLE_IDS.has(agent.id)) .map((agent) => agent.id); @@ -902,6 +917,13 @@ export function agentEffortNote( `OpenCode on a provider ecr passes no level to (ecr passes one only for ${EFFORT_PROVIDERS})`, ); } + if (googleBudget.length > 0) { + notes.push( + `\`effort\` has no effect for ${googleBudget.join(", ")}: Gemini 2.5 and older models take a ` + + "thinking budget, not a level, so ecr sends none. Fix: use a Gemini 3 or later model, or " + + "remove `effort`", + ); + } if (googleLevelNotTaken.length > 0) { notes.push( `\`effort\` has no effect for ${googleLevelNotTaken.join(", ")}: OpenCode's Google adapter ` + diff --git a/src/core/opencode.ts b/src/core/opencode.ts index f1a46b74..94a19ea9 100644 --- a/src/core/opencode.ts +++ b/src/core/opencode.ts @@ -285,7 +285,7 @@ export const STACK_VERIFIER_AGENT = "stack-verifier"; * OpenAI's Responses adapter and xAI's adapter read `reasoningEffort`, Google's reads * `thinkingConfig.thinkingLevel`. */ -export type OpencodeEffortStyle = "openai" | "google" | "xai"; +export type OpencodeEffortStyle = "openai" | "google" | "google-budget" | "xai"; /** * The effort style for a model id, or null when ecr does not pass a level to that @@ -312,7 +312,9 @@ export function opencodeEffortStyle( return "openai"; } if (provider === "google" || provider === "google-vertex") { - return "google"; + // Gemini 2.5 and older take a thinking budget, not a level; OpenCode itself uses + // thinkingBudget for them (review of PR #118), so ecr sends them no level. + return /^gemini-[12](?:[.-]|$)/.test(model.slice(slash + 1)) ? "google-budget" : "google"; } if (provider === "xai") { return "xai"; @@ -343,6 +345,9 @@ export function opencodeEffortOptions( if (style === "openai" || style === "xai") { return { reasoningEffort: effort }; } + if (style === "google-budget") { + return null; + } return GOOGLE_THINKING_LEVELS.has(effort) ? { thinkingConfig: { thinkingLevel: effort } } : null; } @@ -388,8 +393,11 @@ export function buildOpencodeConfig( model: reviewer.model, temperature: reviewer.temperature, // Only reviewers: the fixed roles below are written after this loop, so a reviewer - // that shares a fixed role's id cannot give that pass its level. - ...effortOptions, + // that shares a fixed role's id cannot give that pass its level. `variant: ""`: + // OpenCode merges the developer's global config under this one and applies an + // agent's model variant last, so a global agent of the same name with a variant + // would replace this level (observed with 1.19.5; LLP 0006). + ...(effortOptions ? { ...effortOptions, variant: "" } : {}), prompt: `You are the ${reviewer.id} code reviewer. Follow the user message exactly and return only the requested JSON.`, tools: { ...reviewer.tools, From a1894dbef886997279beca4fa7e7f101cf7b842b Mon Sep 17 00:00:00 2001 From: szdziedzic Date: Thu, 26 Nov 2026 18:12:51 +0100 Subject: [PATCH 15/18] fix: full Gemini 2.5 fix in the note; say what omitting effort means Astra review of 0ae90a4 (approve with comments): - The Gemini 2.5 note said to switch to Gemini 3 or later; with `effort: max` that still sends nothing. It now says to use Gemini 3 or later with low, medium or high, or remove `effort`. - Omitting `effort` leaves the level to the engine, which on OpenCode includes a variant from the developer's global config; the README and the LoadedAgent doc no longer say "the provider's default". - The note test checks the full provider list; the variant-guard test covers a Grok reviewer. Co-Authored-By: Claude Opus 5.5 --- README.md | 3 ++- src/__tests__/claude-code.test.ts | 5 ++++- src/__tests__/opencode.test.ts | 2 ++ src/config/schema.ts | 5 +++-- src/core/claude-code.ts | 4 ++-- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 0df4a484..64bdc826 100644 --- a/README.md +++ b/README.md @@ -538,7 +538,8 @@ are ignored), and a comment that breaks `alwaysRun`, `model` or `temperature`. `effort` sets how much reasoning the model spends on that agent's passes. ecr passes it for these models, and for any other model the review prints a note and -ignores it. Leave it out to use the provider's default. +ignores it. Leave it out to leave the level to the engine: the CLI default, or on +OpenCode the model's default or a variant set in your global OpenCode config. | Model | How the level is sent | | --- | --- | diff --git a/src/__tests__/claude-code.test.ts b/src/__tests__/claude-code.test.ts index cbc181f8..5dff3799 100644 --- a/src/__tests__/claude-code.test.ts +++ b/src/__tests__/claude-code.test.ts @@ -940,7 +940,9 @@ test("agentEffortNote: OpenAI, Google and xAI models take a level through OpenCo expect(note).toContain( "the model of each runs through OpenCode on a provider ecr passes no level to (ecr passes one only for `anthropic/…`", ); - expect(note).toContain("`google-vertex/…` or `xai/…`)"); + expect(note).toContain( + '(ecr passes one only for `anthropic/…`, `openai/…` (or an `upstream: "openai"` alias), `google/…`, `google-vertex/…` or `xai/…`)', + ); expect(named(note)).toBe("muse"); // Without the alias's auth entry, `openai-api` is not known to be OpenAI. expect(named(agentEffortNote(agents, engineOf, []))).toBe("pro, muse"); @@ -954,6 +956,7 @@ test("agentEffortNote: a Gemini 2.5 reviewer is told it takes a budget, once", ( expect(note).toContain( "has no effect for flash: Gemini 2.5 and older models take a thinking budget", ); + expect(note).toContain("Fix: use a Gemini 3 or later model with low, medium or high"); expect(note?.split("has no effect").length).toBe(2); }); diff --git a/src/__tests__/opencode.test.ts b/src/__tests__/opencode.test.ts index 5568cb5a..7e3f298a 100644 --- a/src/__tests__/opencode.test.ts +++ b/src/__tests__/opencode.test.ts @@ -794,6 +794,7 @@ test('buildOpencodeConfig: no level for Gemini 2.5; `variant: ""` guards every l { id: "flash", model: "google-vertex/gemini-2.5-flash", effort: "high" }, { id: "neon", model: "google/gemini-4-neon", effort: "low" }, { id: "astra", model: "openai/gpt-6.2-astra", effort: "xhigh" }, + { id: "grok", model: "xai/grok-4.7", effort: "high" }, { id: "plain", model: "openai/gpt-6.2-astra" }, ], }), @@ -803,6 +804,7 @@ test('buildOpencodeConfig: no level for Gemini 2.5; `variant: ""` guards every l // A global OpenCode agent of the same name with a variant would otherwise replace the level. expect(opencode.agent.neon!.variant).toBe(""); expect(opencode.agent.astra!.variant).toBe(""); + expect(opencode.agent.grok!.variant).toBe(""); // An agent without effort keeps OpenCode's own variant behavior. expect("variant" in opencode.agent.plain!).toBe(false); }); diff --git a/src/config/schema.ts b/src/config/schema.ts index 971d2d3b..4ea371fd 100644 --- a/src/config/schema.ts +++ b/src/config/schema.ts @@ -624,8 +624,9 @@ export interface LoadedAgent { /** * Frontmatter `effort`: how much reasoning the model spends on this agent's passes. * The claude-code engine passes it as `--effort`; OpenCode passes it for OpenAI, Google - * (Gemini 3 and later) and xAI models (opencodeEffortStyle). Absent means the provider's - * own default. + * (Gemini 3 and later) and xAI models (opencodeEffortStyle). Absent leaves the level to + * the engine: the CLI default, or on OpenCode the model's default or a variant from the + * developer's global OpenCode config. */ effort?: AgentEffort; /** diff --git a/src/core/claude-code.ts b/src/core/claude-code.ts index d542ec92..ef47d1ca 100644 --- a/src/core/claude-code.ts +++ b/src/core/claude-code.ts @@ -920,8 +920,8 @@ export function agentEffortNote( if (googleBudget.length > 0) { notes.push( `\`effort\` has no effect for ${googleBudget.join(", ")}: Gemini 2.5 and older models take a ` + - "thinking budget, not a level, so ecr sends none. Fix: use a Gemini 3 or later model, or " + - "remove `effort`", + "thinking budget, not a level, so ecr sends none. Fix: use a Gemini 3 or later model with " + + "low, medium or high, or remove `effort`", ); } if (googleLevelNotTaken.length > 0) { From 8cb739850e1a3af96884cbdd05f0c613bed39ac7 Mon Sep 17 00:00:00 2001 From: szdziedzic Date: Thu, 26 Nov 2026 18:18:37 +0100 Subject: [PATCH 16/18] docs: mark Google levels as Gemini 3 and later in notes, template, docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Gemini Neon review of 0ae90a4 (approve with comments): - The provider list in the run notes named `google/…` without the Gemini 3+ limit, so a fixed-role or built-in-id reviewer already on Gemini 2.5 was told to move to `google/…`. The list now says "(Gemini 3 and later)". - The config template and the OpencodeEffortStyle / agentEffortNote doc comments mention the Gemini 2.5 budget case. - LLP 0006 records the review's wire result for gemini-2.5-flash (thinkingLevel goes out when set, none without it) next to the author's probe, which sent no request. Co-Authored-By: Claude Opus 5.5 --- llp/0006-config-schema-loading-routing.explainer.md | 6 ++++-- src/__tests__/claude-code.test.ts | 2 +- src/core/claude-code.ts | 7 ++++--- src/core/opencode.ts | 3 ++- templates/config.jsonc | 3 ++- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/llp/0006-config-schema-loading-routing.explainer.md b/llp/0006-config-schema-loading-routing.explainer.md index f253ddbd..6b9a03ba 100644 --- a/llp/0006-config-schema-loading-routing.explainer.md +++ b/llp/0006-config-schema-loading-routing.explainer.md @@ -263,8 +263,10 @@ per-agent key and not a run-level flag. role's id cannot give that pass its level. Gemini 2.5 and older take a thinking budget, not a level (OpenCode uses `thinkingBudget` for them; found in review of PR #118), so `opencodeEffortStyle` gives `gemini-1…`/`gemini-2…` ids the `google-budget` style, which sends - nothing, and the run note says so (unit-tested; a `google/gemini-2.5-flash` probe sent no request - even without a level, so this was not observed on the wire). When ecr sends a level it also sets + nothing, and the run note says so. A review of PR #118 saw, with OpenCode 1.19.5, a + `google/gemini-2.5-flash` request carry `thinkingLevel: "low"` when it was set (the adapter does + not reject it; Google's API does) and no `thinkingLevel` without it; the author's own probe of + that model sent no request, so the wire result is the review's. When ecr sends a level it also sets the agent's `variant` to `""`: OpenCode merges the developer's global config under ecr's and applies an agent's model variant after its options, and with a global same-named agent at variant `high`, an inline `reasoningEffort: "low"` went out as `"high"`; with `variant: ""` it went out as `"low"` diff --git a/src/__tests__/claude-code.test.ts b/src/__tests__/claude-code.test.ts index 5dff3799..45289839 100644 --- a/src/__tests__/claude-code.test.ts +++ b/src/__tests__/claude-code.test.ts @@ -941,7 +941,7 @@ test("agentEffortNote: OpenAI, Google and xAI models take a level through OpenCo "the model of each runs through OpenCode on a provider ecr passes no level to (ecr passes one only for `anthropic/…`", ); expect(note).toContain( - '(ecr passes one only for `anthropic/…`, `openai/…` (or an `upstream: "openai"` alias), `google/…`, `google-vertex/…` or `xai/…`)', + '(ecr passes one only for `anthropic/…`, `openai/…` (or an `upstream: "openai"` alias), `google/…` or `google-vertex/…` (Gemini 3 and later), or `xai/…`)', ); expect(named(note)).toBe("muse"); // Without the alias's auth entry, `openai-api` is not known to be OpenAI. diff --git a/src/core/claude-code.ts b/src/core/claude-code.ts index ef47d1ca..ed4590a1 100644 --- a/src/core/claude-code.ts +++ b/src/core/claude-code.ts @@ -820,8 +820,9 @@ export function buildAgentEfforts(config: LoadedConfig): Map Date: Thu, 26 Nov 2026 23:46:11 +0100 Subject: [PATCH 17/18] fix: keep OpenCode variants and send Gemini levels only to Gemini models MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Stop setting `variant: ""` when ecr sends a level. Clearing the variant also dropped its other options, such as an OpenAI service tier. A variant on a same-named agent in the developer's own OpenCode config now wins. - `google-vertex` also serves Claude on the Anthropic adapter, which ignores `thinkingConfig`. Only `gemini-…` ids get the Google style now. - LLP 0006: shorten "Agent Effort" to the high-level design. Co-Authored-By: Claude Opus 5.5 --- ...config-schema-loading-routing.explainer.md | 141 ++++-------------- src/__tests__/opencode.test.ts | 20 +-- src/config/schema.ts | 8 +- src/core/opencode.ts | 29 ++-- 4 files changed, 63 insertions(+), 135 deletions(-) diff --git a/llp/0006-config-schema-loading-routing.explainer.md b/llp/0006-config-schema-loading-routing.explainer.md index 6b9a03ba..9f62d40e 100644 --- a/llp/0006-config-schema-loading-routing.explainer.md +++ b/llp/0006-config-schema-loading-routing.explainer.md @@ -219,115 +219,38 @@ is letters, digits and underscores joined by single hyphens. An agent without `m ## Agent Effort -An agent file may set `effort: low|medium|high|xhigh|max` in its frontmatter. The need came from an -eval replay on one monorepo: a correctness reviewer on an `anthropic/…` model ended a pass after a -median of 8 turns [observed], and a model-written miss analysis put 20 of 55 problems that human -reviewers raised in the class "needs a logic trace" (eval run `full-v2-tune`, 2026-11-25; the data -is private and not in this repo; no person checked the analysis). Depth is a per-agent need, and it costs time and money, so it is a -per-agent key and not a run-level flag. - -- **The claude-code engine passes it as a flag.** `startClaudeCode` copies the declared levels into - `ClaudeCodeHandle.efforts`, and `runClaudePrompt` passes `--effort ` for that agent's - passes [observed] (`buildClaudeArgs` `effort`; tests in `src/__tests__/claude-code.test.ts`). The - fixed roles (cross-cutting, verifier, adjudicator, stack verifier, coordinator) have no entry and - get no flag. The flag exists in the pinned `@anthropic-ai/claude-code@2.1.280` [observed] - (`claude --help`, 2026-11-25). -- **The levels are keyed by pass id, so fixed-role ids are excluded.** Passes are looked up by - agent id, and a reviewer file can share a fixed role's id (`agents/verifier.md`). With an entry, - its level would also reach the built-in pass of that id. `buildAgentEfforts` gives such a - reviewer no entry, and the run note tells the author to rename the file. The id set is the - session archive's `NON_REVIEWER_AGENTS`, so the two cannot drift. The levels live in a - `Map`, so an id such as `constructor` cannot read an inherited `Object.prototype` value - (both found in review of the first version, PR #118). -- **OpenCode passes it for OpenAI, Google and xAI models.** OpenCode hands unknown agent-config keys to - the provider as model options. `buildOpencodeConfig` adds one per reviewer with `effort`, chosen - by `opencodeEffortStyle` from the adapter ecr gives the model's provider: native `openai` and an - alias with `upstream: "openai"` (built on `@ai-sdk/openai`) get `reasoningEffort`; native - `google` and `google-vertex` get `thinkingConfig.thinkingLevel`; native `xai` (Grok, on - `@ai-sdk/xai`) gets `reasoningEffort`. Any other alias, including - `upstream: "google"` (built on `@ai-sdk/openai-compatible`), gets nothing: a Google key on that - adapter reached a mock endpoint as a top-level `thinkingConfig` on `/chat/completions` (found in - review of PR #119). Observed with the pinned OpenCode 1.19.5 against a local mock - endpoint (2026-11-26) [observed]: with no key, an `openai/gpt-6.2-astra` request carried no - `reasoning` field; `reasoningEffort: "xhigh"` and `"max"` arrived as `reasoning.effort`; a - `google/gemini-4-neon` request carried `thinkingConfig: {includeThoughts: true, thinkingLevel: - "high"}` with no key, and `thinkingLevel: "low"` replaced the `high`; an `xai/grok-4.7` request to - `/chat/completions` carried no level field with no key, and `reasoningEffort` `"low"`, `"high"` and - `"xhigh"` arrived as `reasoning_effort` (asked for in review of PR #118). With `XAI_API_KEY` set - in the environment instead of an inline key, the same model went to `/responses` with the level in - `reasoning.effort`; `"max"` and a non-reasoning Grok model got the field too (both seen in review - of PR #118, not re-run here; a second review saw only `/responses`, so the endpoint depends on - the setup). Which levels xAI's API accepts is not verified; per that review, - xAI documents `low` to `xhigh` for Grok 4.7, without `max`. Only reviewer entries get - the key: the fixed roles are written after the reviewer loop, so a reviewer that shares a fixed - role's id cannot give that pass its level. Gemini 2.5 and older take a thinking budget, not a - level (OpenCode uses `thinkingBudget` for them; found in review of PR #118), so - `opencodeEffortStyle` gives `gemini-1…`/`gemini-2…` ids the `google-budget` style, which sends - nothing, and the run note says so. A review of PR #118 saw, with OpenCode 1.19.5, a - `google/gemini-2.5-flash` request carry `thinkingLevel: "low"` when it was set (the adapter does - not reject it; Google's API does) and no `thinkingLevel` without it; the author's own probe of - that model sent no request, so the wire result is the review's. When ecr sends a level it also sets - the agent's `variant` to `""`: OpenCode merges the developer's global config under ecr's and applies - an agent's model variant after its options, and with a global same-named agent at variant `high`, - an inline `reasoningEffort: "low"` went out as `"high"`; with `variant: ""` it went out as `"low"` - (OpenAI and Gemini 4 Neon, OpenCode 1.19.5, mock endpoint, 2026-11-26) [observed]. An agent without - `effort` keeps OpenCode's variant behavior. The pinned Google adapter takes `thinkingLevel` - `minimal`, `low`, `medium` and `high`; with `xhigh` or `max` the pass failed inside OpenCode - (an invalid-provider-options error) with no request sent, on `google/…` and `google-vertex/…` - [observed]. OpenCode's model catalog lists more variants for some Gemini models; the limit comes - from the bundled Google SDK's option schema, so re-check it when the OpenCode pins move. So - `GOOGLE_THINKING_LEVELS` is `low`, `medium`, `high`: for the other two ecr sends no - key, the model runs at its default in OpenCode (`high` for Gemini 4 Neon; a `google/gemini-2.5-flash` - request carried no `thinkingLevel`, per review of PR #119), and the run note names the agent, its level - and the levels that work. Not observed: the ChatGPT/Codex sign-in path and a - real provider's response to each level. ecr passes the level as written; a provider that does - not take it fails that agent's passes with its own error. -- **No level on OpenCode's own agent ids.** OpenCode 1.19.5 defines `build`, `compaction`, - `explore`, `general`, `plan`, `summary` and `title` (`app.agents()`, `native: true`, 2026-11-26) [observed]; a - reviewer config with one of these ids replaces that agent, and `compaction`, `summary` and `title` - also run for other sessions. A reviewer level there reached another reviewer's session - compaction (found in review of PR #119), so `buildOpencodeConfig` gives these ids no level - (`OPENCODE_BUILTIN_AGENTS`), and the run note tells the author to rename the file. -- **Any other OpenCode-routed agent ignores it, with a note.** `agentEffortNote` names agents whose - OpenCode provider takes no level (Meta, OpenAI-compatible and others) once per run, the same way - `claudeTemperatureNote` reports a temperature the CLI cannot take. - `selectReviewers`, which `runReview` calls, builds it from the selected reviewer list, after the - `paths` filter and the router, so an agent either of them left out is never named. A later step - (a blocking pre-check, the budget) can still skip a named agent, so the note states a fact about - the setup ("has no effect for X"), not about a pass that ran. -- **The model must support effort.** The CLI accepts every level for every model, but a model - without effort support gets none: a request from the pinned CLI to `claude-haiku-4-5` with - `--effort high` carried no effort field, and one to `claude-opus-5-5` did (seen in review of PR - #118 against a local mock endpoint, not re-run here). The engine does not check model support. -- **Only reviewer files take it.** `effort` in `coordinator.md` or `shared.md` frontmatter has no - effect, so the loader adds a setup warning that says to remove it, instead of ignoring it. -- **The claude-code no-tools fallback runs at `min(level, medium)`; OpenCode keeps the level.** A - timed-out pass is retried with no tools under a short cap (`maxToolCalls: 0`). A deep level there - would likely time out again (found in a multi-model review of PR #118, not measured in a live - run), and sending no level would use the CLI's default, which can be higher than the agent's own - `low`. So `fallbackEffort` caps the level at `medium` and never raises it, and `runClaudePrompt` - passes that for the fallback. Only the claude-code engine applies this cap. On OpenCode the - fallback, and the finalize and corrective prompts, run at the agent's own level: OpenCode reads - the level from the agent config, and ecr cannot know which lower levels a model takes (GPT-5 pro - takes only `high`, per the provider's docs cited in review of PR #119), so it never sends a level - the author did not write. An earlier version of PR #119 gave each such reviewer a - `__fallback-effort` copy at `min(level, medium)`; review showed it could send a rejected - level, so it was removed. -- **An invalid level never stops a review.** `parseAgentEffort` returns a setup warning with the - fix and no `effort`, so the agent runs at the default. The warning does not repeat the value: a - backtick in it would close the code span in the review comment, and setup notes are not - length-capped. The value is matched after trim and - lower-case, and a trailing `# comment` makes it invalid like any other text. -- **Absent adds no key.** `LoadedAgent.effort` is set only when declared, so a setup without it - keeps its review-cache key, and a setup that adds or changes it gets a fresh review. -- **Not handled here.** In a routed scope, a root `enforceAgents` entry replaces a same-id scope - agent, but the scope keeps its own setup warnings: an invalid root `effort` shows no warning - there, and an invalid scope `effort` warns about an agent that runs at the root's level. `mention` - warnings behave the same way, so a fix belongs to all per-agent warnings at once. An unmatched - quote (`effort: "max`) loads as `max`, because the shared frontmatter reader strips each quote on - its own for every key. -- **`REVIEWER_MODEL` does not clear it.** The override can move an agent to another provider; the - level then goes to that provider, or the note reports it as ignored. +An agent file may set `effort: low|medium|high|xhigh|max` in its frontmatter. Depth is a per-agent +need (a correctness reviewer that must trace callers, not a conventions reviewer), and it costs time +and money, so it is a per-agent key and not a run-level flag. In an eval replay on one monorepo, a +correctness reviewer ended a pass after a median of 8 turns [observed]. + +- **Each engine maps the level to what its model takes.** The claude-code engine passes the CLI's + `--effort`. OpenCode passes it as a model option for the providers whose adapter takes a level: + OpenAI (and an `upstream: "openai"` alias), Gemini 3 and later on `google`/`google-vertex`, and + xAI (`opencodeEffortStyle`). Everything else gets no level: other providers and aliases, Claude + on Vertex (another adapter), Gemini 2.5 and older (they take a thinking budget, not a level), and + Gemini `xhigh`/`max` (the bundled Google adapter rejects them). The pinned OpenCode behavior was + checked against a mock endpoint [observed]; re-check it when the pins move. +- **ecr passes the level as written.** It does not check which levels a model supports; a model can + ignore a level, and a provider can reject one, which fails that agent's passes. +- **Only reviewers get a level.** Levels are looked up by agent id, so a reviewer file that shares + the id of a fixed pass (verifier, cross-cutting, adjudicator, stack-verifier, coordinator) or of + an OpenCode built-in agent (`compaction`, `title`, …) gets none, because the level would also reach + that pass. `effort` in `coordinator.md` or `shared.md` is a setup warning. +- **A note names every level that has no effect.** `selectReviewers` builds it after the `paths` + filter and the router, so it names only selected reviewers, with the fix. +- **The no-tools fallback does not run deeper.** On the claude-code engine, a timed-out pass retried + without tools runs at `min(level, medium)`. On OpenCode it keeps the agent's level, because a + model can reject a lower level that the author did not write. +- **A developer's OpenCode variant wins.** OpenCode applies a variant set on a same-named agent in the + developer's own OpenCode config after ecr's options. ecr does not clear it, because a variant can + carry other options too (for example a service tier). +- **It never stops a review.** An invalid value is a setup warning that does not repeat the value, + and the agent runs at the default. An absent key adds nothing to the agent, so its review-cache key + does not change. `REVIEWER_MODEL` keeps the level. +- **Not handled here.** In a routed scope with `enforceAgents`, per-agent warnings come from the + scope's own files (`mention` has the same gap). The shared frontmatter reader strips an unmatched + quote (`effort: "max` loads as `max`). ## Budgets and Chunking Defaults diff --git a/src/__tests__/opencode.test.ts b/src/__tests__/opencode.test.ts index 7e3f298a..71c62eba 100644 --- a/src/__tests__/opencode.test.ts +++ b/src/__tests__/opencode.test.ts @@ -719,6 +719,8 @@ test("opencodeEffortStyle: OpenAI, Google and xAI families take a level; others expect(opencodeEffortStyle("google-vertex/gemini-2.5-pro", [])).toBe("google-budget"); expect(opencodeEffortStyle("google/gemini-1.5-pro", [])).toBe("google-budget"); expect(opencodeEffortStyle("google/gemini-3-pro", [])).toBe("google"); + // Vertex also serves Claude, on the Anthropic adapter, which ignores thinkingConfig. + expect(opencodeEffortStyle("google-vertex/claude-opus-5-5@default", [])).toBeNull(); }); test("buildOpencodeConfig passes a reviewer's effort as its provider's option, and only a reviewer's", () => { @@ -787,24 +789,22 @@ test("buildOpencodeConfig passes a Grok reviewer's level as reasoningEffort", () expect(opencode.agent.grok!.thinkingConfig).toBeUndefined(); }); -test('buildOpencodeConfig: no level for Gemini 2.5; `variant: ""` guards every level it sends', () => { +test("buildOpencodeConfig: no level for Gemini 2.5 or Claude on Vertex, and no variant override", () => { const opencode = buildOpencodeConfig( configWith({ agents: [ { id: "flash", model: "google-vertex/gemini-2.5-flash", effort: "high" }, + { id: "vertex-claude", model: "google-vertex/claude-opus-5-5@default", effort: "high" }, { id: "neon", model: "google/gemini-4-neon", effort: "low" }, { id: "astra", model: "openai/gpt-6.2-astra", effort: "xhigh" }, - { id: "grok", model: "xai/grok-4.7", effort: "high" }, - { id: "plain", model: "openai/gpt-6.2-astra" }, ], }), ) as { agent: Record> }; expect(opencode.agent.flash!.thinkingConfig).toBeUndefined(); - expect("variant" in opencode.agent.flash!).toBe(false); - // A global OpenCode agent of the same name with a variant would otherwise replace the level. - expect(opencode.agent.neon!.variant).toBe(""); - expect(opencode.agent.astra!.variant).toBe(""); - expect(opencode.agent.grok!.variant).toBe(""); - // An agent without effort keeps OpenCode's own variant behavior. - expect("variant" in opencode.agent.plain!).toBe(false); + expect(opencode.agent["vertex-claude"]!.thinkingConfig).toBeUndefined(); + expect(opencode.agent.neon!.thinkingConfig).toEqual({ thinkingLevel: "low" }); + // ecr never clears a variant: one from the developer's OpenCode config keeps all its options. + for (const id of ["flash", "vertex-claude", "neon", "astra"]) { + expect("variant" in opencode.agent[id]!, id).toBe(false); + } }); diff --git a/src/config/schema.ts b/src/config/schema.ts index 4ea371fd..88c1b127 100644 --- a/src/config/schema.ts +++ b/src/config/schema.ts @@ -623,10 +623,10 @@ export interface LoadedAgent { paths?: string[]; /** * Frontmatter `effort`: how much reasoning the model spends on this agent's passes. - * The claude-code engine passes it as `--effort`; OpenCode passes it for OpenAI, Google - * (Gemini 3 and later) and xAI models (opencodeEffortStyle). Absent leaves the level to - * the engine: the CLI default, or on OpenCode the model's default or a variant from the - * developer's global OpenCode config. + * The claude-code engine passes it as `--effort`; OpenCode passes it for OpenAI, Gemini 3 + * and later, and xAI models (opencodeEffortStyle). Absent leaves the level to the engine: + * the CLI default, or on OpenCode the model's default. On OpenCode, a variant set on a + * same-named agent in the developer's own OpenCode config wins over it. */ effort?: AgentEffort; /** diff --git a/src/core/opencode.ts b/src/core/opencode.ts index 56ea083d..7710f2a5 100644 --- a/src/core/opencode.ts +++ b/src/core/opencode.ts @@ -290,10 +290,12 @@ export type OpencodeEffortStyle = "openai" | "google" | "google-budget" | "xai"; /** * The effort style for a model id, or null when ecr does not pass a level to that - * provider. Native `openai` gets the OpenAI style, native `google` and `google-vertex` the - * Google style, native `xai` (Grok) the xAI style. An alias (an auth entry with `upstream`) follows the adapter - * `buildOpencodeConfig` creates for it: only `upstream: "openai"` gets `@ai-sdk/openai`, - * so only that alias takes a level. Meta, OpenAI-compatible and other providers get null. + * provider. Native `openai` gets the OpenAI style, Gemini models on native `google` and + * `google-vertex` the Google style, native `xai` (Grok) the xAI style. Other + * `google-vertex` models (Claude on Vertex) use another adapter, so they get null. An + * alias (an auth entry with `upstream`) follows the adapter `buildOpencodeConfig` creates + * for it: only `upstream: "openai"` gets `@ai-sdk/openai`, so only that alias takes a + * level. Meta, OpenAI-compatible and other providers get null. */ // @ref LLP 0006#agent-effort [implements] — OpenCode-routed effort, per provider adapter export function opencodeEffortStyle( @@ -313,9 +315,13 @@ export function opencodeEffortStyle( return "openai"; } if (provider === "google" || provider === "google-vertex") { - // Gemini 2.5 and older take a thinking budget, not a level; OpenCode itself uses - // thinkingBudget for them (review of PR #118), so ecr sends them no level. - return /^gemini-[12](?:[.-]|$)/.test(model.slice(slash + 1)) ? "google-budget" : "google"; + // Only Gemini takes `thinkingConfig`: Vertex also serves Claude, on the Anthropic + // adapter. Gemini 2.5 and older take a thinking budget, not a level, so they get none. + const id = model.slice(slash + 1); + if (!id.startsWith("gemini-")) { + return null; + } + return /^gemini-[12](?:[.-]|$)/.test(id) ? "google-budget" : "google"; } if (provider === "xai") { return "xai"; @@ -394,11 +400,10 @@ export function buildOpencodeConfig( model: reviewer.model, temperature: reviewer.temperature, // Only reviewers: the fixed roles below are written after this loop, so a reviewer - // that shares a fixed role's id cannot give that pass its level. `variant: ""`: - // OpenCode merges the developer's global config under this one and applies an - // agent's model variant last, so a global agent of the same name with a variant - // would replace this level (observed with 1.19.5; LLP 0006). - ...(effortOptions ? { ...effortOptions, variant: "" } : {}), + // that shares a fixed role's id cannot give that pass its level. A model variant + // set on a same-named agent in the developer's own OpenCode config still applies + // after these options and wins (LLP 0006). + ...effortOptions, prompt: `You are the ${reviewer.id} code reviewer. Follow the user message exactly and return only the requested JSON.`, tools: { ...reviewer.tools, From f290f0d4c39e2e72eb1c21fdf000406bb5abee1e Mon Sep 17 00:00:00 2001 From: szdziedzic Date: Thu, 26 Nov 2026 23:46:11 +0100 Subject: [PATCH 18/18] docs: shorten the effort docs in the README and template Co-Authored-By: Claude Opus 5.5 --- README.md | 38 ++++++++++++-------------------------- templates/config.jsonc | 8 +++----- 2 files changed, 15 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 64bdc826..65d7a240 100644 --- a/README.md +++ b/README.md @@ -536,32 +536,18 @@ comment (and in the terminal) with the fix, and `ecr doctor` fails on them: frontmatter below an HTML comment, a byte-order mark or blank lines (all its keys are ignored), and a comment that breaks `alwaysRun`, `model` or `temperature`. -`effort` sets how much reasoning the model spends on that agent's passes. ecr -passes it for these models, and for any other model the review prints a note and -ignores it. Leave it out to leave the level to the engine: the CLI default, or on -OpenCode the model's default or a variant set in your global OpenCode config. - -| Model | How the level is sent | -| --- | --- | -| `anthropic/…` (Claude Code CLI) | `--effort ` | -| `openai/…`, or an alias with `upstream: "openai"` (OpenCode) | `reasoningEffort`, sent as the Responses API `reasoning.effort` | -| `google/…`, `google-vertex/…` (OpenCode) | `thinkingConfig.thinkingLevel`, in place of the model's default (OpenCode sends `high` for Gemini 4 Neon); only `low`, `medium` or `high` (for `xhigh` and `max` ecr sends no level, and the run note says so). Gemini 2.5 and older take a thinking budget, not a level, so ecr sends them none and the run note says so | -| `xai/…` (Grok, OpenCode) | `reasoningEffort`, sent as Chat Completions `reasoning_effort` or Responses API `reasoning.effort`, depending on how OpenCode reaches xAI | - -ecr passes the level as written and does not check which levels a model takes. When it sends a level through OpenCode it also sets the agent's `variant` to `""`, so a variant on a same-named agent in your global OpenCode config cannot replace it. A -model without effort support can drop it (the Claude Code CLI sends no level to -Claude Haiku 4.5), and a provider can reject a level its model does not take, which -fails that agent's passes with the provider's error. -A higher level costs more and takes longer, so set it on the agent that needs depth -(a correctness reviewer that must trace callers), not on every agent. A value that -is not a level is listed under **Review setup**, and the agent runs at the default. -`effort` in `coordinator.md` or `shared.md` is also listed there: only reviewer -files take it. -An agent file in `agents/` named after a built-in pass (`verifier.md`, -`cross-cutting.md`, `adjudicator.md`, `stack-verifier.md` or `coordinator.md`) gets -no effort; the review note says to rename it. The same holds, on OpenCode-routed -models, for a file named after one of OpenCode's own agents (`build.md`, -`compaction.md`, `explore.md`, `general.md`, `plan.md`, `summary.md`, `title.md`). +`effort` sets how much reasoning the model spends on that agent's passes. It works +on `anthropic/…`, `openai/…` (or an `upstream: "openai"` alias), Gemini 3 and later +on `google/…` or `google-vertex/…` (only `low`, `medium` or `high`), and `xai/…` +models. For other models the review prints a note and ignores it. Leave it out to +use the model's default. A higher level costs more and takes longer, so set it on +the agent that needs depth (a correctness reviewer that must trace callers), not on +every agent. ecr does not check which levels a model supports: a model can ignore a +level (Claude Haiku 4.5), and a provider can reject one, which fails that agent's +passes. A value that is not a level is listed under **Review setup**, and the agent +runs at the default. Only reviewer files take `effort`, and an agent file named +after a built-in pass (for example `verifier.md`) gets none; the review note says +to rename it. `paths` limits an agent to the changes it covers. It takes a list of repo-relative globs in the routing dialect: `*` stays within a directory, `**` crosses diff --git a/templates/config.jsonc b/templates/config.jsonc index 904f4a24..60d6d958 100644 --- a/templates/config.jsonc +++ b/templates/config.jsonc @@ -15,11 +15,9 @@ // there limits an agent to changes that touch those globs, and `mention: [octocat]` // names the people the review mentions when that agent asks for a human review. // `effort: high` (low, medium, high, xhigh or max) sets how much an agent reasons on - // `anthropic/…`, `openai/…` (or an `upstream: "openai"` alias), `google/…`, - // `google-vertex/…` (Gemini 3 and later) or `xai/…` models; Google takes only low, - // medium or high. Other - // providers get no level. A model can ignore a level it does not support (Claude Haiku - // 4.5) or its provider can reject it, which fails that agent's passes. README: "effort". + // `anthropic/…`, `openai/…` (or an `upstream: "openai"` alias), Gemini 3 and later + // (low, medium or high only) and `xai/…` models; other models get no level. A model + // can ignore a level, or its provider can reject it. README: "effort". // @ref LLP 0009#config-and-prompt-templates [implements] — suggestions off by default, not a schema limit "policy": {