Pin anthropic below 1.0 and guard the SDK call contract - #3799
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3799 +/- ##
=======================================
Coverage 85.11% 85.11%
=======================================
Files 109 109
Lines 6290 6290
Branches 1093 1093
=======================================
Hits 5354 5354
Misses 630 630
Partials 306 306 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
anthropic 1.0.0 (2026-08-20) removed HUMAN_PROMPT and the temperature keyword that ai_analysis_service passes to messages.stream(). The PR Test job and the Cloud Run image both install with unpinned pip (uv.lock is dockerignored), so every new build after 2026-08-20 resolves 1.0.0: the Test job fails at collection, and a fresh production image would raise TypeError on every AI-analysis cache miss. The last production build (2026-08-19) predates 1.0.0, so production is currently unaffected. Pin anthropic>=0.97.0,<1 (pip resolves 0.99.0, which keeps both surfaces; uv.lock stays at 0.97.0) and add a contract test against the installed SDK's real Messages.stream signature, so mocked unit tests can no longer hide the next SDK break. No prompt or runtime behavior changes: the tracer prompt and the AI-analysis cache keys are untouched. The 1.x migration (drop temperature, revisit the model) is a separate change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
MaxGhenis
force-pushed
the
fix/anthropic-sdk-1-human-prompt
branch
from
August 22, 2026 18:33
3a019a2 to
f45a7ab
Compare
MaxGhenis
marked this pull request as ready for review
August 22, 2026 18:43
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.
Every PR's Test job started failing on 2026-08-21 with
AttributeError: module 'anthropic' has no attribute 'HUMAN_PROMPT'(example run on #3798). Root cause: anthropic 1.0.0 was released 2026-08-20 19:58 UTC and removed the legacy Text Completions constants and thetemperature/top_p/top_kkeywords frommessages.stream()/create();anthropicwas unpinned inpyproject.toml.Two install surfaces float: the PR Test job, and — more importantly — the Cloud Run production image (
gcp/cloud_run/Dockerfileruns plainpip install -e .anduv.lockis dockerignored). The last production build was 2026-08-19 18:24 UTC, before 1.0.0 existed; the next master merge would ship anthropic 1.0.0, andai_analysis_service.py:68-74(temperature=0.0→claude_client.messages.stream(...)) would raiseTypeError. Mocked unit tests cannot see this: the fakes accept arbitrary kwargs.Changes (no runtime behavior change)
pyproject.toml:anthropic>=0.97.0,<1(pip resolves 0.99.0;uv.lockstays 0.97.0 — both keeptemperatureandHUMAN_PROMPT, verified by introspecting the realMessages.streamsignature on 0.97.0, 0.99.0 and 1.0.0).tests/unit/services/test_anthropic_sdk_contract.py: asserts the installed SDK'sMessages.streamacceptstemperatureand that the major version is <1, so the next SDK break fails CI loudly instead of passing through mocks.Verification
tests/unit/services: 374 passed under the lock (0.97.0); the analysis tests and the contract test pass under 0.99.0; the contract test fails as designed under 1.0.0.temperatureremoval and the unpinned production image; round 2 caught that a prompt cleanup in the earlier revision would have invalidated AI-analysis caches — that change was dropped so this PR is pin-only.Found en route, tracked separately
AI_ANALYSIS_MODEL = "claude-sonnet-4-20250514"is retired: the Models API returns 404not_found_errorfor it (and forclaude-sonnet-4-0), so the AI-analysis cache-miss path already fails in production today. That needs a model decision and its own PR; see the linked issue.🤖 Generated with Claude Code