Skip to content

Keep Turns running when event text contains NUL - #817

Merged
SaladDay merged 1 commit into
mainfrom
keep-turns-running-when-event-text-contains-nul
Oct 22, 2026
Merged

SaladDay merged 1 commit into
mainfrom
keep-turns-running-when-event-text-contains-nul

Conversation

@SaladDay

@SaladDay SaladDay commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

PostgreSQL jsonb cannot hold \u0000. When a Harness emits output with a NUL byte, InsertTurnEventBatch rejects the whole batch (SQLSTATE 22P05), and the Turn fails with event_persistence_failed after the Harness has already finished. Common commands trigger it, including grep -a, cat on a binary file, reading /proc/*/cmdline and find -print0. It reproduces with Codex and Claude Code. Core logged nothing.

Change

  • sessions.journalPayload normalizes each journal observation and the execution outcome. It replaces U+0000 with U+FFFD in every string and key, as decoding already does for invalid UTF-8. Payloads without \u0000 keep the existing single pass.
  • execution.journal.flush logs a failed journal write with its Session, Turn, first ordinal and event count. It does not log the raw driver error, which can contain submitted values.
  • Documentation: the rule is in Turns and Items, and the OpenAI compatibility ledger has a new difference line. Both have English and Chinese versions.

Checks

  • New TestTurnJournalStoresNULInObservedTextAsReplacementCharacter (PostgreSQL). It fails on main with unsupported Unicode escape sequence (SQLSTATE 22P05) and passes with this change.
  • Focused tests pass for sessions, execution and sessionpg (journal and execution), along with go vet ./... and make check-docs.

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@SaladDay
SaladDay merged commit 62b2df6 into main Oct 22, 2026
19 checks passed
@SaladDay
SaladDay deleted the keep-turns-running-when-event-text-contains-nul branch October 22, 2026 08:56
PostgreSQL jsonb rejects \u0000, so any Harness output with a NUL byte,
such as `grep -a` or `/proc/*/cmdline` command output, failed the whole
journal batch and the Turn with event_persistence_failed. The journal now
stores U+FFFD in place of U+0000 in every string of an observation and of
the execution outcome, as decoding already does for invalid UTF-8, and a
failed journal write is logged with its Session, Turn and first ordinal.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant