Repository navigation
Conversation
claude-sonnet-4-20250514 was retired on 2026-06-15, so every query failed. - Switch ANTHROPIC_MODEL to claude-sonnet-5-5 - Drop temperature (non-default sampling params are rejected) - Raise max_tokens to 4096 since thinking tokens count toward it - Set effort to low via extra_body (pinned SDK lacks output_config) - Extract text blocks explicitly instead of content[0], skipping thinking blocks and handling refusals Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SDK 2.x sends API version 2026-10-21 by default. - Pin anthropic==2.14.0 and regenerate uv.lock (adds httpx2, the SDK's HTTP dependency) - Pass output_config as a native parameter instead of via extra_body Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <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.
Summary
The chatbot was calling
claude-sonnet-4-20250514(Claude Sonnet 4), which was retired on June 15, 2026. Every query to/api/querytherefore failed with an HTTP 500. This PR moves the app to Claude Sonnet 5.5 (claude-sonnet-5-5) and upgrades the Anthropic Python SDK from 0.58.2 to 2.14.0, which also moves requests to API version2026-10-21.Changes
1. Migrate to Claude Sonnet 5.5 (
11fdfcc)backend/config.py:ANTHROPIC_MODELis nowclaude-sonnet-5-5.backend/ai_generator.py:temperature: 0. Sonnet 5.5 rejects non-default sampling parameters.max_tokensfrom 800 to 4096. Thinking is on by default and its tokens count toward the limit, so 800 could truncate answers.efforttolowto keep short Q&A responses fast and inexpensive._extract_text()to replaceresponse.content[0].text. A response can now begin with athinkingblock, so the helper joins only thetextblocks. It also returns a short fallback message whenstop_reasonisrefusal.2. Upgrade the Anthropic Python SDK to 2.14.0 (
f392f79)pyproject.toml: pinnedanthropic==2.14.0.uv.lock: regenerated. It now includeshttpx2, the SDK's HTTP dependency, which is the maintained fork ofhttpxpublished by Pydantic.backend/ai_generator.py:output_configis now passed as a native parameter. Theextra_bodyworkaround was only needed because the old SDK didn't support it.SDK 2.x sends
anthropic-version: 2026-10-21by default. I checked this code against that version's breaking changes:temperature/top_p/top_krejecteddocumentblocks in assistant messages rejectedcitationson user text blocks rejectedAuthorization: Bearerinstead ofX-Api-Keyapi_keyand no proxyMessageParambecomes a per-role unionMigration guide: https://platform.claude.com/docs/en/api/migration-2026-10-21
Testing
python -m compileallpasses onbackend/.anthropic-version: 2026-10-21.search_course_content→ second call without tools) returned an answer built from the tool's result.POST /api/querythrough the FastAPI app with ChromaDB search returned 200. The answer drew on the course content, and the sources were correct (MCP: Build Rich-Context AI Apps with Anthropic - Lesson 1).The repository has no automated test suite.
Notes for reviewers
backend/ai_generator.pyuses CRLF line endings, and the edits preserve them. The diff contains only the real changes.🤖 Generated with Claude Code