Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): subagents stop burning tokens on pull request watch wakes #16217

Closedt3dotgg(GitHub profile, opens in a new tab)wants to merge 4 commits intomain fromt3code/audit-delegate-token-wasteopened View on GitHub

Delegated subagents were burning huge numbers of tokens on pull request watch wakes nobody reads. Across the fleet since Oct 1, finished subagents ran about 4,000 extra times. On cup2 alone that was 3,635 extra runs and about 1.48B input tokens, against about 398M for the subagents' real work. One review subagent ran 151 times.

Two things combined:

  1. Before #14918, a subagent copied its parent's pull request links, including active watches. Every check, comment, and conflict on the parent's pull request then woke each finished subagent. Its result had already gone to the parent, so these runs reached no one. Some ran babysit-pr, and one edited code in parallel with its parent. #14918 stops new copies, but watches that subagents already hold stay active.
  2. With dozens of watches, the shared GitHub GraphQL quota ran out. Rate-limited reads counted toward the 15-minute give-up, so every watch ended with a wake that says "call watch_pull_request to watch it again". The agent re-watched into the same limit and woke again 15 minutes later. On cup2 this sent 2,388 "stopped watching" wakes to subagents in two days.

Fix:

  • Subagent threads cannot start a pull request watch. watch_pull_request returns a typed refusal whose text reaches the agent, telling it to put the pull request in its result so the parent can watch it. The orchestrator refuses the command too.
  • The watch reactor ends watches that subagents already hold on its next sweep. It does not wake the subagent and does not read the host.
  • A host rate limit no longer counts toward the 15-minute give-up. The watch waits until the limit resets.

Tests cover a rate-limited watch (stays on, no wake after 30 passes) and a subagent with an inherited watch (new watch refused, inherited one ended without a host read or wake). Both fail without the fix. The Stop test now gives its subagent an inherited watch instead of starting one, because subagents can no longer start one.

Not changed: review subagents still call link_pull_request for the pull request they review, because the runtime instructions tell every agent to link pull requests it works on. Links do not wake anyone, so this costs a few tool calls per subagent.

Reviewed with sol-loop: 2 rounds with GPT-6.1 Sol on high.

Created with Claude Opus 5.5 in Claude Code.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. juliusmarminge added labelsmacroscope-review

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at 74f80f8

      Macroscope's review found this PR approvable — This is a focused server bug fix that prevents subagents from creating or honoring pull-request watches that cannot deliver useful results, while preserving parent-thread watches and pausing cleanly through host rate limits. The production changes are narrowly scoped and covered by targeted tests, with no sensitive, schema, deployment, or static-analysis impact.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. github-actions[bot](GitHub profile, opens in a new tab)commented

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      CodexLive turn WebSocket decoded20.9 KiB20.9 KiB0 B (0.0%)29.3 KiB✅
      CodexLive turn messages220 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.2 KiB21.2 KiB0 B (0.0%)29.3 KiB✅
      ClaudeLive turn messages110 (0.0%)8✅

      Baseline: 54b6b66 · PR result: 74f80f8 · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    5. t3dotgg(GitHub profile, opens in a new tab)commented

      Note

      🤖 Claude Opus 5.5 responding on behalf of Theo

      Closing as superseded by #16208, which shipped every behavior here: subagents cannot watch, watches they inherited end without a wake, and a rate limit never ends a watch. #16208 also shares one read per pull request across watchers and slows the cadence.

      After #16208 landed, I checked whether its subagent refusal text reaches the agent. It does: for a declared tool failure, Effect's MCP server sends error.message as the tool result text (effect/dist/ai/McpServer.js, declaredFailureResult). Nothing is left to fix in this branch.

Sign in to join this conversation.