← Back to PRs

#18727: fix(compaction): disable extended thinking for non-direct Anthropic endpoints

by Phineas1500 open 2026-02-17 00:58 View on GitHub →
agents stale size: M
## Summary - Fixes compaction failing with `400: thinking type "adaptive" is not supported` on non-direct Anthropic endpoints (Vertex AI, Portkey proxies, etc.) - Adds `normalizeModelForCompaction()` that disables `reasoning` on the model when the `baseUrl` is not the direct Anthropic API, preventing the upstream pi-ai library from adding unsupported `thinking` parameters - Applied in `summarizeChunks()` before calling `generateSummary()`, so all retry attempts use the normalized model consistently The upstream pi-ai library's `supportsAdaptiveThinking()` only checks the model ID (e.g. "opus-4-6") but has no awareness of the destination endpoint. When a user routes through a proxy like Portkey or Vertex AI, `{ type: "adaptive" }` is sent but rejected by the endpoint. Disabling reasoning entirely on the model object prevents the library from adding any thinking parameters. ## Test plan - [x] Unit tests for `normalizeModelForCompaction()` (8 tests) — direct Anthropic preserved, proxy endpoints disable reasoning, non-anthropic-messages API preserved, bedrock preserved, empty/undefined baseUrl handled - [x] Integration tests mocking `generateSummary` through the full `summarizeWithFallback` code path (6 tests) — verifies the model that reaches `generateSummary` has correct `reasoning` value for each endpoint type, including across retries - [x] Existing `compaction.retry.test.ts` tests still pass Fixes #18634

Most Similar PRs