Add a native pre-turn dynamic context hook for time-sensitive metadata
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:
- A native
pre_turn_command/pre_prompt_commandhook in config - Native dynamic variables such as
{{ now_local }},{{ now_utc }},{{ timezone }} - 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.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