Repository navigation
fix(api): correct Haiku/large-output behaviour (adaptive-thinking guard + no truncation) - #9
Merged
Merged
Conversation
The api backend hardcoded thinking:{type:adaptive}, which 400s on Haiku 4.5 / Sonnet 4.5 / older ('adaptive thinking is not supported on this model'). Now gated by supportsAdaptiveThinking(model); omitted for unsupported models. Surfaced by running with ANTHROPIC_MODEL=claude-haiku-4-5. Regression test added.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ncated A whole-component implementation easily exceeds 16K output tokens. The API backend used a non-streaming messages.create capped at 16K, so the model's JSON proposal was silently cut off mid-object and dropped downstream as "agent output could not be parsed" — no code committed, QA blocks every ticket. Surfaced live on the local URL-shortener run (Haiku): every implement step produced a ~48K-char proposal truncated at exactly the cap. - api backend: switch to messages.stream(...).finalMessage() and raise the cap to 32K (streaming avoids the request-timeout risk at high max_tokens). - detect stop_reason === "max_tokens" and return a new StoppedReason "truncated" so a cut-off output is never mistaken for a valid response. - activities: audit a truncated implement step as "agent output truncated (hit token cap)", distinct from a real parse failure or an empty change set. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.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.
Two API-backend correctness fixes surfaced by the live local URL-shortener run (Haiku). Both are required for a ticket to reach
donewith real committed code; without them every ticket blocks.1. Adaptive thinking only where supported
thinking: {type:"adaptive"}was sent unconditionally. Haiku 4.5 (and older models) reject it with400 invalid_request_error: adaptive thinking is not supported on this model, so shaping/implement steps were skipped entirely on Haiku. Now gated bysupportsAdaptiveThinking(model)(+ unit tests).2. Stream + raise output cap so large outputs aren't truncated
A whole-component implementation easily exceeds 16K output tokens. The backend used a non-streaming
messages.createcapped at 16K, so the model's JSON proposal was silently cut off mid-object and dropped downstream as "agent output could not be parsed" — no code committed, QA blocks every ticket. Observed live: each implement step produced a ~48K-char proposal truncated at exactly the cap.messages.stream(...).finalMessage()and raise the cap to 32K (streaming avoids the request-timeout risk at highmax_tokens, per the claude-api skill guidance).stop_reason === "max_tokens"and return a newStoppedReason"truncated"so a cut-off output is never mistaken for a valid response.agent output truncated (hit token cap), distinct from a real parse failure or an empty change set.Verification
pnpm typecheck·pnpm lint·pnpm test(102) ·pnpm buildall pass.🤖 Generated with Claude Code