fix(m0): bound context-test prompt size when tokens are under-reported
The context test re-estimated characters per token from the server's prompt_tokens after every request. A server that reports a tiny count made each next prompt grow by orders of magnitude, so the kit tests reached 8 GB and were killed by the host memory guard. Clamp the estimate to 0.5-4 characters per token. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -61,7 +61,9 @@ def test_context(r: StageResult, c: ChatClient, ctx_limit: int) -> None:
|
||||
row.update(prompt_tokens=(a["usage"] or {}).get("prompt_tokens"), ttft=a["ttft"],
|
||||
first_sentence=a["first_sentence"], total=a["total"])
|
||||
if row["prompt_tokens"]:
|
||||
chars_per_token = len(doc) / row["prompt_tokens"]
|
||||
# Clamp: a server that under-reports tokens (e.g. counts only the
|
||||
# uncached part) would otherwise make each next prompt explode.
|
||||
chars_per_token = min(max(len(doc) / row["prompt_tokens"], 0.5), 4.0)
|
||||
# Same long prefix, a new question at the end: shows prompt-cache reuse.
|
||||
msgs2 = msgs[:1] + [{"role": "user", "content": doc + "\n\n위 글에서 가장 많이 나온 낱말 하나만 말해 줘."}]
|
||||
b = c.chat(msgs2, max_tokens=24, extra=NO_THINK)
|
||||
|
||||
Reference in New Issue
Block a user