Skip to content

feat: add a per-agent effort option (Claude Code and OpenCode) - #118

Open
szdziedzic wants to merge 18 commits into
mainfrom
t3/evaluate-review-cli-quality-gates
Open

szdziedzic wants to merge 18 commits into
mainfrom
t3/evaluate-review-cli-quality-gates

Conversation

@szdziedzic

@szdziedzic szdziedzic commented Nov 26, 2026 •

Copy link
Copy Markdown

Why

There is no way to set how much a reviewer agent reasons. A deep correctness agent and a cheap conventions agent run at the same default. Universe wants its new Expo Simulators scope on Opus 5.5 at high effort (expo/universe#33912), and reviews will use several model providers (Claude, OpenAI, Google, Grok).

How

Agent frontmatter accepts effort: low | medium | high | xhigh | max (AGENT_EFFORT_LEVELS in src/config/schema.ts). The value is trimmed and case-insensitive. Each engine maps it:

Model How the level is sent
anthropic/… (Claude Code CLI) --effort <level> (pinned CLI 2.1.280)
openai/…, or an alias with upstream: "openai" (OpenCode, @ai-sdk/openai) agent reasoningEffort → Responses API reasoning.effort
Gemini 3 and later on google/… or google-vertex/… (OpenCode) agent thinkingConfig.thinkingLevel, only low, medium, high (the pinned adapter rejects xhigh and max before any request; ecr sends nothing and the run note says so)
Gemini 2.5 and older nothing: they take a thinking budget, not a level; the run note says so
xai/… (Grok, OpenCode, @ai-sdk/xai) agent reasoningEffort → Chat Completions reasoning_effort or Responses API reasoning.effort, depending on how OpenCode reaches xAI
any other provider or alias, and Claude on google-vertex/… nothing; the run note names the agent
  • Only reviewers get a level. The fixed passes (verifier, cross-cutting, adjudicator, stack-verifier, coordinator; NON_REVIEWER_AGENTS) never do, even when an agent file shares their id, and neither do OpenCode's own agent ids (build, compaction, explore, general, plan, summary, title), which other sessions use. The run note tells the author to rename the file, with the full fix. Levels live in a Map, so an id such as constructor reads nothing inherited.
  • No-tools fallback. On Claude Code a timed-out pass is retried at min(level, medium) (fallbackEffort), never above the agent's own level. On OpenCode every prompt keeps the agent's own level, because ecr cannot know which lower levels a model takes (GPT-5 pro takes only high).
  • Never stops a review. An invalid value is a setup warning that names the file and the allowed levels without repeating the value; effort in coordinator.md or shared.md is also a setup warning. LoadedAgent.effort is set only when declared, so agents without it, and the review-cache key, do not change. REVIEWER_MODEL does not clear it.
  • One note per run. Reviewer selection (paths filter, router, then the note) lives in selectReviewers, so the note names only selected reviewers.
  • 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 serviceTier). CI has no such config.
  • 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.

Docs: a short README paragraph, templates/config.jsonc, and a high-level "Agent Effort" section in LLP 0006, which also records what is left for later (per-agent warnings in routed scopes with enforceAgents, the shared reader's unmatched-quote handling).

Evidence

With the pinned Claude Code 2.1.280 and OpenCode 1.19.5 against local mock endpoints (no real provider call), using the config ecr builds: Opus 5.5 got effort, Haiku 4.5 got none; openai/gpt-6.2-astra got reasoning.effort for each level; google/gemini-4-neon and google-vertex/… got thinkingLevel for low/medium/high and no request for xhigh/max; xai/grok-4.7 got the level as reasoning_effort (inline key) or reasoning.effort (XAI_API_KEY set); a global same-named agent at variant high turns an inline low into high (kept by design, see above). Not observed: the ChatGPT/Codex sign-in path, and which levels each real provider accepts.

Review

Reviewed in several rounds by GPT-6.2 Astra and Gemini 4 Neon (high effort), Devin, and Kudo's multi-model review. The OpenCode part was #119 (squash-merged into this branch). An earlier OpenCode fallback copy agent was removed after review showed it could send a level a model rejects. An earlier variant: "" guard was removed after Devin showed it also dropped the variant's other options.

Test plan

  • bun run typecheck, bun run lint, bun run fmt:check
  • bun run llp:check: 0 errors
  • bun test: 1189 pass, 0 fail (head commit)
  • Tests cover each provider mapping and alias, Gemini 2.5, Claude on Vertex, no variant override, fixed-role and OpenCode built-in ids, constructor, the fallback level, the selection order with a stand-in router, the coordinator/shared warning, and the run note.

🤖 Generated with Claude Code


Devin Review

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 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

🤖 AI code review

Decision: Ready for human review

Overall PR risk: Low. The change is additive, adding an optional effort frontmatter parameter to route reasoning levels to model providers. Existing behavior is unaffected because the parameter is only used when explicitly declared by an agent, and an absent key adds no flag, option, or cache-key change. The extracted selectReviewers helper and provider-specific level mapping are limited in blast radius and rollback is straightforward. Note: the PR description contained hidden content not visible to human readers.

🔎 Reviewer summaries (4)
  • consistency: Checked the new agent effort frontmatter key against its siblings mention and paths, the template sync, and the fixed-role id set. The key follows the existing shape, so this pass reports no findings. Checked the new selectReviewers helper and the effort template comment against sibling conventions. The progress note uses the same 'Note: ' format as claudeTemperatureNote. The effort option is in the template. I found no consistency problems.
  • correctness: Checked how the per-agent effort level flows from the frontmatter parser to the claude-code --effort flag and the OpenCode agent options. The fixed-role and built-in id exclusions and the no-tools fallback cap are consistent. No defects found. I checked how selectReviewers replaces the inline routing in runReview. I also checked the effort note call and the template text. Routing behavior and the notRouted list do not change. I found no correctness defect.
  • security: I checked the new per-agent effort key from frontmatter parsing through the CLI arguments and the OpenCode config. The value is checked against a fixed list before use, and warnings do not repeat the raw value. I found no security issue. I checked the selectReviewers refactor and the new effort note in the config template. The note uses only agent ids, effort levels and model names. It does not use token values, so it adds no secret or injection path.
  • cross-cutting: Traced the effort level across load.ts, schema.ts, claude-code.ts, opencode.ts and review.ts. The fixed-role id set, engine routing and selected-reviewer note use the same contracts. No cross-file defect was found.

🔗 Review setup:

  • This PR changes code the reviewer prompts cite (src/tests, src/config/load.ts, src/config/schema.ts, templates/config.jsonc). Check that the guidance quoting it is still correct.

No findings.


This review is advisory — it never blocks a merge and never auto-approves.

devin-ai-integration[bot]

This comment was marked as resolved.

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 <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

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 <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

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 <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

szdziedzic and others added 2 commits November 26, 2026 13:29
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

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 <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

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 <noreply@anthropic.com>
@Kudo

Kudo commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

Multi-model review

Three reviewers looked at c6d4a10 on their own: Codex (gpt-6.2-astra), Grok (grok-4.7), and Claude (Opus 5.5), all at high effort. I checked each finding against the code. None is high severity, and the effort level reaches the claude argv as described.

Findings

1. The fallback passes keep the agent's effort. (Claude, Grok)
src/core/review.ts:1052, src/core/claude-code.ts:942

A timed-out pass gets split, or retried as a no-tools pass with a 4-minute cap. childTask keeps the agent id, and runClaudePrompt looks up effort by that id. It clears the tools when maxToolCalls === 0, but still sends --effort. So an effort: max agent that times out retries at max in 4 minutes, and may time out again, which leaves a coverage gap. I didn't measure this in a live run.

Fix: skip effort when maxToolCalls === 0, and note it in LLP 0006.

2. The warning echoes the raw invalid value. (Claude, Codex)
src/config/load.ts, parseAgentEffort

A backtick in the value closes the code span in the setup note, so a mention or link after it renders live. A very long value also goes into the comment with no cap, since truncation doesn't touch setup notes. ecr ci reads config from the base commit, so someone has to merge the bad value first. The mention warning has the same exposure.

Fix: don't repeat the value. Name the file and the allowed levels.

3. Scoped runs can show the wrong effort warning for enforced agents. (Codex)
src/config/load.ts:503-519

A scope takes setupWarnings from its own dir, then a root enforceAgents entry replaces the same-id agent. An invalid root effort shows no warning in that scope. An invalid scope effort shows a "runs at the default" warning while the agent runs at the root's level. mention already works this way, so this may fit a separate PR.

4. An unmatched quote selects a level silently. (Codex)
src/config/load.ts:582

effort: "max loads as max with no warning, because the parser strips each quote on its own. It's the shared parser, so every scalar key does this.

5. Nit: the hidden-frontmatter warning doesn't list effort. (Claude)
src/config/load.ts:825

Not verified

Codex says some models take only some levels (for example xhigh on Opus 4.6 runs at high), so the README could say so. I didn't check that against the docs.

Looks fine

  • Only one of the five literal levels reaches argv, through execFile, so a value can't inject a flag.
  • The pinned CLI 2.1.280 takes --effort with all five levels (checked in the binary).
  • Fixed passes (coordinator, router, verifier, cross-cutting, adjudicator, stack-verifier) never get the flag, even with an agents/verifier.md.
  • An agent without effort keeps its review-cache key. REVIEWER_MODEL keeps effort. selectReviewers keeps the old routing behavior.
  • An invalid value warns once and never fails ecr ci.

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 <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

szdziedzic added a commit that referenced this pull request Nov 26, 2026
Kudo's multi-model review of PR #118 found that a timed-out pass,
retried with no tools under a short cap, kept the agent's level; #118
now sends no level there on the claude-code engine. The same holds for
OpenCode, which has no per-prompt level, so buildOpencodeConfig also
registers each reviewer that has an effort option as
`<id>__default-effort` without it, and opencodePassAgent sends the
fallback prompts (maxToolCalls 0) as that copy. Polling and activity
labels keep the reviewer's own id.

Observed with OpenCode 1.19.5 against a mock endpoint: the reviewer's
entry sent reasoning.effort "xhigh", the copy sent no reasoning field.

Also format the rebase conflict resolution (fmt:check).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

szdziedzic added a commit that referenced this pull request Nov 26, 2026
Kudo's multi-model review of PR #118 found that a timed-out pass,
retried with no tools under a short cap, kept the agent's level; #118
now sends no level there on the claude-code engine. The same holds for
OpenCode, which has no per-prompt level, so buildOpencodeConfig also
registers each reviewer that has an effort option as
`<id>__default-effort` without it, and opencodePassAgent sends the
fallback prompts (maxToolCalls 0) as that copy. Polling and activity
labels keep the reviewer's own id.

Observed with OpenCode 1.19.5 against a mock endpoint: the reviewer's
entry sent reasoning.effort "xhigh", the copy sent no reasoning field.

Also format the rebase conflict resolution (fmt:check).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
szdziedzic added a commit that referenced this pull request Nov 26, 2026
Gemini Neon review of 753305d:

- A reviewer that shares a fixed role's id (agents/cross-cutting.md)
  left a `<id>__default-effort` copy behind, and the built-in pass's
  no-tools fallback then ran as that copy, with the reviewer's model,
  prompt and tools. Fixed-role ids now get no level and no copy.
- The handle inferred copies from any agent name ending in the suffix,
  so a real agent file with that name could take over another
  reviewer's fallback. opencodeFallbackAgents now computes the map from
  the loaded config, skips a copy id that is already an agent id, and
  runReview hands the map to startOpencode.
- A copy with no level ran at the provider's default, which can be
  higher than the agent's own level (Gemini's default is high). The copy
  now carries fallbackEffort (min(level, medium), as #118 does on the
  claude-code engine), and exists only when that differs from the
  reviewer's own options. Renamed to `<id>__fallback-effort`.
- The corrective re-emit of a fallback pass ran as the reviewer at its
  full level; it now runs as the same copy.
- The run note for a fixed-role reviewer on Google xhigh/max also names
  the levels Google takes; a test assertion that could never fail now
  checks the note's end; the effort docs no longer say only the
  claude-code engine reads it.

Observed with OpenCode 1.19.5 against a mock endpoint, using the config
buildOpencodeConfig produces: xhigh OpenAI reviewer "xhigh", its copy
"medium"; max Google reviewer OpenCode's default "high", its copy
"medium".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
szdziedzic added a commit that referenced this pull request Nov 26, 2026
Astra review of fa22f36:

- The fallback copy at min(level, medium) sent a level the author never
  wrote, and a model can reject it (GPT-5 pro takes only `high`, per
  the provider's docs), which turned a working setup into failed
  passes. ecr cannot know which lower levels each OpenAI or Google
  model takes, so on OpenCode every prompt of a pass, including the
  no-tools fallback, finalize and corrective, now runs at the agent's
  own level. This removes the copy agent, its map on the handle and its
  start-up wiring. The claude-code engine keeps fallbackEffort (#118).
- A reviewer named `compaction` replaced OpenCode's own agent, and its
  level then reached other reviewers' session compaction. OpenCode 1.19.5
  defines build, compaction, explore, general, plan, summary and title
  (app.agents(), observed); buildOpencodeConfig gives these ids no level
  (OPENCODE_BUILTIN_AGENTS) and the run note says to rename the file.

Kept from the previous commits: no level for ecr's fixed-role ids, the
fixed-role note's Google levels, the alias in the provider list, and the
test fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@szdziedzic

Copy link
Copy Markdown
Author

@Kudo thanks for the review. I checked each finding against the code.

  1. Fallback passes keep the agent's effort. Fixed for the claude-code engine. The no-tools fallback now runs at min(level, medium) (fallbackEffort), not at the full level. Sending no level instead (my first fix) used the CLI's default, which can be higher than an agent's own low, so the cap is safer. On OpenCode (feat: pass agent effort to OpenAI and Google models through OpenCode #119) the fallback keeps the agent's own level: a model can reject a lower level ecr picks (GPT-5 pro takes only high), so ecr never sends a level the author did not write there.
  2. The warning echoes the raw value. Fixed. The warning names the file and the allowed levels, and no longer repeats the value. A test checks this.
  3. Scoped runs with enforceAgents. Not changed here. mention warnings behave the same, so the fix belongs to all per-agent warnings at once. LLP 0006 records it.
  4. Unmatched quote. Not changed here. It is the shared frontmatter reader, so every key does this. LLP 0006 records it.
  5. Hidden-frontmatter warning. Fixed. It now lists effort.

Not verified, model-level support: the README now says that a model can take only some levels, and that ecr does not check this.

Also fixed from Devin: the rename advice now says that REVIEWER_MODEL, when set, decides the model.

GPT-6.2 Astra and Gemini 4 Neon (high effort) both approve #118 at e0ce4b7.

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 <noreply@anthropic.com>
szdziedzic added a commit that referenced this pull request Nov 26, 2026
Resolves the LLP 0006 fallback paragraph: #118 now names the CLI's
default and scopes the cap to the claude-code engine (Devin review);
this branch keeps that text and adds the OpenCode part. Also adds the
@ref Devin asked for on OPENCODE_BUILTIN_AGENTS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@Kudo Kudo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work! could we support effort on opencode path, not only for claude code path? i'm working on adding grok support and we may have multiple models review later

szdziedzic added a commit that referenced this pull request Nov 26, 2026
Asked for in Kudo's review of #118. OpenCode's xAI adapter
(@ai-sdk/xai) reads the same agent key as OpenAI: with the pinned
OpenCode 1.19.5 against a mock endpoint, 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.
opencodeEffortStyle now maps native `xai` to an `xai` style with that
key. Which levels xAI's API accepts is not verified; like the other
providers, ecr passes the level as written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…119)

## 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: <level>` | Responses API
`reasoning.effort` |
| `google/…`, `google-vertex/…` | `thinkingConfig: { thinkingLevel:
<level> }`, 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 `<id>__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.


---------
@szdziedzic szdziedzic changed the title feat: add a per-agent effort option for Claude Code passes feat: add a per-agent effort option (Claude Code and OpenCode) Nov 26, 2026
@szdziedzic
szdziedzic requested a review from Kudo November 26, 2026 16:13
@szdziedzic

Copy link
Copy Markdown
Author

@Kudo thanks! This PR now covers the OpenCode path too: #119 (which was stacked on this one) is squash-merged into this branch.

  • OpenAI models, including an upstream: "openai" alias, get reasoningEffort (Responses API reasoning.effort).
  • Google and Vertex models get thinkingConfig.thinkingLevel for low, medium and high; the pinned adapter rejects xhigh and max before any request, so ecr sends nothing for them and the run note says so.
  • I added xai/… for Grok: with the pinned OpenCode 1.19.5, reasoningEffort on a Grok agent reaches the API as reasoning_effort (checked against a mock endpoint; which levels xAI accepts is not verified).
  • Other providers get no level, and the run note names the agent.

If your Grok support is its own engine rather than OpenCode, the level mapping would go there; I'm happy to add it to your PR. The description has the full table and evidence.

devin-ai-integration[bot]

This comment was marked as resolved.

szdziedzic and others added 2 commits November 26, 2026 17:56
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 <noreply@anthropic.com>
…riants

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 <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

szdziedzic and others added 2 commits November 26, 2026 18:12
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
@szdziedzic

szdziedzic commented Nov 26, 2026 •

Copy link
Copy Markdown
Author

@Kudo ready for another look. Since your review, besides folding in #119:

  • xAI (Grok): xai/… gets reasoningEffort. OpenCode sends it as reasoning_effort on /chat/completions with an inline key, or reasoning.effort on /responses with XAI_API_KEY set.
  • Gemini 2.5 and older: they take a thinking budget, not a level, so ecr sends them nothing and the run note says so.
  • Global OpenCode config: a same-named agent there with a variant replaced ecr's level, so ecr now sets variant: "" whenever it sends a level.

GPT-6.2 Astra and Gemini 4 Neon (high effort) approve these changes, with the wire results checked against OpenCode 1.19.5 and a mock endpoint. CI is running on the head (8cb7398); every check passed locally.

@Kudo

Kudo commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

Multi-model review of 8cb7398

Three reviewers looked at 8cb7398 on their own: Codex (gpt-6.2-astra), Grok (grok-4.7), and Claude (Opus 5.5), all at high effort. I checked each finding against the code and the OpenCode 1.19.5 source.

The fixes since the last review work: the fallback runs at min(level, medium), the warning no longer repeats the value, and Gemini 2.5 and older get no level with a note. Nothing here breaks a review or fails ecr ci.

Findings

1. Non-Gemini models on google-vertex/ get the Gemini option, and no note says so. (Codex, Grok)
src/core/opencode.ts:315

opencodeEffortStyle treats every google-vertex/… id that isn't Gemini 1.x or 2.x as Gemini 3. In the OpenCode catalog, google-vertex/claude-* uses @ai-sdk/google-vertex/anthropic, and the MaaS models (gpt-oss, grok, DeepSeek, Llama, Qwen) use @ai-sdk/openai-compatible. Neither reads thinkingConfig. So google-vertex/claude-opus-5-5@default with effort: high runs at the default, and the run note is empty. variant: "" also clears a global variant that could have set the right key, so the result can be worse than with no effort at all. The README and template say "Gemini 3 and later", but the code doesn't check the model family.

Fix: use the Google style only for gemini-* ids. Anything else under google/ or google-vertex/ gets no level, no variant: "", and a run note. Add a Vertex Claude test.

2. Some Gemini and Gemma models get a level OpenCode doesn't offer them. (Grok, Claude)
src/core/opencode.ts:331, :342

OpenCode's googleThinkingLevelEfforts gives pro-image only high, and flash-image and Gemma only minimal and high. ecr sends low, medium or high to all of them, and the adapter accepts these, so the request goes out. A provider error is possible, but I didn't confirm it with a live request.

Fix: use OpenCode's per-model sets, or send nothing to image and Gemma models and add a note.

3. The Gemini 2.x regex is narrower than OpenCode's. (Claude)
src/core/opencode.ts:318

ecr uses /^gemini-[12](?:[.-]|$)/. OpenCode uses /gemini-(?:(?:flash|pro)-)?[12](?:[.-]|$)/i. Ids like gemini-pro-1.5, or upper-case ids, still get thinkingLevel. They're rare.

Fix: copy OpenCode's regex.

4. Nit: the Google note says the model runs at its default, but a global variant can still apply. (Codex)
src/core/claude-code.ts:932

When ecr drops a level, it also leaves out variant: "", so the developer's global OpenCode variant applies. The note could say that OpenCode's own configuration applies.

5. Older bug: OpenCode's no-tools fallback can still call tools. (Codex)
src/core/opencode.ts:1191 (same line at :1079 on the base)

The first fallback prompt turns off only MCP proxy tools. The finalize path sends { ...NO_TOOLS, ...handle.mcpToolsOff }. This predates the PR, so it fits a separate one.

Dropped

  • xAI max being rejected before the request: wrong. OpenCode patches @ai-sdk/xai 3.0.139 so reasoningEffort is z.string(), and the value goes to xAI as written.
  • A scope's own setup warnings being dropped: wrong. resolvePreCheckAgents keeps them.
  • Enforced-agent warnings in routed scopes and unmatched quotes: LLP 0006 already lists both as deferred.
  • OpenAI max on OpenCode's native LLM path: needs OPENCODE_EXPERIMENTAL_NATIVE_LLM, which ecr doesn't set.

Looks fine

  • variant: "" works as described: it replaces a global variant (agent.ts:282), and OpenCode treats it as no variant (prompt.ts:654).
  • Only one of the five literal levels reaches argv or the OpenCode config, so a value can't inject a flag or a key.
  • Fixed passes, the router and OpenCode's own agents get no level. Split passes keep the agent's level.
  • The cache key, REVIEWER_MODEL and reviewer selection work as before. Meta's hardcoded effort doesn't collide.

@Kudo Kudo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last review and leaving comments that not a blocker.
please also makes sure ci is green before merge

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe ask agent to make the llp changes shorter. keep it as high-level design would be better. we don't need to cover implementation details in depth

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in cec2865. "Agent Effort" is now about 35 lines instead of about 110. It keeps the design decisions: the per-provider mapping, only reviewers get a level, the fallback cap, the developer's variant wins, and the open gaps. The wire probes and review history are removed.

Comment thread README.md Outdated

| Model | How the level is sent |
| --- | --- |
| `anthropic/…` (Claude Code CLI) | `--effort <level>` |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto. shorter README changes. "how level is sent" is implementation detail. we don't need to cover it in README

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in f290f0d. The "how the level is sent" table is removed. The README now has one paragraph: which models take effort, when to use it, and what happens with an unsupported or invalid level. The template comment is shorter too.

szdziedzic and others added 2 commits November 26, 2026 23:46
- 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 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

Devin Review

Comment thread src/core/opencode.ts
Comment on lines +320 to +323
const id = model.slice(slash + 1);
if (!id.startsWith("gemini-")) {
return null;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Gemini aliases lose reviewer effort

When a reviewer selects Gemini through an OpenCode model alias without gemini-, opencodeEffortStyle drops the requested level. OpenCode resolves the alias to Gemini, so the reviewer still runs but without the requested effort.

Learn more

OpenCode lets users give a model a local name under an existing provider while retaining the underlying API model ID and SDK. loadReviewConfig keeps that local name from the reviewer’s model: field. runReview builds the reviewer’s OpenCode options from that name before starting the server, and fetchProviderModels later sees the alias as a valid model. The effort classifier reads only the local name, so it omits thinkingConfig even though OpenCode still sends the review to Gemini.

Example: In OpenCode, set provider.google.models.review-pro.id to gemini-3.1-pro-preview. A reviewer with model: google/review-pro and effort: low runs on Gemini 3.1 Pro without sending low. Selecting google/gemini-3.1-pro-preview directly sends low.

Recommended fix: Classify Google and Vertex effort using the resolved API model ID and adapter from OpenCode. Use the same classification for the review setup note. Add a regression test for a Gemini alias whose name lacks gemini-, alongside the test that excludes Vertex Claude.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants