Skip to content

fix(codex): accept bounded upstream prompt provenance - #127730

Merged
obviyus merged 1 commit into
openclaw:mainfrom
Marvinthebored:fix/codex-settled-upstream-bound
Aug 22, 2026
Merged

obviyus merged 1 commit into
openclaw:mainfrom
Marvinthebored:fix/codex-settled-upstream-bound

Conversation

@Marvinthebored

@Marvinthebored Marvinthebored commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Related to #125254.

AI-assisted with Codex. I reviewed the generated change and understand the behavior and compatibility boundary it modifies.

What Problem This Solves

Codex settled-turn finalization rejects exact upstreamUserText provenance above 64 KiB before applying the existing 512 KiB complete-projection budget. OpenClaw can legitimately persist a larger exact prompt. The isolated finalizer then aborts before thread/inject_items, leaving the Telegram turn without its final answer.

This fixes only that secondary finalizer contradiction. It does not remove the degraded-engine whole-history continuity producer and must not close #125254.

Root cause and fix

projectSettledCodexMessages applied the ordinary-message 64 KiB field bound to exact prompt provenance. Exact provenance is a distinct contract: adopted-session activity detection exact-matches it against Codex user input, so truncation or substitution would corrupt ownership detection.

The projector now admits exact provenance up to the existing 512 KiB projection budget. Ordinary user, assistant, tool-result, and tool-argument text remains capped at 64 KiB. Serialized response items are still charged to the aggregate 512 KiB limit and fail closed above it.

Evidence

Exact head: 8596e8ca443741f6481a8e611af60095d86d1e1f.

  • Current-main real Telegram reproduction (6cb08cb8ee9ee6235c7bd1f5f3fd7b85b8673ce7): one real-user DM exercised the deterministic tool-only settled-finalizer path with a 68,884-byte prompt. Gateway result: Codex settled-turn projection found oversized upstream user text; Telegram showed the visible agent-failure warning. Verdict: actual=affected, toolOnlyTurnCompleted=true, finalizerStarted=false, injectedHistoryBytes=0, finalAnswerObserved=false.
  • Stock owner-boundary control: 65,537-byte exact provenance throws Codex settled-turn projection found oversized upstream user text on current main.
  • Patched focused suite: node scripts/run-vitest.mjs extensions/codex/src/app-server/settled-turn-projection.test.ts extensions/codex/src/app-server/settled-turn-context.test.ts extensions/codex/src/app-server/settled-turn-finalizer.test.ts extensions/codex/src/app-server/bounded-turn.test.ts — 64/64 pass.
  • Boundary coverage: 65,537-byte exact provenance is preserved; 512 KiB + 1 is rejected; mixed 400 KiB provenance plus ordinary content is rejected by aggregate accounting.
  • pnpm exec oxfmt --check on both touched files — pass.
  • pnpm exec oxlint on both touched files — pass.
  • pnpm tsgo — pass.
  • pnpm check:test-types — pass.
  • git diff --check origin/main...HEAD — pass.
  • Distill audit: exact provenance and ordinary transcript content are genuinely distinct contracts; the patch reuses the canonical projection path and adds no fallback or parallel implementation.
  • Greybeard audit: 50 projections with 512,000 bytes of provenance averaged 0.595 ms each; work remains linear and bounded by the existing aggregate limit.

Pinned Codex contract

Directly verified against openai/codex tag rust-v0.148.0 (3ba0f711642a888aec92a611a3f3b2211157ff89), matching extensions/codex/package.json:

  • codex-rs/app-server-protocol/src/protocol/v2/thread.rs: ThreadInjectItemsParams.items is raw Vec<JsonValue> with no protocol text-size cap.
  • codex-rs/app-server/src/request_processors/turn_processor.rs: thread_inject_items_response_inner deserializes each item as ResponseItem, validates image URLs, and injects the items; it adds no text-size cap.
  • codex-rs/app-server/tests/suite/v2/thread_inject_items.rs: injected response items are retained in model-visible rollout history.

The final real-Telegram repaired-path verdict will be added after the exact-head local ClawSweeper gate.

Final real-Telegram repaired-path proof

A real Telegram user DM exercised the changed path on exact head 8596e8ca443741f6481a8e611af60095d86d1e1f with the retained oversized-provenance fixture:

{
  "actual": "repaired",
  "promptBytes": 68884,
  "toolOnlyTurnCompleted": true,
  "finalizerStarted": true,
  "injectedHistoryBytes": 68884,
  "oversizedProvenanceRejected": false,
  "finalAnswerObserved": true
}

The redacted app-server trace records the first tool-only turn, then an isolated process calling thread/inject_items with six items (largest exact input text: 68,884 bytes) before turn/start. Telegram observed typing plus one SUT answer containing CODEX_SETTLED_FINALIZATION_OK. This is the same deterministic flow that failed on current main before finalizer startup.

@clawsweeper

clawsweeper Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added extensions: codex size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 22, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. 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. labels Aug 22, 2026
@clawsweeper

clawsweeper Bot commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 22, 2026, 12:51 AM ET / 04:51 UTC.

ClawSweeper review

What this changes

The PR allows exact upstream Codex prompt provenance to use the settled-turn projector’s existing 512 KiB aggregate budget instead of the ordinary 64 KiB text limit, with boundary tests.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open for a Codex-area compatibility decision. The patch is narrowly scoped and no discrete code defect was found, but repository policy requires direct inspection of the pinned Codex source before a merge verdict.

Priority: P2
Reviewed head: 8596e8ca443741f6481a8e611af60095d86d1e1f
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused code and after-fix channel evidence are solid; direct confirmation of the pinned Codex contract remains the merge decision.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The PR body provides exact-head, after-fix real Telegram evidence that a 68,884-byte provenance value reached injection and produced the final answer; the remaining source-check limitation is reviewer-side, not missing contributor proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): The PR body provides exact-head, after-fix real Telegram evidence that a 68,884-byte provenance value reached injection and produced the final answer; the remaining source-check limitation is reviewer-side, not missing contributor proof.
Evidence reviewed 5 items Current-main failure boundary: Current main applies the ordinary 64 KiB text limit to exact upstream provenance before the settled transcript can be injected, while retaining a separate 512 KiB aggregate projection budget.
Patch and aggregate guard: The changed call passes the existing aggregate maximum only for exact upstream provenance; serialized response items still fail closed above the 512 KiB aggregate limit.
Caller and dependency signal: Finalization projects the frozen transcript before the bounded turn injects it via thread/inject_items; the owning plugin pins @openai/codex 0.148.0.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs extensions/codex/src/app-server/settled-turn-projection.test.ts

Result: FAIL (failed) — execution before step 1 run: live-proof package manager pnpm is unavailable after its official installer (curl -fsSL https://get.pnpm.io/install.sh | sh -): command failed without output

live-proof package manager pnpm is unavailable after its official installer (curl -fsSL https://get.pnpm.io/install.sh | sh -): command failed without output

Assertions:

  • FAIL expect_output: settled-turn-projection.test.ts

How this fits together

The bundled Codex plugin projects a settled OpenClaw tool transcript into response items for a private app-server finalization turn. Codex receives those items through injection and returns the final channel-visible answer.

flowchart LR
A[Settled OpenClaw transcript] --> B[Exact prompt provenance]
B --> C[Settled-turn projector]
C --> D[512 KiB aggregate budget]
D --> E[Codex item injection]
E --> F[Final channel answer]
Loading

Decision needed

Question Recommendation
Does the pinned Codex 0.148.0 app-server accept the PR’s bounded injected response items without a lower per-item text-size limit? Confirm the pinned handler contract: Inspect the exact 0.148.0 injection handler and proceed with the bounded repair if it has no conflicting text limit.

Why: The plugin directly calls the external Codex app-server protocol, and repository policy requires direct source inspection before this compatibility decision can be made.

Before merge

  • Resolve merge risk (P1) - The exact pinned Codex handler was not independently inspectable, so the compatibility of the raised injected-history limit needs a Codex-area owner check before merge.
  • Resolve merge risk (P1) - Production code grows by three net lines; this appears to be the smallest direct reuse of the existing aggregate-bound contract, with no net-neutral reshaping apparent.
  • Resolve merge risk (P1) - GitHub reports the branch as mergeable but behind current main, so it needs a rebase and exact-head validation after the compatibility decision.
Agent review details

Security

None.

PR surface

Source +3, Tests +48. Total +51 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 4 1 +3
Tests 1 48 0 +48
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 52 1 +51

Review metrics

Metric Value Why it matters
Production vs test delta production +3, tests +48 The runtime change reuses the existing aggregate cap; the added tests cover the new field boundary and aggregate accounting.

Stored data model

Persistent data-model change detected: vector/embedding metadata: extensions/codex/src/app-server/settled-turn-projection.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Verify Codex compatibility before merge (recommended)
    A Codex-area owner should inspect the pinned 0.148.0 item-injection handler, then rebase and validate the exact resulting head.

Technical review

Best possible solution:

Confirm the pinned app-server injection contract, then rebase and land this focused repair while keeping the separate oversized-history producer work in #125254.

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

Yes: current main deterministically rejects exact upstream provenance above 64 KiB before injection; the PR body also supplies an exact-head before/after Telegram trace.

Is this the best way to solve the issue?

Unclear: reusing the established 512 KiB aggregate cap is the narrowest local repair, but its Codex protocol compatibility still needs direct upstream-source confirmation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 48a2b45fede5.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides exact-head, after-fix real Telegram evidence that a 68,884-byte provenance value reached injection and produced the final answer; the remaining source-check limitation is reviewer-side, not missing contributor proof.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The PR body provides exact-head, after-fix real Telegram evidence that a 68,884-byte provenance value reached injection and produced the final answer; the remaining source-check limitation is reviewer-side, not missing contributor proof.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This narrowly affects the Codex final-answer path for oversized but bounded prompt provenance.
  • merge-risk: 🚨 compatibility: The raised injected-history field bound depends on the pinned external Codex app-server contract.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The PR body provides exact-head, after-fix real Telegram evidence that a 68,884-byte provenance value reached injection and produced the final answer; the remaining source-check limitation is reviewer-side, not missing contributor proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides exact-head, after-fix real Telegram evidence that a 68,884-byte provenance value reached injection and produced the final answer; the remaining source-check limitation is reviewer-side, not missing contributor proof.

Evidence

What I checked:

Likely related people:

  • joshavant: Related settled-turn review context associates prior merged work in this area with joshavant; the local partial clone could not complete a feature-history walk. (role: likely prior settled-turn contributor; confidence: low; files: extensions/codex/src/app-server/settled-turn-projection.ts, extensions/codex/src/app-server/settled-turn-finalizer.ts)

Rank-up moves

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

  • Have a Codex-area maintainer inspect the pinned 0.148.0 item-injection handler.
  • Rebase onto current main and rerun the focused projector and finalizer checks on the resulting head.

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 (3 earlier review cycles)
  • reviewed 2026-08-22T01:14:27.115Z sha 8596e8c :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-22T01:56:45.137Z sha 8596e8c :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-22T02:23:22.657Z sha 8596e8c :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 22, 2026
@Marvinthebored

Copy link
Copy Markdown
Contributor Author

ClawSweeper’s remaining item is the pinned Codex compatibility check, which its review environment could not perform: “repository policy requires direct inspection of the sibling Codex source before a Codex compatibility or merge verdict; that checkout is unavailable here.”

The source change is one narrow bound override, ClawSweeper reports no actionable findings, the required CI gate is green, and the PR body includes a real Codex app-server 0.148.0 settled-finalization trace at 65,537 bytes with successful thread/inject_items and transcript attestation.

For maintainer convenience, rust-v0.148.0 resolves to commit 3ba0f711642a. ThreadInjectItemsParams accepts raw Responses API items as Vec<JsonValue> (thread.rs lines 1640–1652); the handler deserializes each item, validates image URLs, calls inject_response_items, and returns success without applying a 64 KiB check (turn_processor.rs lines 875–900).

Could a maintainer make the remaining Codex compatibility call?

@openclaw-barnacle openclaw-barnacle Bot added triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 22, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 22, 2026
@obviyus

obviyus commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

Fast-lane landing resolution for the latest ClawSweeper notes:

  • Pinned Codex compatibility: directly inspected openai/codex tag rust-v0.148.0 (3ba0f711642a888aec92a611a3f3b2211157ff89). ThreadInjectItemsParams.items is raw Vec<JsonValue>; the handler deserializes ResponseItem, validates image URLs, and injects it without a text-size cap. Exact-head local ClawSweeper independently passed with zero findings, security concerns, maintainer decisions, or Rank-up moves.
  • Production delta: +4/-1 (net +3) is the smallest direct reuse of the existing aggregate budget. A net-neutral rewrite would only obscure the distinct provenance contract.
  • Behind-main drift: no conflict (mergeable: MERGEABLE). Per OpenClaw fast-lane policy, BEHIND merges; rebasing solely for drift would invalidate exact-head proof without changing the patch.

Exact-head CI, PR-context validation, owner tests, pinned-contract inspection, and real Telegram changed-path proof are green at 8596e8ca443741f6481a8e611af60095d86d1e1f.

@obviyus
obviyus merged commit 80beef6 into openclaw:main Aug 22, 2026
191 of 194 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 23, 2026
Allow exact upstream prompt provenance to use the existing 512 KiB settled-projection budget while preserving ordinary text bounds and aggregate accounting.

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

Labels

extensions: codex merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

2 participants