[Claimed #1912] Feat: Add Anthropic CUA adaptive thinking

Merged
GI
7mo ago
+510-12

Mirrored from external contributor PR #1912 after approval by @miguelg719.

Original author: @chromiebot
Original PR: https://github.com/browserbase/stagehand/pull/1912
Approved source head SHA: 0ea0332c525017c727743d11a68b8eb74f76b646

@chromiebot, please continue any follow-up discussion on this mirrored PR. When the external PR gets new commits, this same internal PR will be marked stale until the latest external commit is approved and refreshed here.

Original description

why

what changed

test plan


Summary by cubic

Add adaptive thinking for Anthropic Claude 4.6 models in the CUA client with effort controls and automatic temperature=1. Keeps legacy thinkingBudget for older models and improves model detection and tool versioning.

  • New Features

    • Detects 4.6 models (e.g., claude-opus-4-6*, claude-sonnet-4-6*, incl. provider-prefixed) and sends thinking: { type: "adaptive" } with output_config.effort (defaults to "medium").
    • Adds ThinkingEffort and thinkingEffort in ClientOptions ("none" | "low" | "medium" | "high" | "max"); "none" disables adaptive thinking.
    • Forces temperature: 1 with adaptive thinking and logs when overriding a user value; logs when thinkingBudget is provided on 4.6 models.
    • Uses computer_20251124 for 4.6 and claude-opus-4-5-20251101; older models continue with thinking: { type: "enabled", budget_tokens }.
  • Migration

    • For 4.6 models, set thinkingEffort; thinkingBudget is ignored.
    • Adaptive thinking forces temperature: 1; set thinkingEffort: "none" to disable.