Skip to content

Agent Zero AI framework

fix(model-config): detect Claude models across providers

Alessandro60c940fd03fd
diff --git a/plugins/_model_config/AGENTS.md b/plugins/_model_config/AGENTS.md
index aab70195a..1488bfa60 100644
--- a/plugins/_model_config/AGENTS.md
+++ b/plugins/_model_config/AGENTS.md
@@ -34,7 +34,7 @@
- In model overviews, render the effective Vision Model as a text-only `Vision override / Provider / Model` child aligned with Main's provider column, not as an icon-bearing peer row.
- Changing a model provider in the settings UI must clear `api_base` and `kwargs` because both may be provider-specific.
- Repair provider-specific model-config aliases at the model-config read/build boundary; keep provider-specific repairs out of provider-agnostic core wrappers such as `models.py`.
-- The `Agent.read_prompt/end` Anthropic hook adapts only the two bundled thoughts instructions in main/communication/solving prompt results when the effective main provider or model name contains `anthropic` (case-insensitive, including OpenRouter). Keep prompt files, JSON fields, history, custom wording, and other models unchanged; standalone communication reads must match main-prompt rendering for native protocol projection. Verify with `tests/test_anthropic_thoughts_prompt.py`.
+- The `Agent.read_prompt/end` Anthropic hook adapts only the two bundled thoughts instructions in main/communication/solving prompt results when the effective main provider or model name contains `anthropic`, or the model name contains `claude` (case-insensitive, regardless of provider). Keep prompt files, JSON fields, history, custom wording, and other models unchanged; standalone communication reads must match main-prompt rendering for native protocol projection. Verify with `tests/test_anthropic_thoughts_prompt.py`.
- `modelConfig.createPresetEditor()` owns local preset drafts, row actions, and stable UI-only row keys so deletion or renaming cannot rebind nested model fields.
- The preset editor maps each model provider's API-key field to the shared API-key store; saving the editor persists dirty keys separately and never writes secrets into preset YAML.
- The compact chat selector label combines the effective preset with only the leaf name of its main model; utility and provider text stay out of the closed selector.
diff --git a/plugins/_model_config/README.md b/plugins/_model_config/README.md
index 0c85c1560..b4542fba1 100644
--- a/plugins/_model_config/README.md
+++ b/plugins/_model_config/README.md
@@ -9,7 +9,7 @@ Manage the reusable model presets used for Agent Zero's main, utility, and embed
- Preset definitions are global and live in `usr/plugins/_model_config/presets.yaml`. Plugin defaults in `mode_presets_fallback.yaml` are used only when a saved collection cannot be initialized.
- Non-default presets may omit advanced fields or model slots; omitted values resolve from `Default`, while provider-specific `kwargs` are replaced or cleared instead of leaking between providers.
- API keys remain in the approved environment/settings flow and are never written into preset YAML.
-- Models whose provider or name contains `anthropic` receive public-action-summary wording for the bundled `thoughts` instructions, including through OpenRouter. Shared prompt files and the `thoughts` JSON field stay unchanged.
+- Models whose provider or name contains `anthropic`, or whose name contains `claude`, receive public-action-summary wording for the bundled `thoughts` instructions. Matching is case-insensitive and applies regardless of provider, including third-party and OpenAI-compatible routes. Shared prompt files and the `thoughts` JSON field stay unchanged.
## Scoped Selection
diff --git a/plugins/_model_config/extensions/python/_functions/agent/Agent/read_prompt/end/_20_anthropic_thoughts.py b/plugins/_model_config/extensions/python/_functions/agent/Agent/read_prompt/end/_20_anthropic_thoughts.py
index 5d80dbbc9..3a4c5957a 100644
--- a/plugins/_model_config/extensions/python/_functions/agent/Agent/read_prompt/end/_20_anthropic_thoughts.py
+++ b/plugins/_model_config/extensions/python/_functions/agent/Agent/read_prompt/end/_20_anthropic_thoughts.py
@@ -15,7 +15,10 @@ class AnthropicThoughts(Extension):
}:
return
config = get_chat_model_config(self.agent)
- if "anthropic" not in f"{config.get('provider', '')}/{config.get('name', '')}".lower():
+ if (
+ "anthropic" not in f"{config.get('provider', '')}/{config.get('name', '')}".lower()
+ and "claude" not in str(config.get("name", "")).lower()
+ ):
return
data["result"] = data["result"].replace(
"- thoughts: array thoughts before execution in natural language",
diff --git a/tests/test_anthropic_thoughts_prompt.py b/tests/test_anthropic_thoughts_prompt.py
index c828c112d..2adba33a1 100644
--- a/tests/test_anthropic_thoughts_prompt.py
+++ b/tests/test_anthropic_thoughts_prompt.py
@@ -11,9 +11,19 @@ from plugins._model_config.extensions.python._functions.agent.Agent.read_prompt.
@pytest.mark.parametrize("provider,model,adapted", [
("anthropic", "claude-opus-5-5", True),
+ ("AnThRoPiC", "custom-model", True),
("openrouter", "Anthropic/claude-opus-5.5", True),
+ ("other", "Anthropic/custom-model", True),
("bedrock", "us.anthropic.claude-opus", True),
+ ("openrouter", "claude-opus-5.5", True),
+ ("openai", "claude-opus-5-5", True),
+ ("other", "ClAuDe-opus-5-5", True),
+ ("vertex_ai", "claude-sonnet-4@20250514", True),
+ ("bedrock", "claude-opus-5-5", True),
("openrouter", "openai/gpt-5", False),
+ ("openai", "gpt-5", False),
+ ("claude_gateway", "unrelated-model", False),
+ ("other", "", False),
])
def test_scoped_prompt_rendering_preserves_templates_and_native_projection(
monkeypatch, provider, model, adapted,