Skip to content

fix(agent): bump claude-agent-sdk to 0.3.156 for Opus 4.8 thinking shape#2439

Closed
fercgomes wants to merge 1 commit into
mainfrom
posthog-code/bump-claude-agent-sdk-opus-4-8-fix
Closed

fix(agent): bump claude-agent-sdk to 0.3.156 for Opus 4.8 thinking shape#2439
fercgomes wants to merge 1 commit into
mainfrom
posthog-code/bump-claude-agent-sdk-opus-4-8-fix

Conversation

@fercgomes
Copy link
Copy Markdown
Contributor

Summary

  • Bumps @anthropic-ai/claude-agent-sdk 0.3.154 → 0.3.156 in packages/agent.
  • Fixes HTTP 400 on claude-opus-4-8: thinking.type.enabled is not supported for this model. Use thinking.type.adaptive and output_config.effort.
  • Logs the sync in UPSTREAM.md under a new v0.39.0 section.

Why this shape and not the proposed in-repo buildThinkingConfig

The attached bug report proposed a buildThinkingConfig(model, effort) helper in the agent-server. That doesn't apply to this repo — we never build the Anthropic thinking parameter ourselves. The full chain is:

  • packages/agent/src/server/bin.ts reads POSTHOG_CODE_MODEL and POSTHOG_CODE_REASONING_EFFORT.
  • packages/agent/src/adapters/claude/session/options.ts:419 forwards effort as a string: options.effort = params.effort.
  • packages/agent/src/adapters/claude/claude-agent.ts:1223/1769 forwards effort changes: query.applyFlagSettings({ effortLevel }).
  • @anthropic-ai/claude-agent-sdk builds the actual Anthropic request body.

No budget_tokens, thinking.type, or output_config exists anywhere in our TypeScript source, and the Anthropic SDKs are unpatched. The fix lives entirely in upstream claude-code v2.1.156 ("Fixed an issue when using Opus 4.8 where thinking blocks were modified, leading to API errors") which ships as SDK 0.3.156. v0.3.155 was never published.

Test plan

  • pnpm install refreshes lockfile without conflicts.
  • pnpm --filter agent typecheck clean.
  • SDK-mock-heavy tests pass (37/37 across options.test.ts, models.test.ts, model-config.test.ts, claude-agent.refresh.test.ts, claude-agent.slash-command.test.ts).
  • Manual smoke test (cannot run agent-server in sandbox): kick off a task at high/xhigh effort for each model and confirm no HTTP 400:
    • claude-opus-4-8 (the failing model)
    • claude-opus-4-7
    • claude-opus-4-6
    • claude-opus-4-5
    • claude-sonnet-4-6
  • Optional: enable SDK debug logging and confirm Opus 4.8 outbound body now contains thinking: { type: "adaptive" } + output_config: { effort }.

claude-opus-4-8 was failing with HTTP 400 ("thinking.type.enabled is not
supported for this model. Use thinking.type.adaptive and output_config.effort")
because @anthropic-ai/claude-agent-sdk@0.3.154 was emitting the legacy
thinking-block shape. Upstream claude-code v2.1.156 fixes this — the SDK now
sends thinking: { type: "adaptive" } + output_config: { effort } for Opus 4.8
while keeping the legacy shape for Opus 4.7 / Sonnet 4.6 where the API still
accepts it.

No in-repo code change required: this repo never builds the thinking parameter
itself, only forwards options.effort and applyFlagSettings({ effortLevel }) to
the SDK. The fix lives entirely in the SDK bump.

v0.3.155 was never published; latest stable is 0.3.156.

Generated-By: PostHog Code
Task-Id: 25779980-b5ce-4ec1-b8b6-0b9de6204bf5
@charlesvien
Copy link
Copy Markdown
Member

Continuing here #2441

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