Skip to content

fix(codex): keep native tool declarations across completion turns - #183286

Merged
steipete merged 1 commit into
mainfrom
fix/codex-native-declaration-stability-179363
Oct 25, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/codex-native-declaration-stability-179363

Conversation

@steipete

@steipete steipete commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Narrow slice of #179363. Related: #178982.

What Problem This Solves

Fixes native Codex tool declarations disappearing when a session moves from an owner turn to a completion turn, which can disrupt continued use of the native session.

User Impact

Configured native thread, plugin discovery, and supervision tools retain the same declarations across owner and completion turns. Their execution remains restricted to a currently authorized owner.

Why This Change Was Made

The native factories removed tools for nonowner turns even though declaration lifetime belongs to the session. Keep their declarations stable and enforce current owner authority at execution and the existing effect checks. Configuration opt-outs still control availability.

This preserves the four-name fingerprint workaround in src/agents/cli-runner/prepare.ts and the settlement/continuity fixes from #182191 and #183059. It does not include the catalog, widget, descriptor, or schema changes from #179363.

Codex's own contract defines dynamic tools at thread start and restores them from rollout metadata (session owner); a function declaration contains its name, description, and input schema (declaration).

Evidence

  • Regression at the registered native factories: owner → nonowner/unspecified → owner declarations remain identical for all seven tools, while nonowner calls are denied. It failed against the base with an empty declaration list and passes with the fix.
  • All 104 targeted tests passed across six suites: native factory registration, native thread/plugin tools, supervision tools and request lifetime, and agent tool-prefix stability (--maxWorkers=1). Existing fork/archive and policy-revocation coverage remains green.
  • Exact-head CI passed on 260f49d7222aefb7bdf6223d0dd64d4ce7c59249: all 55 jobs completed, none failed.
  • Targeted formatting, whitespace, and syntax/boundary lint passed. Local typed lint/typechecking refused the linked shared installation before analysis; the successful exact-head PR CI supplies the broad type proof.
  • Security Review passed on this head. A separate canceled duplicate remains in the raw rollup; it is not a failed code check.
  • Live native Codex continuity and production-transport supervision owner/revocation controls were not exercised. Existing registered-factory and AppServer client tests cover nonowner denial, policy revocation during client acquisition, and no unauthorized steer/interrupt write. A new supervision transport harness is outside this PR’s bounded live validation.
  • ClawSweeper reported no code findings but requested the additional live authority-chain proof above and left a needs-human/security advisory. That proof request remains a coordinator caveat; it has not been cleared.
  • Diff-scoped simplification and independent review found no actionable findings. Production +24/-19 (net +5), tests +35/-8 (net +27), docs +4/-2 (net +2). The small production increase replaces declaration-time filtering with execution-time owner checks.

Original investigation and contributor work: #179363 by @roboclaw-bot, with @Marvinthebored and Dallin Romney.

Co-authored-by: Marvinthebored [email protected]
Co-authored-by: Dallin Romney [email protected]

Keep configured native Codex declarations across owner and completion turns,
while enforcing current owner authority when the tools execute. Preserve the
existing fingerprint workaround and native session settlement behavior.

Narrow slice of #179363. Related: #178982.

Co-authored-by: Marvinthebored <[email protected]>
Co-authored-by: Dallin Romney <[email protected]>
@clawsweeper

clawsweeper Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review October 25, 2026 05:25
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-25T05:27:43.996095Z 260f49d Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper

clawsweeper Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: codex size: S labels Oct 25, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 25, 2026
@clawsweeper

clawsweeper Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR keeps seven native Codex tools declared across owner and completion turns while checking owner authority when they execute.

Example: A session with user-home access and supervision enabled transitions from an owner turn to a completion turn.

  • Before: codex_threads, codex_plugins, and five supervision declarations disappear, changing the tool catalog.
  • After: The declarations remain identical, while calls without current owner authority are rejected.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The patch is focused and source-consistent, but the required authority evidence is incomplete.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: Owner-to-completion transitions can reset a native conversation because configured Codex tools disappear from its catalog.
Reason: The maintainer-authored direction follows the stable-context contract and repairs the native-tool slice of #178982 without importing the broader open proposal.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep this PR open: it is a focused, maintainer-directed repair for declaration churn still present on main, and no concrete introduced bug was found.

Priority: P1
Reviewed head: 260f49d7222aefb7bdf6223d0dd64d4ce7c59249

Before merge

  • Add real behavior proof - Authority-chain proof required: the registered-factory regression covers stable declarations and initial nonowner rejection, and prior linked live traces cover plugin discovery and thread forks, but they use different earlier implementations and do not cover supervision. Supply production-path owner and nonowner controls plus revocation during awaited supervision preparation, showing no unauthorized turn/steer or turn/interrupt write; redact credentials and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Resolve security review attention item - No concrete bypass was found, but the changed supervision admission boundary requires final-effect authorization validation.
  • Resolve merge risk - Before merge, the PR owner must validate that moving supervision admission to execution preserves owner isolation through queued AppServer control writes.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied evidence does not exercise this candidate's supervision tools through production transport with allowed, nonowner, and revoked-authority controls at the final write boundary.
Agent review details

How this fits together

The Codex plugin builds model-facing tools from session configuration; execution passes through invocation, account, session, and AppServer effect guards before native reads or control writes.

flowchart TD
  A[Session configuration] --> B[Codex tool factories]
  B --> C[Stable tool declarations]
  C --> D[Native session reuse]
  C --> E[Tool invocation]
  E --> F[Live owner and session guards]
  F --> G[Codex AppServer effects]
Loading

Technical review

Best possible solution:

Keep this focused repair in the existing native factories, retaining configuration gates and live authorization at native effects.

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

Current source deterministically removes native declarations on nonowner construction and invalidates reuse when the resulting tool-name hash changes; linked reports supply matching reset traces, but this review ran no target code.

Is this the best way to solve the issue?

Moving turn-dependent admission into the existing execution guards is the smallest complete native-tool repair and preserves genuine configuration-driven catalog changes.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 274a86d02feb.

Merge-risk options

Maintainer options:

  1. Validate supervision authority (recommended)
    The PR owner should exercise registered supervision controls through production transport with an allowed owner, a nonowner, and revocation during awaited preparation, recording whether protected writes occur.

Provenance checked

  • Native thread declarations and effect guards changes intended behavior with a stated reason (3d6a221: Shared native threads were deliberately owner-only and configuration-gated; later supervision and worker refactors retained live session checks and guarded binding settlement.)
  • Native plugin discovery changes intended behavior with a stated reason (e1b8150: Discovery exposes bounded untrusted catalog metadata to owners without allowing ordinary turns to install or authorize plugins; the PR explains why declaration lifetime must be separated from that permission.)
  • Supervision registration and owner continuation changes intended behavior with a stated reason (861f60e: V2 registration carried live invocation authority across explicitly admitted parent continuation; this PR retains that contract and replaces the copied owner boolean with a live getter.)
  • Tests and native-feature documentation changes intended behavior with a stated reason (2957715: The documentation described owner-turn availability; changed tests and wording now distinguish stable declarations from owner-only execution while preserving configuration exclusions.)

Testing

Proof path: in-process harness.

Security

Needs attention: No concrete bypass was found, but the changed supervision admission boundary requires final-effect authorization validation.

Evidence

What I checked:

  • Verified introduced scope: The pinned introduction replaces declaration-time owner filtering with execution checks in the existing factories; configuration gates, schemas, and persistence formats remain unchanged. (extensions/codex/src/native-thread-tool.ts:139, 260f49d7222a)
  • Current-main failure mechanism: Main still removes supervision tools for nonowner construction; CLI preparation fingerprints tool names, and a changed fingerprint invalidates native reuse with prompt-tools. codex_plugins and codex_threads retain analogous construction-time filters. (extensions/codex/index.ts:239, 274a86d02feb)
  • Registered-factory regression: The changed registration test compares names, descriptions, and parameters across owner, nonowner, unspecified, and owner construction, then exercises nonowner rejection for all seven tools; the body reports this regression failed on base. (extensions/codex/index.test.ts:344, 260f49d7222a)
  • Authority chain: Supervision now reads senderIsOwner through a getter. Its existing policy owner checks invocation currency and owner identity, and carries guards through AppServer client acquisition and queued requests; this review found no reachable bypass. (extensions/codex/src/supervision-tools.ts:701, 260f49d7222a)
  • Credited prior live evidence and its limits: Marvinthebored's fix: preserve native CLI sessions across completion turns #179363 (comment) records owner/nonowner plugin discovery and token revocation; fix: preserve native CLI sessions across completion turns #179363 (comment) records allowed forks and no fork or binding write after abort/reset. These are earlier implementations with additional execution wrappers and do not exercise this candidate's supervision controls.
  • Affirmative dependency contract: The PR explicitly relies on Codex's dynamic-tool lifetime contract. I personally inspected the sibling session owner and protocol, then verified the exact cited revision through GitHub: tools are defined at thread start and restored from rollout metadata, with name, description, and input schema in each function declaration. The dependency's review guidance was also inspected. (codex-rs/core/src/session/mod.rs:730, be2951ea34f0)

PR surface

Source +5, Tests +27, Docs +2. Total +34 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 24 19 +5
Tests 3 35 8 +27
Docs 1 4 2 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 63 29 +34

Review metrics

Metric Value Why it matters
Production versus tests Production +24/-19; tests +35/-8 The small production increase adds execution-time checks to existing owners; test growth covers declaration stability and rejection boundaries without new scaffolding.

Root-cause cluster

Relationship: partial_overlap
Canonical: #178982
Summary: This PR repairs the native Codex factory portion of the broader declaration-churn report; the larger open PR also changes other tool and catalog surfaces.

Members:

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

Labels

Label changes:

  • add P1: Source and the linked reporter traces connect owner-dependent tool churn to repeated native-session resets and lost conversation continuity.
  • add merge-risk: 🚨 security-boundary: Previously absent tools now reach nonowner invocation paths, making live execution authorization the security boundary; supervision final-effect validation remains unresolved.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P1: Source and the linked reporter traces connect owner-dependent tool churn to repeated native-session resets and lost conversation continuity.
  • merge-risk: 🚨 security-boundary: Previously absent tools now reach nonowner invocation paths, making live execution authorization the security boundary; supervision final-effect validation remains unresolved.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

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

  • Add production-path supervision proof that an owner can write, a nonowner cannot, and revocation during awaited preparation prevents the final AppServer control write.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 25, 2026, 1:31 AM ET / 05:31 UTC.

@steipete
steipete merged commit 6a62821 into main Oct 25, 2026
186 of 191 checks passed
@steipete
steipete deleted the fix/codex-native-declaration-stability-179363 branch October 25, 2026 06:54
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

RomneyDa pushed a commit that referenced this pull request Oct 26, 2026
…183286)

Narrow slice of #179363. Keep native Codex tool declarations stable across completion turns and enforce current owner authority when tools execute. Preserve the existing four-name fingerprint workaround and the fixes from #182191 and #183059.

Validated with the factory regression red on base and green on this head, 104 targeted tests, and exact-head CI. Live transport proof remains a documented gap.

Co-authored-by: Marvinthebored <[email protected]>
Co-authored-by: Dallin Romney <[email protected]>
(cherry picked from commit 6a62821)

Adapted for 2026.9.x: native-thread-tool.ts resolved by hand against the
9.x execute layout (owner check at execute entry, in the request-options
assertCurrent, and as the binding-clear commit guard; 9.x has no separate
prepared session-entry guard). Tests rewritten onto the 9.x fixtures (sync
createTool, 9.x supervision registration test).
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 26, 2026
…penclaw#183286)

Narrow slice of openclaw#179363. Keep native Codex tool declarations stable across completion turns and enforce current owner authority when tools execute. Preserve the existing four-name fingerprint workaround and the fixes from openclaw#182191 and openclaw#183059.

Validated with the factory regression red on base and green on this head, 104 targeted tests, and exact-head CI. Live transport proof remains a documented gap.

Co-authored-by: Marvinthebored <[email protected]>
Co-authored-by: Dallin Romney <[email protected]>
RomneyDa pushed a commit that referenced this pull request Oct 26, 2026
…183286)

Narrow slice of #179363. Keep native Codex tool declarations stable across completion turns and enforce current owner authority when tools execute. Preserve the existing four-name fingerprint workaround and the fixes from #182191 and #183059.

Validated with the factory regression red on base and green on this head, 104 targeted tests, and exact-head CI. Live transport proof remains a documented gap.

Co-authored-by: Marvinthebored <[email protected]>
Co-authored-by: Dallin Romney <[email protected]>
(cherry picked from commit 6a62821)

Adapted: applied the native-plugin-tool.test.ts owner-denial hunk inside the release describe block.
RomneyDa pushed a commit that referenced this pull request Oct 26, 2026
…183286)

Narrow slice of #179363. Keep native Codex tool declarations stable across completion turns and enforce current owner authority when tools execute. Preserve the existing four-name fingerprint workaround and the fixes from #182191 and #183059.

Validated with the factory regression red on base and green on this head, 104 targeted tests, and exact-head CI. Live transport proof remains a documented gap.

Co-authored-by: Marvinthebored <[email protected]>
Co-authored-by: Dallin Romney <[email protected]>

Release adaptation: stable's thread tool lacks main's session-entry current-check capture; applied only the owner-authority move (declare unconditionally, assert owner at execute/commit). Ported the owner-denial cases into stable's test fixtures.

(cherry picked from commit 6a62821)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. docs Improvements or additions to documentation extensions: codex size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant