#906

[BUG] patterns/agents/util.py and 15 other files: temperature= raises TypeError on anthropic 1.x

Openjayzuccarelliopened 27d ago

Affected Notebook/File

patterns/agents/util.py (plus 15 other files, listed below)

Bug Description

anthropic 1.0 removed temperature, top_p and top_k from messages.create() / messages.stream(), so passing one raises a TypeError before any request goes out. These files still pass temperature= to an SDK call. The notebooks install anthropic unpinned, so a fresh run picks up 1.11.0 (the current release) and fails at the first call.

The most visible one is patterns/agents/util.py: llm_call() passes temperature=0.1, and basic_workflows, orchestrator_workers and evaluator_optimizer all import it.

CI doesn't catch this because uv.lock pins anthropic 0.109.0, where the kwarg still exists.

Files that pass temperature= to messages.create / messages.stream:

  • capabilities/classification/guide.ipynb
  • capabilities/contextual-embeddings/guide.ipynb
  • capabilities/retrieval_augmented_generation/guide.ipynb
  • capabilities/retrieval_augmented_generation/evaluation/eval_end_to_end.py
  • capabilities/retrieval_augmented_generation/evaluation/prompts.py
  • capabilities/retrieval_augmented_generation/evaluation/provider_retrieval.py
  • capabilities/summarization/guide.ipynb
  • capabilities/summarization/evaluation/custom_evals/llm_eval.py
  • capabilities/text_to_sql/guide.ipynb
  • misc/generate_test_cases.ipynb
  • misc/metaprompt.ipynb
  • misc/using_citations.ipynb
  • multimodal/reading_charts_graphs_powerpoints.ipynb
  • patterns/agents/util.py
  • third_party/ElevenLabs/low_latency_stt_claude_tts.ipynb
  • third_party/ElevenLabs/stream_voice_assistant_websocket.py

extended_thinking/extended_thinking.ipynb also passes temperature, but on purpose, to show the thinking + temperature 400. On 1.x that cell shows a TypeError instead.

(#901 covers two other notebooks with the same problem, so they're left out here.)

Expected: the calls run on the current SDK. Actual: TypeError at the first call.

A possible fix is to drop the kwarg where the default is fine. Where a notebook relies on it (e.g. the classification evals), move it to extra_body={"temperature": ...}, which models before Opus 4.7 still accept.

Steps to Reproduce

  1. In a fresh env: pip install anthropic==1.11.0
  2. cd patterns/agents
  3. ANTHROPIC_API_KEY=x python -c "import util; util.llm_call('hi')"

Error Message

TypeError: Messages.create() got an unexpected keyword argument 'temperature'

With anthropic==0.109.0 (the version in uv.lock), the same call builds and sends the request normally.

Environment

  • Python 3.13
  • Linux
  • anthropic 1.11.0 (compared against 0.109.0)

Would you be willing to submit a PR?

Yes

AI disclosure: this report was prepared with Claude Code.

Activity

0

No activity yet.