Skip to content

[Feature] Document hooks payload schema or expose codex session info --json for current model/reasoning effort #21990

Open

Description

@itssosunny

What variant of Codex are you using?

CLI

What feature would you like to see?

Context

Codex CLI exposes per-turn structured spans in ~/.codex/log/codex-tui.log
including thread_id, model, and codex.turn.reasoning_effort. This
lets external tooling read current runtime config by filtering log
lines for the active thread.

This works as a workaround but would be cleaner with a documented API.

Request — any one would help

  1. Document the schema for ~/.codex/hooks.json events (current
    ~/.codex/config.toml shows features.codex_hooks = true, hooks
    stable, but local install has no payload docs).
  2. Expose codex session info --json for current model and
    reasoning_effort, similar to other CLI introspection commands.

Use case

Multi-agent session coordination tooling tracks declared vs actual
runtime config provenance. Codex runtime log parsing works today;
a supported API would reduce maintenance burden and avoid relying
on log line patterns that may change.

Note

Not blocking — runtime-log parsing is a stable workaround. This is
about supported surface area, not unblocking critical functionality.

Additional information

No response

Activity

  1. added
    CLIIssues related to the Codex CLI
    hooksIssues related to event hooks
    sessionIssues involving session (thread) management, resuming, forking, naming, archiving
    on May 10, 2026
  2. github-actions commented on May 10, 2026

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

  3. removed
    CLIIssues related to the Codex CLI
    sessionIssues involving session (thread) management, resuming, forking, naming, archiving
    on May 10, 2026
  4. 09Catho commented on May 10, 2026

    @09Catho

    @mattt0204 I implemented this and pushed it to my fork, but I’m blocked by the repo PR policy (collaborators_only) so I can’t open the PR from my account.

    Ready compare link:
    main...09Catho:21990-hooks-schema-docs

    Commit:
    61bbc5e

    Could a maintainer either:

    1. grant collaborator permission so I can open the PR, or
    2. open the PR from this branch on my behalf?
  5. chrysent commented on Sep 17, 2026

    @chrysent

    +1 from an external PreToolUse hook author, with one concrete sub-case for the schema docs on codex-cli 0.153.3 (official release tarball, Linux x86_64): the tool_use_id shape and length contract.

    What we observed on the wire (captured from real PreToolUse envelopes):

    { "tool_name": "Bash", "tool_input": { "command": "…" }, "tool_use_id": "c1" }
    • Ids are short opaque strings — we observed a 2-character id (c1).
    • Some ids carry a namespace prefix (function:exec_command, namespace:multi_agent_v1 for the agent tools), others are bare.
    • Nothing documents the allowed alphabet, minimum/maximum length, or whether the shape is stable across versions.

    Why it matters. External hooks commonly want to validate or persist correlation ids before using them (we use them as audit correlation labels). Without a documented contract, a validator has two bad options: accept anything (and risk key collisions/injection-shaped ids in downstream storage), or over-restrict (our first implementation required 8..128 bytes — and on 0.153.3 every real request carried ids like c1, so every request failed validation; worse, the harness ignored our hook's failure and executed anyway, per #41979 — the two gaps compound).

    Ask. When the payload schema is documented, please include: the tool_use_id alphabet, min/max length, whether namespace prefixes are part of the id or separable metadata, and stability guarantees across versions. Alternatively, exposing the exact per-event payload via codex session info --json (as proposed) would let hook authors derive the contract empirically.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthooksIssues related to event hooks

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions