Skip to content

Your lightweight open-source personal agent.

refactor(providers): drop unreachable GenerationSettings fallback

04cbeacc9fbb5fbd
diff --git a/nanobot/providers/base.py b/nanobot/providers/base.py
index 60a0fcfe6..42cd1a10f 100644
--- a/nanobot/providers/base.py
+++ b/nanobot/providers/base.py
@@ -514,12 +514,8 @@ class LLMProvider(ABC):
"""Call chat_stream() with retry on transient provider failures."""
if max_tokens is self._SENTINEL or max_tokens is None:
max_tokens = self.generation.max_tokens
- if max_tokens is None:
- max_tokens = GenerationSettings.max_tokens
if temperature is self._SENTINEL or temperature is None:
temperature = self.generation.temperature
- if temperature is None:
- temperature = GenerationSettings.temperature
if reasoning_effort is self._SENTINEL:
reasoning_effort = self.generation.reasoning_effort
@@ -554,19 +550,14 @@ class LLMProvider(ABC):
Parameters default to ``self.generation`` when not explicitly passed,
so callers no longer need to thread temperature / max_tokens /
reasoning_effort through every layer. Explicit ``None`` is also
- normalized to the provider's generation defaults, with a final fallback
- to :class:`GenerationSettings` class defaults so that downstream
+ normalized to the provider's generation defaults so that downstream
``_build_kwargs`` never sees ``None`` for ``max_tokens`` / ``temperature``
(which would crash ``max(1, max_tokens)``).
"""
if max_tokens is self._SENTINEL or max_tokens is None:
max_tokens = self.generation.max_tokens
- if max_tokens is None:
- max_tokens = GenerationSettings.max_tokens
if temperature is self._SENTINEL or temperature is None:
temperature = self.generation.temperature
- if temperature is None:
- temperature = GenerationSettings.temperature
if reasoning_effort is self._SENTINEL:
reasoning_effort = self.generation.reasoning_effort
diff --git a/tests/providers/test_provider_retry.py b/tests/providers/test_provider_retry.py
index 713cf444d..add5e2245 100644
--- a/tests/providers/test_provider_retry.py
+++ b/tests/providers/test_provider_retry.py
@@ -546,23 +546,6 @@ async def test_chat_with_retry_normalizes_explicit_none_max_tokens() -> None:
assert provider.last_kwargs["temperature"] == 0.7
-async def test_chat_with_retry_hard_fallback_when_generation_max_tokens_is_none() -> None:
- """Final fallback: even if provider.generation.max_tokens is None,
- chat() must receive the GenerationSettings class default (not None)."""
- provider = ScriptedProvider([LLMResponse(content="ok")])
- # Bypass the dataclass type hint by constructing with None explicitly.
- provider.generation = GenerationSettings(max_tokens=None, temperature=None) # type: ignore[arg-type]
-
- response = await provider.chat_with_retry(
- messages=[{"role": "user", "content": "hi"}],
- )
-
- assert response.content == "ok"
- assert provider.last_kwargs["max_tokens"] == GenerationSettings.max_tokens
- assert provider.last_kwargs["temperature"] == GenerationSettings.temperature
-
-
@pytest.mark.asyncio
async def test_chat_stream_with_retry_normalizes_explicit_none_max_tokens() -> None:
"""chat_stream_with_retry must apply the same None-guard as chat_with_retry."""