Skip to content

refactor(codex): simplify app-server runtime ownership#93313

Closed
steipete wants to merge 21 commits into
mainfrom
codex/refactor-codex-runtime
Closed

refactor(codex): simplify app-server runtime ownership#93313
steipete wants to merge 21 commits into
mainfrom
codex/refactor-codex-runtime

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

  • Refactors the Codex app-server integration around one lifecycle-owned runtime path: shared clients, explicit turn routing, SQLite-backed binding ownership, and canonical startup/resume decisions.
  • Removes the replay/polling-style native context usage state from steady-state runtime; OpenClaw now persists only terminal managed-turn usage, invalidates stale snapshots before managed turns, and lets Codex own native review/compaction context.
  • Hardens native subagent recovery with status revisions so stale reads cannot complete or fall back a child that became active again.
  • Adds a startup binding fence so prompt/auth state derived from one Codex thread cannot be mixed with a concurrently replaced binding.

Codex source checked

  • Inspected sibling ../codex at current OpenAI Codex sources and the pinned @openai/[email protected] behavior.
  • Relevant upstream paths checked: codex-rs/core/src/session/turn.rs, codex-rs/protocol/src/openai_models.rs, codex-rs/core/src/codex_delegate.rs, codex-rs/core/src/tasks/review.rs, codex-rs/core/src/session/review.rs, codex-rs/core/src/session/mod.rs, and codex-rs/app-server/src/request_processors/thread_processor.rs.
  • Key conclusion: no Codex harness patch is required for this refactor. OpenClaw should not duplicate Codex context accounting; it should preserve Codex-owned native context and avoid trusting stale replayed token state after review/compaction.

Verification

Remote isolated Linux dev box:

  • node scripts/run-vitest.mjs extensions/codex/src/app-server/run-attempt.test.ts ✅ 103 tests
  • node scripts/run-vitest.mjs extensions/codex/src/app-server/startup-binding.test.ts extensions/codex/src/app-server/thread-resume.test.ts extensions/codex/src/app-server/session-binding.test.ts extensions/codex/src/app-server/thread-lifecycle.binding.test.ts extensions/codex/src/app-server/run-attempt.test.ts extensions/codex/src/app-server/run-attempt.context-engine.test.ts extensions/codex/src/app-server/compact.test.ts extensions/codex/src/app-server/native-subagent-monitor.test.ts extensions/codex/src/conversation-control.test.ts ✅ 293 tests
  • node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-codex.config.ts extensions/codex ✅ 90 files / 1,653 tests
  • node_modules/oxfmt/bin/oxfmt --check --threads=1 <changed files>
  • OPENCLAW_OXLINT_SKIP_PREPARE=1 node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.extensions.json extensions/codex ✅ plain oxlint
  • node scripts/run-tsgo.mjs -p tsconfig.extensions.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions.tsbuildinfo

Local non-OpenClaw checks:

  • git diff --check
  • node_modules/oxfmt/bin/oxfmt --write --threads=1 ... used for formatter-only rewrites

Known proof gaps / follow-up before merge

  • Branch-wide autoreview against origin/main timed out after ~40 minutes on a ~194k-char bundle.
  • Scoped autoreview on the final commit found and I fixed the startup binding replacement race. It also recommended restoring native usage replay; I intentionally did not reintroduce that polling path because the refactor keeps Codex as the source of truth for native review/compaction context and treats absent usage as “do not trust a fuse snapshot” rather than reconstructing Codex accounting.
  • Full extension lint prep, extension test typecheck, build, and Docker/live E2E are currently blocked by the dev-box package environment missing esbuild while the configured registry returns 403 without auth. I did not bypass the configured dependency registry/cooldown policy.
  • The branch is currently behind origin/main; a rebase attempt hit conflicts in Codex config/migration/lifecycle files because main moved across the same surfaces. Resolve that rebase before merge, then rerun the focused Codex suite plus Docker/live Codex lanes.

