Skip to content

[MM:   XX.2.M] Give The Claude Turn An Advisor Model - #2229

Open
jaywedgeworth22 wants to merge 3 commits into
mainfrom
minimax/advisor-per-turn
Open

jaywedgeworth22 wants to merge 3 commits into
mainfrom
minimax/advisor-per-turn

Conversation

@jaywedgeworth22

@jaywedgeworth22 jaywedgeworth22 commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Fixes BF-2704

Give The Claude Turn An Advisor Model

Refs BF-2704. Adds per-turn advisor model support to Claude turns via the --advisor <model> launch flag, avoiding the denied /advisor chat command that rewrote the owner's global ~/.claude/settings.json. The flag form is per launch and writes nothing, so global Claude settings stay untouched.

What changed

  • ModelSelection and SendTurnInput carry optional advisorModel, validated by new isAdvisorModel in server/contracts.ts.
  • Claude driver passes --advisor <model> for turns that request one, and probes claude --help for the flag before dispatch, refusing turns on CLIs that do not announce it rather than failing on an unknown option.
  • Bot model selection accepts, validates, and persists advisorModel per bot/thread, and startTurn forwards it to the driver.
  • Fake Claude CLI advertises --advisor in help text, with FAKE_CLAUDE_ADVISOR=off to simulate an older CLI.
  • Docs added: rollout note docs/rollouts/2026-11-26-claude-advisor-per-turn.md and verification fixture docs/verification/claude-advisor.md.

User-visible / operational impact

  • API clients can set {"modelSelection": {"instanceId": "claude", "model": "...", "advisorModel": "..."}} via PATCH /api/bots/:id; the advisor then rides every turn. Invalid values are rejected with 400.
  • Desktop and iOS pickers do not carry an advisor yet; API only.
  • No advisor is chosen automatically: the CLI refuses models that do not support the advisor tool, and that refusal is the CLI's.

Tests added

  • server/drivers/claude.test.ts: turn launches with requested --advisor, turn without advisor omits flag, CLI without flag support is refused.
  • server/index.test.ts: saved selection keeps advisorModel and rejects non-model-id values.
  • Rollout notes report live CLI checks against seat CLI 2.1.330 and Mac CLI 2.1.331, and a throwaway-config run accepting --advisor without writing settings; these runs are reported, not verified here. A live advisor turn requiring a signed-in Claude seat remains unverified in fixtures.

Unresolved risks / review findings

  • [high] server/index.ts:2578 — reported advisor-only PATCH bypass of busy guard mid-turn.
  • [medium] server/drivers/claude.ts:2364 — reported affirmative advisor probe cached indefinitely, missing CLI downgrade.

Summary

Gives the Claude turn an advisor model carried per-turn from the model selection. Validation is centralized in a new isAdvisorModelId helper in server/advisor-model.ts, replacing the former isAdvisorModel in server/contracts.ts.

Changes

  • Added server/advisor-model.ts to validate an advisor model id as a single launch argument: trimmed 1–64 characters matching /^[a-z0-9][a-z0-9._:/-]*$/i. Updated server/drivers/claude.ts and selection validation in server/index.ts to use it.
  • Builds the active selection and turn input advisor property in its own statement with intent that the property is absent when the bot has none, so the driver passes the advisor per launch without writing global engine settings.

Operational impact

Claude turns can now run under the selected advisor model when present. No deployment, approval, or runtime verification is reported in the changes provided.

Unresolved risks / review findings

  • Medium: turn input in server/index.ts always carries the advisorModel key even when unset, per review. Behavior when unset is unverified.
  • Low: active selection in server/index.ts leaks advisorModel: undefined instead of omitting it, per review. Downstream handling of an explicit undefined value is unverified.

Testing

No tests added or tests reported as run were found in the changes provided.


Gives the Claude turn an advisor model with safer lifecycle handling. The advisor CLI flag probe is no longer cached forever on yes, so a later downgraded CLI is re-detected instead of letting the next advisor turn fail on an unknown option. Changing advisorModel while the bot is working is now treated as a model change and refused with 409. Turns without an advisor now omit the advisor key entirely rather than carrying an empty value.

Changes

  • Bound yes advisor probe results to the normal expiry, keeping short retry for unknown.
  • Include advisorModel in busy-bot model-selection change detection.
  • Only set the turn advisor property when a selection actually has one.

Tests

  • Adds a harness API test covering refusal of an advisor-only change while busy. No runtime verification reported.

The Claude Code CLI can consult a second model as an advisor, but the way to turn that on from a chat is denied twice in the driver, because a bare /advisor opus that reached the CLI rewrote advisorModel in the owner's global ~/.claude/settings.json.

The flag form has no such problem:  --advisor <model> is per launch, so it applies to one turn and writes nothing.

- ModelSelection.advisorModel and SendTurnInput.advisorModel carry the advisor, and isAdvisorModel is the one rule for what a model id is.
- The shared Claude driver launches the turn with --advisor <model>.
- The driver probes claude --help for --advisor, cached the way the --strict-mcp-config probe is, and refuses the turn with a clear reason when the CLI does not announce the flag, instead of letting the turn die on an unknown option.
- The bot's model selection accepts and persists advisorModel, so an advisor is set per bot or per thread and rides every turn.

