Skip to content

fix(core): retry forced tool use rejected by Claude thinking - #2510

Merged
okwasniewski merged 6 commits into
mainfrom
t3/manual-thinking-compatibility
Nov 30, 2026
Merged

okwasniewski merged 6 commits into
mainfrom
t3/manual-thinking-compatibility

Conversation

@michal-e2e

@michal-e2e michal-e2e commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

What

agent.act and exploring agent.assert retry with automatic tool choice when a gateway returns Anthropic's HTTP 400 error Thinking may not be enabled when tool_choice forces tool use. The retry keeps manual extended thinking enabled and ignores 5xx retry chains that quote the refusal.

The remembered auto mode has two scopes. A refusal that names the model (Claude Fable 5.1, Muse Spark) covers every later step on that model. Any other refusal or downgrade covers only later steps whose providerOptions match exactly, and a step with no providerOptions is a scope of its own.

Why

The forced-choice fallback missed Anthropic's manual-thinking wording, so the step failed with MODEL_PROVIDER_FAILED even though Claude could continue under auto.

Remembering that refusal on the bare model object would force sibling agents sharing the same model constant into auto even when their providerOptions leave thinking off. The same holds when thinking is a setting of the model itself (AI SDK defaultSettingsMiddleware): the agent that inherits it sends no options, and a sibling whose options turn thinking off must keep forced tool calls. A refusal that names the model is not about options, so scoping it per option set would cost one rejected request per agent where main costs one per model.

Adaptive thinking has a separate behavior. On models that accept a forced tool call, Claude can start its response with that call and skip thinking. A successful response takes no error-driven retry. Anthropic's tool-choice documentation

How it works

  1. FORCED_CHOICE_PATTERNS adds Anthropic's manual-thinking HTTP 400 sentence (tool-choice.ts:21). MODEL_WIDE_PATTERNS lists the refusals that name the model (tool-choice.ts:33).
  2. forcedToolChoiceRefusal, which replaces isForcedToolChoiceRejected, walks the full cause and lastError chain up to depth 8. It returns undefined if any wrapped error carries a non-4xx HTTP status, so a statusless AI_RetryError wrapping an HTTP 502 never triggers the auto fallback. Otherwise it returns 'model' for a model-wide match and 'options' for any other match (tool-choice.ts:103).
  3. rememberAutoToolChoice and prefersAutoToolChoice keep a WeakMap per model instance. It holds a model-wide flag and a set of providerOptions keys, with '' for no options (tool-choice.ts:136). A key is the JSON form of the options with sorted keys, so toJSON applies. Options with no JSON form, such as a bigint an executor passes directly, get no key: the step still retries with auto, and nothing is remembered (tool-choice.ts:174).
  4. LoopRun reads the memory at construction (tool-loop.ts:311). freeToolChoiceRetry records the refusal's scope, and 'options' for a prose reply under a forced choice (tool-loop.ts:656). noticeToolChoiceDowngrade records 'options', because the AI SDK's Anthropic provider downgrades both for models that reject forced use and for manual thinking, and its warning does not say which (tool-loop.ts:673).

Verified

Ran it locally: yes

The built CLI, with a scripted anthropic.messages model, ran on main (7c1b2b258) and on this branch (d00f974b). The model throws the Anthropic 400 errors. The table lists the tool choice of each request.

  • shared-model.e2e.ts: thinking comes from defaultSettingsMiddleware. The default agent sends no options, and lean sends thinking: { type: 'disabled' } with maxModelCalls: 1.
  • fable.e2e.ts: the model refuses every forced choice with Fable 5.1's message. Agents low (effort: 'low'), high (effort: 'high'), and default (no options) run in that order.
 ✓ |verify| tests-verify-2510/shared-model.e2e.ts (2 tests) 331ms ai 240 tokens
 ✓ |verify| tests-verify-2510b/fable.e2e.ts (3 tests) 519ms ai 360 tokens
Main This PR
Inherited manual thinking + forced tool choice required, MODEL_PROVIDER_FAILED required, then auto with thinking intact, passes
Sibling that turns thinking off (maxModelCalls: 1) Skipped after step 1 failed tool:complete_step, passes
Fable-style refusal across three option sets required, then auto ×3: one rejected request required, then auto ×3: one rejected request

One more run covers options whose own field is a bigint and whose toJSON writes it as text, such as a 64-bit request id. Config resolution accepts them. The model answers the manual-thinking 400, and the test runs two agent.act steps. On 2e10b94b, the first step failed after one required call with ACTION_FAILED: Do not know how to serialize a BigInt. On d00f974b the calls are required, auto, auto, and the test passes.

Unit tests in packages/e2e/tests/unit/tool-loop-tool-choice.test.ts cover the following:

  • required and tool:complete_step retries with providerOptions kept
  • shared-model isolation with explicit options and with model-level thinking
  • one rejection across option sets for a model-wide refusal
  • the forcedToolChoiceRefusal scope across gateway wrappers, 502 AI_RetryError chains, and unrelated thinking 400s
  • the options scope of a downgrade warning and of a prose reply under a forced choice. Each test fails when its path remembers the whole model.
  • scope keys from the JSON form of providerOptions (toJSON applied), and options with no JSON form, which are retried but not remembered

On 84f333309 the model-level thinking test and the model-wide test fail. Live gateway behavior is still unverified: no model key was available.

Summary by CodeRabbit

  • Bug Fixes

    • Agent turns now retry with automatic tool choice when a model rejects forced tool use, including Claude’s manual extended-thinking restriction, while retaining thinking settings.
    • Automatic tool choice applies to the affected model or matching provider options, allowing unrelated configurations to continue using forced tool calls.
  • Documentation

    • Clarified which models reject forced tool calls and how fallback behavior applies to later steps.

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Explain Change →

Walkthrough

Changes: Anthropic tool-choice retry

Layer / File(s) Summary
Refusal detection and preference scope
packages/core/src/agent/model/tool-choice.ts
The detector recognizes Anthropic’s manual-thinking error and checks wrapped errors. Automatic tool-choice preferences use a model-wide scope or a canonicalized provider-options scope.
Tool-loop preference and retry
packages/core/src/agent/tool-loop.ts
The tool loop uses the model and effective provider options to select the initial mode. It records an automatic preference after a forced choice is rejected, skipped, or downgraded.
Retry validation and documentation
packages/e2e/tests/helpers/fake-loop-model.ts, packages/e2e/tests/unit/tool-loop-tool-choice.test.ts, docs/models.mdx, .changeset/anthropic-thinking-tool-choice.md
The fake model records provider options. Tests cover retries, provider-option scopes, and refusal classification. The documentation describes retained thinking settings and later steps that use auto; the changeset declares a patch release.

Possibly related issues

  • e2e-inc/e2e#2383: This PR retries forced tool choices that conflict with Claude manual thinking. It does not suppress the SDK downgrade warning described in the issue.

Suggested reviewers: kdy1, nathanwalker

Change: Bug fix

Merge Risk: Minimal · up to d00f9

The change retries forced tool use with automatic tool choice when Claude rejects it under manual thinking, and it remembers that choice per model or per set of provider options. No actionable merge-blocking risk was identified.

Security architecture risk: Low · up to d00f9

The fallback keeps the same permitted actions and usually limits its effect to requests with matching settings. The new memory has no size limit for a long-lived shared configuration, and unusually complex settings can interrupt recovery.

Retained concerns

  • Trivial · reliability · observed: The old cache kept one membership bit per model instance. The new cache keeps the complete canonical JSON for every distinct option scope learned on that instance, with no size limit or eviction. A long-lived instance reused with changing configurations can accumulate request-option data after the originating steps finish. The weak key limits retention to the model object's lifetime, not the lifetime of each configuration.
  • Trivial · reliability · inferred: Only the first serialization is guarded. If deeply nested options serialize successfully but exhaust the stack during recursive sorting, key generation can abort loop construction or escape the refusal handler before the automatic-choice retry. Capability memory can therefore turn a recoverable refusal into a step failure instead of skipping memoization.
Security review details

Security Blast Radius

  • inferred — Preference changes can affect later callers in the same process that reuse the identical model object. A model-wide refusal affects all option sets on that object, as qualifying refusals did on the base; other updates affect only callers whose canonical option keys match. This identity boundary is not a tenant boundary.

Trust Boundaries and Controls

  • observed — Provider or gateway error text can influence request mode through a bounded error-chain scan. A numeric non-4xx status on the traversed chain vetoes classification, but a matching record need not supply a status. The resulting preference governs tool selection mode, not which tools may be offered.

Resilience and Maintainability Implications

  • observed — The cache can be updated by a warning on a successful provider turn or before a retry has completed. There is no outcome-based rollback; the state records an observed compatibility signal, not proof that the step succeeded.

Hardening Proposals

  • proposed — Bound the number and size of remembered option scopes, avoid retaining raw option values where practical, and make all key-generation failures skip memoization without blocking the current step's fallback.
Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@github-actions github-actions Bot added e2e team Opened by the e2e team size:S Up to 29 changed lines, not counting tests, fixtures, translated docs, or the lockfile labels Nov 29, 2026
@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

🟢 e2e web: 95 passed

All 95 tests in 43 files
Test Time
🟢 tests/aria-hidden-flow.e2e.ts · 2 passed 542ms
🟢 aria hidden flow › picks the Pro plan by its visible text and confirms it 410ms
🟢 aria hidden flow › another plan shows the error and keeps the picker open 132ms
🟢 tests/async-states.e2e.ts · 2 passed 6.9s
🟢 async states › reads the code off the transient toast and verifies it once the button enables 2.2s
🟢 async states › a wrong code is rejected after the toast has gone 4.7s
🟢 tests/canvas-only.e2e.ts · 2 passed 235ms
🟢 canvas only › taps square, circle, then diamond at their pixel coordinates 128ms
🟢 canvas only › a shape out of order paints the error and resets progress 107ms
🟢 tests/canvas-whiteboard.e2e.ts · 2 passed 354ms
🟢 canvas whiteboard › drags both shapes into their slots and saves 221ms
🟢 canvas whiteboard › bounces a shape off the wrong slot and refuses to save early 133ms
🟢 tests/cart-totals.e2e.ts · 2 passed 322ms
🟢 cart totals › increasing a quantity updates the line total but the order summary stays stale (planted bug) 191ms
🟢 cart totals › a quantity never drops below one 131ms
🟢 tests/checkout-review.e2e.ts · 1 passed 133ms
🟢 shows a raw greeting token and an undefined delivery date (planted bug), yet places the order 133ms
🟢 tests/context-menu-trap.e2e.ts · 2 passed 494ms
🟢 context menu trap › right-click opens nothing; the row menu renames the file 264ms
🟢 context menu trap › the decoy menu items refuse and keep the file 230ms
🟢 tests/control-inventory.e2e.ts · 8 passed 3.2s
🟢 control inventory › check sets the checkbox and the radio without flipping a set one 215ms
🟢 control inventory › check picks a radio the pick replaces with its summary 145ms
🟢 control inventory › a long press and a double click are told apart from a tap 969ms
🟢 control inventory › the file menu opens on right-click only and Rename renames the file 223ms
🟢 control inventory › setInputFiles attaches files named from the project root 125ms
🟢 control inventory › the details view is left through the browser history 149ms
🟢 control inventory › scrollIntoView brings the footnote into view 154ms
🟢 control inventory › every exercise done shows the success message 1.2s
🟢 tests/css-content-ui.e2e.ts · 2 passed 279ms
🟢 css content ui › the tile labelled Ship it advances and confirming ships 160ms
🟢 css content ui › a wrong tile shows the CSS-rendered error and keeps the picker 119ms
🟢 tests/date-picker.e2e.ts · 2 passed 562ms
🟢 date picker › navigates three months ahead and books the required date 329ms
🟢 date picker › confirming without the exact date shows the error 233ms
🟢 tests/debounced-search.e2e.ts · 2 passed 2.7s
🟢 debounced search › a decoy one character off is refused 1.4s
🟢 debounced search › picking the exact item adds it to the cart 1.4s
🟢 tests/deferred-dialog.e2e.ts · 1 passed 1.0s
🟢 one submit opens one confirm, even when double-clicked 1.0s
🟢 tests/div-soup.e2e.ts · 2 passed 592ms
🟢 div soup › a wrong code is rejected 260ms
🟢 div soup › the right code grants access after the delete tile fixes a typo 332ms
🟢 tests/drag-and-drop.e2e.ts · 2 passed 597ms
🟢 drag and drop › an out-of-order item resets the dropzone 299ms
🟢 drag and drop › dropping Banana then Cherry passes 298ms
🟢 tests/file-round-trip.e2e.ts · 2 passed 294ms
🟢 file round trip › downloads the issued voucher and verifies the same file uploaded back 132ms
🟢 file round trip › rejects a file that is not the voucher, then accepts the issued one 162ms
🟢 tests/filter-deep-link.e2e.ts · 2 passed 207ms
🟢 filter deep link › filtering writes the query to the URL 114ms
🟢 filter deep link › opening a shared link restores the filter 93ms
🟢 tests/gift-card-purchase.e2e.ts · 3 passed 478ms
🟢 gift card purchase › refuses to buy without an amount 128ms
🟢 gift card purchase › refuses a recipient without an at sign 181ms
🟢 gift card purchase › sends the gift card 169ms
🟢 tests/hover-menu.e2e.ts · 2 passed 413ms
🟢 hover menu › a decoy leaf is refused 179ms
🟢 hover menu › hovering Account, then Billing, reaches Redeem voucher 234ms
🟢 tests/iframe-form.e2e.ts · 2 passed 461ms
🟢 iframe form › a wrong code is refused by the host page 228ms
🟢 iframe form › the code read from one frame applies through the other 233ms
🟢 tests/image-only-ui.e2e.ts · 3 passed 383ms
🟢 image only ui › the icons have no names, so the bare svg locator is ambiguous 107ms
🟢 image only ui › a wrong icon shows the error image and keeps the icons 130ms
🟢 image only ui › tapping the star, then the heart, verifies the icons 146ms
🟢 tests/infinite-scroll.e2e.ts · 1 passed 2.6s
🟢 scrolls the feed until the Golden Ticket loads, then claims it 2.6s
🟢 tests/kanban-board.e2e.ts · 3 passed 618ms
🟢 kanban board › pointer drags move both cards into the goal layout 319ms
🟢 kanban board › a swipe along a path drags a card as well 134ms
🟢 kanban board › a plain tap moves nothing and the untouched board is rejected 165ms
🟢 tests/login-form.e2e.ts · 4 passed 664ms
🟢 login form › rejects a malformed email 164ms
🟢 login form › rejects a short password 153ms
🟢 login form › rejects an unknown account 146ms
🟢 login form › signs in and logs out 201ms
🟢 tests/lying-labels.e2e.ts · 4 passed 579ms
🟢 lying labels › the button whose accessible name says Pay now is the wrong one 132ms
🟢 lying labels › a text match for Pay now catches the decoy phrase too 92ms
🟢 lying labels › the field whose accessible name says Amount is the wrong one 183ms
🟢 lying labels › visible text drives the payment through 172ms
🟢 tests/native-dialogs.e2e.ts · 3 passed 383ms
🟢 native dialogs › answers the confirm, prompt, and alert chain 118ms
🟢 native dialogs › dismissing the confirm cancels the order 133ms
🟢 native dialogs › a wrong gift code is rejected 132ms
🟢 tests/new-tab-flow.e2e.ts · 2 passed 381ms
🟢 new tab flow › reads the code in the tab the app opens and enters it back in the original tab 201ms
🟢 new tab flow › a tap that opens a tab leaves the screen on the original tab, and activate shows the new one 180ms
🟢 tests/newsletter-signup.e2e.ts · 1 passed 150ms
🟢 subscribe renders no feedback and logs a TypeError (planted bug) 150ms
🟢 tests/onboarding-wizard.e2e.ts · 5 passed 4.1s
🟢 onboarding wizard › back keeps what was typed and the brief comes back with it 230ms
🟢 onboarding wizard › the address step takes the brief through its bare-div dropdown 298ms
🟢 onboarding wizard › the profile step steers the calendar three decades back 1.1s
🟢 onboarding wizard › the preferences step flips the toggles the brief names and leaves the trap off 1.2s
🟢 onboarding wizard › the review step repeats the brief and finishes with the PIN 1.3s
🟢 tests/order-history.e2e.ts · 2 passed 1.3s
🟢 order history › overview and settings render their panels 159ms
🟢 order history › the orders tab never leaves its loading state (planted bug) 1.2s
🟢 tests/otp-auto-advance.e2e.ts · 3 passed 1.3s
🟢 otp auto-advance › focus advances with each digit and the full code verifies 439ms
🟢 otp auto-advance › backspace on an empty box clears and refocuses the previous one 122ms
🟢 otp auto-advance › a wrong code clears every box and starts over 739ms
🟢 tests/overlay-trap.e2e.ts · 1 passed 678ms
🟢 continues only after the banner and the overlay are gone 678ms
🟢 tests/playbook-cleanup.e2e.ts · 2 passed 411ms
🟢 playbook cleanup › deleting the draft removes it from an exact-name search 210ms
🟢 playbook cleanup › cancelling the dialog keeps the draft searchable 201ms
🟢 tests/price-sorting.e2e.ts · 3 passed 332ms
🟢 price sorting › opens in the featured order with sale prices struck through 99ms
🟢 price sorting › low to high sorts by the original price, not the paid one (planted bug) 109ms
🟢 price sorting › high to low is the same wrong order reversed (planted bug) 124ms
🟢 tests/product-reviews.e2e.ts · 1 passed 96ms
🟢 the running-shoe page lists coffee-grinder reviews (planted bug) 96ms
🟢 tests/promo-storefront.e2e.ts · 1 passed 1.3s
🟢 buys a deal once the promo chrome is out of the way 1.3s
🟢 tests/rich-text-editor.e2e.ts · 2 passed 413ms
🟢 rich text editor › bolding exactly the required word passes the check 213ms
🟢 rich text editor › bold that spills into the previous word fails the check 200ms
🟢 tests/saved-addresses.e2e.ts · 3 passed 497ms
🟢 saved addresses › adds an address and clears the form 171ms
🟢 saved addresses › ignores an add with an empty field 163ms
🟢 saved addresses › delete shows its toast but keeps the address, on retry too (planted bug) 163ms
🟢 tests/shadow-dom-form.e2e.ts · 2 passed 335ms
🟢 shadow DOM form › rejects a wrong access code 168ms
🟢 shadow DOM form › grants access with the code from the hint inside the root 167ms
🟢 tests/smoke.e2e.ts · 1 passed 244ms
🟢 home lists the scenarios and opens one 244ms
🟢 tests/stale-dom.e2e.ts · 1 passed 2.1s
🟢 taps the moving target three times across rebuilds of the list 2.1s
🟢 tests/sticky-chrome.e2e.ts · 1 passed 167ms
🟢 accepts the terms once the button clears the sticky footer 167ms
🟢 tests/virtualized-table.e2e.ts · 1 passed 14.6s
🟢 scrolls the windowed table to the Golden Row and claims it 14.6s
🟢 tests/wishlist.e2e.ts · 2 passed 430ms
🟢 wishlist › saving toggles the button and the tab badge 197ms
🟢 wishlist › the wishlist tab renders the empty state despite the badge count (planted bug) 233ms

Tested by e2e 0.25.0 · 54.5s · web · run artifacts

@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

🟢 e2e web agent: 34 passed

36 agent steps · 26 replayed from cache · 26 model calls · 134.8k tokens (94% cached) · $0.0058

