Skip to content

fix(codex): clarify policy boundaries and preserve legacy withdrawal - #189112

Merged
RomneyDa merged 9 commits into
openclaw:mainfrom
lastguru-net:fix/codex-generic-policy-boundaries
Nov 10, 2026
Merged

RomneyDa merged 9 commits into
openclaw:mainfrom
lastguru-net:fix/codex-generic-policy-boundaries

Conversation

@lastguru-net

@lastguru-net lastguru-net commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Related: #135338.

What Problem This Solves

Makes OpenClaw's native developer-policy replacement boundaries explicit while preserving legacy-policy withdrawal, independent instructions, conversation history, and unfinished requests.

User Impact

The native policy carrier is labeled with <thread_policy> at creation, resume, fork, and in side conversations. Refresh replaces earlier OpenClaw policy blocks and legacy unframed OpenClaw generic policy; omitted rules and explicit empty policy still withdraw previous policy. Independent native, project, and current-request instructions retain authority.

Supersession is still an instruction to the model, not deletion or migration of transcript records or a change to native permission enforcement. No new state or configuration is introduced.

Why This Change Was Made

Restores Dmitry Golubev's original framing design and the corresponding diagnostics, tests, documentation, and generated snapshots. The interim notice-only simplification removed the feature and has been superseded at the request of the maintainer.

Two repairs accompany the restoration:

  • Preserve the established withdrawal contract for legacy unframed conversations instead of excluding their policy from replacement.
  • Frame after final native developer-policy composition. With authored native instructions or model_instructions_file, OpenClaw's fallback base is enclosed in the same frame; the operator's native instructions remain independent. Canonical forks retain framed delivery, and diagnostics reflect authored-base placement.

Default OpenClaw base prompts keep their separate native placement. Managed relay persona, skills, memory, and current-request instructions remain outside the native policy frame; eligible nonrelay fallback sections remain inside it. Lifecycle ownership, handoff timing, warm reuse, and transcript retention are unchanged.

Token tradeoff

Explicit boundaries are retained for instruction reliability. Raw prompt length alone does not measure total task cost: avoiding an erroneous action or recovery turn can outweigh small input overhead. No task-cost or error-rate improvement has been measured here.

Deterministic o200k_base counts, with unchanged policy bodies:

Surface Main Original framed PR Restored/repaired
Refresh notice 77 91 69
Handoff with shared runtime policy 80 109 81
Empty-policy handoff 96 105 77
Framed carrier overhead versus main 0 about 15 about 9

The shorter delimiter saves 6 framing tokens versus the prefixed tag. The repair saves 28 tokens per handoff versus the original framed proposal. Compared with main, the nonempty sample adds 1 token and empty withdrawal saves 19. Fresh/warm contexts retain the roughly 9-token framing overhead; this is not a token-neutral change. Tokenizer boundaries, cached-input pricing, retained handoffs, and actual model behavior determine total cost.

Evidence

  • After renaming the delimiter to <thread_policy>, 321 tests passed across the nine affected/prefix-stability suites. Snapshots were regenerated; targeted lint, formatting, and diff checks passed. All non-generated edits were verified as exact tag substitutions before formatting. The rename changes no lifecycle or replacement scope.

  • Before the mechanical delimiter rename, local autoreview against main b39848a3e49c39965226a8f7fbd849b5ba71f20c, P0–P2: no actionable findings. Source-only review; no model-behavior proof claimed by the reviewer.

  • Extensions production typecheck, targeted lint, formatting, test-line ratchet, and diff checks passed.

  • Prompt snapshots regenerated through the repository generator, not edited by hand.

  • Before the mechanical delimiter rename, 407 tests passed across 14 files: policy payloads; native configuration, lifecycle and bindings; configured MCP; upstream/canonical fork continuation; side-question behavior; prompt snapshots; and prompt-prefix stability. Initial empty-policy assertions were updated to the new empty-frame representation, then the complete affected selection passed.

  • Existing real-model framing evidence from the original contributor is historical evidence, not a rerun of this repaired head. Legacy withdrawal and the shortened notice have not received a new live-model A/B run; focused tests establish emitted payloads, carrier boundaries, and lifecycle behavior, not guaranteed model compliance.

The test-line allocation covers shared start/resume framing, empty withdrawal, and authored-base placement regression coverage.

@clawsweeper

clawsweeper Bot commented Oct 31, 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: S labels Oct 31, 2026
@beru-ant-king
beru-ant-king force-pushed the fix/codex-generic-policy-boundaries branch from bdaff6c to 771d074 Compare October 31, 2026 06:04
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 31, 2026
@clawsweeper

clawsweeper Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR frames OpenClaw’s native Codex policy and clarifies replacement while preserving legacy withdrawal and independent instructions.

Example: An existing Codex conversation changes POLICY_ALPHA to POLICY_BETA, then receives an empty policy.

  • Before: OpenClaw supplies unframed policy and a general replacement notice.
  • After: A labeled policy block and explicit notice identify replacement and withdrawal while preserving history and unfinished requests.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused implementation has no identified code defect, but the supplied historical demonstrations do not prove the repaired behavior.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Preference · Worth it: Yes · Fix scope: Complete
User problem: The model receives policy replacements without explicit boundaries separating OpenClaw policy from independent instructions and retained conversation context.
Reason: The current restoration is authored by a verified repository member with prior Codex lifecycle work and records the framing direction and token tradeoff, so no second product approval is requested.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR preserves distinct, maintainer-engaged work; the earlier withdrawal defect is resolved, and no new actionable code defect was identified.

Priority: P3
Reviewed head: e1924fdff0d8b89e105f8fe1e8665b68a92d120f

Before merge

  • Add real behavior proof - The current body expressly limits original real-model demonstrations to historical evidence; current-head payload tests do not exercise the repaired notice’s model behavior. Supply sanitized terminal output, logs, or a recording through the real CLI or Gateway showing POLICY_ALPHA with an omitted rule changing to POLICY_BETA and then empty policy on an existing unframed native thread, preserving independent instructions, history, and an unfinished request; also show fresh framing and authored-native-base placement. Include continuation from latest-stable state, and redact credentials, IPs, phone numbers, 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.

Findings

None.

Tests

  • Missing end-to-end proof: Current-head CLI or Gateway evidence is missing for fresh framed policy and legacy same-thread replacement/empty withdrawal with independent instructions, history, and unfinished requests retained.
Agent review details

How this fits together

The Codex plugin composes OpenClaw policy into native thread configuration and injects replacement developer messages before resumed or forked inference; parent-local relay instructions remain separate.

flowchart LR
  A[OpenClaw policy and hook output] --> B[Native policy composition]
  B --> C[Policy framing]
  C --> D[Thread start resume or fork]
  C --> E[Replacement developer message]
  D --> F[Native conversation]
  E --> F
  F --> G[Model request]
  H[Parent local relay instructions] --> G
Loading

Technical review

Best possible solution:

Keep one shared policy renderer at the existing native composition boundaries and retain explicit withdrawal of legacy policy.

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

Current main’s unframed carrier is verified, but the supplied evidence does not establish that its wording loses history or cancels unfinished requests; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The change uses the existing composition and handoff owners, updates affected consumers, and introduces no new state or parallel delivery mechanism; the framing tradeoff is recorded in the maintainer-authored repair.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 54e0bc0c2132.

Provenance checked

  • Generic-policy handoff keeps the original intent (f5f44fa: Preserve native fork history while installing complete current policy, including omitted-rule and empty-policy withdrawal.)
  • Independent parent-request instructions keeps the original intent (8169aac: Keep current parent-local workspace instructions outside inherited generic-policy replacement.)
  • Shared native instruction composition keeps the original intent (b875c53: Restore nonrelay skill delivery through the existing developer carrier while retaining separate refresh and compaction ownership.)
  • Native base placement keeps the original intent (94ba8ae: Use OpenClaw’s base prompt while preserving authored native instructions and complete system-prompt replacement.)
  • Diagnostic projection keeps the original intent (d13bd0f: Report registered relay instructions alongside native policy without creating another native instruction carrier.)
  • Side-conversation policy keeps the original intent (35add8e: Keep side questions scoped to their current requests and treat inherited tasks as reference context.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Colton Harris: Raw commit b875c53 adds extensions/codex/src/app-server/thread-policy.ts:74 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b875c537be3b; files: extensions/codex/src/app-server/thread-policy.ts)

PR surface

Source +23, Tests +51, Docs +25, Other +2. Total +101 across 21 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 43 20 +23
Tests 12 116 65 +51
Docs 2 35 10 +25
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 21 196 95 +101

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is bounded prompt-boundary clarification without a demonstrated current-main behavioral failure.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • 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.

  • Provide current-head shipped-entry-point evidence for framed replacement, legacy withdrawal, and preserved independent context.

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.

History

Review history (6 earlier review cycles)
  • reviewed 2026-10-31T06:30:48.625Z sha bcf2f0618cbe3078eb6ef6d30fc7ae94b3b4a284 :: needs real behavior proof before merge. :: [P1] Preserve policy withdrawal for conversations created before this change | [P2] Update the remaining consumers of framed developer instructions
  • reviewed 2026-10-31T06:55:04.600Z sha dff4e8a6e49deb6b9ad2f88fe1b6a27730b5342b :: needs real behavior proof before merge. :: [P1] Preserve policy withdrawal for conversations created before this change
  • reviewed 2026-10-31T08:48:10.629Z sha dff4e8a6e49deb6b9ad2f88fe1b6a27730b5342b :: blocked before merge. :: [P1] Preserve policy withdrawal for conversations created before this change
  • reviewed 2026-11-02T13:39:56.460Z sha fd62fa4b85922b54f416577117371def19ccd551 :: blocked before merge. :: [P1] Preserve withdrawal when resuming unframed conversations
  • reviewed 2026-11-02T14:18:43.190Z sha 13d4733 :: blocked before merge. :: [P1] Preserve withdrawal when resuming unframed conversations
  • reviewed 2026-11-09T22:56:50.644Z sha 95b4f41 :: needs real behavior proof before merge. :: none

Reviewed November 9, 2026, 8:55 PM ET / November 10, 2026, 01:55 UTC (Revision 7).

@lastguru-net

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 31, 2026
@lastguru-net

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 31, 2026
@roboclaw-bot roboclaw-bot added the clawtributors PR from a clawtributor label Oct 31, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 9, 2026
@RomneyDa RomneyDa changed the title fix(codex): clarify policy refresh without prompt growth fix(codex): clarify policy boundaries and preserve legacy withdrawal Nov 10, 2026
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Nov 10, 2026
@RomneyDa

Copy link
Copy Markdown
Member

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 10, 2026
@RomneyDa
RomneyDa merged commit c53974a into openclaw:main Nov 10, 2026
120 of 124 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 10, 2026
…penclaw#189112)

* fix(codex): delimit native thread policy replacements

Use one labelled native policy carrier for creation, refresh and diagnostics. Preserve full replacement and empty withdrawal while explicitly excluding separate instructions, retained history and unfinished user requests.

Co-authored-by: Beru <[email protected]>

* fix(codex): restrict supersession to delimited policy blocks

Remove the unidentifiable legacy-policy fallback. Supersede only earlier blocks with the same delimiters, and leave outside text out of the replacement scope.

Co-authored-by: Beru <[email protected]>

* test(codex): repair policy framing assertions and snapshots

Update the configured-MCP, upstream-fork, and canonical-descendant
expectations to require the complete delimited native policy, including
the empty-policy handoff. Keep exact payload and lifecycle checks.

Render the prompt snapshot from the built thread/start carrier instead
of the raw pre-framing value hidden behind the selected-param mask.
Regenerate both prompt fixtures and check their policy boundaries in
the existing persona-separation test.

Increase this change's test-line allocation by its exact six added
regression-test lines; leave the shared baseline unchanged.

Co-authored-by: Beru <[email protected]>

* fix(codex): avoid opening policy tag in handoff notice

Name the policy tag without angle brackets so the handoff preamble does not emit an extra opening delimiter. Preserve all replacement and preservation clauses.

Co-authored-by: Beru <[email protected]>

* refactor(codex): tighten policy replacement notice

Apply the concise notice while retaining frame-only full replacement, omitted-rule and empty-policy withdrawal, and protection of outside instructions, history and unfinished requests.

Update existing payload and ordinary-resume assertions, and shrink the dedicated test allocation by the exact two removed lines.

Co-authored-by: Beru <[email protected]>

* fix(codex): scope policy replacement to developer instructions

Apply the approved opening that identifies OpenClaw policy in developer-role messages and excludes quoted examples, tool output and files. Leave the remaining replacement and preservation clauses unchanged.

Co-authored-by: Beru <[email protected]>

* fix(codex): restore policy framing with legacy withdrawal

* refactor(codex): shorten thread policy delimiter

---------

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

Labels

clawtributors PR from a clawtributor docs Improvements or additions to documentation extensions: codex P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M 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.

3 participants