ZeroClaw

ZeroClaw peer-agent turns can spend past budgets without recording the cost

A ZeroClaw report finds detached peer delivery starting the recipient turn without a cost-tracking context. Spend rows, budget checks, token totals, and cost_usd all disappear on that path even though gateway-originated turns account correctly.

← Back to homeOriginal source ↗

zeroclaw-labs/zeroclaw issue #9373 is the inspected primary source: “[Bug]: peer-agent delivery runs the recipient turn with no cost-tracking context, so spend is unrecorded and budgets are unenforced.” Issue #9373 traces the gap to send_message_to_peer spawning process_message in a detached Tokio task. The project’s spawn wrapper carries a tracing span but no task-local state, and process_message does not install a fresh ToolLoopCostTrackingContext. Downstream record_tool_loop_cost_usage returns None, check_tool_loop_budget returns None, and AgentEnd reports neither tokens nor dollars. The same process_message function has two production callers: the gateway scopes both usage and cost context, while peer delivery scopes neither. The source’s reproduction enables pricing and budgets, sends from agent A to B, then compares that invisible turn with the same message delivered through the gateway.

The facts

- zeroclaw-labs/zeroclaw issue #9373 was created 2026-07-25T22:16:12Z and updated 2026-07-25T22:16:12Z; state is open. - zeroclaw-labs/zeroclaw returned 32392 GitHub stars, 558 open issues, default branch master, and last push 2026-07-26T00:11:47Z. - Latest tagged-release baseline checked: v0.8.3 published 2026-07-16T01:47:13Z. - Issue #9373 traces the gap to send_message_to_peer spawning process_message in a detached Tokio task. - The project’s spawn wrapper carries a tracing span but no task-local state, and process_message does not install a fresh ToolLoopCostTrackingContext. - Downstream record_tool_loop_cost_usage returns None, check_tool_loop_budget returns None, and AgentEnd reports neither tokens nor dollars. - The same process_message function has two production callers: the gateway scopes both usage and cost context, while peer delivery scopes neither. - The source’s reproduction enables pricing and budgets, sends from agent A to B, then compares that invisible turn with the same message delivered through the gateway.

What changed

Issue #9373 traces the gap to send_message_to_peer spawning process_message in a detached Tokio task. The project’s spawn wrapper carries a tracing span but no task-local state, and process_message does not install a fresh ToolLoopCostTrackingContext. Downstream record_tool_loop_cost_usage returns None, check_tool_loop_budget returns None, and AgentEnd reports neither tokens nor dollars. The same process_message function has two production callers: the gateway scopes both usage and cost context, while peer delivery scopes neither. The source’s reproduction enables pricing and budgets, sends from agent A to B, then compares that invisible turn with the same message delivered through the gateway. The primary record was inspected with its timestamps, state, body, and adjacent project records. ClawCharts supplied the assignment list; it does not establish the claim.

Why it matters

A budget that excludes agent-to-agent work is not a budget; it is a dashboard preference. Detached peer turns are exactly where loops can multiply spend without direct user visibility. Attribution must belong to the recipient task, not be inherited from the sender, because each agent needs an independent ledger and cap. The operational test is whether persisted state, visible control, and runtime behavior agree at the handoff where authority changes.

Current

Issue #9373 was open and described as pre-existing on master. PR #9349 proposes populating cost_usd where a scoped accumulator already exists, but explicitly leaves peer delivery untouched. ZeroClaw’s latest tagged baseline remained v0.8.3; a v0.8.4 release candidate was still open at inspection. Repository metadata, current issues and pull requests, release baseline, Hacker News discovery, and the rendered ranking row were checked. Weak search residue and historically used source spines were not promoted.

Evidence

The primary URL is https://github.com/zeroclaw-labs/zeroclaw/issues/9373. Supporting links are inspected current project records that establish implementation, adjacent direction, or boundary conditions. Dates, reproductions, test totals, and deployment observations remain attributed to their authors unless this brief explicitly says they were independently rerun.

Source boundary

Open work is described as open, merged work as merged, and operator reports as reports. A closed issue or passing branch test is not silently translated into a released fix. Ranking explains why the project was scanned; it does not prove correctness, adoption, or package behavior.

Operator take

Enable a very low recipient budget, issue one peer message, and compare ledger, AgentEnd, and enforcement with a gateway turn. The correct repair constructs a fresh recipient-owned context inside the spawned task and fails the turn when its own cap is crossed. Preserve a before-state receipt and verify the narrowest invariant where state changes. Do not broaden permissions or delete state merely because the visible symptom is inconvenient.

Caveat

Public project records are mutable. Source state was captured at publication time, and later revisions may change status, scope, or evidence. No source here authorizes automatic mutation of a reader’s deployment.

Source inspected; source state, environment, and release boundary remain explicit.