From bd96a83069a7bb84e782442619e44c9d369de9e6 Mon Sep 17 00:00:00 2001 From: Hans Heinemann Date: Sun, 15 Mar 2026 23:47:52 -0400 Subject: [PATCH] fix: derive LLM provider from adapter, not config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove redundant models.provider from team.yaml. Each adapter knows its own provider key — AnthropicAdapter always looks up 'anthropic' in the capability_map. This avoids a footgun where adapters.llm and models.provider could disagree. Future adapters (OpenAIAdapter, OllamaAdapter) will hardcode their own key the same way. --- adapters/llm/anthropic.py | 15 +++++++++------ config/team.yaml | 1 - 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/adapters/llm/anthropic.py b/adapters/llm/anthropic.py index e18214c..4b4a2ec 100644 --- a/adapters/llm/anthropic.py +++ b/adapters/llm/anthropic.py @@ -22,7 +22,6 @@ class AnthropicAdapter(LLMAdapter): Reads model configuration from the loaded team.yaml config dict:: models: - provider: anthropic default_max_tokens: 4096 # fallback max_tokens for all calls default_temperature: 0 # fallback temperature for all calls capability_map: @@ -33,6 +32,10 @@ class AnthropicAdapter(LLMAdapter): fast-cheap: anthropic: claude-haiku-3-5 + The provider key used when looking up ``capability_map`` is hardcoded to + ``"anthropic"`` — the adapter knows its own provider; there is no need for + a separate ``models.provider`` config field. + Both ``default_max_tokens`` and ``default_temperature`` can be overridden per-call via the ``context`` dict passed to :meth:`complete`. @@ -116,15 +119,15 @@ class AnthropicAdapter(LLMAdapter): ------- Anthropic model identifier (e.g. "claude-opus-4-6"). """ - provider: str = self._models_cfg.get("provider", "anthropic") + # The adapter knows its own provider — no need to read it from config. cap_map: dict = self._models_cfg.get("capability_map", {}) - if capability in cap_map and provider in cap_map[capability]: - return cap_map[capability][provider] + if capability in cap_map and "anthropic" in cap_map[capability]: + return cap_map[capability]["anthropic"] # Fall back to "capable" tier - if "capable" in cap_map and provider in cap_map["capable"]: - return cap_map["capable"][provider] + if "capable" in cap_map and "anthropic" in cap_map["capable"]: + return cap_map["capable"]["anthropic"] # Hard-coded last resort return "claude-sonnet-4-6" diff --git a/config/team.yaml b/config/team.yaml index bc3b0b6..ba12e05 100644 --- a/config/team.yaml +++ b/config/team.yaml @@ -10,7 +10,6 @@ adapters: runtime: openclaw models: - provider: anthropic default_max_tokens: 4096 default_temperature: 0 capability_map: