mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 13:49:40 +08:00
Merge pull request #1495 from XinyongGuo/fix/grok-large-context-window
fix(llm): treat grok as a large-context family
This commit is contained in:
@@ -21,6 +21,10 @@ KNOWN_LARGE_CONTEXT_MARKERS = (
|
||||
"deepseek",
|
||||
"moonshot",
|
||||
"kimi",
|
||||
# xAI: grok-3/4+ all ship >=128k windows; without this, an un-annotated
|
||||
# model entry falls back to 16_384 and the agentic loop snips every tool
|
||||
# result (see context_window_guard in agents/loop/pipeline.py).
|
||||
"grok",
|
||||
)
|
||||
|
||||
|
||||
|
||||
34
tests/services/llm/test_context_window.py
Normal file
34
tests/services/llm/test_context_window.py
Normal file
@@ -0,0 +1,34 @@
|
||||
"""Fallback window heuristics for un-annotated model names."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from deeptutor.services.llm.context_window import (
|
||||
DEFAULT_CONTEXT_WINDOW_FALLBACK,
|
||||
LARGE_CONTEXT_MODEL_DEFAULT,
|
||||
looks_like_large_context_model,
|
||||
resolve_effective_context_window,
|
||||
)
|
||||
|
||||
|
||||
def test_grok_is_treated_as_a_large_context_family() -> None:
|
||||
"""Un-annotated grok names must not fall back to the 16k default.
|
||||
|
||||
The agentic loop's context-window guard snips every tool result once the
|
||||
estimated history exceeds 90% of the resolved window. A 16k guess on a
|
||||
128k+ Grok model therefore empties every tool payload and the model
|
||||
re-calls the same tool forever.
|
||||
"""
|
||||
assert looks_like_large_context_model("grok-4.6") is True
|
||||
assert looks_like_large_context_model("grok-4") is True
|
||||
window = resolve_effective_context_window(model="grok-4.6")
|
||||
assert window == LARGE_CONTEXT_MODEL_DEFAULT
|
||||
assert window > DEFAULT_CONTEXT_WINDOW_FALLBACK
|
||||
|
||||
|
||||
def test_unknown_model_still_uses_the_small_fallback() -> None:
|
||||
assert looks_like_large_context_model("mystery-7b") is False
|
||||
assert resolve_effective_context_window(model="mystery-7b") == (DEFAULT_CONTEXT_WINDOW_FALLBACK)
|
||||
|
||||
|
||||
def test_explicit_catalog_window_wins_over_the_family_heuristic() -> None:
|
||||
assert resolve_effective_context_window(context_window=500_000, model="grok-4.6") == 500_000
|
||||
Reference in New Issue
Block a user