fix: validate named custom provider endpoints

This commit is contained in:
chengyongru
2026-06-13 00:04:13 +08:00
committed by Xubin Ren
parent a9308eb8e2
commit 09d24e6c25
6 changed files with 164 additions and 12 deletions
+44
View File
@@ -79,6 +79,50 @@ def test_custom_provider_fallback_uses_model_extra_without_pydantic_warnings() -
assert config.get_provider_name() == "my-company-api"
def test_dynamic_custom_provider_prefix_matches_camel_case_key() -> None:
config = Config.model_validate({
"agents": {
"defaults": {
"provider": "auto",
"model": "companyProxy/gpt-4o-mini",
}
},
"providers": {
"otherProxy": {
"apiBase": "https://other.example.test/v1",
},
"companyProxy": {
"apiBase": "https://company.example.test/v1",
},
},
})
assert config.get_provider_name() == "companyProxy"
assert config.get_api_base() == "https://company.example.test/v1"
def test_dynamic_custom_provider_prefix_does_not_fall_through_when_base_missing() -> None:
config = Config.model_validate({
"agents": {
"defaults": {
"provider": "auto",
"model": "companyProxy/gpt-4o-mini",
}
},
"providers": {
"otherProxy": {
"apiBase": "https://other.example.test/v1",
},
"companyProxy": {
"apiKey": "sk-company",
},
},
})
assert config.get_provider_name() == "companyProxy"
assert config.get_api_base() is None
def test_legacy_defaults_config_without_presets_still_resolves() -> None:
config = Config.model_validate({
"agents": {