You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Hosted extract fails on claude-sonnet-5-5: forced tool_choice (v3 server pins @ai-sdk/anthropic 2.0.81) #3353
On the hosted API (api.stagehand.browserbase.com), extract fails for anthropic/claude-sonnet-5-5 with a 422:
POST /v1/sessions/{id}/extract: 422 Unprocessable Entity
{"success":false,"message":"AI_APICallError: tool_choice: type \"tool\" and \"any\" are not supported for this model."}
The same call succeeds with anthropic/claude-sonnet-4-6 and anthropic/claude-sonnet-5. Sonnet 5.5 (like Opus 5.5 and Fable 5.1) rejects forced tool use, so the request must use native structured output instead of a forced JSON tool.
Cause
packages/core/lib/v3/llm/aisdk.ts calls generateObject with providerOptions.anthropic.structuredOutputMode: "auto", which leaves the choice between outputFormat and jsonTool to @ai-sdk/anthropic.
The v3 server lockfile (tag stagehand-server-v3/v3.7.7 and the v3 branch head) resolves @ai-sdk/[email protected]. Its getModelCapabilities has no entry for any claude-sonnet-5* model, so supportsStructuredOutput is false and auto falls back to jsonTool, which forces tool_choice.
@ai-sdk/[email protected] knows claude-sonnet-5-5 (supportsStructuredOutput: true, rejectsForcedToolUse: true) and switches to outputFormat even when jsonTool is requested.
Stagehand already tracks these models in MODELS_WITHOUT_FORCED_TOOL_USE (packages/core/lib/v3/llm/anthropicOptions.ts), but only agent/utils/handleDoneToolCall.ts consults it; the extract path does not.
Suggested fix
Bump @ai-sdk/anthropic in the v3 server to >=2.0.110 (or the first 2.x release with Sonnet 5.5 capabilities) and release a new stagehand-server-v3. Alternatively, set structuredOutputMode: "outputFormat" when rejectsForcedToolUse(modelId) is true.
Reproduction
Go SDK github.com/browserbase/stagehand-go/v3 v3.21.0 against the hosted API: start a session, navigate to https://example.com, then extract with instruction "the main page heading text" and schema {"type":"object","properties":{"heading":{"type":"string"}}}, with model anthropic/claude-sonnet-5-5. Swapping the model to anthropic/claude-sonnet-4-6 or anthropic/claude-sonnet-5 passes.
Activity