fix: derive LLM provider from adapter, not config

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.
This commit is contained in:
2026-03-15 23:47:52 -04:00
parent 60576fbf2f
commit bd96a83069
2 changed files with 9 additions and 7 deletions

View File

@@ -22,7 +22,6 @@ class AnthropicAdapter(LLMAdapter):
Reads model configuration from the loaded team.yaml config dict:: Reads model configuration from the loaded team.yaml config dict::
models: models:
provider: anthropic
default_max_tokens: 4096 # fallback max_tokens for all calls default_max_tokens: 4096 # fallback max_tokens for all calls
default_temperature: 0 # fallback temperature for all calls default_temperature: 0 # fallback temperature for all calls
capability_map: capability_map:
@@ -33,6 +32,10 @@ class AnthropicAdapter(LLMAdapter):
fast-cheap: fast-cheap:
anthropic: claude-haiku-3-5 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 Both ``default_max_tokens`` and ``default_temperature`` can be overridden
per-call via the ``context`` dict passed to :meth:`complete`. 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"). 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", {}) cap_map: dict = self._models_cfg.get("capability_map", {})
if capability in cap_map and provider in cap_map[capability]: if capability in cap_map and "anthropic" in cap_map[capability]:
return cap_map[capability][provider] return cap_map[capability]["anthropic"]
# Fall back to "capable" tier # Fall back to "capable" tier
if "capable" in cap_map and provider in cap_map["capable"]: if "capable" in cap_map and "anthropic" in cap_map["capable"]:
return cap_map["capable"][provider] return cap_map["capable"]["anthropic"]
# Hard-coded last resort # Hard-coded last resort
return "claude-sonnet-4-6" return "claude-sonnet-4-6"

View File

@@ -10,7 +10,6 @@ adapters:
runtime: openclaw runtime: openclaw
models: models:
provider: anthropic
default_max_tokens: 4096 default_max_tokens: 4096
default_temperature: 0 default_temperature: 0
capability_map: capability_map: