Skip to content

fix(codex): restore installed skills with catalog-backed models - #140422

Merged
jalehman merged 14 commits into
openclaw:mainfrom
Colton-Harris:fix/codex-skill-carrier
Sep 24, 2026
Merged

jalehman merged 14 commits into
openclaw:mainfrom
Colton-Harris:fix/codex-skill-carrier

Conversation

@Colton-Harris

@Colton-Harris Colton-Harris commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Related: #95058.

What Problem This Solves

Installed OpenClaw skills can disappear from the model-facing prompt on Codex connections without a managed inference relay: model-owned collaboration instructions replace the field that previously carried the catalog. Skill discovery and prompt accounting can still report success while the model sees no catalog.

Why This Change Was Made

Preserve the shipped managed behavior and repair only the uncovered delivery path:

  • Managed inference connections: keep the catalog in parent-only model-request instructions. It stays out of native thread history and child requests. Catalog edits and lightweight cron omission do not change thread policy or force resumes.
  • Connections without a managed relay: carry the eligible catalog in thread developer instructions, independently of model-owned collaboration policy. Persistent threads resume with the current catalog; live incognito threads receive catalog-only updates without changing immutable generic policy.
  • Restore fallback catalog updates/withdrawals after automatic compaction, retry failed restoration on the next turn, and invalidate delivery after standalone compaction on both ordinary and incognito paths.

User Impact and Limits

Managed users retain parent-only skill scope and request-local freshness. Users of uncovered connections receive installed skills even with catalog-backed collaboration instructions.

The fallback still has explicit native-runtime limits: children can inherit its thread catalog; an automatic compaction's immediate continuation can see the creation-time catalog before restoration reaches the following request; lightweight cron turns sharing a fallback thread withdraw the catalog until the next ordinary turn. These are not changes to managed connections. Persona and memory delivery are outside this skills-only repair.

Review Feedback Addressed

  • P1, preserve shipped managed parent-only delivery: fixed. Carrier selection follows the actual prepared inference route, including route reselection, and both parent-local callers retain skills.
  • P2, update the inference caller after the field rename: fixed without removing managed skill delivery. Production and test type checks cover the cutover.
  • Earlier compaction findings remain covered, including edited/removed catalogs, failed restore, and both standalone compaction ownership paths.
  • The earlier proposal to replace managed delivery and accept its compatibility tradeoffs is superseded by this narrower repair.
  • Latest ClawSweeper review: no actionable code or security findings. Its four remaining checklist items concern two documented fallback tradeoffs: native-child catalog inheritance and the immediate automatic-compaction stale-catalog window. Source inspection confirms both. Maintainer decision (2026-09-24): Josh Lehman explicitly accepted both fallback limitations and authorized merge. Native-child catalog inheritance and the immediate post-compaction stale-catalog window are accepted for connections without the managed relay. Managed connections retain parent-only, request-local delivery.

Rebase

Rebased onto main at 1514b7c4b5c120ebe201d042400ffa345381f19a; candidate head 371c1866dd0a66af15e234590d7a7de0d73831af. Preserved the contributor commits. Resolved the standalone-compaction conflict by retaining main's canRetainThreadOwnership safety gate and tracking successful native compaction separately for catalog invalidation. This preserves rejection/uncertain-start cleanup and refreshes the catalog after completed compaction, including incognito threads. The previous upstream CI inventory repairs are included through the new base.

Evidence

Current rebased head

  • 362 tests passed across standalone compaction, client ownership, thread binding/lifecycle, managed skill delivery, and packaged-native skill delivery/compaction (five files, two Vitest shards; 142.10 s runner wall).
  • Production and test extension type checks passed using tsconfig.extensions.json and test/tsconfig/tsconfig.extensions.test.json.
  • Formatting passed across all 38 changed files; type-aware lint passed for the conflict-resolution file with zero warnings/errors; git diff --check passed.
  • Test setup note: an initial type-check invocation used the editor/lint graph (extensions/tsconfig.json) and produced graph/root-directory errors. Both actual production/test type-check entry points above passed. No product or test changes were needed.
  • Fresh independent Codex autoreview passed: scoped-clean, no actionable P0–P2 findings. Static review covered the complete rebased diff; runtime evidence is the checks above. Hosted CI for head 371c1866dd0a66af15e234590d7a7de0d73831af is green: 77 successful checks, 48 skipped, no failed or pending checks, including openclaw/ci-gate.

Earlier implementation evidence

CI lint follow-up

Commit 8b666705896 removes the test's object-to-string coercion and explicitly requires string instructions before collecting them. The exact typescript(no-base-to-string) error reproduced before the repair. Type-aware oxlint with --tsconfig extensions/tsconfig.json now passes (zero warnings/errors), as do formatting and git diff --check. All five tests in run-attempt.skills.test.ts pass with --maxWorkers=1 (17.04 s runner wall; 4.205 s test execution). Earlier broader runtime/review evidence below applies to the preceding implementation; this follow-up changes only the test's string validation.

The lint fix passed hosted CI. The remaining tooling failure was the extracted wrapper inventory omitting src/config/config-journal-snapshot.kernel.ts, introduced by an upstream config-journal refactor. Main repaired it in 5b210a8eea758c654ba2fe07bd834805936a9df8; the previous branch head merged main through that exact commit, also incorporating the earlier cli-root-options inventory repair. That earlier merge was conflict-free and preserved contributor history; the current rebase includes the same repairs through its base.

Post-merge local proof: all 18 tests in eager-import-closure.test.ts and pr-wrapper-source-closure.test.ts passed (25.98 s runner wall), including the exact CI failure. All 255 tests across thread-lifecycle.binding.test.ts, run-attempt.skills.test.ts, and run-attempt.skills.native.test.ts passed (88.86 s runner wall). Production extension type checking and git diff --check passed. Fresh independent integration review found no actionable P0–P2 issues (scoped-clean, static review of the candidate against the merged base). New-head hosted CI is pending; this does not claim a green full CI run.

  • 783 passed across eight targeted Codex files: catalog delivery (managed and packaged-native), attempt integration, lifecycle, binding refresh, native routing, client ownership, and standalone compaction. Combined single-worker wall time: 159.18 s.
  • 379 passed in test/vitest-projects-config.test.ts; the new tests are owned exactly once by the current database-worker project (84.95 s command wall).
  • Production and test extension type checks passed (tsgo:extensions, tsgo:extensions:test).
  • Changed-file oxlint and oxfmt --check, git diff --check, both import-cycle checks passed. Documentation link audit: 14,554 checked, zero broken.
  • Fresh independent Codex autoreview of the complete rebased candidate completed with no actionable P0–P2 findings (scoped-clean, patch correct). This was a static diff review; runtime evidence comes from the checks above.

Measured per-file test execution cost (--maxWorkers=1, excluding shared transform/setup):

File Tests Test time
client-runtime.test.ts 43 0.715 s
compact.test.ts 66 4.295 s
run-attempt.skills.native.test.ts 3 4.314 s
run-attempt.skills.test.ts 5 3.443 s
run-attempt.test.ts 190 64.013 s
thread-lifecycle.binding.test.ts 247 21.549 s
thread-lifecycle.native-config.test.ts 12 3.321 s
thread-lifecycle.test.ts 217 0.721 s

The native fixture proves the real Codex-to-Responses carrier and compaction contract; a mocked discovery test cannot substitute. CI duration is pending this push. An initial isolated test startup refused a concurrent lockfile stat change before executing tests; the final direct-Node run avoided package-manager reconciliation and passed. Type errors from moved helpers/callers and module-size lint findings found during rebase were fixed, not suppressed.

The packaged-native regression inspects actual loopback Responses request bodies with a synthetic model-owned collaboration catalog, then exercises native compaction after skill edits and withdrawal. The managed regression drives the production attempt and inference context, checks the outgoing parent body, excludes the catalog from child/compaction bodies and native thread requests, and verifies refresh plus lightweight omission without thread recreation.

No production Gateway or real user session was modified. Merge authorized by Josh Lehman on 2026-09-24 after accepting the documented fallback limitations.

@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: codex size: L labels Sep 6, 2026
@clawsweeper clawsweeper Bot added 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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 24, 2026, 5:16 PM ET / 21:16 UTC (Revision 11).

ClawSweeper review

What this changes

The Codex plugin carries installed-skill catalogs in thread instructions when no managed inference relay is available, refreshes them across thread reuse and compaction, and retains parent-only request delivery on managed connections.

Merge readiness

⛔ Blocked before merge - 4 items remain

Current main fixes skill delivery on managed Codex connections, but still leaves connections without the managed relay using a replaceable collaboration carrier. This PR addresses that distinct path. Its remaining fallback limits need a maintainer decision before merge.

Priority: P2
Reviewed head: 371c1866dd0a66af15e234590d7a7de0d73831af
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The branch has focused native-boundary evidence and no supported code finding, while its documented fallback semantics still need product acceptance.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The current-head native test drives OpenClaw's production attempt through a real Codex app server and loopback Responses transport, observing the catalog in the outgoing model request and its restoration on the request after compaction; the contributor reports that test passing. The immediate continuation remains an acknowledged gap. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The current-head native test drives OpenClaw's production attempt through a real Codex app server and loopback Responses transport, observing the catalog in the outgoing model request and its restoration on the request after compaction; the contributor reports that test passing. The immediate continuation remains an acknowledged gap. No stored-data contract changes.
Evidence reviewed 7 items Current-main gap: Current main still prepares the catalog as collaboration instructions and supplies it to the parent-local path; its thread configuration has no separate skill-catalog input for connections without the relay.
Merged managed-path fix: The same-repository merged fix explicitly covers managed bundled inference and documents that unsupported connections retain the legacy collaboration carrier. Release inspection found the merged fix in v2026.9.6; that does not establish this PR's fallback behavior.
Introduced fallback carrier: The pinned merge-base-to-head patch selects thread delivery only when no inference route is prepared, then joins the catalog to Codex thread developer instructions.
Findings None None.
Security None None.

How this fits together

The Codex plugin turns an OpenClaw skill snapshot into instructions sent through the Codex app server. The selected connection determines whether the catalog reaches only the parent model request or becomes part of native thread context.

flowchart LR
  A[Installed skills] --> B[OpenClaw skill snapshot]
  B --> C{Managed inference relay?}
  C -->|Yes| D[Parent request instructions]
  C -->|No| E[Codex thread instructions]
  E --> F[Refresh after reuse or compaction]
  D --> G[Model request]
  F --> G
Loading

Decision needed

Question Recommendation
Should connections without the managed relay use this thread-level skill-catalog fallback despite native-child inheritance and the immediate post-compaction stale-catalog window? Accept the bounded fallback: Restore skill delivery on uncovered connections while retaining the documented child inheritance and one-request compaction window.

Why: The branch repairs a real delivery gap, but its native carrier has scope and freshness semantics different from the shipped managed path; code review cannot decide whether that product tradeoff is acceptable.

Before merge

  • Resolve merge risk (P2) - On connections without the managed relay, placing the skill catalog in thread instructions can make it available to native Codex children; the shipped managed path keeps this catalog parent-only, and a maintainer has not accepted the fallback scope.
  • Resolve merge risk (P2) - After automatic compaction of a fallback incognito thread, the immediate continuation can use the creation-time catalog before restoration reaches the following request; edits or withdrawal may therefore lag for that request.
  • Complete next step (P2) - Obtain a maintainer decision on native-child catalog inheritance and the immediate post-compaction stale-catalog window before merge.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

PR surface

Source +216, Tests +1035, Docs +26. Total +1277 across 38 files.

View PR surface stats
Area Files Added Removed Net
Source 26 310 94 +216
Tests 8 1046 11 +1035
Docs 4 31 5 +26
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 38 1387 110 +1277

Review metrics

Metric Value Why it matters
Production and test growth production +312/−94, tests +1044/−11 The production growth implements separate fallback lifecycle handling; the added tests exercise native delivery, reuse, and compaction.

Root-cause cluster

Relationship: canonical
Canonical: #140422
Summary: This PR owns the remaining skills-only fallback path; related work covers the managed relay, broader prompt contracts, or persona delivery.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Accept fallback semantics (recommended)
    A maintainer can accept the documented child scope and compaction window for connections that currently lose skill delivery.
  2. Pause for native isolation
    Hold the fallback until a native carrier can refresh the catalog without child inheritance or an immediate stale continuation.

Technical review

Best possible solution:

Keep managed delivery parent-only and request-local; use the fallback only with an explicit maintainer decision on child inheritance and compaction timing, documented as user-visible limits.

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

Yes from source: on current main, use a catalog-backed Codex model on a connection without the managed relay and inspect the outgoing model request for the skill catalog. I did not execute that path during this read-only review.

Is this the best way to solve the issue?

Yes as a bounded technical repair: the branch leaves managed parent-only delivery in place and uses the existing thread carrier for uncovered connections. Acceptance of that carrier's child and compaction semantics remains a product choice.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 30e67dbd5fe6.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The PR addresses missing skills on a limited class of Codex connections, with a product tradeoff still awaiting acceptance.
  • merge-risk: 🚨 compatibility: Fallback connections would move skill catalogs into inheritable thread instructions, changing their scope relative to managed connections.
  • merge-risk: 🚨 session-state: Catalog refresh across reused and compacted native threads can leave the immediate compaction continuation on creation-time context.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The current-head native test drives OpenClaw's production attempt through a real Codex app server and loopback Responses transport, observing the catalog in the outgoing model request and its restoration on the request after compaction; the contributor reports that test passing. The immediate continuation remains an acknowledged gap. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The current-head native test drives OpenClaw's production attempt through a real Codex app server and loopback Responses transport, observing the catalog in the outgoing model request and its restoration on the request after compaction; the contributor reports that test passing. The immediate continuation remains an acknowledged gap. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • RoboClaw: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Galin Iliev: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record the maintainer decision on native-child catalog inheritance and the immediate post-compaction window.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (10 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-06T22:18:04.589Z sha ddf002e :: blocked before merge. :: [P2] Invalidate the catalog on the actual incognito compaction path
  • reviewed 2026-09-06T22:57:07.111Z sha aa64f4d :: blocked before merge. :: none
  • reviewed 2026-09-07T14:27:22.788Z sha 135dbba :: blocked before merge. :: none
  • reviewed 2026-09-14T00:05:19.233Z sha 37dd066 :: blocked before merge. :: [P1] [P1] Preserve the shipped parent-only carrier on managed connections | [P2] [P2] Update the inference caller when renaming the catalog field
  • reviewed 2026-09-14T00:36:06.098Z sha 4c77da3 :: blocked before merge. :: [P1] [P1] Preserve the shipped parent-only carrier on managed connections
  • reviewed 2026-09-24T07:26:30.761Z sha 3e3a2da8297b8c6dc4091c1d7f737cd96c0730bc :: blocked before merge. :: none
  • reviewed 2026-09-24T19:35:14.195Z sha 8b6667058963cdafdfa8eb443d4d9b0d7654f54a :: blocked before merge. :: none
  • reviewed 2026-09-24T20:03:25.571Z sha 3483e618846e4aea8971467c79e19bb1138f43bc :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 6, 2026
@serialx

serialx commented Sep 7, 2026

Copy link
Copy Markdown

I can confirm that I also have this issue

@Colton-Harris
Colton-Harris force-pushed the fix/codex-skill-carrier branch from aa64f4d to 135dbba Compare September 7, 2026 14:18
@Colton-Harris
Colton-Harris force-pushed the fix/codex-skill-carrier branch from 135dbba to 37dd066 Compare September 13, 2026 23:57
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 14, 2026
@Colton-Harris

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@jalehman
jalehman force-pushed the fix/codex-skill-carrier branch from 4c77da3 to 3e3a2da Compare September 24, 2026 07:18
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 24, 2026
@serialx

serialx commented Sep 24, 2026

Copy link
Copy Markdown

Issue seem to be fixed by #142276

Rook and others added 14 commits September 24, 2026 14:01
Moving the installed-skill catalog into thread developer instructions made
every catalog refresh look like a generic policy change. On a live incognito
thread the warm-reuse guard compared the whole creation string, so editing a
skill description and sending another message threw
CodexIncognitoPolicyChangeError before turn/start.

The catalog is now a separate lifecycle input (`skillsInstructions`). The
request builder joins it onto the wire developer carrier after the generic
policy, so catalog-backed models still receive it and persistent threads keep
cold-resuming through the existing policy handoff. The retained ephemeral
record splits the immutable generic policy from the catalog last delivered;
incognito warm reuse compares only the generic policy (unchanged guard, still
fail-closed) and delivers a changed catalog with a `thread/inject_items`
developer message, tracked so an unchanged catalog is not re-sent.

Docs: the runtime guide, system-prompt concept, and token-use reference still
said the catalog rode turn-scoped collaboration instructions; they now match
the thread carrier and the incognito refresh.

Codex protocol behavior checked in sibling ../codex (main 459a79e):
core/src/context/world_state/collaboration_mode.rs:30-42 (catalog messages
replace caller collaboration instructions), app-server-protocol v2 thread.rs
(thread/settings/update has no developerInstructions), turn_processor.rs
thread_inject_items, context-fragments/src/additional_context.rs (1,000-token
cap rules out additionalContext as the catalog carrier).
Adds the missing half of the reused-thread coverage. The incognito case
already proved an edited catalog reaches a live ephemeral thread through
thread/inject_items. This covers the persistent case: the catalog rides the
thread developer carrier, so it participates in the thread-config
fingerprint (thread-fingerprints.ts:121). An edited skill therefore
invalidates warm reuse and cold-resumes the SAME thread with the new
catalog, instead of either losing the conversation or answering from the
stale catalog.

Mutation-checked: dropping options.skillsInstructions from the join in
buildCodexThreadConfiguration fails both this test and the incognito
two-turn test, so neither assertion is vacuous.

Also adapts the native skills test to upstream's changed shutdown contract.
closeAndWait() returns CodexAppServerCloseResult rather than boolean since
bcef3b3 (openclaw#139657); the assertion now uses the same
toMatchObject({ exited: true }) form as the other native tests
(thread-lifecycle.native.test.ts:142, settled-turn-finalizer.native.test.ts:57).
Extract joinPresentSections into a zero-import leaf module so
thread-requests.ts no longer imports run-attempt-state.ts, which closed a
10-file strongly connected component in extensions/codex/src/app-server.
The merge base is clean, so the cycle was introduced by this branch.

Register the two new skills test files in the vitest project that already
owns the comparable run-attempt.native-hook-relay test, so full-suite file
ownership is exactly one project per file.
An incognito thread carries its skill catalog in creation-time native
developer instructions. A mid-session catalog change is delivered as a
client-authored developer message, but Codex remote compaction drops those
messages unless retain_client_developer_messages is enabled (off by default)
and rebuilds initial context from the unchanged native instructions. The host
had already recorded the refreshed catalog as delivered, so later turns
skipped reinjection and the conversation silently reverted to the catalog it
started with: edited skills kept stale descriptions and removed skills
stayed visible.

Track the creation-time catalog separately from the current one and
re-deliver the current catalog after every compaction, including compaction
inside a turn, via the existing onContextCompacted hook. An unchanged catalog
still sends nothing, because compaction rebuilds it natively.
Drive the packaged Codex app-server binary through a real compaction on a
live incognito thread: turn two refreshes the catalog, turn three exceeds the
resolved auto-compact limit, and turn four must still show the model the
current catalog.

The continuation request after summarization is asserted to carry the
creation-time catalog and not the refresh, which reproduces the reversion
natively. The creation-time catalog stays in the ephemeral thread's immutable
developer instructions and is re-emitted on every request, so restoration is
pinned by catalog ordering rather than absence.

Pin nativeSkillsInstructions in the ephemeral policy binding assertions so a
refresh is shown never to rewrite what compaction will restore.
…tore

A failed or aborted restore was logged and dropped while the retained record
still named the refreshed catalog as delivered. Warm reuse compares that
record, so every later turn skipped the refresh and the conversation stayed
stranded on the creation-time catalog for the rest of its life.

Record what compaction actually restored when the injection fails, so the
next turn delivers the current catalog again.
The restore is issued as soon as a compaction completes, but that turn's own
continuation request may already have been built, so the guaranteed floor is
the following request rather than the remainder of the compacting turn.
Standalone compaction re-retained the live thread without its ephemeral
policy, so the record lost the creation-time generic policy and the catalog
it had delivered. The next turn then read the live incognito thread as policy
drift, and the discarded catalog refresh was never re-sent.

Carry the ephemeral policy back through the re-retain and record the catalog
compaction actually restored, so an edited or withdrawn skill is delivered
again on the next turn instead of reverting for the rest of the conversation.
Standalone compaction only claims and re-retains a thread for non-incognito
session keys, so the previous reversion never ran for the conversations it was
written for. An incognito thread keeps its own live subscription, leaving the
retained record still naming the discarded refresh as delivered.

Correct the retained record in place after a completed compaction, and cover
both session kinds so an incognito key can no longer be masked by an ordinary
one in the regression.
The three post-compaction catalog re-delivery tests never observed
`thread/inject_items`, which read as the repair being broken. It was not.

Compaction runs the real `before_compaction` hook, which performs an actual
mirrored-session history read; its first worker start costs several seconds.
`createParams` defaults `timeoutMs` to 5s, so the attempt execution budget
expired inside that read, aborted projection, and the `onContextCompacted`
restore never ran -- reproducing precisely the symptom these tests assert
against.

Give these turns the same budget the sibling compaction tests already use in
`run-attempt.skills.native.test.ts` and `run-attempt.hooks.test.ts`. Every
assertion is unchanged.
@jalehman
jalehman force-pushed the fix/codex-skill-carrier branch from 3483e61 to 371c186 Compare September 24, 2026 21:07
@jalehman
jalehman merged commit b875c53 into openclaw:main Sep 24, 2026
130 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 25, 2026
…claw#140422)

* fix(codex): restore installed skills with catalog-backed models

* fix(codex): keep skill catalog refreshable on live incognito threads

Moving the installed-skill catalog into thread developer instructions made
every catalog refresh look like a generic policy change. On a live incognito
thread the warm-reuse guard compared the whole creation string, so editing a
skill description and sending another message threw
CodexIncognitoPolicyChangeError before turn/start.

The catalog is now a separate lifecycle input (`skillsInstructions`). The
request builder joins it onto the wire developer carrier after the generic
policy, so catalog-backed models still receive it and persistent threads keep
cold-resuming through the existing policy handoff. The retained ephemeral
record splits the immutable generic policy from the catalog last delivered;
incognito warm reuse compares only the generic policy (unchanged guard, still
fail-closed) and delivers a changed catalog with a `thread/inject_items`
developer message, tracked so an unchanged catalog is not re-sent.

Docs: the runtime guide, system-prompt concept, and token-use reference still
said the catalog rode turn-scoped collaboration instructions; they now match
the thread carrier and the incognito refresh.

Codex protocol behavior checked in sibling ../codex (main 459a79e):
core/src/context/world_state/collaboration_mode.rs:30-42 (catalog messages
replace caller collaboration instructions), app-server-protocol v2 thread.rs
(thread/settings/update has no developerInstructions), turn_processor.rs
thread_inject_items, context-fragments/src/additional_context.rs (1,000-token
cap rules out additionalContext as the catalog carrier).

* test(codex): cover catalog refresh on reused persistent threads

Adds the missing half of the reused-thread coverage. The incognito case
already proved an edited catalog reaches a live ephemeral thread through
thread/inject_items. This covers the persistent case: the catalog rides the
thread developer carrier, so it participates in the thread-config
fingerprint (thread-fingerprints.ts:121). An edited skill therefore
invalidates warm reuse and cold-resumes the SAME thread with the new
catalog, instead of either losing the conversation or answering from the
stale catalog.

Mutation-checked: dropping options.skillsInstructions from the join in
buildCodexThreadConfiguration fails both this test and the incognito
two-turn test, so neither assertion is vacuous.

Also adapts the native skills test to upstream's changed shutdown contract.
closeAndWait() returns CodexAppServerCloseResult rather than boolean since
1e6e072 (openclaw#139657); the assertion now uses the same
toMatchObject({ exited: true }) form as the other native tests
(thread-lifecycle.native.test.ts:142, settled-turn-finalizer.native.test.ts:57).

* fix(codex): break app-server import cycle and register skills test lanes

Extract joinPresentSections into a zero-import leaf module so
thread-requests.ts no longer imports run-attempt-state.ts, which closed a
10-file strongly connected component in extensions/codex/src/app-server.
The merge base is clean, so the cycle was introduced by this branch.

Register the two new skills test files in the vitest project that already
owns the comparable run-attempt.native-hook-relay test, so full-suite file
ownership is exactly one project per file.

* fix(codex): keep refreshed incognito skill catalogs across compaction

An incognito thread carries its skill catalog in creation-time native
developer instructions. A mid-session catalog change is delivered as a
client-authored developer message, but Codex remote compaction drops those
messages unless retain_client_developer_messages is enabled (off by default)
and rebuilds initial context from the unchanged native instructions. The host
had already recorded the refreshed catalog as delivered, so later turns
skipped reinjection and the conversation silently reverted to the catalog it
started with: edited skills kept stale descriptions and removed skills
stayed visible.

Track the creation-time catalog separately from the current one and
re-deliver the current catalog after every compaction, including compaction
inside a turn, via the existing onContextCompacted hook. An unchanged catalog
still sends nothing, because compaction rebuilds it natively.

* test(codex): cover catalog restoration across native compaction

Drive the packaged Codex app-server binary through a real compaction on a
live incognito thread: turn two refreshes the catalog, turn three exceeds the
resolved auto-compact limit, and turn four must still show the model the
current catalog.

The continuation request after summarization is asserted to carry the
creation-time catalog and not the refresh, which reproduces the reversion
natively. The creation-time catalog stays in the ephemeral thread's immutable
developer instructions and is re-emitted on every request, so restoration is
pinned by catalog ordering rather than absence.

Pin nativeSkillsInstructions in the ephemeral policy binding assertions so a
refresh is shown never to rewrite what compaction will restore.

* fix(codex): re-deliver the catalog after a failed post-compaction restore

A failed or aborted restore was logged and dropped while the retained record
still named the refreshed catalog as delivered. Warm reuse compares that
record, so every later turn skipped the refresh and the conversation stayed
stranded on the creation-time catalog for the rest of its life.

Record what compaction actually restored when the injection fails, so the
next turn delivers the current catalog again.

* docs(codex): state catalog restore timing precisely

The restore is issued as soon as a compaction completes, but that turn's own
continuation request may already have been built, so the guaranteed floor is
the following request rather than the remainder of the compacting turn.

* fix(codex): keep incognito creation policy across standalone compaction

Standalone compaction re-retained the live thread without its ephemeral
policy, so the record lost the creation-time generic policy and the catalog
it had delivered. The next turn then read the live incognito thread as policy
drift, and the discarded catalog refresh was never re-sent.

Carry the ephemeral policy back through the re-retain and record the catalog
compaction actually restored, so an edited or withdrawn skill is delivered
again on the next turn instead of reverting for the rest of the conversation.

* fix(codex): revert the catalog on the incognito compaction path

Standalone compaction only claims and re-retains a thread for non-incognito
session keys, so the previous reversion never ran for the conversations it was
written for. An incognito thread keeps its own live subscription, leaving the
retained record still naming the discarded refresh as delivered.

Correct the retained record in place after a completed compaction, and cover
both session kinds so an incognito key can no longer be masked by an ordinary
one in the regression.

* fix(codex): preserve trajectory helper import after rebase

* test(codex): budget the compaction history read in skill catalog tests

The three post-compaction catalog re-delivery tests never observed
`thread/inject_items`, which read as the repair being broken. It was not.

Compaction runs the real `before_compaction` hook, which performs an actual
mirrored-session history read; its first worker start costs several seconds.
`createParams` defaults `timeoutMs` to 5s, so the attempt execution budget
expired inside that read, aborted projection, and the `onContextCompacted`
restore never ran -- reproducing precisely the symptom these tests assert
against.

Give these turns the same budget the sibling compaction tests already use in
`run-attempt.skills.native.test.ts` and `run-attempt.hooks.test.ts`. Every
assertion is unchanged.

* fix(codex): preserve parent-only skills on managed connections

* test(codex): validate managed instructions before collection

---------

Co-authored-by: Rook <[email protected]>
Co-authored-by: Colton Harris <[email protected]>
Co-authored-by: jalehman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: codex 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. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants