Repository navigation
fix: heartbeats fail after successful replies in explicit agent fleets - #123303
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 13, 2026, 5:16 PM ET / 21:16 UTC. ClawSweeper reviewWhat this changesThe branch carries the selected agent’s directory and ID through post-run pricing, session accounting, follow-up delivery, heartbeat routing, and status/Doctor probes in explicit agent fleets. Regression provenancePossible regression — probable (reproduction; failure trace). No predecessor PR is attributed. Merge readinessKeep open: this maintainer-labeled PR addresses a credible P1 delivery regression, but its own body confirms after-fix live heartbeat delivery has not yet been independently demonstrated. Priority: P1 Review scores
Verification
How this fits togetherA completed agent run flows into usage accounting and outbound delivery. Those consumers must retain the admitted agent owner so pricing and channel bootstrap do not attempt ambiguous default-agent selection. flowchart LR
A[Explicit agent fleet] --> B[Completed agent run]
B --> C[Owner context]
C --> D[Usage accounting]
C --> E[Heartbeat routing]
E --> F[Channel bootstrap]
D --> G[Delivered reply]
F --> G
Before merge
Agent review detailsSecurityNone. PR surfaceSource +19, Tests +166. Total +185 across 17 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Retain the admitted agent owner through every post-run accounting and heartbeat-delivery boundary, then attach a redacted live Gateway trace showing a selected explicit-fleet agent completes accounting and sends its heartbeat reply. Do we have a high-confidence way to reproduce the issue? No: the PR reports a live pre-fix recurrence and focused tests, but local execution was unavailable and no independent after-fix live delivery trace is present. Is this the best way to solve the issue? Unclear: the supplied patch consistently carries the selected owner, which matches the described failure, but local whole-path and sibling-surface inspection was unavailable. AGENTS.md: unclear because the file could not be read completely. Codex review notes: model internal, reasoning high; reviewed against dbea5a77f08f. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
openclaw#123303) * fix: keep heartbeat reply accounting agent-scoped * fix: close ambient owner fallback gaps
Related: #123283
What Problem This Solves
Fixes an issue where heartbeats in explicit multi-agent fleets could complete the model run successfully but then fail during post-run usage accounting or outbound channel bootstrap, preventing the completed reply from being delivered.
Why This Change Was Made
The completed run already carries the authoritative agent id and agent directory. This change preserves that ownership through reply pricing, persisted session accounting, diagnostics, follow-up delivery, post-compaction context lookup, and heartbeat channel bootstrap instead of asking those downstream consumers to rediscover a default agent that does not exist in an explicit fleet.
The same ownership invariant is applied to status and Doctor heartbeat probes. No config, protocol, storage schema, or fallback behavior changes.
Production LOC: +23/-5 (net +18) | Tests: +96/-2. The production growth is the explicit owner-context propagation across the reply-accounting and heartbeat-routing sibling surfaces; it removes ambiguous default-agent resolution from the affected paths.
User Impact
Operators using explicit multi-agent ownership can expect a successful heartbeat run to finish its accounting and delivery path instead of failing after the response has already been generated.
Evidence
Live recurrence on release
927a97c1ea1f7ca19cbd721ad17294ed940ce6ea:2026-08-13T20:09:45.628Z.2026-08-13T20:09:45.805Z.2026-08-13T20:11:11.675Z, post-run accounting threw throughaccountAgentTurn -> buildReplyUsageState -> resolveModelCostConfigbecause the selected agent directory had been dropped. No outbound delivery occurred.Regression proof before the fix:
resolveDefaultAgentIdin an explicit fleet.estimatedCostUsd.agentIdwas absent from cold plugin bootstrap.Proof after the fix:
node scripts/check-changed.mjs -- <15 changed paths>passed thecoreandcoreTestslanes, including formatting, typechecks, lint, import cycles, native schema, and database-first guards..agents/skills/autoreview/scripts/autoreview --mode localreported no accepted/actionable findings on the exact committed bundle (patch is correct, confidence 0.97).git diff --checkpassed.Remaining proof gap: this exact PR head has not yet been deployed to the manager-owned live Gateway, so a post-fix live heartbeat delivery remains for the independent verifier. GitHub CI is also pending. This PR should not merge until that independent verification is complete.