Repository navigation
Description
Summary
OpenClaw 2026.7.1 introduced Codex session-generation fencing that can break existing runEmbeddedAgent callers which reuse a logical sessionKey while creating a fresh sessionId for each isolated run.
The first invocation can succeed, while subsequent invocations fail locally before model execution with:
Codex session generation is no longer current: <sessionId>
This is an observable compatibility change in the public plugin runtime API.
Regression range
- The published
openclaw@2026.6.10package does not contain the generation-reclamation guard or this exception. openclaw@2026.7.1contains the guard following refactor(codex): store app-server thread bindings in SQLite plugin state #101210.- refactor(codex): store app-server thread bindings in SQLite plugin state #101210 describes "No day-to-day behavior change", but the accepted identity combination and repeated-call behavior changed for plugin SDK callers using the Codex harness.
Minimal reproduction
Using the Codex harness, invoke api.runtime.agent.runEmbeddedAgent(...) twice with:
- the same stable
sessionKey - a newly generated
sessionIdfor each invocation - an isolated temporary transcript/session target
Conceptually:
for (let attempt = 0; attempt < 2; attempt += 1) {
const sessionId = `isolated-task-${crypto.randomUUID()}`;
await api.runtime.agent.runEmbeddedAgent({
sessionId,
sessionKey: "tool:isolated-task",
runId: sessionId,
prompt: "Return a short response",
// normal provider/model/workspace parameters omitted
});
}The first generation can claim the stable key. A later invocation has no binding for its fresh physical session and fails to reclaim the previous generation. In the 2026.7.1 distribution, the exception is thrown by the Codex thread lifecycle when reclaimCurrentCodexSessionGeneration(...) returns false.
Removing sessionKey so that each isolated invocation uses its own identity avoids the failure.
Why this is difficult for plugin authors
RunEmbeddedAgentParamspublicly accepts bothsessionIdand optionalsessionKey.- The SDK documentation does not explain their required lifecycle relationship for Codex.
- The SDK example does not discuss persistent versus isolated session identity.
- The first invocation succeeds; there is no up-front validation of the combination.
- There is no
doctoror lint warning for affected plugins. - The exception does not tell callers whether to omit
sessionKey, reusesessionId, or perform an explicit generation transition. - A single post-upgrade smoke run will pass and therefore miss the regression.
This is not limited to plugins migrated from the legacy pi harness. Any current or future embedded Codex caller can encounter it. The same exception is already visible in the bundled Active Memory failure reported in #106957, although that issue has additional timeout and duplicate-recall behavior.
Expected improvement
At least one of:
- Preserve compatibility for isolated embedded calls.
- Reject incompatible identity combinations immediately with actionable guidance.
- Document the
sessionId/sessionKeylifecycle and how callers intentionally rotate a physical generation. - Add upgrade diagnostics for affected plugins.
- Add a regression test covering two sequential embedded Codex invocations with a stable logical key and rotating physical IDs.
Environment
- Reproduced on OpenClaw 2026.7.1
- macOS arm64
- Native Codex harness through
api.runtime.agent.runEmbeddedAgent(...) - Failure occurs before model generation and is independent of the selected OpenAI model
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jul 16, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed July 16, 2026, 4:28 AM ET / 08:28 UTC.
Summary
Keep this issue open: the report identifies a credible shipped plugin-runtime regression, and current main still contains the post-first-run generation check that can reject a fresh physical session under a stable logical key. The related Active Memory issue has overlapping stale-generation symptoms but also separate timeout and duplicate-recall behavior, so it does not supersede this narrower report. citeturn975881search0turn338428search3.
Reproducibility: yes. at source level: two sequential embedded Codex calls using one stable
sessionKeyand freshsessionIdvalues reach the generation-reclaim failure path after the first call. A focused live current-main run remains outstanding.Root-cause cluster
Relationship:
canonicalCanonical: #108769
Summary: This issue isolates the stable-key/rotating-ID generation-fencing regression; the Active Memory report overlaps on the final error but includes additional timeout and duplicate-run behavior.
Members:
partial_overlap: Active Memory Codex recalls repeat, time out, then fail as generation no longer current #106957 - It observes the same stale-generation failure after repeated recalls, while also reporting older timeout and duplicate-recall behavior that this issue does not explain.Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.
Next step
This is a bounded compatibility regression with a clear Codex lifecycle surface and regression-test shape, but the repair must first prove it preserves concurrent stale-generation fencing.
Review details
Best possible solution:
Preserve the shipped plugin-runtime identity combination with a narrowly defined safe transition for sequential isolated generations, add two-call regression coverage, and document when callers should reuse or rotate
sessionIdandsessionKey.Do we have a high-confidence way to reproduce the issue?
Yes at source level: two sequential embedded Codex calls using one stable
sessionKeyand freshsessionIdvalues reach the generation-reclaim failure path after the first call. A focused live current-main run remains outstanding.Is this the best way to solve the issue?
Yes in direction, but compatibility should be restored without weakening stale-generation protection; documentation or a better error alone would leave previously working shipped callers broken.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning high; reviewed against aaf5d23883a1.
Label changes
Label changes:
P1: A regression in the latest release can stop established embedded Codex workflows after their first successful invocation.impact:session-state: The failure is caused by disagreement between logical session identity and the current physical Codex session generation.issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.clawsweeper:source-repro: Current issue advisory state selects this label.Label justifications:
P1: A regression in the latest release can stop established embedded Codex workflows after their first successful invocation.impact:session-state: The failure is caused by disagreement between logical session identity and the current physical Codex session generation.Evidence reviewed
Acceptance criteria:
What I checked:
Codex session generation is no longer currentwhen reclaiming the generation for the resolved binding identity fails, matching the reported pre-model failure. citeturn975881search0. (extensions/codex/src/app-server/thread-lifecycle.ts, aaf5d23883a1)runEmbeddedAgentas a public helper and accepts session identity parameters, while the published example does not define the lifecycle relationship between a persistent logical key and rotating physical IDs. citeturn338428search3turn338428search1. (src/plugins/types.ts, aaf5d23883a1)0d981095d43093d0abce5e9cb431cfcb5dc716f1; the issue reports the guard absent in 2026.6.10 and present in the shipped 2026.7.1 package. (extensions/codex/src/app-server/thread-lifecycle.ts, 0d981095d430)threadId; OpenClaw'ssessionKeyand physical-generation fencing are additional OpenClaw ownership semantics rather than an upstream Codex requirement. citeturn365012search3turn338428search0. (extensions/codex/src/app-server/session-binding.ts, aaf5d23883a1)Likely related people:
extensions/codex/src/app-server/thread-lifecycle.ts,extensions/codex/src/app-server/session-binding.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.fix(codex): explain sessionKey/sessionId lifecycle when a session gen…
steipete commentedon Jul 29, 2026
Fixed by #115601, merged as fed427a50ede2672f54bfc59ec85b4ecbda8a5fe.
The fix resolves binding authority against the durable session row before Codex client startup. Current durable sessions keep stable-key generation fencing; mismatched or unreadable durable ownership fails closed; row-less ephemeral embedded runs bind their Codex state to the physical session ID, so a new physical run cannot inherit the previous ephemeral generation.
Regression proof:
starts sequential ephemeral generations that share a stable session keyruns two sequential embedded Codex attempts with the same logicalsessionKeyand rotatingsessionIdvalues and proves both start independent native threads. The paired durable-mismatch regression proves a stale physical generation is rejected before client startup. The exact PR head passed the hosted CI gate before merge.