Skip to content

gstack-runaway prices each wake and marks it cold or warm (GST-2770) - #4385

Merged
capy-ai[bot] merged 5 commits into
mainfrom
price-runaway-wakes
Nov 17, 2026
Merged

capy-ai[bot] merged 5 commits into
mainfrom
price-runaway-wakes

Conversation

@garrytan

@garrytan garrytan commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

gstack-runaway now says what a thread's quiet and wasted wakes cost, not just how many there were: each wake is marked cold or warm and priced, and the scan reports cold starts' and empty wakes' share of spend.
Why: most of a busy coordinating agent's spend goes on wakes after the 5-minute prompt cache lapsed, and nothing showed that without a hand count.
Nothing to do: the tool stays read-only, and no threshold changed.

Agent notes

What changed

  • lib/runaway.ts: wakes() returns one record per wake (start, idle seconds, cold, calls, cold calls, empty, cost in warm calls). A cold call costs COLD_CALL_PRICE = 19.4 warm calls (Opus 5.5, measured 2026-11-08: $2.42 against $0.125 per million counted tokens). A wake is cold when it starts more than CACHE_TTL_S (300 s) after the thread's previous model call; any later call issued more than 300 s after the model call before it (the call after a long tool) is also priced cold, and a cold wake's first call is counted once. More than 300 s idle before a call inside a turn, less that call's own run time, starts a new wake (platform wakes leave no transcript item).
  • The RUNAWAY line adds wakes cold_wakes empty_wakes cold_extra_spend empty_spend; the empty-wake WARN adds the empty wakes' share of spend; scan --wakes prints a WAKE line per wake.
  • Behavior change: a message_agent send to another thread (it names a non-null to) is action even with state "working". Before, it counted as an empty wake, which put coordinating threads' empty share 4 to 12 points high. A report to the parent with an explicit "to": null stays a report.
  • /runaway-stopper fetch keeps each message's target (with a fallback on the item's target text when the input is cut short) and each call's run time. Its context-budget ceiling alone moves 3841 → 4328 (fresh capture value).

Measure: priced meter against the 2026-11-08 hand count, four coordinating agent threads, 2026-11-03T20:45Z to 2026-11-08T14:01:54Z, read-only transcripts:

Thread Wakes (meter/hand) Cold share Empty share Old counter's empty share Cold extra, % of spend Empty wakes, % of spend
A 828 / 821 40.0% / 41.0% 34.9% / 34.1% 46.1% 76.5% / 75.2% 22.4% / 22.0%
B 888 / 864 38.5% / 38.1% 36.7% / 36.3% 46.1% 76.8% / 75.2% 29.5% / 30.1%
C 1219 / 1189 21.2% / 21.6% 41.8% / 43.1% 52.8% 63.5% / 60.9% 21.7% / 21.7%
D 945 / 944 38.9% / 38.0% 29.7% / 30.9% 35.0% 72.6% / 71.1% 20.0% / 20.4%

Recounted with the meter as shipped at 97aa5e6; cold and empty shares within 1.3 points of the hand count.

Residual: the hand count's own turn-splitting script isn't readable from here, so the last points are unexplained, not fixed. The hand count's spend shares were themselves modelled from the same ratio.

Checks run locally: bun test test/runaway.test.ts (24 pass, 140 expect calls; the two changed tests fail on the pre-fix code), typecheck, test-typecheck ratchet, module-size ratchet, gen-skill-docs freshness, parity suite, context-budget ratchet, host-config goldens and the skill-size guards.

Plan: lean /autoplan, one reviewer: 1 High (a wrong "9 to 12" figure, corrected to 4 to 12), 3 Medium and 4 Low, all fixed or documented; gate answered rec.

Approvals

Approved: yes (record r-8a52294c3a83). The full approval record stays private.
Plan: approved (record r-787b1ecf5c01)
Plan check: approved (record r-787b1ecf5c01)

Pre-Landing Review

Pass 1 at 1dc33b7 (full panel: batched testing/security/state-machines specialist, red-team, targeted money reader, Claude adversarial pass, second-model review on GPT-6.1 Sol): 10 findings, 3 marked blocking by the second-model review, 0 by the others; the targeted money reader found nothing. One fix round (7c57510) fixed 4: a "to": null report counted as a send, cache expiry after a long tool charged to the wrong call, and a cold wake's first call counted twice. Pass 2 on the fix range (specialist, red-team, targeted money reader): 0 blocking, 2 notes.

REVIEW_LOOP: passes=2 blocking_found=3 deferred=0 noted=6 fixed=4 scope=frozen ledgers_read=3 dispatches=5 est_input_tokens=21036
Gate edits: none detected (5 listed, 3 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)

Second-model review (GPT-6.1 Sol): FINDINGS, 3 marked blocking; 2 fixed, 1 left open below.

Open note: lib/runaway.ts:81 sums the run times of an execute program's parallel calls, so overlapping calls can overstate run time and understate idle time (second-model review finding 2, also adversarial note 2). Left unfixed after the second round; the recount above at 97aa5e6 shows the published shares hold with it in place.

Review notes

