GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Quota-aware session placement: filter by quota % and session type (root vs subsession) · Issue #566 · developing-today-forks/opencode

Quota-aware session placement: filter by quota % and session type (root vs subsession) #566

New issue
Copy link
New issue
Copy link
Closed
#2421
Closed
Quota-aware session placement: filter by quota % and session type (root vs subsession)#566
#2421
Copy link
Labels
effort/lLarge: multi-day or open-ended; expect staged check-insepic/opencode-platformEpic: opencode-platform - all issues of this effort carry itkind/featureNew feature or capability requestmeta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/normalOrdinary priority (the default)task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

Description

@dezren39
dezren39
opened on Oct 27, 2026
Issue body actions

Problem

OpenCode routes sessions to providers/models without considering how much quota is left on a pool or what kind of session is being placed. In our fleet discipline (see the provider quota registry in developing-today/code), plan quotas are meant to be used all the way to 100% and then stop — never spilling into pay-as-you-go. But the shape of usage near the limit matters:

  • A subsession (a subtask/subagent spawned inside a running session) is short and bounded. Near the limit, a pool is ideal subsession territory: the subsession can push the pool to 100% and then stop, without ever entering PAYG.
  • A root/primary session is long-lived and open-ended. Starting a new root session on a pool that is already near its limit strands that session mid-work when the quota runs out.

Today there is no way to express that distinction, so placement is quota-blind.

Desired behavior

Quota-aware placement filtering, driven by live quota percentage per pool and the session type:

  1. Subsession gate: subsessions may be placed on a pool up to 100% of its plan quota. At 100% they stop — they must never enter PAYG (configurable, default: hard stop).
  2. Root session start gate: new root/primary sessions are not started on a pool above a configurable threshold (default 85%). A root session already running on a pool may continue until the quota runs out — or stop exactly at the limit — configurable.
  3. Per-pool / per-model weights: every rule carries an adjustable weight, and every rule can be individually disabled without removing its configuration.
  4. All thresholds and behaviors are configuration, not constants: percentages, the PAYG stop, and the at-limit behavior for running root sessions are all settable per pool/provider.

Config sketch

quota:
  gates:
    rootSessionStartMaxPct: 85     # don't start new root sessions above this
    subsessionMaxPct: 100          # subsessions may burn to the limit
    subsessionAllowPayg: false     # hard stop before PAYG
    runningRootAtLimit: continue   # continue | stop-at-limit
  # each gate: { enabled: true, weight: 1.0, ... } — disable or re-weight per pool

Acceptance criteria

  • Placement decisions consult the current quota % for the candidate pool (using the existing quota sources; a stale read older than a configurable age is treated as unknown, not as headroom).
  • A subsession request against a pool at 97% is admitted; at 100% it is refused/redirected and no PAYG call is made.
  • A root session request against a pool above rootSessionStartMaxPct is redirected to the next eligible pool; a root session already running is unaffected until its configured at-limit behavior triggers.
  • Setting any gate's enabled: false restores today's quota-blind behavior for that gate, verified by test.
  • Weights change selection order among eligible pools, verified by test.
  • Behavior is covered by unit tests for: below threshold, at threshold, at 100%, PAYG-stop, disabled gate.

Context

Fleet rule (Drew, 2026-10-27): pools burn to 100%, then stop until reset or until a fresh read shows the quota has dropped off 100% (some providers reset early). Related: time-based weighting and native quota-driven reprioritization are filed as separate issues.

Activity

Next
  1. developing-today commented on Oct 27, 2026

    @developing-today
    developing-todayBot
    on Oct 27, 2026 – with developing.today
    More actions

    OPENCODE-84

  2. dezren39
    added
    kind/featureNew feature or capability request
    status/needs-triageNot yet triaged; needs a first look
    priority/normalOrdinary priority (the default)
    effort/lLarge: multi-day or open-ended; expect staged check-ins
    meta/enrichedIntake review done: acceptance criteria, links, and normalized labels added
    on Oct 27, 2026
  3. dezren39 commented on Oct 27, 2026

    @dezren39
    dezren39
    on Oct 27, 2026
    Author
    More actions

    Intake review

    Fleet monitor intake pass (protocol §5), 2026-10-27. Verified still live: no merged PR implements or resolves this issue as of this run, and no duplicate open issue covers it.

    Related: Related: companions #567 (time-based weighting) and #568 (native quota intelligence) filed in the same wave; the fleet-side counterparts live in developing-today/code epic #1334. No labels were applied at filing — this pass normalizes them. No queue label/task exists for this issue in repo-health-opencode-pilot as of this run; routing is a producer decision.

    Notes / risks / suggested approach: Risk: placement gating on stale quota reads could misroute — the criteria already require stale reads to count as unknown, not headroom. Suggested approach: share the weight model with #567 as the Context section directs.

    Labels normalized by this pass: kind/feature, status/needs-triage, priority/normal, effort/l, meta/enriched.

  4. dezren39
    added
    queue/claimedA queue worker has claimed the task for this item
    work/assignedAn agent holds this item via the queue (claimed task)
    status/in-progressActively being worked
    and removed
    status/needs-triageNot yet triaged; needs a first look
    on Oct 28, 2026
  5. dezren39 commented on Oct 28, 2026

    @dezren39
    dezren39
    on Oct 28, 2026
    Author
    More actions

    Triage verdict (task 2138, Lane B): CONFIRMED unimplemented on current main 1e28942 — and blocked on a design decision, not on evidence.

    Evidence at HEAD:

    • packages/core/src/quota-snapshot.ts (Phase 1 of design design(core): one quota signal, three consumers — shared QuotaSnapshot and weight-layer contract for #566/#567/#568 #587, landed via feat(core): QuotaSnapshot derivation with a single staleness contract (design #587, phase 1) #588) derives Snapshot {percent, remaining, resetAt, stale} — and its own header states: 'Nothing in the selection path reads snapshots yet.'
    • Selection-path quota handling in packages/core/src/model-route.ts is only reactive: per-target quota-error demotion (DEMOTED_FACTOR) and quotaCooldownMs after a provider reports exhaustion. No proactive percent-based filtering.
    • No quota-gates config exists in packages/schema/src/config/model-routes.ts, and model-route.ts / model-resolver.ts / model-governance.ts carry no root-vs-subsession (parentID / session-type) distinction.

    Blocker: #566 is Phase 3 of design #587, whose first acceptance criterion is a recorded decision — adopt the shared QuotaSnapshot contract (gates filter before weighting; controller writes only through the tuner Adjustment channel) or keep #566/#567/#568 independent. That decision is not recorded on #587 yet (it sits in user/review). Per #587's phased plan, Phase 3 re-scopes #566 itself once the decision lands — #566 is the vehicle — so no separate small_fix packet is enqueued; a packet filed now would presuppose the undecided contract.

    Recommendation (for the #587 decision): adopt the shared contract. Phase 1 already landed on that basis (#588 merged: snapshot + single staleness contract) and per-layer weight attribution exists in the route-review surface; rejecting now would orphan that landed work and return to three incompatible config sketches.

  6. dezren39
    added
    status/blockedBlocked on something named in the issue/PR
    and removed
    status/in-progressActively being worked
    queue/claimedA queue worker has claimed the task for this item
    on Oct 28, 2026
  7. 86 remaining items

  8. dezren39
    added
    status/parkedDeliberately paused with a recorded resume condition
    and removed
    queue/claimedA queue worker has claimed the task for this item
    on Nov 15, 2026
  9. dezren39 commented on Nov 15, 2026

    @dezren39
    dezren39
    on Nov 15, 2026
    Author
    More actions

    agent-note:v1
    state: picked-up
    task: 16332
    lane: any-a (repo-worker-code)

    Resuming task 16332 (#566 quota-aware session placement) from checkpoint stage pr_opened. Fresh state: issue #566 OPEN, no hold labels. Slice 1 (root-start predicate + rootStartMaxPct config) already landed via PR #2421 (merged 2026-11-14). Slice 2 is PR #2464 (branch queue/16332-566-slice2-placement, head 903f446, +260/-6 across 7 files, MERGEABLE) — this shift shepherds it: disposition the CodeRabbit review (commented 2026-11-15T07:33Z), run the packages/core targeted suites on the branch, fix valid findings, and merge under the standing criteria. The preserved fb566 worktree's uncommitted slice-1 files are being checked against merged PR #2421 before anything is discarded or reused.

  10. dezren39
    added
    queue/claimedA queue worker has claimed the task for this item
    status/in-progressActively being worked
    and removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Nov 15, 2026
  11. dezren39
    added 2 commits that reference this issue on Nov 15, 2026

    fix(core): root-start gate re-derives snapshot staleness at judgement…

    e6986dd

    Merge pull request #2464 from developing-today-forks/queue/16332-566-…

    d35c434
  12. dezren39 commented on Nov 15, 2026

    @dezren39
    dezren39
    on Nov 15, 2026
    Author
    More actions

    agent-note:v1
    state: done
    task: 16332
    lane: any-a (repo-worker-code)
    outcome: fixed_merged — PR #2464 MERGED (merge commit d35c434, 2026-11-15T08:44:48Z). Issue #566 CLOSED by this note: with slice 1 (PR #2421, root-start predicate + rootStartMaxPct config, merged 2026-11-14) the packet's remainder is fully landed.

    What slice 2 (PR #2464, head e6986dd) adds: root vs subsession placement wiring — sessionKind from session parentID; credentialRootStartBlocked / providerRootStartBlocked / rootStartBlocked judged by QuotaSnapshot.blocksRootStart with the configured rootStartMaxPct (default 85) and the rootStartEnabled switch; subsessions ride the existing known-full gate to 100% as their hard PAYG stop; per-gate enabled/weight config in the model-routes schema.

    This shift additionally fixed the one CodeRabbit finding on PR #2464 (Major, thread 4577525271): the root-start wrappers judged the retained snapshot's derivation-time stale flag, so a retained 90% snapshot with resetAt null would have walled root starts indefinitely. Both wrappers now re-derive staleness from observedAt against QuotaSnapshot.DEFAULT_MAX_AGE_MS at judgement time (judgedSnapshot helper), with regression tests for both scopes; CodeRabbit's re-check raced the push and examined the old head — the correction is recorded on thread 4577702332 at head e6986dd.

    Verification on merged main (primary clone at d35c434): model-route-root-start + model-route + model-resolver + quota-snapshot = 312 pass / 0 fail. bunx tsc --noEmit in packages/core clean. Push note: husky pre-push (turbo typecheck) fails on the pre-existing clean-main breakage in test/session-step.test.ts tracked as #2442 (verified identical on main), so the fix commit was pushed with HUSKY=0, recorded on PR #2464.

    Left untouched, named for the record: the preserved worktree ~/git/fleet/fb566-566-root-start still holds uncommitted slice-1 files (model-route.ts, quota-snapshot.ts, model-routes.ts) that duplicate what PR #2421 merged — not discarded (not this lane's dirt to delete). The queue-16332-566-slice2 worktree carries unrelated uncommitted whats-new changes (packages/app e2e + gui-extensions updater, +13) from an earlier session — also left exactly as found.

  13. dezren39
    closed this as completedon Nov 15, 2026
  14. dezren39
    removed
    status/in-progressActively being worked
    queue/claimedA queue worker has claimed the task for this item
    work/assignedAn agent holds this item via the queue (claimed task)
    on Nov 15, 2026
  15. dezren39
    added a commit that references this issue on Nov 17, 2026

    Merge pull request #2624 from developing-today-forks/queue/20743-2622…

    7399577
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lLarge: multi-day or open-ended; expect staged check-insepic/opencode-platformEpic: opencode-platform - all issues of this effort carry itkind/featureNew feature or capability requestmeta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/normalOrdinary priority (the default)task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.