Skip to content

[codex] support hook input rewrites#21302

Draft
abhinav-oai wants to merge 1 commit intomainfrom
abhinav/hooks-updated-input-complete
Draft

[codex] support hook input rewrites#21302
abhinav-oai wants to merge 1 commit intomainfrom
abhinav/hooks-updated-input-complete

Conversation

@abhinav-oai
Copy link
Copy Markdown
Collaborator

Why

Hooks can currently inspect tool input, but callers cannot safely substitute a rewritten payload while preserving the approval semantics around that new payload. That leaves sanitizing or normalizing hook workflows unable to change what actually runs.

What

  • Add updatedInput support for PreToolUse and PermissionRequest hook outputs.
  • Let PreToolUse rewrites carry allow or ask semantics into shell, apply_patch, unified exec, and MCP execution paths.
  • Let PermissionRequest rewrites replace the full input, then re-enter normal approval evaluation so rewritten input is checked again before execution.
  • Regenerate hook schemas and add coverage for shell/apply_patch/MCP rewrites, ask parsing, no-op handling, and rewritten-input re-evaluation.

Validation

  • cargo test -p codex-hooks
  • cargo test -p codex-core --lib mcp_tool_call::tests::permission_request_hook_can_update_mcp_tool_input
  • cargo test -p codex-core --test all suite::hooks::permission_request_hook_rewrites_shell_command_before_execution -- --exact
  • cargo test -p codex-core --test all suite::hooks::permission_request_hook_rechecks_rewritten_shell_command -- --exact
  • cargo test -p codex-core --test all suite::hooks::pre_tool_use_rewrites_shell_command_before_execution -- --exact
  • just fmt
  • just fix -p codex-core
  • just fix -p codex-hooks

cargo test -p codex-core --lib was also attempted; it aborted in the existing tools::handlers::multi_agents::tests::multi_agent_v2_close_agent_accepts_task_name_target test with a stack overflow unrelated to this change.

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