feat: Add Anthropic advisor functionality and tests#12095
Draft
TDFSE wants to merge 4 commits intoRooCodeInc:mainfrom
Draft
feat: Add Anthropic advisor functionality and tests#12095TDFSE wants to merge 4 commits intoRooCodeInc:mainfrom
TDFSE wants to merge 4 commits intoRooCodeInc:mainfrom
Conversation
Author
|
Working on resolving the known gap - want to get the call/result of the advisor to display in chat. Then will add translations/fix failing checks. |
Author
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.

Related GitHub Issue
Closes: #12094
Roo Code Task Context (Optional)
Description
Adds UI controls and API-layer support for Anthropic's Advisor Tool (beta
advisor-tool-2026-03-01), which allows a Claude executor model to consult Claude Opus 4.6 mid-generation for strategic guidance — within a single/v1/messagesrequest.How it works:
supportsAdvisorToolcapability flag is added to theModelInfoZod schema (packages/types/src/model.ts) and set on the three currently supported executor models:claude-haiku-4-5-20251001,claude-sonnet-4-6, andclaude-opus-4-6.anthropicSchemainpackages/types/src/provider-settings.ts:anthropicAdvisorEnabled,anthropicAdvisorModel, andanthropicAdvisorMaxUses.ProviderSettingsderives from the Zod schema viaz.infer<>— no manual interface edits required.webview-ui/src/components/settings/providers/Anthropic.tsx) renders a new sub-section in the Advanced area, gated bymodelInfo?.supportsAdvisorTool. When enabled, a model dropdown (currentlyclaude-opus-4-6only) and a max uses number input are shown. Uses i18n strings viawebview-ui/src/i18n/locales/en/settings.json.src/api/providers/anthropic.ts) pushes"advisor-tool-2026-03-01"onto thebetasarray and appends anadvisor_20260301tool definition to the tools array whenanthropicAdvisorEnabledis true.max_usesdefaults to3and is always included in the tool definition when the feature is enabled; set viaanthropicAdvisorMaxUsesin settings.Design choices / reviewer notes:
advisor_20260301is not yet in the official@anthropic-ai/sdkTypeScript types. A type cast (as unknown as Anthropic.Tool) is used to avoid a type error while keeping the runtime object correct.advisor_tool_use/advisor_tool_resultcontent blocks that Anthropic inserts into assistant turns will be stripped byfilterNonAnthropicBlocks()before the next request, becauseVALID_ANTHROPIC_BLOCK_TYPES(src/api/transform/anthropic-filter.ts) does not include those types. This PR does not add them to the allowlist. The practical impact depends on whether Anthropic requires those blocks in subsequent turns for correct continuation — reviewers should verify this with the Anthropic API docs before merging.anthropicAdvisorEnabledis falsy.Files changed:
packages/types/src/model.tssupportsAdvisorTool: z.boolean().optional()tomodelInfoSchemapackages/types/src/provider-settings.tsanthropicAdvisorEnabled,anthropicAdvisorModel,anthropicAdvisorMaxUsestoanthropicSchemapackages/types/src/providers/anthropic.tssupportsAdvisorTool: trueonclaude-haiku-4-5-20251001,claude-sonnet-4-6,claude-opus-4-6src/api/providers/anthropic.tsadvisor-tool-2026-03-01beta header and advisor tool definition when enabledwebview-ui/src/components/settings/providers/Anthropic.tsxwebview-ui/src/i18n/locales/en/settings.jsonanthropicAdvisorToolLabel,anthropicAdvisorModelLabel,anthropicAdvisorMaxUsesLabel,anthropicAdvisorMaxUsesPlaceholdersrc/api/providers/__tests__/anthropic.spec.tsadvisor tool featuredescribe block with 6 unit testsTest Procedure
Unit tests covering the API handler are in
src/api/providers/__tests__/anthropic.spec.tsunder theadvisor tool featuredescribe block. Run verified locally.Pre-Submission Checklist
Screenshots / Videos
Before:

After:

Documentation Updates
Does this PR necessitate updates to user-facing documentation?
Additional Notes
advisor-tool-2026-03-01). The API shape may change before GA. The implementation is intentionally minimal and additive.max_usesdefaults to3when not configured. This controls the maximum number of advisor consultations per API request, not per Roo-Code task — a long agentic task with many API calls will invoke the advisor up tomax_usestimes per call.supportsAdvisorTool: truein the model info map — no UI changes needed.Interactively review PR in Roo Code Cloud