Skip to content

Enable configured prompt hooks in Codex - #24634

Closed
abhinav-oai wants to merge 1 commit into
abhinav/prompt-hooks-runtimefrom
abhinav/prompt-hooks
Closed

abhinav-oai wants to merge 1 commit into
abhinav/prompt-hooks-runtimefrom
abhinav/prompt-hooks

Conversation

@abhinav-oai

@abhinav-oai abhinav-oai commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR enables prompt hooks end to end.

It defines the prompt-hook configuration shape, discovers and trust-checks configured prompt handlers, and connects the execution layer from the first PR to Codex's model client.

After this PR, a trusted type = "prompt" hook can run for supported events and affect the hook outcome.

Configuration and discovery

Prompt hooks support:

  • prompt
  • model
  • timeout
  • statusMessage
  • continueOnBlock

Discovery validates the event, rejects empty prompts, applies defaults, includes the full definition in the trust hash, and constructs runnable prompt handlers.

Model execution

Each hook runs as a separate model request containing only the rendered hook prompt and hook input.

The request:

  • has no conversation history
  • has no tools
  • does not inherit developer instructions
  • uses the thread model unless the hook selects another model
  • uses an isolated ModelClientSession

The isolated session is important because a normal model session reads and replaces the main conversation's cached WebSocket continuation state. A hook request must not disturb the next normal turn.

Example

[[hooks.UserPromptSubmit.hooks]]
type = "prompt"
statusMessage = "Checking whether the request is actionable"
prompt = "Evaluate if the ask is well specified: $ARGUMENTS. Block requests that are underspecified!"

Given:

› help

The hook can return:

• UserPromptSubmit hook (blocked)
  feedback: Request is underspecified: clarify what help is needed and the desired outcome.

Stack

  1. Add prompt-handler execution to codex-hooks #26267
  2. (this PR) Enable configured prompt hooks in Codex #24634
  3. Expose prompt hooks to clients #26268

FeedbackOrStop,
}

pub(crate) fn prompt_hook_behavior(event_name: HookEventName) -> PromptHookBehavior {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread codex-rs/config/src/hook_config.rs
@abhinav-oai
abhinav-oai marked this pull request as ready for review June 2, 2026 20:50
@abhinav-oai
abhinav-oai requested a review from a team as a code owner June 2, 2026 20:50

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cd80c08856

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/core/src/hook_prompt.rs
Comment thread codex-rs/core/src/hook_prompt.rs Outdated
Comment thread codex-rs/hooks/src/engine/mod.rs
Comment thread codex-rs/config/src/hook_config.rs
@abhinav-oai
abhinav-oai force-pushed the abhinav/prompt-hooks branch from db75d47 to 4bc4f2a Compare June 3, 2026 23:50
@abhinav-oai
abhinav-oai changed the base branch from main to abhinav/prompt-hooks-runtime June 3, 2026 23:51
@abhinav-oai
abhinav-oai force-pushed the abhinav/prompt-hooks-runtime branch from d729770 to d546866 Compare June 4, 2026 00:30
@abhinav-oai
abhinav-oai force-pushed the abhinav/prompt-hooks branch from 4bc4f2a to 627631d Compare June 4, 2026 00:30

/// Creates a fresh streaming session that does not read or write the session's cached
/// WebSocket state.
pub(crate) fn new_isolated_session(&self) -> ModelClientSession {

@abhinav-oai abhinav-oai Jun 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A normal ModelClientSession checks out the main session’s cached WebSocket state and writes its latest request/response back on drop

If a hook used that path, it could replace the continuation state for the real transcript. Starting fresh here and not caching on drop keeps hook inference from disturbing the next main turn.

@abhinav-oai
abhinav-oai force-pushed the abhinav/prompt-hooks branch from 627631d to c621ca2 Compare June 4, 2026 00:52
@abhinav-oai abhinav-oai changed the title Add prompt hooks Enable configured prompt hooks in Codex Jun 4, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 14 days. If you plan to continue working on it, feel free to reopen or open a new PR.

@github-actions github-actions Bot closed this Jun 19, 2026
@abhinav-oai abhinav-oai reopened this Jul 10, 2026
@abhinav-oai abhinav-oai reopened this Jul 10, 2026
@abhinav-oai
abhinav-oai force-pushed the abhinav/prompt-hooks-runtime branch from d546866 to ced3120 Compare July 10, 2026 03:25
@abhinav-oai
abhinav-oai force-pushed the abhinav/prompt-hooks branch from c621ca2 to 9d14b48 Compare July 10, 2026 03:25
@abhinav-oai

Copy link
Copy Markdown
Contributor Author

Moved to the internal stack: https://github.com/openai/codex-internal/pull/1279

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant