-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
Codex harness app-server shared client is evicted across agents because cache key includes agentDir #79495
Copy link
Copy link
Closed
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.ClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.Crash, hang, restart loop, or process-level availability failure.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.Channel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.
Description
Metadata
Metadata
Assignees
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.ClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.Crash, hang, restart loop, or process-level availability failure.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.Channel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.
Type
Fields
Priority
None yet
Summary
In
v2026.5.7, the Codex harness app-server shared client appears to be a single global singleton, but its start-options cache key includesagentDir. In multi-agent OpenClaw setups, different agents use different agent dirs, so switching between agents can clear the existing shared app-server client instead of reusing a warm per-agent client.This can cause repeated app-server startup/reconnect/logging overhead under normal multi-agent workloads, and is especially expensive on smaller ARM hosts such as Raspberry Pi.
Relevant code paths
extensions/codex/src/app-server/shared-client.tsgetSharedCodexAppServerClient(...)stores one globalstate.client,state.promise, andstate.key.clearSharedCodexAppServerClient().extensions/codex/src/app-server/config.tscodexAppServerStartOptionsKey(...)includesagentDirin the key.That means agents with different
agentDirvalues, for examplemain,dev,ops, andanalyst, can evict each other's app-server client.Observed impact
On a Raspberry Pi Docker install with multiple OpenClaw agents and scheduled/background sessions:
*.jsonl.codex-app-server.jsonbinding files across agents.This does not look like a Docker memory/swap issue. It looks like the current shared-client design does not scale well when multiple OpenClaw agents use the Codex app-server harness concurrently or interleaved.
Expected behavior
The Codex app-server client should be reused per compatible start-options key instead of using one global singleton that is cleared on every key mismatch.
Suggested fix
Replace the singleton shared client with a keyed pool/map, roughly:
Then reuse the warm client for the matching
codexAppServerStartOptionsKey, with idle TTL cleanup to avoid leaking clients.I would not simply remove
agentDirfrom the key, since it may be needed to preserve per-agentHOME/CODEX_HOME/auth/session isolation. A keyed pool seems safer: keepagentDirin the key, but stop different agent dirs from evicting each other.Secondary related issue
Dynamic tool fingerprints also appear to be stored as full normalized JSON strings rather than compact hashes. On the same host, dynamic tool fingerprints averaged about 9.5 KB and reached about 37 KB per binding file. That is probably separate from the singleton eviction issue, but it adds extra filesystem/log churn and makes compatibility checks heavier than necessary.
A compact stable hash plus lightweight metadata would likely be enough for durable compatibility checks.