agent-orchestrator icon indicating copy to clipboard operation
agent-orchestrator copied to clipboard

[Feature]: Stagger parallel sessions so they don't all burn through the usage limit at once

Open rhithesh opened this issue 2 weeks ago • 2 comments

Problem

Relayed community report from NNTin (their words, lightly trimmed; their original post included a usage chart that is not attached here):

I updated my agent orchestrator and let it work on a feature. However I get usage limited so fast and the feature I implement should definitely be possible within the weekly usage limit (I guess < ~50%). But instead I've now used 150%+ of the weekly usage limit and it is still going...

I have a suspicion it is because I told let a "master" orchestrator talk to the orchestrator of 2 separate git repos and therefore have too many parallel sessions.

You can see that previously my usage was gradually approaching the limit but now it just jumps towards the limit. Previously my work flow was to work on 1 session at the time and there I could use my tokens much more efficiently.

Because I get usage limited so fast the "thinking" gets lost as well. So it will start the thinking again, may make mistakes because it didn't know what it did before and in general waste thinking tokens.

We are seeing the same thing: running several AO sessions in parallel uses up the usage limit far faster than working in one session at a time.

Proposed direction

From the reporter:

Is it possible to "stagger" the ao sessions so we don't have multiple rate limited usage session at the same time? Once a session is done another session can be continued. This way we can ensure that only 1 session gets usage limited and not e.g. 5 parallel sessions.

Before submitting

  • [x] I searched existing issues / discussions for something similar
  • [ ] I am willing to help implement this if maintainers agree on scope

rhithesh avatar Nov 14 '26 08:11 rhithesh

Agent-collected evidence

Collected by a coding agent on 2026-11-14 against OrchestratorInc/agent-orchestrator main @ db74eaec3a, by reading source only. This was not reproduced, and no logs from the reporter's run were examined. Everything below the code excerpts is a hypothesis.

What the code shows

  1. No cap on active sessions. Searching backend/ for a concurrency or queue limit on sessions finds none. The only limits found are internal: maxConcurrentVersionMoves = 4 (backend/internal/session_manager/version_refresh.go) and the auto-resume pool below.
  2. Usage-limit auto-resume runs up to 4 sessions at once. backend/internal/service/chat/usage_limit.go:23:
    // Bound provider processes and wakes without making one session block another.
    const usageLimitAutoResumeWorkers = 4
    
    Auto-resume is armed per failed turn (SetTurnAutoResume), so this applies only to turns the user opted in.
  3. Orchestrators are told to monitor workers, and workers are told not to report routinely.
    • backend/internal/session_manager/prompt.go:290 (orchestrator role): 5. Monitor worker output, PR state, CI, and reviews.
    • backend/internal/session_manager/prompt.go:433 (worker role): Message it only for true blockers, cross-session coordination, or decisions you cannot resolve locally
    • I did not find a daemon path that wakes the orchestrator when a worker finishes. The reactions in backend/internal/lifecycle/reactions.go that I checked target the worker. This search was not exhaustive.

Hypothesis: where the extra usage comes from

Each orchestrator layer is a separate conversation, and every one of its turns re-sends its whole context.

flowchart TD
    U[User] --> M["Master orchestrator"]
    M -- "ao send" --> OA["Repo A orchestrator"]
    M -- "ao send" --> OB["Repo B orchestrator"]
    OA --> W1[Worker] & W2[Worker]
    OB --> W3[Worker] & W4[Worker]
  • Status checks. With no completion signal, an orchestrator that follows "monitor workers" can only check repeatedly (ao status, ao session get). Each check is a full-context turn. Illustration, not measured: a 150k-token orchestrator checking every 2 minutes for an hour sends about 4.5M input tokens and writes no code. A master orchestrator over 2 orchestrators adds a second layer of this.
  • Everything hits the limit together. Parallel sessions hit the limit within minutes of each other. Turns cut off mid-way lose their output and reasoning, and the agent redoes the work. This matches the reporter's "the thinking gets lost".
  • Resuming re-pays the cache. A session that waits hours for a reset has lost its prompt cache, which lasts about 5 minutes to 1 hour. Its first turn afterwards re-writes the whole context at the cache-write price. With up to 4 sessions resuming at once, plus orchestrators waking, they all use up the new window together. This would explain the step-like jumps the reporter describes instead of a gradual climb.
flowchart LR
    A["Many sessions run at once"] --> B["All hit the limit together"]
    B --> C["Cut-off turns lose work and reasoning"]
    B --> D["Hours of waiting: prompt cache expires"]
    D --> E["Reset: up to 4 auto-resume at once"]
    E --> F["Each re-writes its full context"]
    C --> A
    F --> A

Similar reports elsewhere (T3 Code)

  • pingdotgg/t3code#30006 (open): a parent agent waiting on a subagent with delegate_task mode: "wait" woke about every 30 seconds and re-sent its ~200k context each time. The reporter measured about 19M input tokens over about 12 minutes.
  • pingdotgg/t3code#7338, tracked in #24649 (closed): the Claude 5-hour meter charged Agent SDK traffic about 1.6–1.7× more than the interactive CLI for the same tokens, upstream anthropics/claude-code#97074. That issue reports the weekly limit was not affected. AO's chat mode also runs Claude through the Agent SDK (claude-agent-acp), so this may affect 5-hour usage in AO, but it does not explain a weekly overrun.
  • A comment on pingdotgg/t3code#7338 traced cache rewrites on --resume: Claude Code places git status output in the cached prompt prefix, so a status change between spawns re-bills everything after it as cache writes (anthropics/claude-code#78720).

Related AO issues

The duplicate search used terms including stagger, concurrent sessions limit, queue, max active sessions, orchestrator polling and usage limit parallel.

  • #3921: no concurrency cap, framed around memory and crashes under load.
  • #6035 (closed): policy surface for orchestrator actions, including spawn caps.
  • #7793: usage readings ignore 429/Retry-After, and the per-session rate_limit_event is dropped.

I found no existing issue about parallel sessions using up subscription limits.

rhithesh avatar Nov 14 '26 08:11 rhithesh

Agent-collected evidence — measured reporter run

I investigated the affected installation's native Claude JSONLs and AO usage/report rows. There is a concrete link to existing bug #7606 and open PR #6387 that is worth considering alongside staggering.

On 2026-11-14, account session utilization rose 34% → 81% between 08:16:50 and 08:26:50 UTC, about 47 minutes after the account window reset. That interval contains 96 successful responses / 19.18M raw tokens: 18.21M cache reads, 916,982 cache writes, 199 other input and 57,099 output. Raw totals are not subscription-quota weights.

One Terminal-mode Claude orchestrator received the same report batch nine times. AO recorded 12 delivery attempts for each of the three report rows in that batch. The first eight recorded submissions began with <pasted_content>; the ninth began with the AO report tag and was acknowledged 283 ms later. Seven repeat-only status cycles used 14 responses / 4.67M raw tokens, mostly repeatedly reading a 322k–343k-token context. Useful merge/dispatch work in the other report-driven cycles was excluded from that redundant subtotal.

Another worker began a new follow-up task inside a 359-message / 463,550-input-token conversation, writing 452,997 tokens back into cache. It then made 11 responses during the jump, totaling 5.21M raw tokens. New deployment work and two reviewer conversations also ran concurrently. No compaction-boundary records appeared in these active transcripts.

This supports treating three mechanisms separately: duplicate delivery, retained history at task boundaries, and concurrency/scheduling. Staggering could reduce the burst but would not remove duplicate wakes or oversized histories. The observed report-delivery path also means the repeated checks cannot be attributed solely to missing completion notifications.

Affected daemon: AO 0.14.10, built 2026-11-08T13:42:45Z, Docker/Linux amd64. Captured Claude records: 2.1.311, model claude-opus-5-5. The receiver used native CLI/TUI; other active sessions included SDK chat and CLI reviews. All 207 AO-tracked responses in the full two-hour snapshot matched AO's usage-event counters; two small background title responses are additional.

Sanitized evidence and offline replay (download ZIP) include nine redacted prompt fixtures, a per-response token ledger and an isolated Go replay using public release parser code plus PR #6387 normalization helpers. It confirms eight baseline recognition misses and recognition of all nine after candidate normalization. This is a payload-level replay, not a full daemon/provider reproduction or a test of the entire PR. It also checks preservation of a trailing human instruction. No live sessions were messaged or modified.

The public SDK-metering and resume-cache reports remain separate possibilities; this run does not measure their quota multipliers or prove git-status-induced cache invalidation. This adds a measured occurrence and replay fixtures for #7606 / #6387; #8385 can remain focused on scheduling.

NNTin avatar Nov 14 '26 11:11 NNTin