executing-plans
executing-plans
Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available
anth-upgrade-migrationUpgrade Anthropic SDK versions and migrate between Claude API versions. Use when upgrading the Python/TypeScript SDK, migrating from Text Completions to Messages API, or adopting new API features like tool use or batches. Trigger with phrases like "upgrade anthropic sdk", "anthropic migration", "update claude sdk", "migrate to messages api".
Independent GitHub snapshot · Automated classification · Original documentation governs
name: anth-upgrade-migration description: 'Upgrade Anthropic SDK versions and migrate between Claude API versions.
Use when upgrading the Python/TypeScript SDK, migrating from Text Completions
to Messages API, or adopting new API features like tool use or batches.
Trigger with phrases like "upgrade anthropic sdk", "anthropic migration",
"update claude sdk", "migrate to messages api".
' allowed-tools: Read, Write, Edit, Bash(npm:), Bash(pip:), Bash(git:*) version: 1.7.0 license: MIT author: Jeremy Longshore jeremy@intentsolutions.io tags:
Guide for upgrading the Anthropic SDK and migrating between API versions. The SDK follows semver — major versions may have breaking changes.
# Python
pip show anthropic | grep Version
# Version: 0.40.0
# TypeScript
npm list @anthropic-ai/sdk
# @anthropic-ai/sdk@0.35.0
# Check latest available
pip index versions anthropic 2>/dev/null | head -1
npm view @anthropic-ai/sdk version
git checkout -b upgrade/anthropic-sdk
# Python
pip install --upgrade anthropic
pip show anthropic | grep Version
# TypeScript
npm install @anthropic-ai/sdk@latest
Key breaking changes by version:
Python SDK 0.20+ (anthropic-version: 2023-06-01)
# OLD: Text Completions API (deprecated)
response = client.completions.create(
model="claude-2",
prompt="\n\nHuman: Hello\n\nAssistant:",
max_tokens_to_sample=256
)
# NEW: Messages API
response = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=256,
messages=[{"role": "user", "content": "Hello"}]
)
Python SDK 0.30+ (streaming changes)
# OLD: Manual SSE parsing
response = client.messages.create(..., stream=True)
for line in response.iter_lines():
...
# NEW: High-level streaming
with client.messages.stream(...) as stream:
for text in stream.text_stream:
print(text)
TypeScript SDK 0.20+ (import path change)
// OLD
import Anthropic from 'anthropic';
// NEW
import Anthropic from '@anthropic-ai/sdk';
# The SDK sends anthropic-version header automatically
# To pin a specific version:
client = anthropic.Anthropic(
default_headers={"anthropic-version": "2023-06-01"}
)
# For beta features:
client = anthropic.Anthropic(
default_headers={"anthropic-beta": "token-counting-2024-11-01"}
)
# Run your test suite
python -m pytest tests/ -v
npm test
# Verify a live call
python3 -c "
import anthropic
c = anthropic.Anthropic()
m = c.messages.create(model='claude-haiku-4-20250514', max_tokens=8, messages=[{'role':'user','content':'hi'}])
print(f'OK: {m.model} {m.usage}')
"
| Text Completions | Messages API |
|---|---|
client.completions.create() | client.messages.create() |
prompt (string) | messages (array) |
max_tokens_to_sample | max_tokens |
model: "claude-2" | model: "claude-sonnet-4-20250514" |
\n\nHuman:...\n\nAssistant: | [{role: "user"}, {role: "assistant"}] |
response.completion | response.content[0].text |
# Python — pin to previous version
pip install anthropic==0.39.0
# TypeScript — pin to previous version
npm install @anthropic-ai/sdk@0.34.0
# Git rollback
git checkout main -- package.json package-lock.json
npm install
max_tokens, authentication through the secret manager, and least-privileged workspace access.Produce a migration receipt containing source and target SDK versions, API-version header, lockfile/artifact digests, test and canary results, model IDs, workspace/environment, approval, rollout state, rollback reference, and retention deadline. Exclude API keys, prompt/response text, customer identifiers, and raw exception payloads.
| Failure | Response |
|---|---|
| Dependency or API contract test fails | Pin the prior version, isolate the failing fixture, and do not promote. |
| Authentication or permission failure | Stop the canary, verify the secret-manager reference and workspace scope, and never print the key. |
| 429/5xx, timeout, or latency regression | Respect SDK retry guidance, apply a bounded circuit breaker, and roll back when the canary threshold is exceeded. |
| Response-shape or tool-use drift | Quarantine the result, update the adapter only after an approved contract decision, and rerun the full suite. |
For a synthetic migration fixture, pin anthropic from 0.39.0 to the reviewed target, run 100 sandbox Messages API calls with customer=fixture-017, assert response-shape parity and customer_content_logged=0, then promote to a 1% internal canary. A failed threshold yields promotion=halted; rollback=prior-lockfile.
For CI integration during upgrades, see anth-ci-integration.