Skip to content

[codex] support session-isolated app-server clients - #81777

Closed
henkterharmsel wants to merge 1 commit into
openclaw:mainfrom
henkterharmsel:codex-appserver-session-isolation
Closed

henkterharmsel wants to merge 1 commit into
openclaw:mainfrom
henkterharmsel:codex-appserver-session-isolation

Conversation

@henkterharmsel

@henkterharmsel henkterharmsel commented May 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add opt-in appServer.clientIsolation=session so Codex app-server clients and thread bindings can be isolated per OpenClaw runtime-policy session/topic instead of shared per agent
  • route run attempts, queued follow-ups, native compaction, /btw, /compact, Codex plugin commands, bound conversation turns, diagnostics, gateway compaction, and reset/delete cleanup through the same runtime-policy isolation key
  • expose appServer.turnTerminalIdleTimeoutMs and appServer.nativeCompaction; keep existing defaults (clientIsolation=agent, native compaction on, 30 minute terminal idle timeout)

Why

Codex app-server workers can silently stop producing terminal events (see openai/codex#21937). OpenClaw previously reused one shared Codex app-server client per agent, so a wedged worker could poison unrelated topics. This keeps old behavior by default and lets operators opt into per-session/topic isolation.

Real behavior proof

  • Behavior or issue addressed: Multiple concurrent Telegram topics using Codex could eventually stall because OpenClaw reused one shared Codex app-server client per agent. When one Codex worker stopped producing terminal events, unrelated topics could inherit the same wedged client. This patch adds opt-in per-runtime-session/topic isolation with appServer.clientIsolation="session".
  • Real environment tested: Human-run local production OpenClaw setup on a Linux host using a user-level openclaw-gateway systemd service, the bundled Codex plugin, @openai/codex 0.130.0, and a Telegram group with multiple active topics. Hostname, account identifiers, topic ids, and tokens are redacted.
  • Exact steps or command run after this patch: Applied the source-equivalent patch to the installed Codex plugin bundle and manifest, enabled appServer.clientIsolation="session", restarted openclaw-gateway, checked systemctl --user show openclaw-gateway, checked journalctl --user -u openclaw-gateway, then exercised multiple Telegram topics with Codex enabled.
  • Evidence after fix: Redacted terminal output and runtime log excerpt from the real gateway after the patched service restart:
    $ systemctl --user show openclaw-gateway --property=ActiveState --property=SubState --property=MainPID
    ActiveState=active
    SubState=running
    MainPID=<redacted>
    
    $ journalctl --user -u openclaw-gateway
    [gateway] http server listening (5 plugins: acpx, codex, memory-core, openai, telegram; 5.9s)
    [gateway] ready
    
  • Observed result after fix: Concurrent Telegram topics no longer cascade-stalled through one shared frozen Codex app-server client after enabling session isolation.
  • What was not tested: Real WebSocket remote app-server isolation and non-Codex providers/extensions.

Not tested in CI/local suite:

  • CI full suite clean on this machine; local pnpm test still fails on unrelated existing non-Codex failures listed below.

Validation

  • pnpm exec vitest run extensions/codex/src/commands.test.ts --reporter=dot (1 file / 89 tests passed)
  • pnpm exec vitest run extensions/codex/src/app-server/compact.test.ts --reporter=dot (1 file / 15 tests passed)
  • pnpm exec vitest run src/gateway/server.sessions.reset-hooks.test.ts src/gateway/server.sessions.compaction.test.ts --reporter=dot (2 files / 15 tests passed)
  • pnpm test src/plugins/commands.test.ts (1 file / 42 tests passed)
  • pnpm test extensions/codex/src/commands.test.ts (1 file / 89 tests passed)
  • pnpm test extensions/codex/src/app-server/session-binding.test.ts extensions/codex/src/app-server/shared-client.test.ts extensions/codex/src/app-server/compact.test.ts extensions/codex/src/app-server/run-attempt.test.ts (4 files / 134 tests passed)
  • pnpm test src/gateway/server.sessions.reset-hooks.test.ts src/gateway/server.sessions.compaction.test.ts (2 files / 15 tests passed)
  • pnpm test:extension codex (50 files / 681 tests passed)
  • pnpm check (passed)
  • pnpm build (passed)
  • codex review --base upstream/main (no actionable correctness issues)
  • pnpm test (failed after 76 shards on unrelated existing non-Codex failures: Telegram durable-final proof, NVIDIA/LM Studio provider expectations, oc-path perf threshold, acpx source-vs-dist path, gateway credential/auth env expectations, Discord patch summary truncation, IPv6 loopback EADDRNOTAVAIL ::1, and agent/config test mocks missing unrelated exports.)

AI-assisted

Yes. Codex implemented and locally reviewed the change; the production behavior proof above was run by a human operator on their own OpenClaw instance. I understand the code paths changed.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling extensions: codex size: XL triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 14, 2026
@clawsweeper

clawsweeper Bot commented May 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed July 3, 2026, 11:54 PM ET / 03:54 UTC.

Summary
The PR adds opt-in Codex app-server session isolation, runtime-policy isolation keys across Codex commands/compaction/reset/bindings, new Codex app-server config fields, plugin command context fields, and regression coverage.

PR surface: Source +775, Tests +957. Total +1732 across 50 files.

Reproducibility: yes. for the review finding from source: PR-head app-server bound conversations can carry distinct isolation keys while still serializing through a queue keyed only by sessionFile. I did not run the PR tests in this read-only review.

Review metrics: 3 noteworthy metrics.

  • Codex app-server config surfaces: 2 added. appServer.clientIsolation and appServer.turnTerminalIdleTimeoutMs are operator-facing runtime settings, so defaults and upgrade behavior need maintainer acceptance.
  • Plugin command API fields: 2 optional fields added. runtimePolicySessionKey is added to command context and diagnostics session data, expanding public plugin command surface.
  • Serialized state surfaces: 3 fields plus 1 sidecar path variant added. Binding isolationKey, conversation-binding isolationKey, session-origin senderId, and hashed binding sidecars affect persisted state and cleanup behavior.

Stored data model
Persistent data-model change detected: serialized state: extensions/codex/src/app-server/session-binding.test.ts, serialized state: extensions/codex/src/app-server/session-binding.ts, serialized state: src/auto-reply/reply/session-hooks-context.test.ts, serialized state: src/auto-reply/reply/session.ts, serialized state: src/config/sessions/types.ts, serialized state: src/gateway/server-methods/sessions.ts, and 7 more. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦞 diamond lobster
Patch quality: 🦐 gold shrimp
Result: needs maintainer review before merge.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Key bound-turn queues by isolation key and add two-isolated-bindings regression coverage.
  • Refresh the draft branch against current main.
  • Get maintainer acceptance for the new Codex config, plugin command context, and serialized state surfaces.

Mantis proof suggestion
A live Telegram recording would materially show whether two Codex topics with session isolation stop blocking each other when one turn is slow or stalled. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis telegram desktop proof: verify two Telegram topics using Codex with appServer.clientIsolation=session do not block each other when one turn is slow or stalled.

Risk before merge

  • [P1] Bound app-server conversation turns still serialize by transcript file instead of isolation key, so one slow or wedged bound turn can still delay another topic that the PR otherwise isolates.
  • [P1] The diff adds operator-facing Codex config, public plugin command context fields, hashed sidecar binding paths, and serialized metadata; maintainers need to accept the API/default/upgrade contract before merge.
  • [P1] The PR is draft and GitHub currently reports mergeable=CONFLICTING / mergeStateStatus=DIRTY, so final review needs a refreshed branch or concrete merge result against current main.
  • [P1] The supplied real behavior proof covers a production Telegram/local app-server path, but not WebSocket remote app-server isolation or the bound-conversation queue path after repair.

Maintainer options:

  1. Refresh And Repair Queue Isolation (recommended)
    Refresh the branch against current main, include the isolation key in bound-turn queue keys, and add concurrent two-isolated-bindings coverage before final review.
  2. Accept New Runtime Surfaces
    Maintainers can intentionally accept the new Codex config fields, plugin command context fields, and serialized metadata after reviewing defaults, docs, and upgrade behavior.
  3. Pause For Runtime Direction
    If maintainers do not want an OpenClaw config knob or public plugin-context expansion for this isolation mode, pause this branch and settle the Codex runtime policy direction first.

Next step before merge

  • [P2] A narrow queue-key repair exists, but the draft conflict and new config/API/state surfaces need maintainer acceptance before an automated repair lane is safe.

Security
Cleared: No concrete security or supply-chain regression is visible; the diff changes runtime routing, config/API types, serialized state, and tests without new dependencies, workflow edits, or broader secret access.

Review findings

  • [P2] Include isolation key in bound-turn queue keys — extensions/codex/src/conversation-binding.ts:201
Review details

Best possible solution:

Refresh the branch, key every Codex app-server binding/client/active-turn/bound-turn path by one canonical isolation key, and merge only after maintainer acceptance for the config/API/state surfaces with upgrade and Telegram proof.

Do we have a high-confidence way to reproduce the issue?

Yes for the review finding from source: PR-head app-server bound conversations can carry distinct isolation keys while still serializing through a queue keyed only by sessionFile. I did not run the PR tests in this read-only review.

Is this the best way to solve the issue?

No, not yet: session isolation is a plausible mitigation, but the implementation is incomplete until bound-turn queues use the same isolation dimension as bindings, active turns, and shared clients, and maintainers accept the new config/API/state surfaces.

Full review comments:

  • [P2] Include isolation key in bound-turn queue keys — extensions/codex/src/conversation-binding.ts:201
    This PR stores and uses isolationKey for app-server bindings, clients, and active turns, but handleCodexConversationInboundClaim() still enters app-server bound turns through enqueueBoundTurn(data.sessionFile). With appServer.clientIsolation="session", two topics sharing one transcript can still serialize behind the same promise queue, so include the isolation key in that queue key and add concurrent regression coverage.
    Confidence: 0.91

Overall correctness: patch is incorrect
Overall confidence: 0.88

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 9d68f877ac3e.

Label changes

Label justifications:

  • P1: The PR targets a real Codex app-server isolation problem that can stall unrelated Telegram topic workflows.
  • merge-risk: 🚨 compatibility: The diff adds operator config, public plugin command context, and persisted metadata surfaces that can affect upgrades and external plugin behavior.
  • merge-risk: 🚨 message-delivery: Incomplete queue isolation can still let one slow or wedged Codex topic suppress replies for another isolated topic.
  • merge-risk: 🚨 availability: The diff changes Codex app-server client lifecycle, reset cleanup, compaction, and long-running turn handling.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (logs): The PR body includes redacted production gateway/systemd logs and an operator-observed after-fix Telegram concurrency result with session isolation enabled, though WebSocket and bound-queue proof remain gaps.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes redacted production gateway/systemd logs and an operator-observed after-fix Telegram concurrency result with session isolation enabled, though WebSocket and bound-queue proof remain gaps.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The PR changes user-visible Telegram topic responsiveness for Codex app-server sessions, which can be demonstrated in a short Telegram Desktop recording.
Evidence reviewed

PR surface:

Source +775, Tests +957. Total +1732 across 50 files.

View PR surface stats
Area Files Added Removed Net
Source 36 946 171 +775
Tests 14 981 24 +957
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 50 1927 195 +1732

What I checked:

  • Repository policy applied: Root and scoped AGENTS.md were read; the policy treats Codex dependency behavior, plugin config/API, session state, gateway cleanup, and compatibility surfaces as merge-sensitive. (AGENTS.md:14, 9d68f877ac3e)
  • Live PR state: GitHub reports the PR open, draft, mergeable=CONFLICTING, mergeStateStatus=DIRTY, head 5d0933d, and labels including proof sufficient plus compatibility/message-delivery/availability risk. (5d0933d0c449)
  • Current main lacks requested mode: Current main has no clientIsolation or turnTerminalIdleTimeoutMs support in the Codex app-server config or plugin manifest, so the central requested mode is not already implemented on main. (extensions/codex/src/app-server/config.ts:250, 9d68f877ac3e)
  • Bound-turn queue gap: PR head reads isolated bindings and clients by isolationKey, but app-server bound conversation turns still call enqueueBoundTurn(data.sessionFile), so distinct isolated topics sharing a transcript still serialize behind one queue. (extensions/codex/src/conversation-binding.ts:201, 5d0933d0c449)
  • PR isolates other Codex control state: PR head keys active turns by sessionFile plus isolationKey and keys shared app-server clients by isolationKey, which makes the bound-turn queue omission a one-sided isolation gap. (extensions/codex/src/conversation-control.ts:37, 5d0933d0c449)
  • Persisted sidecar/state surface: PR head hashes non-empty isolation keys into separate Codex app-server binding sidecars and stores isolationKey in the binding payload, making cleanup and upgrade behavior state-sensitive. (extensions/codex/src/app-server/session-binding.ts:71, 5d0933d0c449)

Likely related people:

  • steipete: GitHub commit history shows Peter Steinberger authored Codex app-server support-helper docs, timeout fallout, and shared-client state typing in the same runtime area this PR changes. (role: feature-history owner; confidence: high; commits: 5a7d5c6defe5, e72447de408a, 89532d3a92a8; files: extensions/codex/src/app-server/shared-client.ts, extensions/codex/src/app-server/session-binding.ts, extensions/codex/src/conversation-binding.ts)
  • vincentkoc: Recent history shows Vincent Koc worked on Codex thread binding flow, shared app-server start context, service-tier binding normalization, and network proxy profiles around the same app-server config/binding boundary. (role: recent adjacent contributor; confidence: high; commits: 815ffb3bb2e1, 07870dff45eb, 8afc1f770bbe; files: extensions/codex/src/conversation-binding.ts, extensions/codex/src/app-server/shared-client.ts, extensions/codex/src/app-server/session-binding.ts)
  • kevinslin: Recent commits by Kevin Lin changed Codex app-server config and binding schema/API surfaces, making him a plausible reviewer for the public plugin/config compatibility side effects. (role: recent API/config surface contributor; confidence: medium; commits: d9b5afad180b, c5d34c8376f8, bc5081c58730; files: extensions/codex/src/app-server/config.ts, extensions/codex/src/app-server/session-binding.ts, src/plugins/types.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 14, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 14, 2026
@henkterharmsel
henkterharmsel force-pushed the codex-appserver-session-isolation branch from 8380a66 to 229df6e Compare May 18, 2026 10:22
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 18, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels May 18, 2026
@henkterharmsel
henkterharmsel force-pushed the codex-appserver-session-isolation branch from 229df6e to c8ca8e6 Compare May 18, 2026 12:59
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 18, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 18, 2026
@henkterharmsel
henkterharmsel force-pushed the codex-appserver-session-isolation branch from c8ca8e6 to 5d0933d Compare May 18, 2026 17:23
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 18, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. and removed merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels May 18, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jun 2, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jun 2, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jun 15, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Jun 15, 2026
@henkterharmsel

Copy link
Copy Markdown
Contributor Author

Closing this draft because the implementation has been superseded by the Codex runtime and lifecycle redesign that landed after it was opened. The branch now conflicts across 50 files, its persisted/config/plugin API surfaces no longer match current main, and review identified an incomplete bound-turn queue isolation path. We also no longer deploy this patch locally on OpenClaw 2026.7.1; current app-server liveness retirement and terminal-idle recovery have kept the original cascading-stall symptom bounded in production. The upstream Codex silent-turn issue (openai/codex#21937) remains open, so if the blast-radius problem reproduces on the current runtime, I will report it against the current architecture and propose a narrower fix rather than reviving this stale implementation.

This branch had an error being deployed

1 failed deployment
qa-live-shared — 5d0933d0 Deployed May 18, 2026 by clawsweeper[bot] via Run agentic native Telegram proof #15424
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling extensions: codex gateway Gateway runtime mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant