Add prompt hooks#24634
Draft
abhinav-oai wants to merge 5 commits into
Draft
Conversation
abhinav-oai
commented
May 26, 2026
| FeedbackOrStop, | ||
| } | ||
|
|
||
| pub(crate) fn prompt_hook_behavior(event_name: HookEventName) -> PromptHookBehavior { |
Collaborator
Author
There was a problem hiding this comment.
https://code.claude.com/docs/en/hooks#response-schema for reference
abhinav-oai
commented
May 26, 2026
abhinav-oai
commented
May 26, 2026
|
|
||
| let request = PromptHookRequest { | ||
| event_name: handler.event_name, | ||
| prompt: render_prompt(prompt, input_json), |
Collaborator
Author
There was a problem hiding this comment.
[P1] This renders the full hook input JSON into a model request. For PostToolUse and Stop hooks that input can include unbounded tool output or last assistant text, so a single prompt hook can exceed context limits or spend a huge number of tokens before existing hook output spilling applies. Please hard-cap or truncate the rendered prompt before calling the runner.
Collaborator
Author
There was a problem hiding this comment.
since we're not injecting to the main context I don't think its an issue? p sure codex picked this up from the AGENTS.md guidance to limit injected context to 10k toks
# Conflicts: # codex-rs/core/src/session/session.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Codex hooks should support prompt handlers for the events where prompt hooks have defined semantics
What
Example
Tried this hook
Results