mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-05 17:29:36 +08:00
* fix(config): bump probe budget for reasoning models Reasoning models (o1/o3, gpt-5.x) require max_completion_tokens, and the API rejects the test-connection probe when the completion budget is too low to cover the internal reasoning pass. Bumps the default probe budget to 4096 for models that use max_completion_tokens. * fix(config): preserve probe token overrides * review: seed the probe knob, and test the thing this PR changes The raised fallback is unreachable. `get_agent_params` always returns both keys — it falls back to `DEFAULT_AGENTS_SETTINGS`, then to a generic 0.5/4096 — so `_test_llm`'s constant never decides anything and the probe has been running at 4096 all along. This PR, as written, changes nothing for anyone. What does change it is the seed, which had no `diagnostics` section at all: a fresh agents.yaml never showed the knob, and a stale one kept whatever it already said. Seeded at the same number the fallback names, because two lists of the same value is how a default and its seed drift apart (#1316). The temperature moves 0.5 -> 0.1 as a result, which is what `test_runner` always meant to ask for: a diagnostic wants a reproducible answer. `tests/config/test_reasoning_probe_budget.py` tested `uses_max_completion_tokens()`, a function this PR does not touch. It now pins the floor, that agents.yaml still wins over it, that an unusable value falls back rather than raising, and that the seed and the floor agree. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: XZH <cto@xzh.ai> Co-authored-by: Bingxi Zhao (Frank) <13051345080@163.com> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
74 lines
2.6 KiB
Python
74 lines
2.6 KiB
Python
"""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)
|
|
|
|
|
|
@pytest.mark.parametrize("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
|
|
|
|
|
|
@pytest.mark.parametrize("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)
|