Loading…
Reference in a new issue
No description provided.
Delete branch "fix/614-context-window-retry"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #614, for the failure diagnosed in #613.
What went wrong
A real prompt that
estimate_tokenssized at 27,174 tokens was counted by llama.cpp at 43,382 against a 40,960-token window, and rejected:_CHARS_PER_TOKEN = 3.4is tuned for prose. A merged transcript is not prose — every line carries[01:12:47] Name (label):plus short disfluent fragments — so the estimate ran ~1.6× under andfits_in_contextpassed a prompt the server had to refuse.The damaging half was not the rejection but what a caller did with it. Re-extracting a real session's quote board with window 1 rejected and window 2 succeeding wrote a board built only from the session's last twenty minutes — and the delete-then-reinsert had already destroyed the previous good one. A nonempty result was indistinguishable from a complete one.
What this changes
Scope: a recovery path only.
estimate_tokens,_CHARS_PER_TOKENandPROMPT_BUDGET_FRACTIONare untouched, and no call that succeeds today reaches any new code — the cache is only ever populated by a rejection. The beats pipeline that currently produces good summaries is deliberately not re-tuned.ContextWindowExceededError(RuntimeError)carryingn_ctx,n_prompt_tokens,estimated_tokensandprovider, raised from a shared helper at both the llama.cpp and Ollama non-200 sites. It parses the untruncated body — the error JSON only just fits inside the existingresp.text[:200]— and any other 400 shape still raises the original message character-for-character, which a test pins.n_prompt_tokens / estimated_tokens, cached process-wide by endpoint URL, highest ratio wins, ratios ≤ 1 ignored. Modelled on the ASR capability cache, and for the same reasons — including not keying on the API key.context_tokensis the operator's own hand-set value andllm_configis encrypted at rest, so a learned correction stays in memory; a fresh process re-learns it rather than trusting a stale number, and no operator-visible setting moves without the operator moving it.extract_highlightsnow returnsHighlightsExtraction(highlights, failed_windows), andprocess_audioskips the replace entirely when any window failed, keeping whatever was already stored. The #397 approved/hand-edited protection on the delete is unchanged.The beats retry is opt-in (
context_tokens/endpoint_urldefault toNone), so the #349 eval harness keeps its existing behaviour rather than silently changing what the evals measure.Notes from review
quotes_by_window, so_interleavegives it proportionally more of the final quote slots than an un-split window. Defensible (more text, more windows) and left as-is, but worth knowing.extraction_windows, notsplit_windows_for_extraction, andchunk_transcript_for_extraction's caller isgenerate_lore_proposals— the retry went intolore_chunk_extract, where the LLM call and therefore the rejection actually happen. Both correct as built.Verification
ruff format --checkandruff checkclean under CI's pinned 0.4.4.An autouse conftest fixture clears the new cache between tests, mirroring the existing ASR one, because endpoint URLs are reused across test files.
After merge
v4.4.1, then dev, then prod — and re-extract the affected session's quote board, which currently holds 8 rows from the partial run.
🤖 Generated with Claude Code