Switch explainer to Sonnet 5.5 and upgrade deps (anthropic 1.x) - #48
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The model migration, SDK adaptation, dependency updates, and associated tests are consistent and complete.
Review effort: Balanced
Findings: None
What changed in this PR
Upgrades the explainer to Sonnet 5.5 and Anthropic SDK 1.x while preserving request, caching, and cost-tracking behavior.
Changes:
- Migrates production to Sonnet 5.5 with
between_toolsthinking. - Updates SDK payload construction, pricing data, enums, and tests.
- Refreshes Python dependencies and Ruff configuration.
| File | Description |
|---|---|
app/prompt.yaml |
Configures Sonnet 5.5. |
app/prompt.py |
Adapts payloads for Anthropic SDK 1.x. |
app/explain.py |
Logs the active thinking type. |
app/model_costs.py |
Updates Claude 5 pricing. |
app/explanation_types.py |
Migrates enums to StrEnum. |
app/test_explain.py |
Tests temperature payload handling. |
app/test_model_costs.py |
Tests Sonnet 5 pricing. |
pyproject.toml |
Raises dependency floors. |
uv.lock |
Locks upgraded dependencies. |
.pre-commit-config.yaml |
Upgrades Ruff hooks. |
CLAUDE.md |
Documents Sonnet 5.5 behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Moves the production explainer from
claude-sonnet-5toclaude-sonnet-5-5(released 2026-09-28) and upgrades all Python deps, including the anthropic SDK 0.120 → 1.9.Eval: Sonnet 5 vs Sonnet 5.5
Setup:
prompt-test run --reviewwith the production prompt, 21 cases, 2 runs per config, Opus 5 reviewer with adaptive thinking. Everything ran on the upgraded deps, so the model is the only thing that changes. Accuracy covers the 16 assembly cases per run. The haiku cases are excluded because the reviewer marks every haiku "incorrect" for not explaining the assembly, and does so for every config.high).Changes
Model
app/prompt.yaml:claude-sonnet-5-5withthinking: {type: between_tools}. Sonnet 5.5 returns a 400 forthinking: {type: disabled}.between_toolsis its lowest setting, and with no tools it means no thinking. Verified: the response is a singletextblock. TheuseThinkingper-request path (adaptive) is unchanged.app/model_costs.py: Sonnet 5 goes to $2/$10, since the planned September rise to $3/$15 was cancelled and $2/$10 is now the standard price. Adds Sonnet 5.5 ($2/$10) and Opus 5.5 ($4/$20).CLAUDE.md: updates the thinking, temperature, caching and refusal gotchas for 5.5. Two notable changes: the minimum cacheable prefix drops to 512 tokens, and 5.5 refuses in more categories (bio,reasoning_extraction,general_harms).Deps
uv lock --upgrade, with pyproject floors raised to the locked versions. Pre-commit ruff goes v0.13.0 → v0.16.9.build_api_payload. It puttemperaturestraight into the kwargs, which is aTypeErroron 1.x, and it also defaulted to sending 0.0 even when the YAML didn't set one. Now temperature is sent only when configured, viaextra_body, and only when thinking is off. New tests cover this. There is nowith_raw_response,httpxoroutput_formatusage.httpx2arrives transitively with anthropic 1.x. It is the SDK's HTTP layer: the maintained fork ofhttpx, published by Pydantic (github.com/pydantic/httpx2).httpx2-jsfetchin the lock only applies on Emscripten and is never installed here.(str, Enum)(UP042), so the two enums move toStrEnum. All uses go through.valueor Pydantic, so behaviour is unchanged.Truenow.GitHub Actions and Docker base images are left to Dependabot. setup-uv v9 → v10 is a major bump.
Testing
uv run pytest: 113 passed.pre-commit run --all-files: clean.fastapi dev+./test-explain.shagainst SDK 1.9.0 and Sonnet 5.5: explanation returned, and the log showsthinking=between_tools.ClaudeExplainRefusalbecause 5.5 refuses in more categories.🤖 Generated with Claude Code