[DOCS] Update SDK and CLI Hook documentation to include `additionalContext` support for `PreToolUse` events
Documentation Type
Missing documentation (feature not documented)
Documentation Location
- Agent SDK Docs: https://platform.claude.com/docs/en/agent-sdk/hooks 2. CLI/Config Docs: https://code.claude.com/docs/en/hooks
Section/Topic
- Agent SDK: The "Callback outputs" section, specifically the table "Fields inside
hookSpecificOutput". 2. CLI/Config: The "Hook Output" section, specifically the subsection "PreToolUse Decision Control".
Current Documentation
1. Agent SDK Docs (docs/en/agent-sdk/hooks.md):
The table for hookSpecificOutput fields currently says:
| Field | Type | Hooks | Description |
|---|---|---|---|
| additionalContext | string | PostToolUse, UserPromptSubmit, SessionStart, SubagentStart | Context added to the conversation |
2. CLI Docs (docs/en/hooks.md):
The JSON example for PreToolUse only lists permission fields:
{
"hookSpecificOutput": {
"hookEventName": "PreToolUse",
"permissionDecision": "allow",
"permissionDecisionReason": "My reason here",
"updatedInput": {
"field_to_modify": "new value"
}
}
}
What's Wrong or Missing?
According to the v2.1.9 Changelog, support was added for PreToolUse hooks to return additionalContext to the model.
Both documentation pages omit PreToolUse from the lists of events that support additionalContext. This leads developers to believe they cannot inject context immediately before a tool executes, which is now a supported feature.
Suggested Improvement
1. Agent SDK Update:
Update the table row to include PreToolUse:
| Field | Type | Hooks | Description |
|---|---|---|---|
| additionalContext | string | PreToolUse, PostToolUse, UserPromptSubmit, SessionStart, SubagentStart | Context added to the conversation |
2. CLI/Config Update:
Update the PreToolUse Decision Control text and JSON example to include additionalContext:
{
"hookSpecificOutput": {
"hookEventName": "PreToolUse",
"permissionDecision": "allow",
"additionalContext": "Context injected before tool execution",
"updatedInput": { ... }
}
}
Impact
High - Prevents users from using a feature
Additional Context
- Changelog v2.1.9: "Added support for PreToolUse hooks to return additionalContext to the model"
- This update ensures consistency across the SDK (Python/TypeScript) and the JSON-based configuration used by the CLI.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