Skip to content

release: v0.12.1 — closed children stay closed; the tree budget is gone - #119

Merged
wangtai merged 3 commits into
mainfrom
develop
Nov 13, 2026
Merged

wangtai merged 3 commits into
mainfrom
develop

Conversation

@wangtai

@wangtai wangtai commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Two runtime fixes carried since 0.12.0. No new features.

1. A closed child stays closed (fbcc10c3)

agent_close only set the in-memory handle's flag. The durable row kept its last run's status, so a later turn — which builds a fresh pool and has no handle at all — read completed and resumed a child the user had explicitly closed. _resume_from_registry already refused a closed row; nothing ever wrote one.

Observed in a live acceptance turn: agent_close returned success, then agent_send to the same id came back delivery: "resumed".

  • close writes closed before cancelling.
  • _settle_child keeps it closed rather than overwriting with the cancelled that the close-triggered cancel produces.
  • shutdown still leaves rows resumable: a turn ending is not the user giving up. A pool_gone flag separates the two.

2. The tree token budget is removed (18f7b7c1)

It answered the wrong question. Evidence:

  • It never ran in a real product. None of the three products sends budgetTokens, so the gate written to protect them had never executed.
  • When it did run, it cost more than it saved. A live turn of four sub-agents spent 934,882 tokens (~¥0.24). Hitting a limit there throws away most of that work and leaves a half-finished refactor — worse than the spend.
  • It also did not work as its own acceptance criterion claimed: a 500-token budget let a 499,898-token turn run to completion, because spend was only charged at settlement.

TreeBudget / SessionBudgetExceeded / budget.py → TreeSpend / spend.py: record(usage, agent=...) + report() -> {spent, by_agent}. No limit, no exception, no way to add one. stream.done.treeUsage is now {spent, byAgent} and always present.

budgetTokens itself is untouched — it keeps its older job of capping the parent run's own loop via BudgetLimit. So are maxParallel (orchestration_budget_exceeded) and maxRounds (budget_exhausted); neither is a token limit.

R6's per-turn bill needed no change: it reads the same usage numbers, which the counter still records.

Breaking change

TreeBudget, TreeBudgetReport, SessionBudgetExceeded were exported from steerable_agent_runtime since 0.10. Removed per the repo's pre-stable convention; the migration note is in agent-runtime/py/README.md → "Upgrading from 0.10".

Verification

  • 2612 py tests, 1646 agent-shell tests
  • tsc --noEmit clean
  • check_docs_drift / check_doc_anchors green

Made with Cursor

`agent_close` only set the in-memory handle's flag. The durable row kept the
status of the child's last run, so a later turn — which builds a fresh pool
and has no handle at all — read `completed` and resumed the child.
`_resume_from_registry` already refuses a `closed` row, but nothing ever
wrote one.

Observed in a live acceptance turn: `agent_close` returned success, then
`agent_send` to the same id came back `delivery: "resumed"`.

- `close` now writes `closed` onto the row before cancelling.
- `_settle_child` keeps it `closed` instead of overwriting it with the
  `cancelled` that the close-triggered cancel produces. That overwrite would
  have restored exactly the resumable state this fix removes.
- `shutdown` still marks handles closed, but that is the turn ending rather
  than the user giving up: those rows settle as `cancelled` and stay
  resumable. A `pool_gone` flag keeps the two apart — without it, the existing
  "interrupted by shutdown is not terminal" test fails, correctly.

Tests: close writes the row; closing a running child is not settled as
cancelled; a fresh pool still finds the row closed and unresumable.

Signed-off-by: Wang Tai <i@wangtai.me>
The tree-wide token budget is gone. It answered the wrong question: it
stopped a task partway through, left children at `budget_exhausted` waiting
for a human to click resume, and never once fired in a real product run —
`budgetTokens` is not sent by any of the three products, so the gate that
was written to protect them had never executed.

What it was costing: a live acceptance turn of four sub-agents spent
934,882 tokens (~¥0.24). Stopping that at a limit would have thrown away
most of a cent's worth of completed work and left the user with a
half-finished refactor, which is a worse outcome than the spend.

- `TreeBudget` / `SessionBudgetExceeded` / `budget.py` → `TreeSpend` /
  `spend.py`: `record(usage, agent=...)` and `report() -> {spent, by_agent}`.
  No limit field, no exception, no way to add one.
- `AgentPool(budget=...)` → `AgentPool(spend=...)`; `spawn` no longer refuses
  when the tree is "exhausted" (there is nothing to exhaust), and the
  `budgetExceeded` field on `child_completed` is gone with it.
- `stream.done.treeUsage` is now `{spent, byAgent}` and always present, since
  the figure is for display. A host cannot tell "no limit" from "spent
  nothing" any more because there is no limit to tell apart.
- `budgetTokens` keeps its older, separate job: capping the parent run's own
  loop via `BudgetLimit`. That path is untouched.

Why not fix the enforcement timing instead (charge per round so the wall
lands earlier)? Because the wall itself is the problem. A turn that runs
long had more work, not a failure; cost control belongs before a turn starts
or on a period budget, not inside one already half done.

R6's per-turn bill is the replacement surface, and it needed no change: it
reads the same usage numbers, which the tree counter still records.

Verified: 2612 py tests, 1646 agent-shell tests, tsc clean, doc gates green.
Signed-off-by: Wang Tai <i@wangtai.me>
Signed-off-by: Wang Tai <i@wangtai.me>
@wangtai
wangtai merged commit f519bd2 into main Nov 13, 2026
42 of 43 checks passed

This branch was successfully deployed

1 active deployment
pypi — 0c718bd3 Deployed Nov 16, 2026 by github-actions[bot] via publish-pypi / publish #118
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