Skip to content

feat: select reasoning effort from request complexity - #24

Closed
BaconDroid wants to merge 4 commits into
ian-pascoe:mainfrom
BaconDroid:feat/auto-effort
Closed

BaconDroid wants to merge 4 commits into
ian-pascoe:mainfrom
BaconDroid:feat/auto-effort

Conversation

@BaconDroid

@BaconDroid BaconDroid commented Oct 19, 2026 •

Copy link
Copy Markdown

Summary

Closes #20.

Adds an opt-in autoSelect mode that classifies the first user request in a session and carries the chosen reasoning effort from the current model's variants.

Stacked on #23. This branch is based on fix/reliable-temporary-resets, so the diff includes #23. Review/merge #23 first; I will rebase this branch once it lands.

How it works

  • chat.message receives the incoming UserMessage. OpenCode persists that object after the hook (trigger("chat.message", …, { message, parts }) followed by updateMessage(message)) and SessionPrompt.run copies X.model.variant onto the assistant message, so writing the chosen variant onto the message applies it to the turn without a synthetic prompt.
  • src/complexity.ts scores the prompt for debugging, architecture, error, test, scope, and length signals, then maps simple / normal / complex / deep to an available variant. none, off, and disabled are skipped; single-variant models keep their only level.
  • The selected level is cached per session and re-applied on later turns while it remains valid for the model. The agent can still override it with set_reasoning_effort, and a model switch reclassifies.
  • An explicit variant on a request (UI picker, CLI flag, or API field) is honored and becomes the carried level.
  • Disabled by default, so existing behavior is unchanged.
["opencode-adaptive-thinking", { "autoSelect": true }]

In this mode the plugin manages turns that do not carry an explicit variant; explicit variants are honored.

Tests

  • Classification examples and variant mapping across models with different variant sets.
  • Auto-select writes the variant, carries it across turns, honors explicit variants, and ignores synthetic messages.
  • pnpm verify passes (21 tests, format, lint, typecheck, build).

The heuristic is intentionally dependency-free and deterministic; it can be tuned without touching the plugin flow.

Repeated set_reasoning_effort calls in one turn could reset to an
intermediate level, or cancel the reset entirely when the same level was
set twice, because the baseline was re-read after the override.

Keep the first reset target, read session history once per call with a
bounded query, cache provider variants, merge guidance into an existing
system prompt, and replace Zod config parsing with a small validator.
Fall back to the cached current level when the recent history window
carries no variant, and read model identity and variants from assistant
messages too. Reuse the SDK provider type for the cached provider list.
Add an opt-in autoSelect mode. The chat.message hook classifies each
user request and writes the chosen variant onto the message, which
OpenCode persists and uses for the turn. The level is carried across
turns until the agent changes it or the model changes.
Respect a variant supplied with the request and treat image-only prompts
as no signal. Document that autoSelect classifies the first request and
carries the level instead of reclassifying every turn.
@BaconDroid

Copy link
Copy Markdown
Author

Closing: the word-list complexity classifier this PR introduces is too heuristic. The fork is reverting to the simpler reset fix in #23.

@BaconDroid BaconDroid closed this Oct 19, 2026
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.

Feature request: automatic initial reasoning effort selection

1 participant