The turn-side tests are in server/drivers/claude.test.ts and the API test is in server/index.test.ts.  The rollout note is docs/rollouts/2026-11-26-claude-advisor-per-turn.md and the recipe is docs/verification/claude-advisor.md.

Fixes BF-2704
@linear-code

linear-code Bot commented Nov 26, 2026

Copy link
Copy Markdown

BF-2704

@kody-ai

This comment has been minimized.

@swu-minimax

swu-minimax Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

@kody start-review
[MM:   XX.2.M]

Head: 89af3bd
PR: #2229
Branch: minimax/advisor-per-turn, base main.

The change wires the Claude Code advisor model into one turn.  SendTurnInput and ModelSelection carry advisorModel, the shared Claude driver launches the turn with --advisor , and a capability probe refuses the turn when the CLI does not announce the flag.  No settings file is written, so the owner's global Claude settings stay untouched.

Tests: server/drivers/claude.test.ts (the flag reaches the turn, a turn without one has no flag, and a CLI without the flag is refused) and server/index.test.ts (the selection keeps the advisor and refuses a value that is not a model id).  The server typecheck is clean.

Docs: docs/rollouts/2026-11-26-claude-advisor-per-turn.md and docs/verification/claude-advisor.md.

@swu-minimax
swu-minimax Bot enabled auto-merge (squash) November 26, 2026 05:40
Comment thread server/drivers/claude.ts Resolved
Comment thread server/index.ts Resolved
@kody-ai

kody-ai Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Automatic approval held

Kody's assessment:

Risk was identified in this PR.

The lint baseline check counts per rule, so two of the repo's anti-slop rules caught the first pass:  an unknown parameter on the advisor check, and a conditional empty object spread where the advisor rides the turn.

The advisor rule now lives in its own module (server/advisor-model.ts) with a typed parameter, and the two places that carry the advisor build the object in its own statement.  The baseline check passes, and the branch adds no warning of any kind.

Refs BF-2704
@swu-minimax

swu-minimax Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

@kody start-review
[MM:   XX.2.M]

Head: b84a967
PR: #2229
Branch: minimax/advisor-per-turn, base main.

This head is the second commit on the branch.  The lint baseline check counts per rule, so the repo's anti-slop rules caught the first pass: an unknown parameter on the advisor check, and a conditional empty object spread where the advisor rides the turn.  The advisor rule now lives in its own module with a typed parameter, the two places that carry the advisor build the object in its own statement, and the baseline check passes with no new warning of any kind.

What the change does: SendTurnInput and ModelSelection carry advisorModel, the shared Claude driver launches the turn with --advisor , and a capability probe refuses the turn when the CLI does not announce the flag.  No settings file is written, so the owner's global Claude settings stay untouched.

Tests: server/drivers/claude.test.ts (123 pass) and the advisor case in server/index.test.ts.  The server typecheck is clean and the lint baseline check passes.

@swu-minimax
swu-minimax Bot disabled auto-merge November 26, 2026 05:46
@swu-minimax
swu-minimax Bot enabled auto-merge (squash) November 26, 2026 05:47
@kody-ai

This comment has been minimized.

Comment thread server/index.ts Resolved
Comment thread server/index.ts Resolved
… Turn

The four findings on the first two commits are fixed in this third commit.

- The affirmative advisor probe now expires with the same bound as every other probe answer, so a CLI downgraded after the first lookup is noticed instead of believed forever.
- An advisor change is a model change:  the selection check compares the advisor as well, so an advisor-only PATCH while the bot works is refused with the same 409 as a model swap.
- The advisor property is omitted when the bot has none, in the turn input and in the active selection, so neither carries an empty advisor key.
- A new API test holds the fixture busy and proves that the advisor-only PATCH is refused with 409.

Refs BF-2704
@swu-minimax

swu-minimax Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

@kody start-review
[MM:   XX.2.M]

Head: 49f042c
PR: #2229
Branch: minimax/advisor-per-turn, base main.

This head answers the four findings from the previous two commits.  The affirmative advisor probe now expires like every other probe answer, an advisor change goes through the same busy guard as a model change, and the advisor property is omitted when the bot has none.

A new API test holds the fixture busy and proves that the advisor-only PATCH is refused with 409.  The server typecheck is clean, the lint baseline check passes, and the Claude driver suite is green at 123 tests.

@kody-ai

kody-ai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

​

@swu-minimax
swu-minimax Bot disabled auto-merge November 26, 2026 06:05
@swu-minimax
swu-minimax Bot enabled auto-merge (squash) November 26, 2026 06:05
@swu-minimax

swu-minimax Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

@kody start-review
[MM:   XX.2.M]

Head: 49f042c
PR: #2229
Branch: minimax/advisor-per-turn, base main.

The previous request on this head was skipped with no changed files, so this is a fresh request on the same head.  The three commits carry the per-turn advisor model, the lint baseline fix, and the answer to the four findings from the first two commits.

Nothing else changed on the branch since that request: the diff against main is the same ten files, and the four threads are answered and resolved.  The server typecheck is clean, the lint baseline check passes, and the Claude driver suite is green at 123 tests.

This branch has not been deployed

No deployments
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