#18727: fix(compaction): disable extended thinking for non-direct Anthropic endpoints
agents
stale
size: M
Cluster:
Compaction Safeguards and Summaries
## 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
#10457: fix(compaction): abort compaction when summarization fails instead ...
by lailoo · 2026-02-06
70.7%
#6685: fix: suppress thinking leak for Synthetic reasoning models
by AkiLetschne · 2026-02-01
68.9%
#10711: fix: cancel compaction instead of truncating history when summariza...
by DukeDeSouth · 2026-02-06
68.8%
#19407: fix(agents): strip thinking blocks on cross-provider model switch (...
by lailoo · 2026-02-17
68.4%
#10505: feat(compaction): add timeout, model override, and diagnostic logging
by thebtf · 2026-02-06
68.1%
#17864: fix(compaction): pass model through runtime + reduce chunk ratio to...
by battman21 · 2026-02-16
67.7%
#10214: feat(compaction): Add Anthropic server-side compaction API support
by GodsBoy · 2026-02-06
66.9%
#18926: fix(agents): preserve thinking signatures for direct Anthropic API
by BinHPdev · 2026-02-17
66.7%
#12046: fix(compaction): add fallback for undefined ctx.model (#12016)
by anandsuraj · 2026-02-08
66.2%
#20620: feat: add anthropic/claude-opus-4-6 to XHIGH_MODEL_REFS
by chungjchris · 2026-02-19
66.2%