Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(studio): hold the recall reserve back only on rolling whole-docum…
…ent retries

A checkpoint fit reserves nothing for recall, and the recall right after an accepted document is already capped below the headroom line, so subtracting the reserve on checkpoint fits only refused documents that fit (at 8k the accepted prompt dropped from 4,608 to 2,560 tokens).
  • Loading branch information
Lyxot committed Nov 27, 2026
commit 5a3d57b4aae2f9343dc79ace271790217600cf4f
4 changes: 2 additions & 2 deletions studio/backend/core/inference/llama_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -42309,7 +42309,7 @@ def _count() -> None:
measured = _fit_count_tokens(
candidate, candidate_tools, _reasoning_kw
)
# Leave the compaction headroom and, when recall runs, its reserve free, also on a replay.
# The fit's own target, also on a replay: headroom, plus the recall reserve a rolling fit holds back.
budget = prompt_budget(
self._effective_context_length, _iteration_max_tokens
)
Expand All @@ -42319,7 +42319,7 @@ def _count() -> None:
)
reserve = (
_conversation_recall_reserve(thread_id)
if truncation.get("checkpoint_started", True)
if not truncation.get("checkpoint")
else 0
)
fitted_tokens = truncation["prompt_tokens_after"]
Expand Down
3 changes: 2 additions & 1 deletion studio/backend/tests/test_llama_cpp_tool_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -7736,6 +7736,7 @@ def test_a_python_call_runs_with_the_analysis_its_classification_made(monkeypatc
("rolling", None, True, 2, 0, False, "Medium document " * 25, "Medium document " * 25),
("rolling", None, True, 2, 300, False, "Medium document " * 25, "Partial passage"),
("rolling", None, True, 2, 100, False, "Medium document " * 25, "Medium document " * 25),
("checkpoint", None, True, 0, 300, False, "Medium document " * 25, "Medium document " * 25),
("checkpoint", None, True, 0, 0, False, "Large document " * 50, "Partial passage"),
("checkpoint", None, True, 0, 0, True, "Complete document", "Partial passage"),
("checkpoint", None, False, 0, 0, False, "", None),
Expand Down Expand Up @@ -7844,7 +7845,7 @@ def inject(
assert truncation["prompt_tokens_after"] == sum(
len(str(m.get("content", ""))) for m in payloads[0]["messages"]
)
if policy == "rolling":
if recall_budgets:
from core.inference.context_window import prompt_budget, retrieval_budget

prompt = truncation["prompt_tokens_after"]
Expand Down