Skip to content

Add a native pre-turn dynamic context hook for time-sensitive metadata #14814

Closed as not planned

Description

@AntheaLaffy

What variant of Codex are you using?

CLI

What feature would you like to see?

A native way to inject dynamic context before every user turn in Codex CLI.

A concrete example is current local time / UTC time / timezone, but the same mechanism would also be useful for other runtime metadata.

Why this matters

Some prompts are time-sensitive. Static instructions in AGENTS.md, developer_instructions, or config files are not enough, because the value changes every turn.

Right now, there does not seem to be an official native mechanism for:

  • pre-turn hooks
  • dynamic prompt/context injection before each message
  • automatic MCP calls before each turn
  • built-in runtime variables like current time

Current workaround

The workaround is to build an external wrapper around codex exec / codex exec resume that injects a time block before every prompt.

This works, but it is not ideal because:

  • it is not native to the interactive Codex UX
  • it adds maintenance overhead
  • it is harder to share and standardize
  • it feels like something the CLI should support directly

Suggested feature

Any of these would solve the problem:

  1. A native pre_turn_command / pre_prompt_command hook in config
  2. Native dynamic variables such as {{ now_local }}, {{ now_utc }}, {{ timezone }}
  3. A way to auto-run a configured MCP tool before each turn and inject the result into context

Expected benefit

This would help with:

  • time-aware conversations
  • reminders and scheduling workflows
  • dynamic environment metadata
  • safer handling of prompts that depend on real current time

Related issues

This seems adjacent to, but different from, #3540.

#3540 is about global preamble/instructions not being applied reliably in interactive sessions.
This request is specifically about native per-turn dynamic context injection, which static preambles still would not solve.

Additional information

If this lands, it would remove the need for custom wrapper scripts for a whole class of runtime-sensitive workflows.

Activity

  1. added
    hooksIssues related to event hooks
    and removed
    agentIssues related to the core agent loop
    on Apr 2, 2026
  2. etraut-openai commented on Apr 18, 2026

    @etraut-openai
    Contributor

    This feature request hasn't received any upvotes in over a month, so I'm going to close it.

  3. oxysoft commented on May 8, 2026

    @oxysoft

    Indexed this hook ticket in the umbrella tracker: #21753

    Goal: collect the scattered Codex hook requests and bugs into one parity matrix for Full Claude Code Hook Parity (29+), while preserving this issue as the detailed thread for its specific behavior.

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