Repository navigation
[MM: XX.2.M] Give The Claude Turn An Advisor Model #2229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
89af3bd
Give The Claude Turn An Advisor Model That Never Touches Global Settings
jaywedgeworth22 b84a967
Hold The Lint Baseline: One Advisor Rule And No New Warnings
jaywedgeworth22 49f042c
Answer The Kody Findings: Expire The Advisor Probe And Guard The Busy…
jaywedgeworth22 e50df2b
Hold The Linux Closure: The Retained Source Policy Names The Advisor …
jaywedgeworth22 b4a4c8b
Hold The Port Inventory: The Advisor Module Has An Owner Row
jaywedgeworth22 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # The Claude Advisor Model Rides The Turn | ||
|
|
||
| Refs BF-2704. | ||
|
|
||
| The Claude Code CLI can consult a second model as an advisor while it answers. The way to turn that on from a chat, the `/advisor` command, 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` (server/drivers/engine-commands.ts:5-6, :48, :105). | ||
|
|
||
| The flag form has no such problem: `--advisor <model>` is per launch, so it applies to one turn and writes nothing. | ||
|
|
||
| ## What changed | ||
|
|
||
| - `ModelSelection.advisorModel` and `SendTurnInput.advisorModel` (server/contracts.ts) 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>` (server/drivers/claude.ts). | ||
| - 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` (server/index.ts), so an advisor is set per bot or per thread and rides every turn. | ||
|
|
||
| ## What it does not do | ||
|
|
||
| - It never writes a settings file, so the owner's global Claude settings stay untouched. | ||
| - It does not choose the advisor for you: the CLI refuses a model that does not support the advisor tool, and that refusal is the CLI's. | ||
| - The desktop and iOS pickers do not carry an advisor yet; the API does (`PATCH /api/bots/:id` with `modelSelection.advisorModel`). | ||
|
|
||
| ## Evidence | ||
|
|
||
| - The server's own Claude seat CLI is 2.1.330 and the Mac's is 2.1.331. Both carry `--advisor <model>` and the `advisorModel` settings key. | ||
| - A live CLI run against a throwaway config accepted both `--advisor <model>` and `--settings '{"advisorModel":"..."}'` with no unknown-option or validation error, and wrote no settings file. | ||
| - The turn-side tests are in `server/drivers/claude.test.ts` (the turn launches with the flag, a turn without one has no flag, and a CLI that does not announce the flag is refused) and the API test is in `server/index.test.ts` (the selection keeps the advisor, and a value that is not a model id is refused). | ||
|
|
||
| ## Setting one | ||
|
|
||
| `PATCH /api/bots/:id` takes the whole selection, the way any other selection field is set: | ||
|
|
||
| {"modelSelection": {"instanceId": "claude", "model": "claude-sonnet-5-5", "advisorModel": "claude-opus-5-5"}} | ||
|
|
||
| The advisor model has to be one the CLI accepts for the advisor tool, and the main model has to accept one. |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # Claude Advisor Verification | ||
|
|
||
| The advisor is a launch flag on the Claude engine, so it is verified against the fake CLI that stands in for the real one, and against the real CLI's own help text. | ||
|
|
||
| ## The flag reaches the turn | ||
|
|
||
| `server/drivers/claude.test.ts` drives the fake CLI (`server/testing/fake-claude-cli.ts`) and reads the argv the turn was launched with. | ||
|
|
||
| | Case | What it proves | | ||
| | --- | --- | | ||
| | `launches the turn with the advisor model the turn asked for` | a turn with an advisor launches with `--advisor <model>` | | ||
| | `leaves the advisor off a turn that asked for none` | a turn without one has no `--advisor` in its argv | | ||
| | `refuses the turn when the CLI does not announce the advisor flag` | a CLI whose help does not announce `--advisor` is refused before the turn starts, not after | | ||
|
|
||
| The fake answers `--help` with the flags the real CLI announces, and `FAKE_CLAUDE_ADVISOR=off` takes the flag back out, which is how the refusal case is produced. | ||
|
|
||
| ## The selection keeps it | ||
|
|
||
| `server/index.test.ts` covers the API: a bot's model selection keeps `advisorModel`, and a value that is not a model id is refused with a 400, because an advisor reaches the engine as one launch argument. | ||
|
|
||
| ## The real CLI | ||
|
|
||
| The real CLI's own help is the authority on whether a CLI can run an advisor turn: | ||
|
|
||
| claude --help | grep -- --advisor | ||
|
|
||
| A CLI that predates the flag answers with an unknown option, so the driver refuses the turn before it starts rather than letting the launch fail. | ||
|
|
||
| ## What a fixture cannot prove | ||
|
|
||
| A live advisor turn, where the CLI calls a second model at a key moment, needs a signed-in Claude seat. The fleet injects seat credentials per seat, so that part is verified on a real bot rather than in a fixture. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| /** The advisor model id: a model slug, a short alias, or an injected id. | ||
| * | ||
| * An advisor reaches the engine as one launch argument, so a value with | ||
| * spaces or punctuation would be a different argument than the one meant. | ||
| * The rule is one place, so the API that saves one and the driver that | ||
| * passes one agree on what an id is. */ | ||
| const ADVISOR_MODEL_ID = /^[a-z0-9][a-z0-9._:/-]*$/i; | ||
|
|
||
| /** True when the value is an advisor model id this fleet may pass. */ | ||
| export function isAdvisorModelId(value: string): boolean { | ||
| const trimmed = value.trim(); | ||
| return trimmed.length > 0 && trimmed.length <= 64 && ADVISOR_MODEL_ID.test(trimmed); | ||
| } |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.