Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
49d05c9
feat: add a per-agent effort option for Claude Code passes
szdziedzic Nov 26, 2026
da4d940
fix: keep agent effort off fixed-role passes and skipped agents
szdziedzic Nov 26, 2026
c28e3eb
fix: report ignored effort only for reviewers that run
szdziedzic Nov 26, 2026
9f9f0cd
refactor: select reviewers in one tested step that owns the effort note
szdziedzic Nov 26, 2026
48d8f54
fix: word the effort note as a fact about the setup
szdziedzic Nov 26, 2026
9094fa6
fix: warn on effort outside reviewer files, and test selection edges
szdziedzic Nov 26, 2026
f06ba08
fix: give the full fix for a fixed-role reviewer on an OpenCode model
szdziedzic Nov 26, 2026
c6d4a10
fix: align effort comments and warnings with the setup-fact wording
szdziedzic Nov 26, 2026
b6dd1ca
fix: no effort on the no-tools fallback, and never echo an invalid value
szdziedzic Nov 26, 2026
e0ce4b7
fix: run the no-tools fallback at the agent's level capped at medium
szdziedzic Nov 26, 2026
2270ed3
docs: scope the fallback cap to the claude-code engine in LLP 0006
szdziedzic Nov 26, 2026
d16c574
feat: pass agent effort to OpenAI and Google models through OpenCode …
szdziedzic Nov 26, 2026
abdfeb4
docs: both xAI wire formats; a provider can reject an unsupported level
szdziedzic Nov 26, 2026
0ae90a4
fix: no level for Gemini 2.5; guard OpenCode levels against global va…
szdziedzic Nov 26, 2026
a1894db
fix: full Gemini 2.5 fix in the note; say what omitting effort means
szdziedzic Nov 26, 2026
8cb7398
docs: mark Google levels as Gemini 3 and later in notes, template, docs
szdziedzic Nov 26, 2026
cec2865
fix: keep OpenCode variants and send Gemini levels only to Gemini models
szdziedzic Nov 26, 2026
f290f0d
docs: shorten the effort docs in the README and template
szdziedzic Nov 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,10 @@ 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
paths: ["packages/ios/**", "**/*.swift"]
---

Expand All @@ -534,6 +536,19 @@ 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. 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
directories, and a leading `**/` also matches files at the repo root. Write the
Expand Down
35 changes: 35 additions & 0 deletions llp/0006-config-schema-loading-routing.explainer.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,41 @@ 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. 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

`budget.totalPassesMinutes` defaults to 55, not the scaffolded workflow's full 90-minute timeout,
Expand Down
257 changes: 256 additions & 1 deletion src/__tests__/claude-code.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { describe, expect, it, test } from "bun:test";

import {
assertClaudeModels,
agentEffortNote,
buildAgentEfforts,
buildClaudeArgs,
buildEngineMap,
claudeActivities,
Expand Down Expand Up @@ -37,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>): AuthConfigEntry => ({
provider: "anthropic",
Expand Down Expand Up @@ -820,6 +822,249 @@ 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 {
// 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");
// The no-tools fallback of a timed-out pass runs at the level capped at medium.
await runClaudePrompt(handle, {
agent: "reviewer",
system: "SYS",
text: "hi",
title: "t",
maxToolCalls: 0,
});
const fallback = (await argsLog(4)).split("\n");
expect(fallback[fallback.indexOf("--effort") + 1]).toBe("medium");
} finally {
await cleanup();
}
});

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" },
...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"],
["compaction", "high"],
]);
expect(efforts.get("constructor")).toBeUndefined();
});

test("agentEffortNote: names the agents whose effort an OpenCode-routed model ignores", () => {
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("has no effect for b:");
expect(note).not.toContain("for a");
});

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();
});
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
Resolved

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(note).toContain(
'(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.
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).toContain("Fix: use a Gemini 3 or later model with low, medium or high");
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" },
{ 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: 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 a model that takes no level is told to change the model too", () => {
const agents = [
{ 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 a model that takes a level",
);
expect(note).toContain("`REVIEWER_MODEL` when that is set");
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" }, []);
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");
});

test("claudeTemperatureNote: flags non-default temperatures on CLAUDE-ROUTED passes only", () => {
const config = (agentTemp: number, coordTemp: number): LoadedConfig =>
({
Expand Down Expand Up @@ -955,6 +1200,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) {
Expand Down
Loading
Loading