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

Resolved 💬 2 comments Opened Mar 16, 2026 by AntheaLaffy Closed Apr 18, 2026

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.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