[FEATURE] PreToolUse hooks inside sub-agents cannot surface interactive output to the user terminal
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
When a PreToolUse hook fires inside a sub-agent (spawned via the Agent tool), the hook process cannot display output to the user or read user input. The sub-agent's stdio is piped to the parent Claude Code process, not the user's tty. Calling open("/dev/tty") inside the hook fails silently or returns a tty disconnected from the user's session.
This means any hook that need to do the following (as examples), cannot do so from a sub-agent:
- Print a panel or message the user will actually see
- Prompt the user for a decision (allow / deny / modify)
The hook is forced to either default to Pass (allow) or auto-block without user input — neither of which is the
intended behaviour.
Proposed Solution
Inherit the parent tty file descriptor into sub-agent hook processes. When Claude Code spawns a sub-agent, pass the parent's tty file descriptor through so hooks in the child can write to and read from it. This mirrors how Docker --interactive forward ttys to child processes.
Alternative Solutions
None that preserves interactive behaviour. The only current workaround is to auto-block (exit 2) unconditionally when tty is unavailable, which removes user choice entirely.
Priority
Medium - Would be very helpful
Feature Category
Interactive mode (TUI)
Use Case Example
https://github.com/dbmikeldb/tokenGate
A token analyser, developed to improve user knowledge and token efficency.
Additional Context
_No response_
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