All 34 tests in 5 files
Test Agent Time
🟢 tests-agent/control-inventory.e2e.ts · 7 passed 7 steps 7.2s
🟢 control inventory › check sets the checkbox and the radio 1 step 580ms
🟢 control inventory › check picks a radio the pick replaces with its summary 1 step 247ms
🟢 control inventory › a long press and a double click are chosen over a plain tap 1 step 867ms
🟢 control inventory › a right-click opens the file menu and Rename renames the file 1 step 2.5s
🟢 control inventory › upload attaches the named project files 1 step 2.4s
🟢 control inventory › back returns from the details view to the inventory 1 step 242ms
🟢 control inventory › scroll_to brings the footnote into view 1 step 369ms
🟢 tests-agent/login-form.e2e.ts · 1 passed 1 step 340ms
🟢 act signs in with the benchmark account 1 step 340ms
🟢 tests-agent/planted-bugs.e2e.ts · 3 passed 5 steps · 9 calls 12.6s
🟢 cart totals: a judgment catches the stale order summary 2 steps · 4 calls 5.6s
🟢 checkout review: a judgment catches the broken copy 1 step · 1 call 1.1s
🟢 wishlist: a judgment catches the lost saved items 2 steps · 4 calls 5.9s
🟢 tests-agent/scenarios.e2e.ts · 22 passed 22 steps · 17 calls 1m 7s
🟢 act completes shadow-dom-form 1 step · 3 calls 3.5s
🟢 act completes lying-labels 1 step · 3 calls 3.9s
🟢 act completes iframe-form 1 step · 3 calls 3.0s
🟢 act completes infinite-scroll 1 step 3.3s
🟢 act completes virtualized-table 1 step 15.4s
🟢 act completes overlay-trap 1 step 810ms
🟢 act completes sticky-chrome 1 step 873ms
🟢 act completes async-states 1 step · 3 calls 5.3s
🟢 act completes debounced-search 1 step 2.2s
🟢 act completes hover-menu 1 step 473ms
🟢 act completes drag-and-drop 1 step 415ms
🟢 act completes kanban-board 1 step 585ms
🟢 act completes context-menu-trap 1 step 2.6s
🟢 act completes stale-dom 1 step 416ms
🟢 act completes otp-auto-advance 1 step 644ms
🟢 act completes date-picker 1 step 740ms
🟢 act completes rich-text-editor 1 step 9.9s
🟢 act completes playbook-cleanup 1 step 511ms
🟢 act completes promo-storefront 1 step 2.2s
🟢 act completes new-tab-flow 1 step · 5 calls 7.8s
🟢 act completes gift-card-purchase 1 step 2.4s
🟢 act filters the list and the URL carries the filter 1 step 192ms
🟢 tests-agent/unique-cache.e2e.ts · 1 passed 1 step 253ms
🟢 act adds an address with a run-unique label 1 step 253ms

Tested by e2e 0.25.0 · 1m 28s · web · run artifacts

@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Microbenchmarks

For d00f974b0642, the pull request's head, measured merged into its base.

🔴 1 case costs more.

Repeatability: two builds of the head agree in every case, 10 trials each.

Base 7c1b2b2589cc, head c765091acbb1.

A direction is reported only when the trial ranges of base and head do not overlap and the change is at least 0.5%.

Case Mode Base Head Change Direction Base spread Head spread
mobile/project-snapshot jitless 141,055,527 143,440,495 +1.691% 🔴 higher (ranges do not overlap) 0.047% 0.113%
3 unchanged cases
Case Mode Base Head Change Direction Base spread Head spread
redact/screen-text jitless 789,701 789,683 -0.002% ⚪ same (ranges overlap, change under 0.5%) 0.035% 0.028%
redact/fragments jitless 467,945,363 467,944,034 0% ⚪ same (ranges overlap, change under 0.5%) 0.030% 0.013%
locate/catalog jitless 51,699,329 51,699,826 +0.001% ⚪ same (ranges overlap, change under 0.5%) 0.017% 0.014%
How this is measured

Instructions per iteration: the difference between a run of N and of 3N iterations, divided by 2N, so startup, loading, warmup, and compilation cancel. 5 trial(s) per case and checkout. Lower is better.

Machine: linux x64, AMD EPYC, Node v26.13.1, valgrind-3.22.0, ASLR off.

  • jitless: node --jitless --predictable --single-threaded --predictable-gc-schedule --random-seed=42 --hash-seed=42 --expose-gc --v8-pool-size=0 --no-memory-protection-keys

Workflow run: each job's summary, and result.json in its artifact.

@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

🟢 e2e android agent: 20 passed

24 agent steps · 15 replayed from cache · 44 model calls · 285.5k tokens (88% cached) · $0.0159

All 20 tests in 1 file
Test Agent Time
🟢 tests-agent/scenarios.e2e.ts · 20 passed 24 steps · 44 calls 5m 35s
🟢 act completes Login Form 1 step 19.0s
🟢 act completes Infinite Scroll List 1 step 20.3s
🟢 act completes Modal Flow 1 step 10.0s
🟢 act completes Bottom Tabs 1 step 8.0s
🟢 act completes Text Input Variations 1 step 6.8s
🟢 act completes Broken Accessibility 2 steps · 5 calls 12.7s
🟢 act completes Vision Only 2 steps · 1 call 6.4s
🟢 act completes Gestures 1 step · 14 calls 29.2s
🟢 act completes Async States 1 step · 12 calls 22.2s
🟢 act completes Debounced Search 1 step 6.6s
🟢 act completes Huge Virtualized List 1 step 1m 50s
🟢 act completes Flattened Registration Form 2 steps · 1 call 7.7s
🟢 act completes Flattened Login 2 steps · 6 calls 13.2s
🟢 act completes Sticky Chrome Target 1 step 8.7s
🟢 act completes WebView Accessibility 1 step · 5 calls 12.9s
🟢 act completes Permission Prompt 1 step 6.3s
🟢 act completes Product Catalog 1 step 8.4s
🟢 act completes Error Recovery 1 step 8.9s
🟢 act completes Choice Controls 1 step 8.2s
🟢 act completes Sequential Onboarding 1 step 9.8s

Tested by e2e 0.25.0 · 5m 36s · android-emulator · run artifacts

@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

🟢 e2e ios agent: 21 passed, 1 skipped

25 agent steps · 12 replayed from cache · 70 model calls · 529.7k tokens (84% cached) · $0.0339

All 22 tests in 1 file
Test Agent Time
⏭️ tests-agent/scenarios.e2e.ts · 21 passed, 1 skipped 25 steps · 70 calls 8m 43s
🟢 act completes Login Form 1 step 41.3s
🟢 act completes Infinite Scroll List 1 step 36.7s
🟢 act completes Modal Flow 1 step 10.0s
🟢 act completes Bottom Tabs 1 step 7.4s
🟢 act completes Text Input Variations 1 step 12.5s
🟢 act completes Broken Accessibility 2 steps · 5 calls 20.2s
🟢 act completes Vision Only 2 steps · 6 calls 26.3s
🟢 act completes Gestures 1 step · 9 calls 32.1s
🟢 act completes Async States 1 step · 15 calls 50.3s
🟢 act completes Debounced Search 1 step · 1 call 28.5s
🟢 act completes Flattened Registration Form 2 steps · 1 call 25.4s
🟢 act completes Flattened Login 2 steps · 13 calls 1m 7s
🟢 act completes Sticky Chrome Target 1 step 13.2s
🟢 act completes WebView Accessibility 1 step 12.2s
🟢 act completes Permission Prompt 1 step 11.3s
🟢 act completes Photo Picker 1 step · 2 calls 26.7s
🟢 act completes Product Catalog 1 step 10.7s
🟢 act completes Error Recovery 1 step 9.8s
🟢 act completes Choice Controls 1 step · 6 calls 34.1s
🟢 act completes Stripe PaymentSheet 1 step · 12 calls 33.5s
🟢 act completes Apple Pay 1 step 14.1s
⏭️ act completes Apple Pay Billing Address (skipped: the CI simulator's Apple Pay sheet skips the billing-address step, so the scenario cannot be completed there)

Tested by e2e 0.25.0 · 8m 44s · ios-simulator · run artifacts

@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

🟢 e2e ios: 67 passed, 1 skipped

All 68 tests in 8 files
Test Time
⏭️ tests/controls.e2e.ts · 25 passed, 1 skipped 3m 16s
🟢 control inventory › a label query resolves a labeled text field 17.2s
🟢 control inventory › a labeled field answers name, display value, value reads, fill, and clear 16.7s
🟢 control inventory › a placeholder query and attribute reads find the field 5.3s
🟢 control inventory › getAttribute reads the label, resource id, and class an Appium suite asks for 5.5s
🟢 control inventory › a secure field takes a fill and denies value reads 7.9s
🟢 control inventory › press sends a character and Enter through the soft keyboard 9.2s
🟢 control inventory › a field autofocuses on mount and focus() moves the focus 10.5s
🟢 control inventory › toBeFocused follows the focus 8.1s
🟢 control inventory › a switch checks, unchecks, and reports its state 8.8s
🟢 control inventory › checkbox and radio roles answer getByRole, and a checkbox toggles by tap 8.5s
🟢 control inventory › checkbox and radio roles check, uncheck, and report their state 9.8s
🟢 control inventory › a radio group reports the checked option 8.1s
🟢 control inventory › buttons report disabled, enabled, and a state that arrives later 8.0s
🟢 control inventory › a display: none element is absent rather than hidden, its visible twin attached 7.3s
🟢 control inventory › a header answers its accessible name 5.2s
🟢 control inventory › a tab row answers count, all, texts, filters, positions, and switching 7.0s
🟢 control inventory › a list answers counts, list-form text, reads, and boxes in order 6.9s
⏭️ control inventory › a row contains its texts (skipped: React Native flattens a plain View out of the accessibility tree on both platforms: XCTest and the Android helper report a View with a testID as a leaf beside its children, so filter({ has }) and a query scoped to it match nothing; only Sc…)
🟢 control inventory › a long press lands as one 8.5s
🟢 control inventory › tap({ count: 3 }) lands three presses 8.2s
🟢 control inventory › pointer verbs land at the point asked for 9.3s
🟢 control inventory › an ambiguous locator fails at once 5.7s
🟢 control inventory › screenshot, restart, and clearState reopen the app on its home list 12.4s
🟢 refusals › verbs a device never declares are refused before the engine 2ms
🟢 refusals › keys the soft keyboard cannot send are refused by the engine 203ms
🟢 refusals › a missing locator fails as not found once its timeout passes 1.1s
🟢 tests/device-fixture.e2e.ts · 15 passed 2m 20s
🟢 device fixture › setAppearance flips the color scheme the app reads 19.6s
🟢 device fixture › setOrientation rotates the window and viewport dimensions 8.7s
🟢 device fixture › the clipboard reads back what was written 5.8s
🟢 device fixture › home leaves the app, openApp brings it back where it was 8.2s
🟢 device fixture › closeApp then openApp relaunches on the home list 9.3s
🟢 device fixture › closeApp leaves the next commands on the same device 14.2s
🟢 device fixture › foregroundApp after closeApp reports the closed session as APP_NOT_OPEN 5.8s
🟢 device fixture › openLink opens the scenario a deep link names 13.8s
🟢 device fixture › isAppInstalled finds the app under test and no app that is absent 6.5s
🟢 device fixture › uninstallApp removes the app until installApp puts it back 10.4s
🟢 device fixture › device.back pops the scenario 5.9s
🟢 device fixture › unstable_raw reaches the test session through the raw driver 4.7s
🟢 device fixture › setLocation and clearLocation change what the app reads 9.9s
🟢 device fixture › enrollBiometrics and setBiometrics answer a biometric prompt 11.5s
🟢 device fixture › pressButton is refused on an iOS simulator 5.5s
🟢 tests/device.e2e.ts · 7 passed 1m 22s
🟢 permissions all grants the microphone without a system dialog 12.6s
🟢 sequential onboarding echoes the exact values 25.4s
🟢 isKeyboardShown follows the keyboard up and through a dismissal 7.8s
🟢 a control under the keyboard reads hidden and refuses a tap until the keyboard is dismissed 10.0s
🟢 a shake is sent without an error and leaves the screen readable 5.3s
🟢 onboarding rejects a malformed email before advancing 9.5s
🟢 dismissing the keyboard over choice controls leaves them as they were 11.0s
🟢 tests/flows-lists.e2e.ts · 7 passed 4m 9s
🟢 infinite scroll reaches the target item 35.2s
🟢 product catalog adds exactly two of the right variant 10.3s
🟢 gestures: long-press, then swipe left 8.7s
🟢 sticky chrome: accept below the fold, then continue 12.5s
🟢 async states: load, pull to refresh, claim through the toast 12.2s
🟢 huge virtualized list reaches row 512 2m 37s
🟢 web view coupon form applies the code shown on the page 12.6s
🟢 tests/flows.e2e.ts · 7 passed 1m 9s
🟢 text inputs unlock the submit button 12.2s
🟢 filled text inputs report their values 10.5s
🟢 modal flow confirms through the native alert 9.7s
🟢 bottom tabs act inside the last tab 7.4s
🟢 error recovery retries, then confirms the delete 9.5s
🟢 choice controls place the exact order 7.7s
🟢 debounced search selects the target once results arrive 11.5s
🟢 tests/login-form.e2e.ts · 3 passed 43.7s
🟢 login form › rejects a malformed email 12.4s
🟢 login form › rejects an unknown account 12.6s
🟢 login form › signs in and logs out 18.7s
🟢 tests/scroll-to.e2e.ts · 2 passed 2m 51s
🟢 screen.scrollTo reaches the last row of the list and comes back to the first 1m 46s
🟢 locator.scrollTo scrolls the list it names 1m 4s
🟢 tests/smoke.e2e.ts · 1 passed 7.8s
🟢 home lists the scenarios and opens one 7.8s

Tested by e2e 0.25.0 · 8m 26s · ios-simulator · run artifacts

@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

🟢 e2e android: 68 passed, 1 skipped

All 69 tests in 8 files
Test Time
⏭️ tests/controls.e2e.ts · 26 passed, 1 skipped 2m 28s
🟢 control inventory › a label query resolves a labeled text field 16.8s
🟢 control inventory › a labeled field answers name, display value, value reads, fill, and clear 10.8s
🟢 control inventory › a placeholder query and attribute reads find the field 4.8s
🟢 control inventory › getAttribute reads the label, resource id, and class an Appium suite asks for 4.3s
🟢 control inventory › a secure field takes a fill and denies value reads 6.2s
🟢 control inventory › press sends a character and Enter through the soft keyboard 7.4s
🟢 control inventory › a field autofocuses on mount and focus() moves the focus 6.4s
🟢 control inventory › toBeFocused follows the focus 6.2s
🟢 control inventory › a switch checks, unchecks, and reports its state 6.5s
🟢 control inventory › checkbox and radio roles answer getByRole, and a checkbox toggles by tap 6.6s
🟢 control inventory › checkbox and radio roles check, uncheck, and report their state 7.0s
🟢 control inventory › a tab role answers getByRole 3.3s
🟢 control inventory › a radio group reports the checked option 6.3s
🟢 control inventory › buttons report disabled, enabled, and a state that arrives later 6.5s
🟢 control inventory › a display: none element is absent rather than hidden, its visible twin attached 4.8s
🟢 control inventory › a header answers its accessible name 3.3s
🟢 control inventory › a tab row answers count, all, texts, filters, positions, and switching 4.9s
🟢 control inventory › a list answers counts, list-form text, reads, and boxes in order 4.9s
⏭️ control inventory › a row contains its texts (skipped: React Native flattens a plain View out of the accessibility tree on both platforms: XCTest and the Android helper report a View with a testID as a leaf beside its children, so filter({ has }) and a query scoped to it match nothing; only Sc…)
🟢 control inventory › a long press lands as one 6.7s
🟢 control inventory › a double tap lands inside the 300 ms window 6.1s
🟢 control inventory › tap({ count: 3 }) lands three presses 5.6s
🟢 control inventory › an ambiguous locator fails at once 4.8s
🟢 control inventory › screenshot, restart, and clearState reopen the app on its home list 5.9s
🟢 refusals › verbs a device never declares are refused before the engine 2ms
🟢 refusals › keys the soft keyboard cannot send are refused by the engine 1.3s
🟢 refusals › a missing locator fails as not found once its timeout passes 1.1s
🟢 tests/device-fixture.e2e.ts · 14 passed 1m 26s
🟢 device fixture › setOrientation rotates the window and viewport dimensions 4.4s
🟢 device fixture › home leaves the app, openApp brings it back where it was 3.8s
🟢 device fixture › foregroundApp sees the home screen after home() 3.0s
🟢 device fixture › closeApp then openApp relaunches on the home list 5.2s
🟢 device fixture › closeApp leaves the next commands on the same device 5.5s
🟢 device fixture › foregroundApp after closeApp reports the closed session as APP_NOT_OPEN 3.9s
🟢 device fixture › openLink opens the scenario a deep link names 4.1s
🟢 device fixture › isAppInstalled finds the app under test and no app that is absent 3.5s
🟢 device fixture › uninstallApp removes the app until installApp puts it back 6.1s
🟢 device fixture › device.back pops the scenario 4.0s
🟢 device fixture › unstable_raw reaches the test session through the raw driver 2.9s
🟢 device fixture › setNetwork and setAirplaneMode change what the app sees 14.8s
🟢 device fixture › setLocation and clearLocation change what the app reads 17.4s
🟢 device fixture › pressButton shows the volume panel on Android 7.3s
🟢 tests/device.e2e.ts · 8 passed 51.1s
🟢 permission prompt › allowing the system dialog enables the microphone 5.3s
🟢 permission prompt › a denied prompt recovers once the permission is granted outside 10.7s
🟢 permissions all grants the microphone without a system dialog 5.9s
🟢 sequential onboarding echoes the exact values 9.2s
🟢 a shake is sent without an error and leaves the screen readable 4.3s
🟢 a lock and an unlock both complete and leave the app readable 4.4s
🟢 onboarding rejects a malformed email before advancing 5.1s
🟢 dismissing the keyboard over choice controls leaves them as they were 6.1s
🟢 tests/flows-lists.e2e.ts · 7 passed 3m 2s
🟢 infinite scroll reaches the target item 27.4s
🟢 product catalog adds exactly two of the right variant 8.1s
🟢 gestures: long-press, then swipe left 7.3s
🟢 gestures: double-tap completes the flow 9.1s
🟢 sticky chrome: accept below the fold, then continue 10.2s
🟢 async states: load, pull to refresh, claim through the toast 11.4s
🟢 huge virtualized list reaches row 512 1m 49s
🟢 tests/flows.e2e.ts · 7 passed 46.2s
🟢 text inputs unlock the submit button 5.6s
🟢 filled text inputs report their values 5.1s
🟢 modal flow confirms through the native alert 8.4s
🟢 bottom tabs act inside the last tab 6.1s
🟢 error recovery retries, then confirms the delete 8.0s
🟢 choice controls place the exact order 5.3s
🟢 debounced search selects the target once results arrive 7.8s
🟢 tests/login-form.e2e.ts · 3 passed 25.2s
🟢 login form › rejects a malformed email 6.6s
🟢 login form › rejects an unknown account 6.6s
🟢 login form › signs in and logs out 12.1s
🟢 tests/scroll-to.e2e.ts · 2 passed 1m 5s
🟢 screen.scrollTo reaches the last row of the list and comes back to the first 39.9s
🟢 locator.scrollTo scrolls the list it names 24.9s
🟢 tests/smoke.e2e.ts · 1 passed 4.5s
🟢 home lists the scenarios and opens one 4.5s

Tested by e2e 0.25.0 · 10m 9s · android-emulator · run artifacts

@michal-e2e
michal-e2e marked this pull request as ready for review November 29, 2026 19:37

@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 4 files

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

@michal-e2e
michal-e2e added this pull request to the merge queue Nov 29, 2026
@michal-e2e
michal-e2e removed this pull request from the merge queue due to a manual request Nov 29, 2026
@michal-e2e michal-e2e added the Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. label Nov 29, 2026
@github-actions github-actions Bot added size:L Up to 499 changed lines, not counting tests, fixtures, translated docs, or the lockfile and removed Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. size:S Up to 29 changed lines, not counting tests, fixtures, translated docs, or the lockfile labels Nov 29, 2026

@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.

0 issues found across 6 files (changes from recent commits).

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

@okwasniewski okwasniewski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Automated review (AI triage pass), not yet read by a maintainer.

Reviewed 84f333309. Adds Anthropic's manual-thinking refusal to the existing forced-tool-choice fallback, stops a 5xx retry chain that quotes the refusal from triggering it, and scopes the remembered auto mode per model + providerOptions. Correct, well-contained, tests fail when the fix is reverted.

Not a heuristic in the policy sense: Anthropic documents that forced tool_choice is incompatible with manual extended thinking, and the 400 body carries no structured code beyond invalid_request_error, so the message match is the same signal main already uses for Fable 5.1 / DeepSeek / Muse Spark (tool-choice.ts:21). Detection is tight: exact sentence, 4xx only, and any non-4xx status anywhere in the cause/lastError chain vetoes the match (tool-choice.ts:99).

Verified locally: targeted suite passes (24/24). Mutation checks, each rebuilt core and re-ran the file:

  • drop the new pattern: 4 new tests fail
  • remember auto globally (ignore options): the shared-model scoping test fails
  • old early return true on first match: the 502 AI_RetryError test fails
  • only check status on the matched node (break instead of return false): same test fails

Nits

  1. tool-choice.ts:143-146 - the catch returns '*', which would widen a scoped refusal to every agent on the model, the exact leak this PR removes. providerOptions is JSON by type (it goes over HTTP), so the branch is dead; drop the try/catch instead of keeping a fallback that points the wrong way.
  2. A model that rejects forced choice outright (Fable 5.1) now pays one extra 400 per distinct providerOptions set instead of one per model. Negligible, but the docs line "Later steps on that model with the same provider options start with auto" (models.mdx:175) reads as if steps without options are also scoped, while a refusal with no options applies to all ('*', tool-choice.ts:127). Fine as is for users; mention only if touching it again.

For the maintainer

  • Error-driven vs proactive: the loop could start in auto when providerOptions.anthropic.thinking.type === 'enabled' and skip the first 400. The PR keeps the generic error-driven path, which also covers gateway/Bedrock/Vertex option shapes. Reasonable; say if you want the proactive shortcut too.
  • CI: runner tests and mobile jobs still pending at review time; everything finished so far is green.

@okwasniewski okwasniewski added the Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. label Nov 29, 2026
@michal-e2e

Copy link
Copy Markdown
Collaborator Author

[claude-fable-5-2] responding on behalf of michal-e2e

Answers to the review of 84f3333 and to the retained concerns in the CodeRabbit summary. Nothing is pushed for them.

Nit 1, the catch in providerOptionsScope. Half right. The fallback does widen: a key that cannot be serialized is remembered as '*'. The branch is not dead, though: ProviderOptions values are unknown (types.ts:1941). A 10n in agents.<name>.providerOptions stops the run at config load, but the providerOptions of createToolLoopExecutor are not part of the config digest. In two runs of the built CLI at this head against a local stand-in for the Anthropic API, a 10n under a key the Anthropic provider does not read made the next request of a sibling agent on the same model object carry auto; with 10 in its place it carried tool:complete_step. Dropping the try/catch trades the widening for a TypeError: by reading, rememberAutoToolChoice would throw in the retry path, and prefersAutoToolChoice in the LoopRun constructor once a scope is remembered for the model. The author decides between keeping the fallback, dropping it, and remembering nothing when the key cannot be built.

Nit 2, docs/models.mdx:175. Correct, and left as written, as the review suggests. The sentence is read again if the scope code changes.

Proactive auto under enabled thinking. Not added: the pull request keeps the error-driven path. One fact for the maintainer's call: @ai-sdk/anthropic 4.0.111 already sends auto in place of a forced choice under manual thinking and warns, and the loop handles that warning, so the shortcut would save the first 400 only where the provider does not downgrade the choice itself, as on the gateway path.

CI. Finished since the review: on 84f3333, 45 checks pass and 3 are skipped, the four required gates among the passes.

CodeRabbit, a refusal with no local options. True as described, and it is the stated rule (tool-choice.ts:113-120): a refusal with no providerOptions is remembered for the whole model object. In the same runs, an agent with no options that got the manual-thinking 400 from the stand-in passed after the retry, and the next request of a sibling with thinking: { type: 'disabled' } on that model object carried auto. This needs thinking switched on outside e2e's options. The author decides whether a refusal with no options keeps the wildcard.

CodeRabbit, keys with no bound. True as described: one string per distinct option set that was refused or downgraded, per live model object. The options are set per agent entry or per executor, so the set grows with the config, not with the steps. No bound is added here; the author decides whether one is wanted.

CodeRabbit, the hardening proposal. Its three parts are the three points above (serialization failure, the wildcard for omitted options, the bound); each is with the author as stated there.

kdy1 and others added 2 commits November 30, 2026 10:11
A forced-tool-choice refusal under no providerOptions was remembered as
'*', which matched every option set on the model. When thinking comes from
the model itself (AI SDK defaultSettingsMiddleware), an agent that sends
explicit options turning it off then also started in auto, and with a
one-call budget its prose reply failed the step with STEP_NO_CONCLUSION.

Absent options now get their own scope key, so only steps with the same
options (or none) start in auto. The try/catch around the key is gone:
providerOptions are JSON values by type, and its fallback widened the
scope to the whole model.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Scoping the remembered auto mode by providerOptions made a model that never
takes a forced choice (Claude Fable 5.1, Muse Spark) refuse once per option
set: three agents with different options cost three rejected requests where
main cost one.

forcedToolChoiceRefusal (replacing isForcedToolChoiceRejected) now says what
a refusal depends on. A message that names the model ("not supported for
this model", "only auto is supported") is remembered for the whole model;
the manual-thinking refusal, the other patterns, and provider downgrades
stay scoped to the step's providerOptions, since the AI SDK's Anthropic
provider downgrades for manual thinking too and its warning does not say
which cause applied. The loop's JSDoc and docs/models.mdx describe the two
scopes instead of a per-model memory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot removed the Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. label Nov 30, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Architecture findings (1)

Advisory architecture findings (1)

  • Trivial — The patch removes the named export isForcedToolChoiceRejected from a module exposed by the package’s ./lib/* mapping. A consumer that imports that symbol through the mapped path can fail during module loading after the upgrade. No downstream consumer was confirmed.
Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d4a41d1d-642f-4df7-aa25-7907b1ad3619
Commits

Reviewing files that changed from the base of the PR and between 84f3333 and 2e10b94.

Files selected for processing: 4

  • docs/models.mdx
  • packages/core/src/agent/model/tool-choice.ts
  • packages/core/src/agent/tool-loop.ts
  • packages/e2e/tests/unit/tool-loop-tool-choice.test.ts
Files skipped from review as they are similar to previous changes: 1

  • docs/models.mdx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@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

kdy1 and others added 2 commits November 30, 2026 10:31
…ions

The scope key canonicalized providerOptions by walking their own fields,
which dropped a value's toJSON. An option whose own field is a bigint but
whose JSON form is text (a 64-bit id) passes config resolution, then made
JSON.stringify throw while the loop recorded a forced-choice refusal, so
the step failed with ACTION_FAILED instead of retrying with auto. Two
settings told apart only by toJSON also shared one key.

The key now comes from the options' JSON form, with keys sorted. Options
with no JSON form (a bigint or a cycle an executor passes directly) get no
key: the refusal is still retried, just not remembered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The downgrade warning and a prose reply under a forced choice now remember
auto only for the step's providerOptions, but no test told that apart from
remembering it for the whole model: both paths passed with 'model' too.
Each new test runs a thinking agent and a lean agent on one model and
fails when its path widens the scope.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@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.

0 issues found across 2 files (changes from recent commits).

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Architecture findings (2)

Advisory architecture findings (2)

  • Trivial — The old cache kept one membership bit per model instance. The new cache keeps the complete canonical JSON for every distinct option scope learned on that instance, with no size limit or eviction. A long-lived instance reused with changing configurations can accumulate request-option data after the originating steps finish. The weak key limits retention to the model object's lifetime, not the lifetime of each configuration.
  • Trivial — Only the first serialization is guarded. If deeply nested options serialize successfully but exhaust the stack during recursive sorting, key generation can abort loop construction or escape the refusal handler before the automatic-choice retry. Capability memory can therefore turn a recoverable refusal into a step failure instead of skipping memoization.
Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bccb3b09-e67a-4361-91fe-2b2faeb2b06f
Commits

Reviewing files that changed from the base of the PR and between 2e10b94 and d00f974.

Files selected for processing: 2

  • packages/core/src/agent/model/tool-choice.ts
  • packages/e2e/tests/unit/tool-loop-tool-choice.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@kdy1 kdy1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Note

This text was drafted with AI and posted after human approval.

  • Harness: T3 Code
  • AI agents: coordinator: Claude Opus 5.5 (claude-opus-5-5), reviewer: GPT-6.2 Astra (gpt-6.2-astra), reviewer: GPT-6.2 Sol (gpt-6.2-sol), reviewer: Claude Opus 5.5 (claude-opus-5-5), reviewer: Claude Sonnet 5.5 (claude-sonnet-5-5)

Verdict: Approve

This review approves the pull request. The P3 items are optional and do not block the merge.

Live check on Vercel AI Gateway (gateway('anthropic/claude-sonnet-4.5'), manual thinking, built CLI on the testbed): the gateway does not return the HTTP 400. It downgrades the forced choice to auto itself and sends a toolChoice warning, on gateway(), /v1/messages, and /v1/chat/completions alike. So the new 400 retry path was not reached live; only the downgrade path was. On that path, three agents shared one model (thinking enabled, thinking disabled, no options). On main, the second and third agents were sent auto. On this branch they kept required, and the thinking agent's next step started with auto. The test passed on both.

Reviewed commit: d00f974b06427ce85c50e6b9159a7a530c54a7fd

  • P3 (non-blocking): 2 (2 inline)

"@e2e-dev/core": patch
---

Retry agent turns with automatic tool choice when Anthropic rejects forced tool use with manual extended thinking, keeping that fallback scoped to the model's provider options.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

P3 · Non-blocking · The changeset does not say that downgrade and prose-reply memory is now per providerOptions

Optional. This does not block the merge.

Before this change, a provider downgrade (noticeToolChoiceDowngrade, packages/core/src/agent/tool-loop.ts:673) or a prose reply under a forced choice (tool-loop.ts:649-650) put the whole model in auto. Now each distinct providerOptions set learns it again.

Trigger: several agents share one model that always downgrades forced choice, for example Claude Sonnet 5.5 through @ai-sdk/anthropic, with different providerOptions. A scripted run with agents default (no options) and low ({ anthropic: { effort: 'low' } }), steps default, low, default, gave these tool choices:

  • main: required, auto, auto, auto
  • this branch: required, auto, required, auto, auto

The extra call is a billed turn when the model answers in prose. A DeepSeek-style options refusal also costs one more rejected request per option set.

docs/models.mdx describes the trade-off. The release note reads as if only the new manual-thinking refusal is scoped, so users who share one model across agents get no notice of the added turn.

AUTO_TOOL_CHOICE.set(model, memory);
}
if (refusal === 'model') memory.model = true;
else if (scope !== undefined) memory.options.add(scope);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

P3 · Non-blocking · The per-model option set grows without a bound in a long-lived process

Optional. This does not block the merge.

rememberAutoToolChoice adds the full canonical JSON of every refused or downgraded providerOptions set to a Set that lives as long as the model object (AUTO_TOOL_CHOICE, line 136). No path removes an entry, and line 165 still adds option keys after memory.model is true.

Trigger: a long-lived host (openHost, e2e mcp, createAgent) reuses one model constant while it varies a per-session option such as gateway.user. A probe with 100 distinct gateway.user values and a downgrading provider kept one marker on main and 100 serialized option strings on this branch. The memory grows with the number of distinct option sets, not with the number of steps, so the impact is small.

@okwasniewski okwasniewski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Automated review (AI triage pass), not yet read by a maintainer.

Reviewed d00f974b0. Since 84f333309 the refusal memory splits in two: a refusal that names the model (Fable 5.1, Muse Spark) puts the whole model in auto, while every other refusal, a downgrade warning, and a prose reply apply only to the same providerOptions. The key is now canonical JSON with toJSON applied. Correct, and the tests fail when the change is reverted.

Earlier nits:

The delta is sound. MODEL_WIDE_PATTERNS (tool-choice.ts:33-36) match only messages that name the model. A downgrade warning does not say why the provider sent auto, so recording it per options (tool-loop.ts:673) is the safe choice: if the model was the cause, it costs one warned call per options set, not a failure.

Verified locally: the targeted suite passes (31/31). Mutation checks, each with core rebuilt:

  • Treat every refusal as options: 3 tests fail, including "remembers a refusal that names the model for agents with other providerOptions".
  • Remember the downgrade for the whole model: "remembers a downgrade only for the providerOptions it came with" fails.

CI is green.

Nits

  1. The changeset (.changeset/anthropic-thinking-tool-choice.md) does not say that DeepSeek V4 refusals, downgrades, and prose replies are now remembered per providerOptions, not per model. This matches kdy1's P3; it is optional.

For the maintainer

  • DeepSeek V4 refuses a forced choice because it thinks by default, and that refusal now counts as options. Each distinct options set on a shared DeepSeek model pays one extra 400 before it falls back. In return, an agent that turns thinking off keeps forced calls. Fine as long as that trade is intended.
  • kdy1 approved d00f974b0 with two P3s: the changeset wording (nit 1 above) and the unbounded per-model options set. That set holds one entry per distinct refused options set and lives only as long as the model object, so it is fine as is.

@okwasniewski okwasniewski added the Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. label Nov 30, 2026
@okwasniewski
okwasniewski merged commit 114a497 into main Nov 30, 2026
54 checks passed
@okwasniewski
okwasniewski deleted the t3/manual-thinking-compatibility branch November 30, 2026 09:17
kblok pushed a commit to hardkoded/e2e that referenced this pull request Dec 1, 2026
* docs(pt): bring nine guide pages back in line with English

Picks up the English changes the pt guides missed: the experimental
warnings on the Electron and desktop engines (e2e-inc#2540, e2e-inc#2541), driving a
Mac app with @e2e-dev/core (e2e-inc#2499), expect(electron) and waitForURL
(e2e-inc#2439), the ffmpeg download (e2e-inc#2502), the desktop placeholder lines
(e2e-inc#2529), forced tool use under extended thinking (e2e-inc#2510), and e2e-inc#2448's
new descriptions and links. Adds three glossary rows.

* docs(pt): pick up e2e-inc#2470, e2e-inc#2504, e2e-inc#2509, and e2e-inc#2547 in the guides

* docs(pt): pick up e2e-inc#2555 in electron
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

e2e team Opened by the e2e team Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. size:L Up to 499 changed lines, not counting tests, fixtures, translated docs, or the lockfile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants