IDE preToolUse runCommand hooks receive empty toolArgs — CLI passes full context, IDE passes {}
Before opening, please confirm:
- [x] I have searched for duplicate or closed issues
Operating System
darwin
Kiro Version
0.11.131
Bug Description
IDE preToolUse runCommand hooks don't receive tool context. The USER_PROMPT env var is set but contains {} (empty JSON object). No TOOL_NAME, TOOL_INPUT, or other tool-related env vars are provided. No data is available on stdin.
This means runCommand hooks cannot make conditional decisions based on which tool is being invoked or what arguments it's being called with. The only workaround is askAgent, which invokes the LLM on every tool call — non-deterministic and expensive in tokens.
The CLI already passes full tool context as JSON via stdin for preToolUse hooks (documented here). The IDE should provide equivalent context.
Steps to Reproduce
- Create a
preToolUsehook withrunCommand:
{
"name": "Debug Hook",
"version": "1",
"when": {
"type": "preToolUse",
"toolTypes": ["read"]
},
"then": {
"type": "runCommand",
"command": "bash debug-hook.sh"
}
}
- Create
debug-hook.sh:
#!/usr/bin/env bash
echo "USER_PROMPT=$USER_PROMPT" > /tmp/hook-debug.txt
echo "ENV_VARS:" >> /tmp/hook-debug.txt
env | grep -i 'TOOL\|HOOK\|KIRO' >> /tmp/hook-debug.txt 2>/dev/null
exit 0
- Trigger a
readFiletool call. - Check
/tmp/hook-debug.txt— it showsUSER_PROMPT={}and no tool-related env vars.
Expected Behavior
The hook script should receive context about the tool invocation, at minimum the tool name and its arguments. The CLI provides this via stdin:
{
"hook_event_name": "preToolUse",
"tool_name": "read",
"tool_input": {
"operations": [{ "mode": "Line", "path": "/some/file.ts" }]
}
}
For the IDE, this could be via env vars (e.g. TOOL_NAME, TOOL_INPUT) or stdin — either would work.
Conversation ID
No response
Additional Context
The IDE source code does pass toolArgs through the hook pipeline in executePreToolUseHooks:
const toolArgsJson = JSON.stringify(toolArgs);
updatedState = await runHookCommandInstance.executeHook(hook2, updatedState, toolArgsJson);
And spawnHookCommand forwards it as USER_PROMPT:
env: { USER_PROMPT: userPrompt }
But toolArgs arrives as {} at the hook executor. The plumbing exists — the args just aren't being populated upstream.
Notably, postToolUse hooks appear to pass richer context ({ toolName, toolArgs, toolResult, toolSuccess }), suggesting this may be specific to the preToolUse path.
🤖 Potential Duplicate Detected
This issue appears to be similar to:
- #6188: postToolUse hooks: toolArgs not populated in USER_PROMPT environment variable (95% similar)
- #7138: Kiro CLI Bug - AgentSpawn Hook Retries on Every Tool Call (85% similar)
- #6342: ValidationException when PreToolUse hook blocks tool in multi-tool turn due to missing tool results (85% similar)
- #4867: Hook matcher does not match new builtin tool names (85% similar)
What happens next?
- ⏰ This issue will be automatically closed in 3 days
- 🏷️ If this is not a duplicate, you can prevent automatic closure by adding a comment or reacting with 👎 to this message.
- 💬 Comment on the original issue if you have additional information
Why is this marked as duplicate? Both report the same issue with preToolUse hooks not receiving proper toolArgs context - new issue focuses on IDE while existing issue mentions postToolUse but describes identical symptoms of empty toolArgs in USER_PROMPT environment variable
This issue has been automatically closed as it appears to be a duplicate of #6188.
If you believe this is incorrect, please comment on this issue and a maintainer will review it.