Skip to content

Support PreToolUse additionalContext#20692

Merged
abhinav-oai merged 5 commits into
mainfrom
abhinav/pretooluse-additional-context
May 5, 2026
Merged

Support PreToolUse additionalContext#20692
abhinav-oai merged 5 commits into
mainfrom
abhinav/pretooluse-additional-context

Conversation

@abhinav-oai
Copy link
Copy Markdown
Collaborator

@abhinav-oai abhinav-oai commented May 1, 2026

Why

PreToolUse already exposes hookSpecificOutput.additionalContext in the generated hook schema, but the runtime still rejected it as unsupported. That leaves PreToolUse out of step with the other context-injecting hooks and prevents hook authors from attaching model-visible guidance to a pending tool call before it runs.

What

  • Parse PreToolUse.additionalContext and carry it through the hook event pipeline.
  • Record PreToolUse context at the hook boundary so successful context is preserved for both allowed and blocked calls without widening the tool registry surface.
  • Preserve existing deny behavior when context is combined with either permissionDecision: "deny" or the legacy decision: "block" shape.

@abhinav-oai abhinav-oai marked this pull request as ready for review May 1, 2026 22:19
@abhinav-oai abhinav-oai requested a review from a team as a code owner May 1, 2026 22:19
@abhinav-oai abhinav-oai changed the title Support PreToolUse additional context Support PreToolUse additionalContext May 1, 2026
Copy link
Copy Markdown
Contributor

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

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: da2567023f

ℹ️ 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/hooks/src/engine/output_parser.rs
@abhinav-oai
Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Hooray!

ℹ️ 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/tools/registry.rs Outdated
@abhinav-oai
Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown
Contributor

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ 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".

@abhinav-oai abhinav-oai enabled auto-merge (squash) May 3, 2026 17:53
additional_contexts,
} = hooks.run_pre_tool_use(request).await;
emit_hook_completed_events(sess, turn_context, hook_events).await;
record_additional_contexts(sess, turn_context, additional_contexts).await;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

is this uncapped? maybe an existing/broader concern (though PreToolUse is probably a high volume hook), but allowing injection of an uncapped amount of context directly into a dev message seems like an easy way for users to unknowingly blow up their own context window

Copy link
Copy Markdown
Collaborator

@sayan-oai sayan-oai left a comment

Choose a reason for hiding this comment

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

this pr logic seems fine; discussed in slack implementing a hook-level context injection cap as a follow up.

@sayan-oai sayan-oai self-requested a review May 4, 2026 19:34
@sayan-oai sayan-oai disabled auto-merge May 4, 2026 19:37
@sayan-oai sayan-oai self-assigned this May 4, 2026
@abhinav-oai abhinav-oai merged commit af86be5 into main May 5, 2026
37 of 38 checks passed
@abhinav-oai abhinav-oai deleted the abhinav/pretooluse-additional-context branch May 5, 2026 17:29
@abhinav-oai
Copy link
Copy Markdown
Collaborator Author

merging as we got #21069 in

@github-actions github-actions Bot locked and limited conversation to collaborators May 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants