packages/ai: adapt Anthropic thinking payloads#49
Merged
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5b7ea25. Configure here.
| outputConfig.effort = effortFromBudgetTokens(thinking.budget_tokens); | ||
| next.output_config = outputConfig; | ||
| return next; | ||
| }; |
There was a problem hiding this comment.
Missing TSDoc on payload hook
Low Severity
The new exported anthropicAdaptiveThinkingOnPayload hook has no TSDoc describing when it rewrites thinking for Sonnet 5, how output_config.effort is derived, or that it returns undefined to leave other models and payloads unchanged.
Triggered by learned rule: Exported types, interfaces, and classes require TSDoc
Reviewed by Cursor Bugbot for commit 5b7ea25. Configure here.
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
thinking.type=enabledpayloads to adaptive thinking for models that require or recommend the new format.output_configwhile settingoutput_config.effortfrom the existing budget-token levels.Test plan
npm run build --workspace @onkernel/cua-ainpm test --workspace @onkernel/cua-ainpm test --workspace @onkernel/cua-agent -- --exclude "**/*.live.test.ts"npm pack --workspace @onkernel/cua-ai --dry-runNote
Medium Risk
Changes outbound Anthropic API payload shape for a defined set of newer models; behavior is gated by model ID and only applies when legacy thinking is enabled, but incorrect mapping could affect model reasoning/cost.
Overview
@onkernel/cua-ai 0.3.4 adds Anthropic request payload middleware so callers can keep sending legacy
thinking: { type: "enabled", budget_tokens }while newer CUA models get the adaptive format.For matching models (Sonnet 5/4.6, Opus 4.8/4.7/4.6, Fable 5, Mythos families),
anthropicAdaptiveThinkingOnPayloadrewritesthinkingto{ type: "adaptive" }, merges existingoutput_config, and setsoutput_config.effortfrom the old budget tiers (lowthroughxhigh). Older models like Sonnet 4.5 are left untouched when the hook returnsundefined. The hook is registered on the AnthropicproviderModule, soresolveCuaRuntimeSpecnow exposesonPayloadfor Anthropic like Yutori/Tzafon.Unit tests cover conversion, model coverage, effort mapping, and runtime-spec expectations. The agent payload-hook test is relaxed to
toMatchObjectso composed payloads with extra fields still pass.Reviewed by Cursor Bugbot for commit dac33b8. Bugbot is set up for automated code reviews on this repo. Configure here.