Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/anthropic-sdk-1-human-prompt.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pin the anthropic SDK below 1.0: anthropic 1.0 (released 2026-08-20) removed HUMAN_PROMPT and the temperature keyword the AI analysis services pass to messages.stream(), and both the PR Test job and the Cloud Run image install with unpinned pip, so fresh builds would have failed at import (tests) or on AI-analysis cache misses (production). A contract test now checks the installed SDK's real stream() signature.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ classifiers = [
dependencies = [
"a2wsgi>=1.10,<2",
"alembic>=1.14,<2",
"anthropic",
"anthropic>=0.97.0,<1",
"assertpy",
"click>=8,<9",
"cloud-sql-python-connector",
Expand Down
30 changes: 30 additions & 0 deletions tests/unit/services/test_anthropic_sdk_contract.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""Guard the installed anthropic SDK against the call shape the services use.

The AI analysis services call ``claude_client.messages.stream(...)`` with a
``temperature`` keyword. The unit suites mock the client with permissive
fakes, so an SDK whose real signature dropped that keyword (anthropic 1.x
removed ``temperature``/``top_p``/``top_k`` and ``HUMAN_PROMPT``) still
passes every mocked test while failing at runtime on a cache miss. This test
checks the real installed SDK instead.
"""

import inspect

import anthropic
from anthropic.resources.messages import Messages


def test_installed_anthropic_sdk_accepts_stream_temperature():
parameters = inspect.signature(Messages.stream).parameters
assert "temperature" in parameters, (
f"anthropic {anthropic.__version__} no longer accepts temperature in "
"Messages.stream(); migrate ai_analysis_service before raising the pin"
)


def test_installed_anthropic_sdk_is_pre_1_0():
major = int(anthropic.__version__.split(".")[0])
assert major < 1, (
f"anthropic {anthropic.__version__} installed; pyproject pins <1 until "
"the services are migrated to the 1.x call surface"
)
6 changes: 3 additions & 3 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading