Repository navigation
feat(telemetry): route 413/stale-call estimator through shared 3.5 divisor - #26
Merged
Merged
Conversation
…visor The last char/4 holdout: estimate_request_context_tokens (the stale-call / 413 oversize detector in chat_completion_helpers.py) hardcoded 5x // 4. Routes all five sites through the shared _ceil_chars_to_tokens() helper so the single COMPOSITION_CHARS_PER_TOKEN knob (default 3.5) now governs ALL estimators — display, compression trigger, preflight, AND 413 detection. 3.5 > 4 estimates higher, the safe direction for oversize detection (fires context-tier scaling / compression sooner, never later). Empty payloads still return 0 (ceil(0)=0). Existing threshold assertions (>=/>) only get safer; fixed one stale char/4 comment. 12/12 stale-timeout tests pass, ruff clean.
🔎 Lint report:
|
ang-fleet-workers Bot
pushed a commit
that referenced
this pull request
Oct 4, 2026
Moves the floor `uses:` pin to debd27598fa6 (fleet-floor-workflows#26 merge commit). #26 keys the floor concurrency group per-ref and cancels only on pull_request; every other event (push:main backstop) gets a per-run group, so a newer push no longer cancels or replaces it. Diff old pin -> debd275 for the called workflow file: concurrency block + a caller-paths comment only. Inputs and defaults unchanged; the scanner is embedded in the workflow, so scanner bytes are identical. The other files changed since the old pin (#22-#25: python-ci/js-ci inputs, steps-mode actions, README, tests) are not called by this workflow. Card t_ca5322d9.
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.
What
Closes the last char/4 holdout.
estimate_request_context_tokens(the stale-call / 413 payload-too-large oversize detector inchat_completion_helpers.py) hardcoded 5×// 4. Routes all five sites through the shared_ceil_chars_to_tokens()helper (added in #24), so the singleCOMPOSITION_CHARS_PER_TOKENknob (default 3.5, env-tunable) now governs every estimator in the codebase:compose_request_breakdown)estimate_*_rough)estimate_request_context_tokens)Why
3.5 > 4 estimates higher, which is the safe direction for oversize detection — context-tier scaling and compression fire sooner, never later. Real Hermes payloads are JSON/code-dense (~3.5 chars/tok), so char/4 under-counted here too. Consistency: one knob, one rule, everywhere.
Safety
ceil(0) == 0).test_non_stream_stale_timeout.pyare>=/>thresholds — a higher estimate only makes them safer. 12/12 pass.# char/4comment.Tests
12/12
test_non_stream_stale_timeout.pypass; ruff clean. Behavioral check: 4000 chars → 1143 tokens (was 1000).Notes
_ceil_chars_to_tokens.