Suggested final E2E after rebase/package auth

  • OPENCLAW_LIVE_CODEX_HARNESS_AUTH=api-key OPENCLAW_LIVE_CODEX_BIND_MODEL=gpt-5.5 pnpm test:docker:live-codex-bind
  • OPENCLAW_LIVE_CODEX_HARNESS_MODEL=codex/gpt-5.5 pnpm test:docker:live-codex-harness
  • OPENCLAW_CODEX_NPM_PLUGIN_MODEL=codex/gpt-5.5 pnpm test:docker:live-codex-npm-plugin

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord channel: telegram Channel integration: telegram gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling channel: feishu Channel integration: feishu extensions: codex size: XL maintainer Maintainer-authored PR labels Jun 15, 2026
@clawsweeper

clawsweeper Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 30, 2026, 10:35 PM ET / 02:35 UTC.

Summary
The PR refactors Codex app-server runtime ownership across binding storage, shared client leases, startup/resume/compaction/reset routing, diagnostics, and related plugin command/session APIs.

Reproducibility: yes. at source level. A legacy app-server binding with no stored agentId but a non-default inbound ctx.agentId reaches the native guard with the resolved value overwritten by data.agentId; this was verified from PR-head source.

Review metrics: 1 noteworthy metric.

  • Plugin/runtime contract surfaces: 6 added or changed optional fields/options. The PR adds plugin-state, plugin hook, plugin command, harness reset, and compaction event surfaces that maintainers should review as compatibility-sensitive before merge.

Stored data model
Persistent data-model change detected: migration/backfill/repair: extensions/codex/doctor-contract-api.test.ts, migration/backfill/repair: extensions/codex/doctor-contract-api.ts, migration/backfill/repair: src/flows/doctor-health-contributions.test.ts, migration/backfill/repair: src/flows/doctor-health-contributions.ts, migration/backfill/repair: src/infra/state-migrations.test.ts, persistent cache schema: extensions/codex/src/app-server/client-runtime.test.ts, and 18 more. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🦐 gold shrimp
Patch quality: 🧂 unranked krab
Result: blocked until stronger real behavior proof is added.

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

Rank-up moves:

  • [P1] Fix the duplicate agentId guard and sandbox-guard duplicates while preserving non-default-agent legacy-binding coverage.
  • Resolve the dirty base and rerun focused Codex lifecycle validation.
  • Attach current-head real behavior proof for bound Codex chat and lifecycle paths with private details redacted.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The existing Mantis Telegram recording is real transport proof, but it was captured for older candidate 97059b9 and does not show the current-head guard, reset, compaction, or side-question paths changed here. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Mantis proof suggestion
A native Telegram Desktop recording can directly show whether bound Codex chat and side-question or compact delivery still work after the runtime ownership refactor. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis telegram desktop proof: verify Codex bound chat replies, /btw side-question replies, and /codex compact still deliver after the runtime ownership refactor.

Risk before merge

  • [P1] Current head can evaluate native execution and sandbox policy under the wrong agent for legacy bound Codex app-server turns.
  • [P1] The PR changes plugin-visible context fields, plugin-state overflow behavior, persistent Codex binding migration, shared-client routing, reset ordering, and compaction adoption, so upgrade/session-state compatibility remains maintainer-sensitive.
  • [P1] The available Mantis proof is tied to an older candidate SHA and shows Telegram reply delivery only, not the current-head guard, reset, compaction, or side-question lifecycle paths.
  • [P1] GitHub reports the PR as dirty/conflicting against the current base, so conflict resolution and fresh validation are required before merge.

Maintainer options:

  1. Fix guard and refresh proof (recommended)
    Repair the duplicate agentId guard and sandbox-guard duplicates, keep non-default-agent legacy-binding coverage, resolve conflicts, and attach current-head proof for bound Codex chat plus lifecycle paths before merge.
  2. Split the runtime refactor
    If current-head proof and upgrade review remain too broad, pause this PR and split the guard/session fixes from durable binding and runtime ownership changes.
  3. Accept compatibility risk explicitly
    Maintainers may decide the plugin-state and session-migration contract changes are acceptable after upgrade review, but the concrete guard and type defects still need repair first.

Next step before merge

  • [P1] Human/contributor action is needed because the PR has P1 guard/type defects, dirty merge state, current-head proof gaps, a protected maintainer label, and broad compatibility/session-state review requirements.

Security
Needs attention: The diff still has a concrete security-boundary concern because legacy bound app-server turns can evaluate sandbox/native execution policy under the wrong agent.

Review findings

  • [P1] Use the resolved agent for app-server guard — extensions/codex/src/conversation-binding.ts:219
  • [P1] Remove duplicate agentId fields in sandbox guard — extensions/codex/src/app-server/sandbox-guard.ts:135
Review details

Best possible solution:

Fix the duplicate agentId guard and sandbox-guard duplicates, resolve the base conflicts, rerun focused Codex lifecycle validation plus relevant live lanes, and have maintainers explicitly review the plugin/runtime compatibility surfaces before merge.

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

Yes at source level. A legacy app-server binding with no stored agentId but a non-default inbound ctx.agentId reaches the native guard with the resolved value overwritten by data.agentId; this was verified from PR-head source.

Is this the best way to solve the issue?

No. The ownership direction is plausible, but this PR is not the best merge path until the wrong-agent guard and duplicate sandbox-guard fields are fixed, conflicts are resolved, and current-head lifecycle proof is refreshed.

Full review comments:

  • [P1] Use the resolved agent for app-server guard — extensions/codex/src/conversation-binding.ts:219
    agentId is resolved from the stored binding or inbound context, but this object literal then overwrites it with data.agentId. Legacy app-server bindings without a stored agent id can therefore evaluate native execution and sandbox policy under the default or undefined agent instead of the actual inbound session owner.
    Confidence: 0.96
  • [P1] Remove duplicate agentId fields in sandbox guard — extensions/codex/src/app-server/sandbox-guard.ts:135
    This patch adds agentId to the sandbox guard types and policy call without removing the existing entries, leaving duplicate property names in the type literals and object literal. Remove the duplicate fields so the guard compiles cleanly and has one source of truth for agent ownership.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 816038e97a5d.

Label changes

Label justifications:

  • P2: This is a normal-priority Codex runtime refactor with concrete merge-blocking defects and broad but bounded Codex/plugin blast radius.
  • merge-risk: 🚨 compatibility: The diff changes plugin-visible context fields and plugin-state overflow behavior that external or bundled plugin/runtime callers may depend on.
  • merge-risk: 🚨 session-state: The refactor changes durable Codex binding ownership, sidecar migration, reset ordering, shared-client routing, and compaction adoption.
  • merge-risk: 🚨 security-boundary: The patch can evaluate sandbox and native execution restrictions under the wrong agent for legacy bound Codex app-server turns.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦐 gold shrimp and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The existing Mantis Telegram recording is real transport proof, but it was captured for older candidate 97059b9 and does not show the current-head guard, reset, compaction, or side-question paths changed here. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • proof: 🎥 video: Contributor real behavior proof includes video or recording evidence. The existing Mantis Telegram recording is real transport proof, but it was captured for older candidate 97059b9 and does not show the current-head guard, reset, compaction, or side-question paths changed here.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The PR affects Telegram-visible Codex delivery through bound chat and side-command behavior, so a short Telegram Desktop proof remains useful.
Evidence reviewed

Security concerns:

  • [high] Wrong agent reaches native execution guard — extensions/codex/src/conversation-binding.ts:219
    The duplicate agentId property discards the resolved inbound agent for legacy app-server bindings, which can evaluate sandbox or node-exec restrictions under the default/undefined agent rather than the actual session owner.
    Confidence: 0.95

What I checked:

  • Root policy read and applied: Root AGENTS.md requires full-source review, scoped policy reads, Codex dependency inspection, and compatibility-sensitive handling for plugin APIs, provider routing, auth/session state, migrations, and fallback behavior. (AGENTS.md:1, 816038e97a5d)
  • Scoped policy read and applied: Relevant scoped AGENTS.md files under extensions, src/agents, src/plugins, src/channels, src/gateway, docs, and test were read and applied to this broad Codex/plugin/session PR. (extensions/AGENTS.md:1, 816038e97a5d)
  • Live PR state: GitHub reports this PR open, non-draft, head 7641ec8, mergeable false / dirty, and 169 changed files with maintainer and merge-risk labels. (7641ec8ba7b7)
  • Wrong-agent guard defect: At PR head, agentId is resolved from data.agentId ?? ctx.agentId, but resolveCodexNativeExecutionBlock receives a later duplicate agentId: data.agentId, discarding the inbound agent for legacy app-server bindings. (extensions/codex/src/conversation-binding.ts:219, 7641ec8ba7b7)
  • Test encodes the intended invariant: The PR adds a test expecting shipped app-server and CLI-node bindings under global scope to use inbound ctx.agentId: "work" and block when that agent is sandboxed, which the current app-server guard path does not honor. (extensions/codex/src/conversation-binding.test.ts:1304, 7641ec8ba7b7)
  • Duplicate agentId declarations: The PR head has duplicate agentId entries in sandbox-guard parameter type literals and a duplicate agentId property in the native execution policy call, which should be removed with the same guard repair. (extensions/codex/src/app-server/sandbox-guard.ts:135, 7641ec8ba7b7)

Likely related people:

  • vincentkoc: Recent current-main Codex app-server, auth, and plugin-state history plus current blame on the central files overlap this PR's runtime and guard surfaces. (role: recent area contributor; confidence: high; commits: 51e0997c2bbd, f1cc8f0cfc7c, a0182574873e; files: extensions/codex/src/conversation-binding.ts, extensions/codex/src/app-server/session-binding.ts, src/plugin-state/plugin-state-store.ts)
  • steipete: Prior merged Codex app-server lifecycle, harness, and registry work overlaps the app-server runtime ownership refactor; he is also the PR author with related prior history. (role: feature-history owner; confidence: high; commits: 659bcc5e5b59, 9ac7a0398213, 44ec4d05de4a; files: extensions/codex, src/agents/harness/registry.ts)
  • Tak Hoffman: Recent session reset and CLI continuity work overlaps the PR's reset ordering and session-generation cleanup changes. (role: adjacent session/reset contributor; confidence: medium; commits: fa56682b3ced, 1a9abb13bd33, 615fe4a06be2; files: src/gateway/session-reset-service.ts, src/auto-reply/reply/session.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.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jun 15, 2026
@clawsweeper
clawsweeper Bot temporarily deployed to qa-live-shared June 15, 2026 14:28 Inactive
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jun 15, 2026
@openclaw-mantis

Copy link
Copy Markdown
Contributor

Mantis Telegram Desktop Proof

Summary: Mantis captured native Telegram Desktop before/after GIFs showing Codex replies delivered in chat.

Main screenshot This PR screenshot
Baseline native Telegram Desktop screenshot Candidate native Telegram Desktop screenshot
Main This PR
Baseline native Telegram Desktop proof GIF Candidate native Telegram Desktop proof GIF

Motion-trimmed clips:

Raw QA files: https://artifacts.openclaw.ai/mantis/telegram-desktop/pr-93313/run-27553271495-1/index.json

@clawsweeper clawsweeper Bot added proof: 🎥 video Contributor real behavior proof includes video or recording evidence. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. proof: 🎥 video Contributor real behavior proof includes video or recording evidence. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jun 15, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7daba184b5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread extensions/codex/index.ts
Comment on lines 24 to +27
import {
createCodexCliSessionNodeHostCommands,
createCodexCliSessionNodeInvokePolicies,
listCodexCliSessionsOnNode,
resumeCodexCliSessionOnNode,
resolveCodexCliSessionForBindingOnNode,
} from "./src/node-cli-sessions.js";
import { createCodexWebSearchProvider } from "./src/web-search-provider.js";
} from "./src/node-cli-session-registration.js";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restore the Codex web-search provider import

This import rewrite drops createCodexWebSearchProvider, but register() still calls it when the Codex plugin is loaded. In any runtime that loads the plugin, registration now throws a ReferenceError before the later migration provider, commands, and lifecycle hooks can be registered, so the Codex plugin surface fails to start.

Useful? React with 👍 / 👎.

? modelScopedAppServer.approvalPolicy
: (binding.approvalPolicy ?? modelScopedAppServer.approvalPolicy);
const sandbox = useModelScopedPolicy
let sandbox = useModelScopedPolicy
? modelScopedAppServer.sandbox
: (binding.sandbox ?? modelScopedAppServer.sandbox);
const nativeProviderWebSearchSupport =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Recreate the side-question native tool policy

The refactor removed the local nativeToolSurfaceEnabled = shouldEnableCodexAppServerNativeToolSurface(...) assignment, but this path still reads nativeToolSurfaceEnabled while starting every Codex /btw side question. As soon as a side question reaches this block it throws before it can fork the side thread, so /btw is unusable for Codex sessions.

Useful? React with 👍 / 👎.

Comment on lines +757 to +760
return createCodexDynamicToolBridge({
tools,
signal: input.signal,
loading: resolveCodexDynamicToolsLoading(input.pluginConfig),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Return the side-question bridge tuple

runCodexAppServerSideQuestion() destructures { toolBridge, webSearchPlan } from this helper and immediately reads webSearchPlan.threadConfig, but the helper now returns only the CodexDynamicToolBridge object. After the native-tool flag issue is fixed, Codex /btw still crashes here with webSearchPlan undefined instead of carrying the web-search plan into the forked thread config.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9d4d07175d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +224 to +227
const agentId = resolveSessionAgentIds({
sessionKey,
config: params.config,
}).sessionAgentId;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve the store agent for legacy session keys

When a Codex sidecar is owned by an agent-specific legacy store whose session key has not been canonicalized yet (for example agents/<agent>/sessions/sessions.json entries before the core legacy-session migration runs), resolving the owner from sessionKey alone falls back to the default agent. The migration then writes the binding under the default agent’s session-key: row, while runtime lookup uses the actual agent from sessionBindingIdentity, so upgraded non-default-agent sessions lose their existing Codex thread binding and start over instead of resuming it. Carry the agent id associated with the storePath/surface into this owner resolution when the key itself does not encode one.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e773981088

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

pluginThreadConfigRequired,
resolvedPluginPolicy,
enabledPluginConfigKeys,
pluginAppCacheKey,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Define pluginAppCacheKey before logging

Every Codex app-server startup reaches this debug payload before the inner startupAttempt() computes pluginAppCacheKey, so evaluating the object throws a ReferenceError before a client is leased or a thread can start. Move this log after the key is computed or omit the field until then.

Useful? React with 👍 / 👎.

Comment on lines 281 to 283
let sandbox = useModelScopedPolicy
? modelScopedAppServer.sandbox
: (binding.sandbox ?? modelScopedAppServer.sandbox);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use a distinct sandbox policy variable

When the Codex /btw side-question module is loaded, this redeclares sandbox in the same block where the sandbox context was already declared above, so the module fails to parse and side questions cannot run. Keep the resolved sandbox context under one name and store the app-server sandbox policy in a separate variable.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jun 21, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jun 21, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7641ec8ba7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +217 to 219
agentId,
sessionKey: event.sessionKey ?? ctx.sessionKey,
agentId: data.agentId,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use the resolved agent for app-server guard

When a Codex app-server conversation binding has no stored agentId but the inbound claim context does (for example an older/legacy binding claimed under a non-default agent), this newly added shorthand agentId is immediately overwritten by the existing agentId: data.agentId. The native execution/sandbox guard then evaluates the undefined/default agent instead of the actual ctx.agentId, so agent-scoped sandbox or exec-host=node policy can be bypassed for bound Codex conversation turns; pass the resolved agentId only.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added proof: 🎥 video Contributor real behavior proof includes video or recording evidence. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. and removed merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jun 21, 2026
@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Closing this as superseded: the branch forked from main on 2026-06-21 and main has since moved several thousand commits across the same surfaces (Codex config, migrations, thread lifecycle, subagent monitor). A rebase attempt already hit conflicts per the PR description, and at this drift a mechanical rebase would amount to a rewrite, so we are landing the design piecemeal on current main instead of force-pushing this branch.

Disposition of the PR's content:

  • Several of the protocol/runtime cleanups in this diff (dead notification-field aliases, validator normalizers, event-projector fallbacks) are re-implemented on current main as part of the Codex app-server floor bump to 0.142 (branch claude/great-mendeleev-de4d3b, arriving as a fresh PR).
  • The SQLite-backed session-binding store plus doctor sidecar migration is being re-implemented on current main in a dedicated follow-up, using this PR's session-binding.ts / session-binding-store.ts / migration/session-binding-sidecars.ts design as the reference.
  • The turn router, client-runtime.ts per-client observer ownership, client-scoped rate-limit cache, and the native-subagent-monitor status-revision hardening are a second dedicated follow-up on the same reference basis.
  • Parts of the problem space were independently fixed on main in the meantime (for example the yielded native subagent delivery fix and shared native threads), which is exactly the overlap that made the rebase conflict.

The branch stays available as the design reference. If any piece of the follow-up work turns out to need code lifted verbatim from here, we will cherry-pick from this branch rather than reopen the PR.

@steipete

steipete commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

The turn-routing and client-runtime-ownership track of this PR has now landed on main, re-implemented on current shapes in #101376 (commit 554d772): the keyed turn router, the client-scoped rate-limit cache with per-limit revisions (cross-client usage-limit bleed fix), the per-physical-client auth/rate-limit runtime handlers, the thread-resume subscription-safety split, and the client-factory deletion. The SQLite session-binding track landed separately in #101210.

Still unique to this branch: the native-subagent-monitor status-revision rework and the compact/review native-turn generalization (main has since shipped its own compaction completion-watch design, so that part would need a fresh evaluation). Tracking for the remainder: #101338.

steipete added a commit that referenced this pull request Jul 12, 2026
…02060)

Codex native subagent results now survive parent cleanup, app-server persistence races, resumptions, and transient delivery failures. The monitor treats app-server thread/read and thread/turns/list history as canonical recovery state (works on non-stdio transports), retains the shared physical client only while detached children need monitoring, fences stale reads across lifecycle changes, keeps interrupted children resumable, preserves multi-agent V2 subAgentActivity lineage, and bounds terminal delivery retries with a durable failed state. Removes rollout-file discovery, transcript parsing, periodic whole-client rescans, and the deferred one-shot cleanup path.

Adds an opt-in live E2E lane (OPENCLAW_LIVE_CODEX_NATIVE_SUBAGENT=1) proving detached delivery and history-only recovery against a real app-server with an OpenAI key, restores the registered-child user-spoof regression test, and registers both codex opt-in live files in the release shard optional-env map.

Closes #97593
Related: #93313
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 13, 2026
…enclaw#102060)

Codex native subagent results now survive parent cleanup, app-server persistence races, resumptions, and transient delivery failures. The monitor treats app-server thread/read and thread/turns/list history as canonical recovery state (works on non-stdio transports), retains the shared physical client only while detached children need monitoring, fences stale reads across lifecycle changes, keeps interrupted children resumable, preserves multi-agent V2 subAgentActivity lineage, and bounds terminal delivery retries with a durable failed state. Removes rollout-file discovery, transcript parsing, periodic whole-client rescans, and the deferred one-shot cleanup path.

Adds an opt-in live E2E lane (OPENCLAW_LIVE_CODEX_NATIVE_SUBAGENT=1) proving detached delivery and history-only recovery against a real app-server with an OpenAI key, restores the registered-child user-spoof regression test, and registers both codex opt-in live files in the release shard optional-env map.

Closes openclaw#97593
Related: openclaw#93313
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: discord Channel integration: discord channel: feishu Channel integration: feishu channel: telegram Channel integration: telegram docs Improvements or additions to documentation extensions: codex gateway Gateway runtime maintainer Maintainer-authored PR mantis: telegram-visible-proof Mantis should capture Telegram visible proof. 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. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: 🎥 video Contributor real behavior proof includes video or recording evidence. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant