You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Summarizer port: coerce the provider budget to a non-negative integer #16
Every completion request that leaves the core summarizer port asks the provider for a whole, non-negative number of tokens, whatever the caller computed. A leaf target that is half of an odd calibrated chunk budget, a heal target, a tiled chunk target and any future producer all arrive at the provider as integers, so a provider that validates the field strictly accepts the call instead of rejecting it and falling to the deterministic truncate.
The coercion belongs at the request boundary, not at the division sites: half a chunk is the intended target, and the provider contract is what needs enforcing. Round to nearest, clamp to at least one, and coerce a non-finite value to that same floor. The reasoning headroom is already an integer and keeps its current placement.
Acceptance criteria
A request built from a fractional budget carries an integer maxTokens at the host double, for both a reasoning and a non-reasoning model
A request built from a zero, negative, NaN or infinite budget carries the floor of one, plus headroom where it applies
A strict host double that rejects a non-integer budget, the way the provider in the report does, fails against the current code and passes after the change (red first)
An integer budget produces the same request as before the change, so existing exact-value assertions keep their meaning
No change to the ladder, the quality tiers, the metric row shapes or any config surface
vp check, bun run test, bun run typecheck and bun run pack pass
Enrichment for #16 — no duplicate found, ready with a plan.
Duplicates checked: #15 is the parent report (fractional max_tokens → 422 → truncate fallback), not a duplicate. #18 is the sibling changeset ticket for this same fix, not a duplicate. No other issue matches summarizer / provider / budget / maxTokens / coerce.
Related context: #15 (parent) holds the wire evidence (540× floating point 5543.5, expected u32 on the direct DeepSeek route, 24.5% of summaries at level 3) and the one-seam decision. #18 is blocked on this ticket and should describe the shipped behavior afterward.
Plan (seam: requestOf in packages/core/src/llm.ts:435-444, the single builder every adapter and heal path reaches):
Add a small coerceBudget helper next to requestOf: non-finite → 1, else Math.max(1, Math.round(budget)). Apply it to the caller-supplied maxTokens before adding REASONING_HEADROOM (headroom at packages/core/src/llm.ts:28 is already an integer and stays after coercion). Leave the division sites in packages/core/src/compaction-engine.ts:324,416 (leafChunkBudget / 2) untouched.
Red-first test in packages/core/test/llm.test.ts (prior art lines 88-102, doubles in test/support/fake-host.ts): a strict host double that throws on non-integer maxTokens. Drive makeLlm with budgets 1447.5, 0, -3, NaN, Infinity for both a reasoning and a non-reasoning model; assert integer maxTokens on the wire and floor-of-one plus headroom where applicable. Confirm it fails before the fix.
Keep exact-value assertions meaningful: integer budgets produce byte-identical requests as before. No ladder, quality-tier, metric-row, or config-surface changes.
Gates: vp check, bun run test, bun run typecheck, bun run pack.
The coercion is a providerBudget helper used only inside the request builder: finite values round to nearest and never below one, non-finite values take the same floor, and the reasoning headroom is added after. Neither adapter changes, because both reach this seam.
Coverage: a strict host double that rejects a non-integer budget with the provider's 422 wording, plus a boundary table across reasoning and non-reasoning models.
Activity
pullfrog commentedon Nov 6, 2026
Enrichment for #16 — no duplicate found, ready with a plan.
Duplicates checked: #15 is the parent report (fractional
max_tokens→ 422 → truncate fallback), not a duplicate. #18 is the sibling changeset ticket for this same fix, not a duplicate. No other issue matchessummarizer / provider / budget / maxTokens / coerce.Related context: #15 (parent) holds the wire evidence (540×
floating point 5543.5, expected u32on the direct DeepSeek route, 24.5% of summaries at level 3) and the one-seam decision. #18 is blocked on this ticket and should describe the shipped behavior afterward.Plan (seam:
requestOfinpackages/core/src/llm.ts:435-444, the single builder every adapter and heal path reaches):coerceBudgethelper next torequestOf: non-finite → 1, elseMath.max(1, Math.round(budget)). Apply it to the caller-suppliedmaxTokensbefore addingREASONING_HEADROOM(headroom atpackages/core/src/llm.ts:28is already an integer and stays after coercion). Leave the division sites inpackages/core/src/compaction-engine.ts:324,416(leafChunkBudget / 2) untouched.packages/core/test/llm.test.ts(prior art lines 88-102, doubles intest/support/fake-host.ts): a strict host double that throws on non-integermaxTokens. DrivemakeLlmwith budgets1447.5,0,-3,NaN,Infinityfor both a reasoning and a non-reasoning model; assert integermaxTokenson the wire and floor-of-one plus headroom where applicable. Confirm it fails before the fix.vp check,bun run test,bun run typecheck,bun run pack.muse-spark-1.3-contributor| 𝕏SutuSebastian commentedon Nov 6, 2026
Done in
0c70748onmain, not pushed yet.The coercion is a
providerBudgethelper used only inside the request builder: finite values round to nearest and never below one, non-finite values take the same floor, and the reasoning headroom is added after. Neither adapter changes, because both reach this seam.Coverage: a strict host double that rejects a non-integer budget with the provider's 422 wording, plus a boundary table across reasoning and non-reasoning models.