fix: preserve dynamic custom provider semantics

maintainer edit: treat arbitrary custom provider names as direct OpenAI-compatible providers, validate their api_type consistently, and avoid Pydantic instance-field warnings in fallback routing.
This commit is contained in:
chengyongru
2026-06-13 00:04:13 +08:00
committed by Xubin Ren
parent e9e1489cee
commit 68c6844c0b
4 changed files with 71 additions and 14 deletions
+31
View File
@@ -1,3 +1,5 @@
import warnings
import pytest
from nanobot.config.schema import Config
@@ -47,6 +49,35 @@ def test_provider_api_type_is_openai_only() -> None:
}
})
with pytest.raises(ValueError, match="only supported"):
Config.model_validate({
"providers": {
"my-company-api": {
"apiBase": "https://example.test/v1",
"apiType": "responses",
}
}
})
def test_custom_provider_fallback_uses_model_extra_without_pydantic_warnings() -> None:
config = Config.model_validate({
"agents": {
"defaults": {
"model": "unmatched-model",
}
},
"providers": {
"my-company-api": {
"apiBase": "https://example.test/v1",
}
},
})
with warnings.catch_warnings():
warnings.simplefilter("error")
assert config.get_provider_name() == "my-company-api"
def test_legacy_defaults_config_without_presets_still_resolves() -> None:
config = Config.model_validate({