Skip to content

DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.

fix(config): bump probe budget for reasoning models (#1401)

evan188199-tech2e9629785acb
diff --git a/deeptutor/services/config/test_runner.py b/deeptutor/services/config/test_runner.py
index a0f6fba86..a410c384e 100644
--- a/deeptutor/services/config/test_runner.py
+++ b/deeptutor/services/config/test_runner.py
@@ -238,7 +238,7 @@ class ConfigTestRunner:
from .loader import get_agent_params
probe_params = get_agent_params("llm_probe")
- max_tokens = _coerce_int(probe_params.get("max_tokens"), 1024)
+ max_tokens = _coerce_int(probe_params.get("max_tokens"), 4096)
temperature = _coerce_float(probe_params.get("temperature"), 0.1)
token_kwargs: dict[str, Any] = get_token_limit_kwargs(
llm_config.model, max_tokens=max_tokens
diff --git a/deeptutor/services/setup/init.py b/deeptutor/services/setup/init.py
index c5d3b8714..a5deb16ea 100644
--- a/deeptutor/services/setup/init.py
+++ b/deeptutor/services/setup/init.py
@@ -105,6 +105,12 @@ DEFAULT_AGENTS_SETTINGS = {
"vision_solver": {"temperature": 0.3, "max_tokens": 12000},
"math_animator": {"temperature": 0.4, "max_tokens": 12000},
},
+ # Settings' "test this model" probe. A reasoning model spends its budget
+ # thinking before it answers, so the 1024 that sufficed for a chat model
+ # returned an empty completion and the probe reported the model broken.
+ "diagnostics": {
+ "llm_probe": {"temperature": 0.1, "max_tokens": 4096},
+ },
}
# Per-stage budgets are seeded from the same tables the pipelines read, so a
diff --git a/tests/config/test_reasoning_probe_budget.py b/tests/config/test_reasoning_probe_budget.py
new file mode 100644
index 000000000..3a614c7cc
--- /dev/null
+++ b/tests/config/test_reasoning_probe_budget.py
@@ -0,0 +1,73 @@
+"""The Settings LLM probe's token budget.
+
+A reasoning model spends part of its budget thinking before it emits any
+content. The probe's old 1024 was enough for a chat model and not for a
+reasoning one, which answered with an empty completion — so Settings told the
+user a working model was broken. The budget lives in agents.yaml like every
+other LLM budget; the code constant is only the floor for a config that does
+not mention it.
+"""
+
+from __future__ import annotations
+
+from typing import Any
+
+import pytest
+
+from deeptutor.services.config import test_runner
+from deeptutor.services.setup.init import DEFAULT_AGENTS_SETTINGS
+
+EXPECTED_PROBE_MAX_TOKENS = 4096
+
+
+def _probe_budget(params: dict[str, Any], monkeypatch: pytest.MonkeyPatch) -> tuple[int, float]:
+ """The budget ``_test_llm`` would resolve for ``params``."""
+ monkeypatch.setattr(
+ "deeptutor.services.config.loader.get_agent_params",
+ lambda _module: params,
+ )
+ from deeptutor.services.config.loader import get_agent_params
+
+ resolved = get_agent_params("llm_probe")
+ return (
+ test_runner._coerce_int(resolved.get("max_tokens"), EXPECTED_PROBE_MAX_TOKENS),
+ test_runner._coerce_float(resolved.get("temperature"), 0.1),
+ )
+
+
+def test_a_config_that_says_nothing_gets_the_reasoning_safe_floor(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ max_tokens, temperature = _probe_budget({}, monkeypatch)
+
+ assert max_tokens == EXPECTED_PROBE_MAX_TOKENS
+ assert temperature == pytest.approx(0.1)
+
+
[email protected]("configured", [512, 2048, 32000])
+def test_agents_yaml_owns_the_probe_budget(
+ configured: int, monkeypatch: pytest.MonkeyPatch
+) -> None:
+ """The floor is a fallback, never a ceiling: agents.yaml still wins."""
+ max_tokens, _ = _probe_budget({"max_tokens": configured}, monkeypatch)
+
+ assert max_tokens == configured
+
+
[email protected]("unusable", [None, "", "lots", {}])
+def test_an_unusable_value_falls_back_instead_of_raising(
+ unusable: Any, monkeypatch: pytest.MonkeyPatch
+) -> None:
+ max_tokens, _ = _probe_budget({"max_tokens": unusable}, monkeypatch)
+
+ assert max_tokens == EXPECTED_PROBE_MAX_TOKENS
+
+
+def test_a_fresh_agents_yaml_shows_the_probe_knob() -> None:
+ """Seeded, so the number is editable in Settings rather than living only
+ in the code path a user cannot reach — and seeded to the same value the
+ fallback uses, so the two cannot drift."""
+ probe = DEFAULT_AGENTS_SETTINGS["diagnostics"]["llm_probe"]
+
+ assert probe["max_tokens"] == EXPECTED_PROBE_MAX_TOKENS
+ assert probe["temperature"] == pytest.approx(0.1)
diff --git a/tests/services/config/test_llm_probe_config.py b/tests/services/config/test_llm_probe_config.py
index 99f987019..5a13bc654 100644
--- a/tests/services/config/test_llm_probe_config.py
+++ b/tests/services/config/test_llm_probe_config.py
@@ -40,7 +40,18 @@ class TestGetAgentParamsLlmProbe:
params = get_agent_params("llm_probe")
assert params["max_tokens"] == 2048
- def test_uses_default_when_section_absent(self, tmp_path: Path, monkeypatch):
+ def test_uses_the_seeded_probe_defaults_when_the_section_is_absent(
+ self, tmp_path: Path, monkeypatch
+ ):
+ """A stale agents.yaml still gets the probe's own defaults.
+
+ `get_agent_params` falls back to `DEFAULT_AGENTS_SETTINGS` before the
+ generic 0.5/4096, so seeding `diagnostics.llm_probe` is what actually
+ sets this — the module-level constant in `test_runner` is unreachable,
+ since this function always returns both keys.
+ """
+ from deeptutor.services.setup.init import DEFAULT_AGENTS_SETTINGS
+
project_root = _write_agents_yaml(
tmp_path,
{
@@ -49,8 +60,10 @@ class TestGetAgentParamsLlmProbe:
)
monkeypatch.setattr(loader_module, "PROJECT_ROOT", project_root)
params = get_agent_params("llm_probe")
- assert params["max_tokens"] == 4096
- assert params["temperature"] == 0.5
+ seeded = DEFAULT_AGENTS_SETTINGS["diagnostics"]["llm_probe"]
+ assert params["max_tokens"] == seeded["max_tokens"] == 4096
+ # A diagnostic wants a reproducible answer, not a creative one.
+ assert params["temperature"] == seeded["temperature"] == 0.1
def test_uses_default_when_max_tokens_key_absent(self, tmp_path: Path, monkeypatch):
project_root = _write_agents_yaml(