Skip to content

fix: CodexParser skips zero-length messages - #20

Merged
royalpinto007 merged 1 commit into
AgentPostmortem:mainfrom
sharadvc:fix/codex-skip-empty-messages
Sep 16, 2026
Merged

royalpinto007 merged 1 commit into
AgentPostmortem:mainfrom
sharadvc:fix/codex-skip-empty-messages

Conversation

@sharadvc

Copy link
Copy Markdown
Contributor

What

CodexParser emitted empty-content message items as empty messages — inconsistent with the Claude and OpenAI parsers, which already skip empties. Empty messages pollute token totals.

Change

In _emit_item, skip message items whose text is empty or whitespace-only (mirrors claude_code.py's if content.strip(): convention). Turn numbers, tool calls, and reasoning are unaffected.

Tests

Added a failing test first: a Codex session with empty "content": "" and whitespace-only messages must skip them while keeping the real messages. Full suite: 62 passed. ruff check clean.

Related

Closes #9

Empty-content message items were emitted as empty messages, polluting
token totals — unlike the Claude and OpenAI parsers which already skip
empties. Skip message items whose text is empty or whitespace-only.

Closes AgentPostmortem#9
@royalpinto007
royalpinto007 merged commit 3a5c7f3 into AgentPostmortem:main Sep 16, 2026
3 checks passed
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.

CodexParser keeps zero-length messages instead of skipping them

2 participants