Skip to content

Codex hooks emit [mnemon] … and Codex rejects them as invalid JSON #86

Description

@MoonCaves

Question for anyone running Mnemon with the Codex CLI.

After mnemon setup for Codex, the SessionStart (prime) and UserPromptSubmit hooks print context that begins with [mnemon] .... Current Codex (codex-cli 0.144.6) classifies any hook stdout that starts with [ or { as an attempted JSON object, and if it is not a valid hook-JSON object it rejects it — so those two hooks fail on every session start and prompt, and the memory context can be dropped.

This looks unconditional in Codex source (not config-specific):

  • codex-rs/hooks/src/engine/output_parser.rslooks_like_json() returns true when stdout starts with { or [.
  • codex-rs/hooks/src/events/session_start.rs — valid hook-JSON is used; otherwise if it looks_like_json it fails; otherwise plain text becomes model context.

So any hook whose output starts with [/{ but is not valid hook JSON hits this, and [mnemon] does.

Is anyone else seeing this on Codex, or is it specific to our setup? Either way I have a fix ready: wrap the existing output in Codex documented hookSpecificOutput.additionalContext envelope (context text unchanged), plus regression tests that execute the embedded hook scripts. Happy to open the PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions