Skip to content

Fix Codex exec outcomes for content-item results - #3033

Merged
HypForge merged 1 commit into
masterfrom
codex/fix-codex-exec-outcomes-3029
Nov 18, 2026
Merged

HypForge merged 1 commit into
masterfrom
codex/fix-codex-exec-outcomes-3029

Conversation

@philcunliffe

Copy link
Copy Markdown
Contributor

Summary

  • Recognize the Codex script header in native and JSON-encoded content-item arrays, including the Wall time line without a colon.
  • Keep the script outcome in status.tool_status and a single nested command's integer exit code in attributes.codex.exit_code. A completed script can have a command that exited 3.
  • Preserve captured output text and fallback message IDs across live capture and rollout import.

Verification

  • William's three examples failed before the fix and pass in both array encodings. A separate replay verified the same outcomes and exit codes through rollout import.
  • 162 focused Codex tests passed.
  • npm test passed with 9,754 passing and 9 skipped. npm run typecheck and npm run smoke -- gateway_codex_capture also passed.

The parser checks at most two content items, with an 8 Ki-character header limit and a 64 Ki-character limit per additional JSON parse. It retains a single integer when available and adds no state across records.

Fixes #3029

Read the script outcome from the first text item. Preserve a single nested command exit code separately from the script outcome and keep the captured output and fallback message identity stable.

Refs #3029
@philcunliffe philcunliffe added the neutral:adopt Foreign PR adopted into neutral's reconcile scope label Nov 18, 2026 — with ChatGPT Codex Connector
@HypForge HypForge added the neutral:adopted Adoption completion record: merged while carrying neutral:adopt (LLP 0031) label Nov 18, 2026
@HypForge

Copy link
Copy Markdown
Contributor

Final review (HypForge steward) at head d0b3eaf.

Rating: LOW. Clean. 4 files in the codex plugin, nothing under hypaware-core/skills/.

What was checked:

  • Codex exec outcomes stay unknown on 1.53.0: the #3003 parser does not match Codex's content-item output #3029 reproduced. The three reported results went through the live projector and the rollout import, each as a native content-item array and as a JSON string.
    • On master all three have no outcome.
    • At this head: the failed script is is_error = true / tool_status = error. The two completed scripts are success, with attributes.codex.exit_code 3 and 0.
  • Message ids do not move. Across those runs, message_id, part_id and content_text are identical between master and this head, and between the live and import lanes, in both encodings.
    • preserveToolResultIds hashes the block without is_error, and the hash never covers message.attributes.
    • toolOutputText is unchanged.
    • A turn both lanes see still settles to one row.
  • What is stored. attributes.codex.exit_code is a new key inside the existing attributes JSON. There is no new column. content_text is the same content as before.
  • Backfill. The gateway projector skips ids it has already seen, so rows captured before this change are not rewritten. A repeat import writes nothing new.
  • Parser bounds.
    • Item 0 is cut to 8 Ki before anchored regexes. There are at most two JSON.parse calls per result, each on 64 Ki characters or less.
    • 28 malformed inputs (truncated JSON, wrong item types, non-integer and 1e400 exit codes, __proto__ keys) all return a message, and none throws.
  • Tests. 897 codex and ai-gateway plugin tests pass locally, and npm run smoke -- gateway_codex_capture is ok.
  • Real Codex. Not run by a seat. The inputs are the real outputs reported in Codex exec outcomes stay unknown on 1.53.0: the #3003 parser does not match Codex's content-item output #3029.

Lines:

  • CPU and memory: no concern. The extra work per tool result is bounded.
    • Large outputs cost the same as master: a 10 MB native array is 12.2 ms here vs 12.9 ms on master, and the existing JSON.stringify dominates.
    • Nothing is retained.
  • Privacy: LOW (hypforge LLP 0015 scale). The same content is stored, plus one integer derived from it. A docs and legal-page check found no sentence that becomes untrue.
  • Security: LOW. Untrusted output is only parsed with bounded JSON.parse and anchored regexes.

Gates:

  • Server-suite gate: not triggered. There is no CLI command, contract, MCP codec or tool schema change.
    • The server does load codex/src/response-items.js for JSON intake, but uses only netInputUsage, which is unchanged.
    • Nothing references the old toolResultBlockFromPayload name.
  • CI is green at this head, test-windows included; CLEAN.

Release note: "Codex script results now record the right outcome. A failed script is marked as an error. A finished script counts as a success even when a command inside it exited non-zero, and a single command's exit code is kept in attributes.codex.exit_code. This applies to live capture and session-file import. Rows captured earlier are not changed."

Note, not a hold: when a result is stored as a JSON string over 64 Ki characters, its outcome stays unknown. The same result as a native array gets an outcome. Rows settle by id, so for a large result the lane that writes first decides the outcome.

@HypForge

Copy link
Copy Markdown
Contributor

Landing note (HypForge orchestrator): enqueuing at d0b3eaf. The author handed this PR over with neutral:adopt at 04:10Z on 2026-11-18. It lands on a clean LOW review with green checks, so there is no merge ask.

  • Review: LOW, clean, at this exact head (final comment above, 6968936430). Privacy LOW. Security LOW. CPU and memory: no concern.
  • The point that mattered most: message ids do not move. Rows captured before this change are not rewritten, and a turn both capture lanes see still settles to one row.
  • Server-suite gate: not triggered. The server loads codex/src/response-items.js but uses only netInputUsage, which is unchanged. The server suite was not run against this head.
  • HypForge pushed nothing to this branch. The docs and legal-page check found nothing that must change.
  • Guard: open, not a draft, CLEAN, all checks green including test-windows, master CI green on c091c12, no release PR open. The branch is 3 behind master; the merge queue runs CI on the merged tree.
  • Not run: a real Codex. The inputs are the real outputs reported in Codex exec outcomes stay unknown on 1.53.0: the #3003 parser does not match Codex's content-item output #3029.

One note left as it is unless the author says otherwise: a result stored as a JSON string over 64 Ki characters keeps an unknown outcome, while the same result as a native array gets one.

A merge is not a release. The fix reaches users with the next published version; rows captured earlier are not changed.

@HypForge
HypForge added this pull request to the merge queue Nov 18, 2026
Merged via the queue into master with commit b5df306 Nov 18, 2026
11 checks passed
@HypForge
HypForge deleted the codex/fix-codex-exec-outcomes-3029 branch November 18, 2026 04:25
@HypForge

Copy link
Copy Markdown
Contributor

Merged (HypForge orchestrator) as b5df306 at 04:25:55Z on 2026-11-18, on the first pass through the merge queue. CI on the merge commit is green, and #3029 closed with the merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

neutral:adopt Foreign PR adopted into neutral's reconcile scope neutral:adopted Adoption completion record: merged while carrying neutral:adopt (LLP 0031)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codex exec outcomes stay unknown on 1.53.0: the #3003 parser does not match Codex's content-item output

2 participants