refactor(core): remove redundant runtime scaffolding (#5127)

This commit is contained in:
chengyongru authored and GitHub committed 2026-07-28 11:07:58 +08:00
1 parent 4c77126b3d
commit ef9e687f19
19 files changed
+89 -312

No files matched your search

+8 -17
View File
@@ -13,7 +13,6 @@ from nanobot.providers.base import LLMProvider, LLMResponse
# Circuit breaker tuned to match OpenAICompatProvider's Responses API breaker.
_PRIMARY_FAILURE_THRESHOLD = 3
_PRIMARY_COOLDOWN_S = 60
_MISSING = object()
_FALLBACK_ERROR_KINDS = frozenset({
"timeout",
"connection",
@@ -279,25 +278,17 @@ class FallbackProvider(LLMProvider):
await self._notify_fallback_model(fallback_model)
original_values = {
name: kwargs.get(name, _MISSING)
for name in ("model", "max_tokens", "temperature", "reasoning_effort")
fallback_kwargs = {
**kwargs,
"model": fallback_model,
"max_tokens": fallback.max_tokens,
"temperature": fallback.temperature,
}
kwargs["model"] = fallback_model
kwargs["max_tokens"] = fallback.max_tokens
kwargs["temperature"] = fallback.temperature
if fallback.reasoning_effort is None:
kwargs.pop("reasoning_effort", None)
fallback_kwargs.pop("reasoning_effort", None)
else:
kwargs["reasoning_effort"] = fallback.reasoning_effort
try:
fallback_response = await call(fallback_provider, kwargs)
finally:
for name, value in original_values.items():
if value is _MISSING:
kwargs.pop(name, None)
else:
kwargs[name] = value
fallback_kwargs["reasoning_effort"] = fallback.reasoning_effort
fallback_response = await call(fallback_provider, fallback_kwargs)
if fallback_response.finish_reason != "error":
logger.info(