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
[C-9399-D1-S3] enforce strictest per-tier token limits before dispatch #20060
effort/mMedium: expected under 1 day of workkind/featureNew feature or capability requestmeta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/normalOrdinary priority (the default)status/needs-triageNot yet triaged; needs a first looktask/feature-sliceQueue packet kind: bounded vertical feature slice
At the OpenCode route boundary, compute effective {input, output, cache, total} token limits independently per resolved member and tier. Each limit is a positive integer or null (unknown; not zero or unlimited). Use the minimum positive known bound for each metric across provider/model native limits, provider/door policy caps, leaf/target caps, referenced pool/tier caps, and selected pool/tier caps. Use the existing requestTokens?: number route-resolution argument as the known total/legacy-context request size (context caps map to D1 total). Build the pre-dispatch comparison shape {input, output, cache, total}: use other positive request counts only if the existing route request path explicitly supplies them; otherwise leave those fields null. Provider usage returned after the call cannot gate that same call. Unknown sizes do not skip on that metric. Do not add a tokenizer or guess counts. Skip a member with typed tier-limit-exceeded before provider dispatch when any known request size exceeds its effective cap; this route-level skip is distinct from an upstream provider/account limit failure.
Read first
D1 effort-tier design in draft PR #19550, especially §§7–8 and §10; §8.1 enumerates cap sources and strictest-wins aggregation, §8.2 defines null/validation/request behavior.
Write the property test first using generated cap sets and explicit request-size vectors: adding or tightening any applicable cap can never increase that metric’s effective limit. For each input/output/cache/total metric, test independent minimum selection across the cap sources above; null/unknown behavior; rejection of zero/negative caps and cache > input when both are known; preservation of null when no bound exists; and an over-limit explicit pre-dispatch count skipped as route-level tier-limit-exceeded before any provider call, distinct from an upstream provider/account limit failure. The existing requestTokens value drives total; input/output/cache stay null unless supplied on the pre-dispatch request path. Post-call provider usage is not a request-size source. Missing counts, including cache counts known only after dispatch, remain unknown and do not cause a skip. No tokenizer or token-accounting feature is in scope. For a cross-pool reference, the effective limit is the minimum of the referenced effective limit and the receiving tier cap.
Done check:cd packages/core && bun run test test/model-route-tier-limits.test.ts
Use a property-based test oracle: each metric equals the minimum positive known applicable cap; unknown adds no numeric bound and the result remains null if all sources are unknown. Adding a stricter cap cannot increase the result. Pre-dispatch comparison consumes only explicit positive counts from the existing route request; absent counts are unknown, and this slice adds no tokenizer.
Dependencies and boundaries
Blocked by D1-S2 (#20059); do not start until that implementation is merged. Consume its ordered resolved leaves, each identified by provider/door, model, and exact native variant, with the selected tier and any referenced pool/tier caps and source provenance. The code-level TypeScript type is the one D1-S2 actually exports; adapt to it after merge rather than inventing a parallel resolved-member shape.
Use the existing requestTokens parameter as total; other dimensions are positive only when already supplied before dispatch, otherwise null. Provider usage cannot gate the completed call. No tokenizer is added. Do not introduce provider-specific empirical limits or tier rankings here.
At the OpenCode route boundary, effective {input, output, cache, total} token limits are computed independently per resolved member and tier.
Each limit is the minimum positive known bound across provider/model native limits, provider/door policy caps, leaf/target caps, and referenced + selected pool/tier caps; unknown limits stay null (never zero/unlimited).
The pre-dispatch comparison uses the existing requestTokens argument as the known total; other request counts are used only when the route path explicitly supplies them, else null.
Tests cover per-tier strictest-limit selection, null/unknown handling, and dispatch rejection when a known limit is exceeded.
Expectation: [C-9399-D1-S3] enforce strictest per-tier token limits before dispatch
Links: parent/related items are named in the notes below.
Notes: Parent program issue #9399 (D1-S3 slice). Labels already kind/feature, priority/normal, effort/m; monitor added status/needs-triage + meta/enriched and appended acceptance criteria from the body's Goal section.
Risks / suggested approach: Depends on the D1-S1 resolver contract (issue #20058) landing first, per the D1 slice map; a queued slice task for sibling D1-S2 (issue #20059, task 27592) is dep-blocked on the same contract. No merged PR explicitly resolves this issue as of this run.
effort/mMedium: expected under 1 day of workkind/featureNew feature or capability requestmeta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/normalOrdinary priority (the default)status/needs-triageNot yet triaged; needs a first looktask/feature-sliceQueue packet kind: bounded vertical feature slice
Activity
developing-today-fleet commentedon Dec 5, 2026
Intake review
🤖 Agent note · filed
Notes: Parent program issue #9399 (D1-S3 slice). Labels already kind/feature, priority/normal, effort/m; monitor added status/needs-triage + meta/enriched and appended acceptance criteria from the body's Goal section.
Risks / suggested approach: Depends on the D1-S1 resolver contract (issue #20058) landing first, per the D1 slice map; a queued slice task for sibling D1-S2 (issue #20059, task 27592) is dep-blocked on the same contract. No merged PR explicitly resolves this issue as of this run.