feat(core): add auto reasoning effort coordinated with RedRouter - #373
Merged
Merged
Conversation
filipeforattini
enabled auto-merge (squash)
September 23, 2026 05:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an opt-in
autoreasoning variant. Withauto, every request carries one of the model's own effort variants, chosen per turn. The stringautois never sent to a provider. Redcode and RedRouter now agree on which one of them decides.Choosing
autoctrl+tcycles through it, when the model has two or more effort levels (ReasoningAuto.options).--variant auto. Saved and session values are kept when the model offersauto.variant: "auto".auto. Subagents inherit the variant the person picked, not the level a turn applied.decideEffort(packages/core/src/session/reasoning-auto.ts, pure)feedbackcorrects or rejects, then frustration ≥ 2/3.must_clarify≥ 0.8.failed_result, or a response-quality repair runs.reasoning.auto.floor/ceiling(default minimal..xhigh;noneandmaxonly when configured). A missing level snaps to the nearest variant; a tie goes to the one with more thought.S1
user_feedback: agrees | corrects | rejects | neutral, about how the latest user message judges the agent's previous turn.promptContextadds a feedback line (optional, so older evaluations still render).routerHintaddsstall,feedbackandfrustration.effortAssessmentmaps the answers todecideEffortinputs.RedRouter coordination (
ReasoningAuto.coordinate, following red-router#53)x-red-router-reasoning: offon direct models;<level>plus hint on auto/smart combosautox-red-router-reasoning: autoplus hint (stall, andfeedbackwhen known), also on direct models;X-RedRouter-Reasoningis parsed and adoptedappliesx-red-router-reasoning: offwhenever a router with the reasoning capability is detectedreasoning,reasoning-auto(acceptsincludesauto),reasoning-applies, andhint-signals(hint_keyslists stall, feedback and frustration).validHintacceptseffort,stall,feedbackandfrustration. Signal keys are dropped for routers that do not list them.reported()parsesX-RedRouter-Reasoning: <from|->-><level>; cause=…[; shadow]. Shadow reports are never adopted.autosessions, RedRouter's own connection, or models that a router described trigger a probe. The V2 runner reads the cached detection only.Display
auto → high · frustrationorrouter: medium, read from the session'smetadata.reasoning. The legacy runtime writes it only when it changes.auto → <level>: the assistant message'svariantnow records the concrete level its turn applied.Runtimes
prompt.tsand applies the level through theuserpassed to the processor, sorequest.tsmerges a real variant.SessionRunnerModel.resolve(session, choose)resolvesautothrough the chooser (the default applies when there is no chooser). The runner decides once per turn attempt, and the published assistant model carries the concrete variant.Notes on the red-router#53 contract
low->high; cause=feedback,-->xhigh; cause=hint,; shadow).efforthint key is accepted byvalidHint, but Redcode sends the level through the header, which takes precedence in fix(opencode): honor configured model in ACP default selection #53.hint-signalsrequires all three signal keys indecision.hint_keys.Tests
packages/core/test/session-reasoning-auto.test.ts:decideEfforttables (bands, feedback, frustration, impact, clarify, context, plan and explicit think, dwell, the in-turn loop step, variant clamping), explicit-think detection in PT and EN, progress extraction,options, thecoordinatetable, and session-state adopt and note.provider-router.test.ts: capabilities to features, the reasoning header and hint filtering, the hint grammar, andX-RedRouter-Reasoningparsing.intelligence.test.ts: theuser_feedbackquestion, hint signals,effortAssessment, and the feedback line.session-runner-model.test.ts:autoresolves through the chooser, and falls back to the default without one.redcode/test/session/llm.test.ts: a localBun.serveRedRouter fixture that counts decision-model decisions, checking one decider per turn across the manual, dual-direct, dual-combo and single rows, and that the reported level is adopted.packages/tui/test/util/reasoning.test.ts).I did not run tests or typecheck locally; CI validates.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.