Below the blocking floor (advisory, informational, test-gap or wording items); recorded here and not fixed in this PR.

  • INFORMATIONAL lib/runaway.ts:123 a sleep inside an execute program past 300 s splits one turn and can add an empty wake
  • INFORMATIONAL lib/runaway.ts:81 summing parallel call durations can push idle below zero and hide idle time
  • INFORMATIONAL lib/runaway.ts:118 two inbound messages with no tool call between them share the first one's start and warm flag
  • INFORMATIONAL lib/runaway.ts:78 the cut-short send fallback rests on an unconfirmed transcript text field for reports to the parent
  • INFORMATIONAL lib/runaway.ts:78 the cut-short fallback in addressed() and its template copy can count a long report to the parent as a send
  • INFORMATIONAL lib/runaway.ts:296 gstack-runaway --help still says a wake is cold after the thread's previous item; the code now measures from the previous model call

Exploratory QA

One functional probe on bin/gstack-runaway scan --wakes with a synthetic two-wake fixture: a wake after 600 s quiet reads cache=cold cold_calls=1 cost=20.4 and the RUNAWAY line carries the wake and spend shares. Verdict: pass (1 capture).

Documentation

Status: updated, with one factual correction to docs/skills.md and no blockers.

Scope: 18652ccc..7c57510 on price-runaway-wakes (4 commits, 7 files: lib/runaway.ts, test/runaway.test.ts, runaway-stopper/SKILL.md(.tmpl), docs/skills.md, changelog.d/price-runaway-wakes.md, test/fixtures/context-budget.json). There were no uncommitted or new files.

Documentation health:

  • docs/skills.md: Updated. cold_extra_spend and empty_spend are now described as shares of spend, and cold_extra_spend now includes calls made after a tool that ran past 5 minutes.
  • runaway-stopper/SKILL.md.tmpl: Current. It says only cold starts count toward cold_extra_spend. That is close enough, so I left it unedited.
  • changelog.d/price-runaway-wakes.md: Current. It matches the code and was not edited.
  • README.md, AGENTS.md: Current. The skill list is unchanged.

Coverage debt: The new scan --wakes flag and the WAKE: line have reference coverage in docs/skills.md, the skill template and the CLI usage text, but no how-to example. COLD_CALL_PRICE is documented only in a code comment and the changelog.

Diagram drift: none.

Test plan

  • bun run test: free suite at 97aa5e6 from CI run 44058599585 (1672 files); macOS named regressions from the same run, Windows smoke from run 44049762314.

Open in Capy

Agent notes
{
  "schema_version": 1,
  "pr": 4385,
  "head": "97aa5e6fdb18f93f0e951786cedc9f3867a34c57",
  "version": "1.99.5.0",
  "base": "main",
  "gate": {
    "test": {
      "pass": 1672,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "test",
      "run": 44058599585,
      "attempt": 1,
      "tree": "84512d1164e93ab93d60037f4042aab56f2868e0"
    }
  ],
  "session_kind": "unattended",
  "head_tree": "84512d1164e93ab93d60037f4042aab56f2868e0",
  "product_patch_id": "69aa83088ac26b36b0a229398596d7dfb5129cf0",
  "gstack_version": "1.99.5.0",
  "review_depth": {
    "depth": "full",
    "class": "code",
    "runtime_lines": 120,
    "rules": "66e5174161eecc2c",
    "base": "18652ccc159970db44a038e71840d7bf6f252209",
    "registry": "18652ccc159970db44a038e71840d7bf6f252209",
    "gate_scan": {
      "tagged": 0,
      "head": "97aa5e6fdb18f93f0e951786cedc9f3867a34c57"
    },
    "reasons": [
      "risk:money",
      "runtime=120"
    ],
    "risk": [
      "money"
    ],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @84512d1164e9 (8 checks, current for 97aa5e6fdb18)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/44058599585/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/44049762314/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=84512d1164e9 tests=37343 skipped=105 runs=44058599585/1 profiles=ci-reuse/free-tests heads=97aa5e6fdb18 verified=2026-11-17T11:20:59.905Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "updated",
    "scope": "docs/, README.md, AGENTS.md, CLAUDE.md and runaway-stopper/SKILL.md.tmpl against 18652ccc..HEAD"
  },
  "review_loop": {
    "passes": 2,
    "blocking_found": 3,
    "deferred": 0,
    "noted": 6,
    "fixed": 4,
    "scope": "frozen",
    "rounds": 2,
    "est_input_tokens": 21036,
    "ledgers_read": 3,
    "dispatches": {
      "specialist-batched": 2,
      "red-team": 2,
      "targeted": 1
    }
  },
  "gate_dispositions": [],
  "review_targeted": {
    "classes": [
      "money"
    ],
    "rules": "8811fd300bf305f0",
    "brief_sha": "7f92a0d0a8319c3c0e076fb3b1a4689c45120b2be2c14dfc7d4cb03aafa9d6a5",
    "product_patch_id": "69aa83088ac26b36b0a229398596d7dfb5129cf0",
    "status": "done",
    "findings": 0,
    "raised_by": "targeted"
  }
}

Each wake read is priced in warm model calls, with a cold call (after the 5-minute prompt cache lapsed) at 19.4. The scan line reports cold and empty wakes' share of spend, and scan --wakes lists each wake. A message sent to another thread now counts as action.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@trunk-io

trunk-io Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

@capy-ai
capy-ai Bot marked this pull request as ready for review November 15, 2026 06:00
garrytan and others added 4 commits November 17, 2026 08:20
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

# Conflicts:
#	test/fixtures/context-budget.json
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…nd ignores a null message target

A cold wake no longer counts its first call twice, a call issued more than 5 minutes after the previous model call is cold whether or not an inbound item was recorded, and a report to the parent with an explicit null target stays a report.

Review-Finding: p1/outside-voice#1 reader=outside-voice
Review-Finding: p1/outside-voice#3 reader=outside-voice
Review-Finding: p1/red-team#1 reader=red-team
Review-Finding: p1/red-team#2 reader=red-team
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…of spend in docs/skills.md

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai
capy-ai Bot merged commit 800a926 into main Nov 17, 2026
77 checks passed
@garrytan garrytan mentioned this pull request Nov 17, 2026
capy-ai Bot added a commit that referenced this pull request Nov 17, 2026
- /autoplan's approval page no longer hides a reviewer's product objection behind "keep your direction". (#4431)
- Every skill that loads the shared preamble, on every host, now says to ask a question once and to check a file before handing it over. (#4383)
- The Captain manuals now name the `Failed or skipped:` and `Also changed:` lines that READY and lane reports carry. (#4432)
- gstack's shell locks hold again on Ubuntu 26.04, where `mkdir` reports success when another process won the race (GST-2247). (#4262)
- `test/gstack-lock-race.test.ts` runs the old pattern and the helper against a PATH shim that behaves like uutils 0.8.0 `mkdir`, so it runs on any runner image: the old pattern lets two of four racers win, the helper admits exactly one in each of 60 races and never overlaps across take, hold and release loops, and parallel `gstack-config` writers keep every key. (#4262)
- Windows Setup E2E now runs when `bin/gstack-lock.sh` changes. (#4433)
- Claude Code's skill list now says when to use each gstack skill, so Opus loads /review and /plan-eng-review when a request fits. (#4387)
- A pull request's merge head can no longer keep its `/ship` receipt without a full review. (#4365)
- `/ship` now counts review rounds per pull request, and the head that merges always gets a full review. (#4360)
- /ship's documentation audit no longer accepts a passing result when an earlier line from the same audit said "blocked". (#4434)
- /ship's documentation audit no longer spends an attempt when the audit child writes text after its result. (#4285)
- The README lists the two new guides, and the install doc counts its hooks right. (#4403)
- docs/releases.md now says the stable release cut treats a failed commit status as red and a pending one as still going, as it has since #4257. (#4436)
- /ship's `finish --docs-requested` now accepts a docs fix when the audit named the file with a line number. (#4437)
- Document the `.gstack/approval-classes.json` schema, `gstack-approval-classes` CLI commands, and owner approval citation format in `docs/ship-policy.md#approval-classes`. (#4355)
- `/eval-plan` now runs four result checks instead of leaving them to judgment. (#4384)
- The /review coverage-audit eval no longer fails a run that really read the source file when zsh stops a command line at an `echo ====` separator. (#4364)
- Sixteen in-repo documentation links reach their section again. (#4394)
- gstack agents now open every status report with what failed, what they didn't verify and what else they changed. (#4273)
- Two new short guides. (#4380)
- A skill you wrote whose contract still lists `check_after_last_edit` keeps the rest of its contract. (#4439)
- The ship policy guide now explains how to merge any pull request with `gstack-ship-queue land`, even in a repository with one maintainer. (#4377)
- /ship's test step runs a large unit suite on Linux. (#4426)
- Every skill that loads the shared preamble, on every host, now says never to print a whole environment, git config or process table. (#4382)
- Pull requests from /ship now open with at most three plain lines, and every merge lands as one commit titled with the PR title. (#4438)
- `gstack-pr-wait`, `gstack-ci-gate` and the release cut no longer call a commit green while a check on it failed. (#4257)
- `gstack-runaway` now says what a thread's cold and empty wakes cost, not just how many there were (GST-2770). (#4385)
- The optional Stop hook no longer checks for a test run after the last edit, and /verify asks for it in plain words instead. (#4428)
- /ship's test step says when it ran out of time, and you can set its budget. (#4429)
- The remote test command no longer puts every file on one command line. (#4429)
- The stable release no longer waits on the nightly Windows tests (GST-2815). (#4400)
- Ubicloud fan-outs can no longer overshoot the vCPU limit, and owners no longer delete each other's VMs. (#4430)
- hono is pinned to 4.13.16, which fixes five advisories the weekly OSV scan found in 4.13.13 (gstack#4406). (#4408)
- `package.json` overrides (#4408)
- `test/dependency-security.test.ts`: the lockfile floor check now covers `hono >= 4.13.16`. (#4408)
- The nightly Windows test run finishes again. (#4409)
- A short write-up checklist in ETHOS.md. (#4381)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant