Skip to content

Bug: Codex hook message counting does not match Codex transcript schema #347

@xiaomayi-ant

Description

@xiaomayi-ant

What happened?

hooks_cli.py claims to support both claude-code and codex harnesses, but _count_human_messages() appears to only count transcript entries shaped like:

{"message": {"role": "user", "content": "..."}}

That matches the Claude-style transcript shape, but it does not match the Codex session format already handled in normalize.py, where user messages are parsed from event_msg entries with payload.type == "user_message".

As a result, Codex hook message counting may stay at 0 or undercount user turns, which means the stop hook auto-save threshold may never trigger correctly for Codex sessions.

What did you expect?

If hooks_cli.py supports the codex harness, it should count user turns from the Codex transcript schema correctly, so stop-hook checkpointing works the same way it does for Claude-compatible transcripts.

How to reproduce:

  1. Inspect mempalace/hooks_cli.py and note that _count_human_messages() only looks for entry["message"]["role"] == "user"
  2. Inspect mempalace/normalize.py and note that Codex sessions are parsed from event_msg entries with payload.type == "user_message"
  3. Run the stop hook against a Codex transcript using the Codex schema
  4. Observe that user messages may not be counted correctly, so the save interval logic does not trigger as expected

Environment:

  • OS: macOS
  • Python version: 3.12
  • MemPal version: 3.0.14

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions