Skip to content

feat: pass agent effort to OpenAI and Google models through OpenCode - #119

Merged
szdziedzic merged 10 commits into
t3/evaluate-review-cli-quality-gatesfrom
t3/effort-opencode
Nov 26, 2026
Merged

szdziedzic merged 10 commits into
t3/evaluate-review-cli-quality-gatesfrom
t3/effort-opencode

Conversation

@szdziedzic

@szdziedzic szdziedzic commented Nov 26, 2026 •

Copy link
Copy Markdown

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 feat: add a per-agent effort option (Claude Code and OpenCode) #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

  • bun run typecheck, bun run lint, bun run fmt:check
  • bun run llp:check: 0 errors
  • bun test: 1186 pass, 0 fail
  • 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.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

🤖 AI code review

Decision: Ready for human review (with comments)

Overall PR risk: Medium. The change modifies effort level passing for OpenCode reviewers on OpenAI and Google models. opencodeEffortStyle and buildOpencodeConfig duplicate their alias-to-adapter mapping logic, creating drift risk. If one mapping is updated and the other is not, the wrong configuration key reaches a provider, or run notes give incorrect advice. The LLP already cites a similar mismatch (PR #119).

🔎 Reviewer summaries (3)
  • consistency: Checked the OpenCode effort routing against the config, template, README and LLP. The template and docs are in sync. The alias-to-adapter mapping is duplicated in opencodeEffortStyle and can drift from buildOpencodeConfig.
  • correctness: Checked the OpenCode effort mapping, the run-note logic and the reviewer-only key injection. The runtime paths are consistent. One design gap remains: the alias-to-adapter decision is written twice.
  • security: I checked how the PR adds OpenCode effort options and run notes. The effort values come from a fixed enum, and the token, exec and prompt boundaries do not change. I found no security issue.

🔗 Review setup:

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

🏗️ Design (1)

  • opencodeEffortStyle duplicates the alias-to-adapter mapping in buildOpencodeConfig — src/core/opencode.ts:307 (quality) · id:1b2993d98841
    Confidence: High — the two mappings are separate code in the same file.
    Impact if shipped: Medium — a change to one mapping silently breaks effort routing or the run note.
    Suggested remediation: Extract one helper function that returns the adapter package for an alias entry (for example aliasAdapter(entry)). Use it in buildOpencodeConfig to set the npm adapter and in opencodeEffortStyle to pick the effort style. Apply the same tokenEnv condition in both places.

    Evidence and reasoning

    buildOpencodeConfig selects the npm adapter for an alias at lines 506-512: upstream: "openai" gets @​ai-sdk/openai, "anthropic" gets @​ai-sdk/anthropic, and all others get @​ai-sdk/openai-compatible. opencodeEffortStyle encodes the same decision again at line 309: alias.upstream === "openai" ? "openai" : null. Its doc comment says it follows the adapter that buildOpencodeConfig creates. No shared helper ties the two together.

    The conditions also differ. buildOpencodeConfig creates an alias provider only when the entry has tokenEnv (line 496). opencodeEffortStyle treats any entry with upstream as an alias. The Meta entry has a special path at line 466 that opencodeEffortStyle does not know.

    If a later change maps upstream: "google" to @​ai-sdk/google, or adds a new upstream, opencodeEffortStyle keeps the old answer. Then ecr sends a key the adapter does not read, or the run note gives wrong advice. The LLP already records one bug of this kind: a Google key on an openai-compatible adapter (PR feat: pass agent effort to OpenAI and Google models through OpenCode #119).

    Suggestion: Extract one helper function that returns the adapter package for an alias entry. Use it in both buildOpencodeConfig and opencodeEffortStyle to ensure the two mappings stay synchronized.


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

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

szdziedzic added a commit that referenced this pull request Nov 26, 2026
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>
szdziedzic and others added 4 commits November 26, 2026 15:11
`effort` reached only `anthropic/…` agents (the claude-code engine's
`--effort`). OpenCode hands unknown agent-config keys to the provider as
model options, so buildOpencodeConfig now adds one per reviewer with
`effort`, chosen by opencodeEffortStyle from the model's provider:

- openai/… (and an alias with upstream "openai"): reasoningEffort,
  sent as the Responses API reasoning.effort.
- google/… and google-vertex/…: thinkingConfig.thinkingLevel, in place
  of the "high" that OpenCode sends to Gemini by default.

Observed with the pinned OpenCode 1.19.5 against a local mock endpoint,
using the agent entries buildOpencodeConfig produces. Other OpenCode
providers still get the "has no effect" run note, which now names only
those. Fixed-role passes never get a level. ecr passes the level as
written; a provider that does not take it fails the pass with its own
error.

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

Astra review of 4f6afb5:

- With the pinned OpenCode 1.19.5, thinkingLevel xhigh or max fails
  inside the Google adapter ("invalid google provider options") before
  any request, on google/… and google-vertex/…, so every pass of that
  agent failed. GOOGLE_THINKING_LEVELS is now low, medium, high: for
  xhigh and max ecr sends no key, the model runs at OpenCode's default,
  and the run note names the agent, its level and the levels that work.
- An alias with upstream "google" is built on @ai-sdk/openai-compatible,
  so a Google key reached the endpoint as a stray top-level field and
  the note stayed silent. opencodeEffortStyle now follows the adapter ecr
  creates: only an upstream "openai" alias takes a level.
- The config template lists every route and the Google limit; the
  comment at selectReviewers no longer says only the claude CLI reads it.

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

This comment was marked as resolved.

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>
devin-ai-integration[bot]

This comment was marked as resolved.

Gemini Neon review of fa22f36: the provider list in the note followed
"a provider ecr passes no level to", so it read as a list of providers
that take no level. It now says "ecr passes one only for …".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Astra final review of 3bca528 (approve with comments):

- The note for an OpenCode built-in agent id said only to rename the
  file; on a model that takes no level, or Google xhigh/max, the next run
  then gave a second fix. It now gives both in one note, as the
  fixed-role note does.
- OpenCode's Google default varies by model (Gemini 4 Neon: high; a
  gemini-2.5-flash request carried no thinkingLevel), so the README, the
  LLP and the note no longer call `high` the default for every model.
- The built-in agent list comment names the field app.agents() returns
  (`native: true`).
- The LLP fallback heading says the cap is Claude Code's; OpenCode keeps
  the level.

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 15:41
Gemini Neon final review of 3bca528 (approve with comments):

- The README now says that an OpenCode-routed file named after one of
  OpenCode's own agents gets no effort, as a fixed-role file does.
- agentEffortNote's doc comment lists all four cases.
- buildAgentEfforts' test includes `compaction`, which keeps its level
  on the claude-code engine.

Its other nits (one note with the full fix for a built-in id, the LLP
heading) were fixed in 4d4137b, whose test also fails if the duplicate-
note guards are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
@szdziedzic
szdziedzic requested a review from Kudo November 26, 2026 14:54
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>
@szdziedzic
szdziedzic merged commit d16c574 into t3/evaluate-review-cli-quality-gates Nov 26, 2026
3 of 4 checks passed
@szdziedzic
szdziedzic deleted the t3/effort-opencode branch November 26, 2026 16:13

@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 README.md
| `anthropic/…` (Claude Code CLI) | `--effort <level>` |
| `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` |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔍 Native xAI wire format mismatch

With XAI_API_KEY, OpenCode’s native xai loader uses /responses and sends reasoning.effort. The mock result covers Chat Completions, not the native loader’s request format.

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.

1 participant