Repository navigation
fix(typesafe): shrink and retry a request Jev finds over its window, stop dropping decision answers - #5794
Merged
Conversation
…stop dropping decision answers Jev counts mixed-script text at about twice our tokenizer, so a request sized to fit by our count can come back 400 max_tokens_exceeded (#5715). In recall's TypeSafe reranker that was an HTTP 500; in the decision-model client it was logged and the answers silently left out, ranking those candidates last. - TypeSafe reranker: rank, cut, evidence sufficiency and page impact rebuild an overflowing request at half the budget (26k -> 13k -> 6.5k -> 3.25k), then raise. - Decision model: ask() splits an overflowing request in halves until one question alone is too long; ask_all() raises instead of dropping answers. - Decision reranker: caps each memory at 4k tokens so one long memory cannot overflow its question and fail the whole rerank. Fixes #5715
This was referenced Oct 20, 2026
6 tasks
This was referenced Oct 23, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5715.
Problem
We size TypeSafe requests with our own tokenizer, but Jev counts mixed-script text (emoji, CJK, Arabic, accents) at about 2× ours. A request that fits our 26k budget can come back
400 {"detail":{"error_type":"max_tokens_exceeded"}}:ask_all→ the failure was logged and those answers silently left out; the decision reranker then ranked those candidates last.Jev's tokenizer isn't published and there is no count endpoint, so we can't count exactly. Instead, recover when Jev refuses.
Fix
cross_encoder.py): rank, cut, evidence sufficiency and page impact rebuild an overflowing request at half the budget (26k → 13k → 6.5k → 3.25k), then raise.decision_model.py):ask()splits an overflowing request into halves until a single question is too long;ask_all()now raises instead of dropping answers.No long-context header and no new setting, unlike the patch proposed in the issue: that was opt-in, so the default would have stayed broken.
Verified
ask_allraising, memory cap.