Skip to content

fix(v3): avoid forced done tool use for newer Claude models - #3132

Merged
miguelg719 merged 4 commits into
v3from
shubh24/sonnet-55-auto-done-v3
Oct 14, 2026
Merged

miguelg719 merged 4 commits into
v3from
shubh24/sonnet-55-auto-done-v3

Conversation

@shubh24

@shubh24 shubh24 commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The v3 DOM/hybrid agent's final done request can fail when Claude Sonnet 5.5, Opus 5.5, or Fable 5.1 rejects forced tool use. Use automatic tool choice for these models, preserving the existing Fable 5 behavior and conservative incomplete result for plain-text replies.

  • Cover all four models with bare and anthropic/-prefixed IDs, tool-call responses, and text responses.
  • Include a patch changeset for @browserbasehq/stagehand.
  • Merge current v3 (f6b3d851d) into the PR branch.

Validation

  • ESM build, core TypeScript check, ESLint for changed TypeScript files, and test formatting passed.
  • 36 tests passed across agent done-tool choice, Anthropic options, and the v3 act response-schema regression suites.
  • Fresh CI on fd298e269: 242 checks passed, 8 skipped, none failed or pending. Both previously failing server act and agentExecute checks pass.

Scope

This fixes the final done request in the v3 DOM/hybrid agent path. Live model behavior and a full browser run with prior thinking blocks were not revalidated in this review. CUA support remains separate.

@changeset-bot

changeset-bot Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fd298e2

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

This PR includes changesets to release 3 packages
Name Type
@browserbasehq/stagehand Patch
@browserbasehq/stagehand-evals Patch
@browserbasehq/stagehand-server-v3 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

@shubh24
shubh24 marked this pull request as ready for review October 7, 2026 19:23

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 5 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.
Architecture diagram
sequenceDiagram
    participant V3Agent as v3 Agent (DOM/Hybrid)
    participant DoneUtil as handleDoneToolCall.ts
    participant Opts as anthropicOptions.ts
    participant AI as AI SDK generateText
    participant Model as Claude Sonnet 5.5 API
    participant Tests as Unit Tests

    Note over V3Agent,Model: Final Done Request Flow

    V3Agent->>DoneUtil: Request final done tool call
    DoneUtil->>Opts: rejectsForcedToolUse(modelId)
    
    alt Model rejects forced tool use (Sonnet 5.5 or Fable 5)
        Opts->>Opts: Check MODELS_WITHOUT_FORCED_TOOL_USE set
        Opts-->>DoneUtil: True (model in set)
        DoneUtil->>AI: generateText with toolChoice: "auto"
        AI->>Model: Send request with automatic tool choice
    else Model accepts forced tool use (e.g. Opus)
        Opts-->>DoneUtil: False
        DoneUtil->>AI: generateText with toolChoice: "tool" (forced)
        AI->>Model: Send request with forced done tool
    end

    alt Model returns tool call
        Model-->>AI: tool-call: "done" with reasoning
        AI-->>DoneUtil: Done tool result
        DoneUtil-->>V3Agent: taskComplete: true
    else Model returns text reply
        Model-->>AI: text response (no tool call)
        AI-->>DoneUtil: Text content
        DoneUtil-->>V3Agent: taskComplete: false
    end

    Note over Tests: Unit Coverage
    Tests->>Opts: rejectsForcedToolUse("claude-sonnet-5-5")
    Opts-->>Tests: True
    Tests->>Opts: rejectsForcedToolUse("anthropic/claude-sonnet-5-5")
    Opts-->>Tests: True (prefix stripped)
    Tests->>Opts: rejectsForcedToolUse("claude-opus-4-8")
    Opts-->>Tests: False
    
    Tests->>DoneUtil: handleDoneToolCall with Sonnet mock
    DoneUtil->>AI: Verify toolChoice = auto
    AI-->>DoneUtil: Mock "done" tool call
    DoneUtil-->>Tests: taskComplete: true
    DoneUtil-->>Tests: reasoning preserved
    
    Tests->>DoneUtil: handleDoneToolCall with text response
    DoneUtil->>AI: Verify toolChoice = auto
    AI-->>DoneUtil: Mock text reply
    DoneUtil-->>Tests: taskComplete: false
Loading

View guided diff | Turn on auto-fix | Re-trigger cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 4 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

@miguelg719 miguelg719 changed the title fix(v3): avoid forced done tool use for Sonnet 5.5 fix(v3): avoid forced done tool use for newer Claude models Oct 14, 2026
@miguelg719
miguelg719 merged commit 09063f6 into v3 Oct 14, 2026
252 checks passed
@miguelg719
miguelg719 deleted the shubh24/sonnet-55-auto-done-v3 branch October 14, 2026 05:22
@github-actions github-actions Bot mentioned this pull request Oct 14, 2026
seanmcguire12 pushed a commit that referenced this pull request Nov 18, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to v3, this PR will
be updated.


# Releases
## @browserbasehq/[email protected]

### Patch Changes

- [#3150](#3150)
[`69c2440`](69c2440)
Thanks [@miguelg719](https://github.com/miguelg719)! - Fix OpenAI
strict-schema rejection of the nullable `act` action while still
stripping unknown keys when parsing.

- [#3114](#3114)
[`f6b3d85`](f6b3d85)
Thanks [@miguelg719](https://github.com/miguelg719)! - Fix CAPTCHA
awareness options for local Browserbase attachments and forward them
through the API.

- [#3491](#3491)
[`57b905e`](57b905e)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Fix clicks
on partially occluded elements

- [#3132](#3132)
[`09063f6`](09063f6)
Thanks [@shubh24](https://github.com/shubh24)! - Use automatic tool
choice for the final agent `done` call with Claude Sonnet 5.5, Opus 5.5,
and Fable 5.1.

- [#3287](#3287)
[`27ee07c`](27ee07c)
Thanks [@akeimach](https://github.com/akeimach)! - Fix XPath resolution
for light DOM elements when the page has a shadow root and a host
element overrides `children`.

## @browserbasehq/[email protected]

### Patch Changes

- Updated dependencies
\[[`69c2440`](69c2440),
[`f6b3d85`](f6b3d85),
[`57b905e`](57b905e),
[`09063f6`](09063f6),
[`27ee07c`](27ee07c)]:
    -   @browserbasehq/[email protected]

## @browserbasehq/[email protected]

### Patch Changes

- [#3312](#3312)
[`e11bbe5`](e11bbe5)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Rebuild the
standalone server binaries with Node.js 24.22.1 and Undici 7.30.1 to
include the October 2026 security fixes. Binary builds now reject
outdated Node versions and rebuild instead of reusing cached
executables.

- Updated dependencies
\[[`69c2440`](69c2440),
[`f6b3d85`](f6b3d85),
[`57b905e`](57b905e),
[`09063f6`](09063f6),
[`27ee07c`](27ee07c)]:
    -   @browserbasehq/[email protected]

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

2 participants