From 8524b63a7604c864e187c6436c3f208f82384ede Mon Sep 17 00:00:00 2001 From: Hans Heinemann Date: Sun, 15 Mar 2026 21:40:05 -0400 Subject: [PATCH] fix: read default_temperature from team.yaml; update docstrings - Add default_temperature: 0 to config/team.yaml models block - Read self._default_temperature from models cfg in __init__ - Use self._default_temperature as fallback in complete() instead of hardcoded 0 - Update class docstring to document both default_max_tokens and default_temperature - Update complete() context param docs to reference team.yaml keys --- adapters/llm/anthropic.py | 16 +++++++++++----- config/team.yaml | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/adapters/llm/anthropic.py b/adapters/llm/anthropic.py index 7836473..e18214c 100644 --- a/adapters/llm/anthropic.py +++ b/adapters/llm/anthropic.py @@ -23,6 +23,8 @@ class AnthropicAdapter(LLMAdapter): models: provider: anthropic + default_max_tokens: 4096 # fallback max_tokens for all calls + default_temperature: 0 # fallback temperature for all calls capability_map: reasoning-heavy: anthropic: claude-opus-4-6 @@ -31,6 +33,9 @@ class AnthropicAdapter(LLMAdapter): fast-cheap: anthropic: claude-haiku-3-5 + Both ``default_max_tokens`` and ``default_temperature`` can be overridden + per-call via the ``context`` dict passed to :meth:`complete`. + Environment variables --------------------- ANTHROPIC_API_KEY : Required. Authenticates with the Anthropic API. @@ -59,6 +64,7 @@ class AnthropicAdapter(LLMAdapter): self._client = anthropic.Anthropic(api_key=api_key) self._models_cfg: dict = config.get("models", {}) self._default_max_tokens: int = self._models_cfg.get("default_max_tokens", 4096) + self._default_temperature: float = self._models_cfg.get("default_temperature", 0) def complete(self, prompt: str, capability: str, context: dict) -> str: """ @@ -68,10 +74,10 @@ class AnthropicAdapter(LLMAdapter): ---------- prompt : User-role prompt content. capability : One of "reasoning-heavy" | "capable" | "fast-cheap". - context : Optional overrides: + context : Optional per-call overrides: system_prompt (str) — prepended as the system turn. - max_tokens (int) — defaults to 4096. - temperature (float) — defaults to 0. + max_tokens (int) — defaults to models.default_max_tokens in team.yaml. + temperature (float) — defaults to models.default_temperature in team.yaml. Returns ------- @@ -79,7 +85,7 @@ class AnthropicAdapter(LLMAdapter): """ model = self.resolve_model(capability) max_tokens: int = context.get("max_tokens", self._default_max_tokens) - temperature: float = context.get("temperature", 0) + temperature: float = context.get("temperature", self._default_temperature) system_prompt: str = context.get("system_prompt", "") create_kwargs: dict = { @@ -89,7 +95,7 @@ class AnthropicAdapter(LLMAdapter): } if system_prompt: create_kwargs["system"] = system_prompt - if temperature != 0: + if temperature != 0.0: create_kwargs["temperature"] = temperature response = self._client.messages.create(**create_kwargs) diff --git a/config/team.yaml b/config/team.yaml index 277fa04..bc3b0b6 100644 --- a/config/team.yaml +++ b/config/team.yaml @@ -12,6 +12,7 @@ adapters: models: provider: anthropic default_max_tokens: 4096 + default_temperature: 0 capability_map: reasoning-heavy: anthropic: claude-opus-4-6