Skip to content

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

Open
github-actions[bot] wants to merge 8 commits intomainfrom
external-contributor-pr-1912
Open

[Claimed #1912] Feat: Add Anthropic CUA adaptive thinking#1954
github-actions[bot] wants to merge 8 commits intomainfrom
external-contributor-pr-1912

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Apr 3, 2026

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

Original author: @chromiebot
Original PR: #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.

Written for commit ebe95e7. Summary will update on new commits. Review in cubic

Chromie Bot and others added 4 commits March 30, 2026 06:20
Add comprehensive tests for the new adaptive thinking API used by
Claude 4.6 models (claude-opus-4-6, claude-sonnet-4-6).

Tests verify:
- Adaptive thinking uses thinking.type: 'adaptive' (not 'enabled')
- Effort levels are passed via output_config.effort (not budget_tokens)
- All effort levels: low, medium, high, max
- Older models continue using deprecated budget_tokens API
- Model name detection handles provider-prefixed names

These tests define the expected API contract per:
https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update AnthropicCUAClient to use the correct API contract for
Claude 4.6 models (claude-opus-4-6, claude-sonnet-4-6).

Claude 4.6 models use adaptive thinking:
- thinking: { type: "adaptive" }
- output_config: { effort: "low" | "medium" | "high" | "max" }

This replaces the deprecated API:
- thinking: { type: "enabled", budget_tokens: N }

Changes:
- Add ThinkingEffort type for effort levels
- Add thinkingEffort option to ClientOptions
- Detect 4.6 models and use adaptive thinking with output_config
- Keep backward compatibility with thinkingBudget for older models
- Add deprecation notice for thinkingBudget on 4.6 models

The implementation follows the API contract documented at:
https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add test for default "medium" effort when thinkingEffort not set
- Add tests verifying temperature=1 is set for adaptive thinking
- Add test that older models don't force temperature=1

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Always set temperature=1 when adaptive thinking is enabled (required by API)
- Default to "medium" effort for Claude 4.6 models when thinkingEffort not set
- This ensures adaptive thinking works out of the box for 4.6 models

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions github-actions bot added external-contributor Tracks PRs mirrored from external contributor forks. external-contributor:mirrored An internal mirrored PR currently exists for this external contributor PR. labels Apr 3, 2026
@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions bot commented Apr 3, 2026

This mirrored PR tracks external contributor PR #1912 at source SHA 0ea0332c525017c727743d11a68b8eb74f76b646, approved by @miguelg719.
Original PR: #1912

When the external PR gets new commits, this same internal PR will be refreshed in place after the latest external commit is approved.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 3, 2026

🦋 Changeset detected

Latest commit: ebe95e7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@browserbasehq/stagehand Patch
@browserbasehq/stagehand-evals Patch
@browserbasehq/stagehand-server-v3 Patch
@browserbasehq/stagehand-server-v4 Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files

Confidence score: 5/5

  • This looks low risk to merge: the only reported issue is a documentation/behavior mismatch with low severity (3/10), not a functional break in core logic.
  • In packages/core/lib/v3/types/public/model.ts, docs say ThinkingEffort defaults to high, while runtime behavior uses medium when thinkingEffort is unset, which could mislead integrators about default model behavior.
  • Pay close attention to packages/core/lib/v3/types/public/model.ts - align the ThinkingEffort default in docs with the actual adaptive-thinking fallback (medium).
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/core/lib/v3/types/public/model.ts">

<violation number="1" location="packages/core/lib/v3/types/public/model.ts:101">
P3: The new `ThinkingEffort` docs claim `high` is the default, but the implementation defaults adaptive thinking to `medium` when `thinkingEffort` is unset.</violation>
</file>
Architecture diagram
sequenceDiagram
    participant App as Application Logic
    participant Client as AnthropicCUAClient
    participant SDK as Anthropic SDK (Beta)
    participant API as Anthropic API

    Note over App,API: Runtime Flow for Adaptive Thinking

    App->>Client: getAction(messages)
    
    Client->>Client: Detect model version (4.6 vs older)

    alt NEW: Model is Claude 4.6 (Opus or Sonnet)
        Client->>Client: NEW: Set thinking.type = "adaptive"
        Client->>Client: NEW: Set output_config.effort = thinkingEffort (default: "medium")
        Client->>Client: NEW: Force temperature = 1
        Note right of Client: Required for adaptive thinking mode
    else CHANGED: Older Claude models (e.g., 4.5)
        opt thinkingBudget provided
            Client->>Client: CHANGED: Set thinking.type = "enabled"
            Client->>Client: CHANGED: Set budget_tokens = thinkingBudget
        end
    end

    Client->>SDK: beta.messages.create({ model, messages, thinking, ... })
    
    Note over SDK,API: Uses computer_20251124 header
    
    SDK->>API: POST /v1/messages
    API-->>SDK: Response (with thinking blocks)
    SDK-->>Client: Message Object
    Client-->>App: Action Result
Loading

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

Comment thread packages/core/lib/v3/types/public/model.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor:mirrored An internal mirrored PR currently exists for this external contributor PR. external-contributor Tracks PRs mirrored from external contributor forks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant