Feature request: let PostToolUse hooks replace tool output (updatedToolOutput)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 125k
- Forks
- 19.5k
- PR merge metrics
- PR metrics pending
Description
Motivation
We build toonify-mcp, a context-compression tool: it converts large JSON/YAML tool output to a compact tabular format and collapses repetitive logs (60%+ token reduction on realistic payloads), while passing through anything it can't reproduce losslessly.
On Claude Code this works as a PostToolUse hook that returns hookSpecificOutput.updatedToolOutput, which replaces what the model sees — that replacement is what actually shrinks context.
Current Codex behavior
PostToolUseOutcome supports block / additionalContext / feedback, but no output replacement. The output parser already recognizes a Claude-style updatedMCPToolOutput field — and explicitly rejects it as unsupported (codex-rs/hooks/src/events/post_tool_use.rs, unsupported_updated_mcp_tool_output_fails_open), so the concept appears to be on your radar already.
additionalContext can't serve this use case: appending a compressed copy on top of the original output makes context larger, the exact opposite of the goal.
Request
Support an updatedToolOutput (and/or the already-parsed updatedMCPToolOutput) in PostToolUse hook output that replaces the tool result before it enters model context — schema-checked against the tool's output type, with fail-open on mismatch, like the current unsupported-field handling.
This would let context-optimization tools (compression, redaction, truncation policies) work across both ecosystems with the same hook contract.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in codex-rs/hooks/src/events/post_tool_use.rs, including unsupported_updated_mcp_tool_output_fails_open, to understand the existing parser and fail-open behavior. Trace how PostToolUseOutcome reaches model context; done means a supported updatedToolOutput or updatedMCPToolOutput can replace the result when schema-compatible, while mismatches fail open.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100