OpenClaw
OpenClaw traces frozen cost totals to a reused process ID
An OpenClaw patch says a crashed gateway can leave a refresh lock that survives a supervised restart when the new process receives the same PID. The report links stale usage totals to transcript rescans and cron setup failures, while two related records expose compaction cost and unsafe worktree cleanup.
openclaw/openclaw PR #114254 is the inspected primary source: “fix(usage-cost): cost totals freeze after a restart reuses the refresh-lock PID.” The related records below were inspected as supporting context rather than independent confirmation.
The facts
- openclaw/openclaw PR #114254 was created 2026-07-27T03:14:31Z and was open at inspection; its title is “fix(usage-cost): cost totals freeze after a restart reuses the refresh-lock PID.” - openclaw/openclaw issue #110336 was created 2026-07-18T02:42:16Z and was open at inspection; its title is “Safeguard compaction doesn't trigger during fast tool loops — 172K context paid per turn.” - openclaw/openclaw issue #119691 was created 2026-08-05T17:12:15Z and was closed at inspection; its title is “Bug: reconcileOrphans() deletes worktree contents when worktree is placed directly under worktreesRoot (no fingerprint subdir).” - The repository reported 385259 stars, 5509 open issues, default branch main, and last push 2026-08-06T01:05:36Z. - The latest tagged-release baseline checked was v2026.7.1-2 published 2026-08-04T00:41:26Z.
What changed
openclaw/openclaw PR #114254 reports: Closes #114234 What Problem This Solves Fixes an issue where operators running the gateway under a supervisor or container init would see usage and cost reporting silently freeze at a stale snapshot, and never recover on its own. The trigger is a gateway that dies without releasing the usage-cost refresh lock and then restarts into the same PID — routine for containers, where the gateway lands on the same low PID (1, or 9 under tini) every time. Once that happens the leaked lock row still matches process.kill(pid, 0), so it is honoured indefinitely: every later refresh gets {acquired: false} and the cache can never be rewritten. Nothing logs an error, and no retry, restart, or doctor pass clears it — the only recovery is deleting the row by hand. The downstream damage is worse than stale dashboards. With the cache frozen, usage-cost consumers fall back to recomputing from every
openclaw/openclaw issue #110336 reports: Problem The safeguard compaction mode only triggers near token limits. During fast tool loops, context can grow to 80%+ of the limit without ever triggering compaction — the agent keeps paying for the full growing history on every call. Real-world impact 236-turn tool loop (175 exec calls): context grew from 26K to 172K tokens (86% of 200K limit). Safeguard never compacted because 172K/200K was still "safe." Agent paid for **15M+ input tokens** just repeating the same conversation. Root cause Safeguard is threshold-based (proximity to token limit), not cost-aware or density-aware. It doesn't detect: High tool-call density with no user interaction Context growth rate (26K → 172K with zero new user messages) Rising per-turn cost Proposed fix Add a costAware or proactive compaction mode that triggers on: 1. **No-progress signal**: N+ tool calls without user message or successful external action 2. **Density trigger**: M tool calls in T seconds with growing
openclaw/openclaw issue #119691 reports: Summary The reconcileOrphans() function in src/agents/worktrees/service.ts recursively deletes subdirectories of worktrees that are placed directly under the worktrees root directory (e.g., /root/.openclaw/worktrees/ /) instead of the expected fingerprint-path layout (/root/.openclaw/worktrees/ / /). When a worktree exists at / /, the function treats as a fingerprint directory and iterates its **contents** (scripts/, data/, docs/, etc.) as candidate worktree names — deleting them all with fs.rm(candidate, { recursive: true, force: true }). Environment OpenClaw: 2026.7.1-2 (0790d9f) OS: Linux 6.8.0-111-generic (x64) Node: v22.22.3 Root Cause In src/agents/worktrees/service.ts, lines 696-728: The bug:** When readdir(worktreesRoot) returns a worktree directory directly (e.g., pipeline-20260805_163019), the function treats it as a fingerprint directory. Then readdir(fingerprintPath) returns the worktree's own subdirectories (scripts/, data/, docs/, tests/, etc.), which are treated as unmanaged orphan worktrees and deleted. The resolveRepository() + listGitWorktrees() check is supposed to prevent this, but it fails because: 1. The candidate path (/root/.openclaw/worktrees/pipeline-xxx/scripts) is not a git repository
Why it matters
The lock bug turns a cheap identity shortcut into stale billing data and growing startup work. A live PID proves only that some process exists; it does not prove that process owns persisted state. The operator test is whether persisted state, execution authority and the visible outcome describe the same event after retries, restarts or delegation.
Current
The primary record was open when captured on 2026-08-06. The release baseline was v2026.7.1-2 published 2026-08-04T00:41:26Z. Repository metadata, pull requests, issues, release records, Google News discovery, Hacker News discovery, Lobsters, Metamesh and the rendered ClawCharts row were checked. ClawCharts selected the subject; it did not prove the claim.
Evidence
The primary URL is https://github.com/openclaw/openclaw/pull/114254. Supporting records are https://github.com/openclaw/openclaw/issues/110336 and https://github.com/openclaw/openclaw/issues/119691. Source bodies, timestamps and states are preserved in the daily evidence bundle. Test counts, reproductions and deployment observations remain attributed to their authors unless explicitly identified as independently rerun.
Source boundary
Open work is described as open, closed work as closed, and operator reports as reports. A pull request is evidence of proposed or reviewed direction, not proof of a shipped release. Search residue, package mirrors and historically published source spines were excluded.
Operator take
Use nonce-based ownership, preserve fail-closed behavior on inconclusive checks, and test crash/restart with deterministic PID reuse before trusting recovered cost totals. Preserve a before-state receipt, make the smallest reversible change, and verify the original failure independently after intervention.
Caveat
Public project records are mutable. Status, scope and evidence can change after publication. This brief records the inspected state and does not authorize changes to a reader’s deployment.
Source inspected; source state, environment and release boundary remain explicit.