You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
codex not support additionalContext on PreToolUse #533
I can reproduce this on macOS with the current Codex hook behavior.
Environment:
graphifyy: 0.4.32 (graphify --version is not supported, checked via Python package metadata)
codex-cli: 0.125.0
OS: macOS
shell: zsh
Generated project hook:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "[ -f graphify-out/graph.json ] && echo '{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"additionalContext\":\"graphify: Knowledge graph exists. Read graphify-out/GRAPH_REPORT.md for god nodes and community structure before searching raw files.\"}}' || true"
}
]
}
]
}
}
When graphify-out/graph.json exists, every matching Bash tool invocation causes:
PreToolUse hook returned unsupported additionalContext
This is not a shell syntax issue on macOS. The command runs and emits JSON, but the JSON contains an unsupported field for the PreToolUse event.
According to the current Codex hooks docs, PreToolUse supports JSON stdout with systemMessage, or a hook-specific deny decision. The docs also state that additionalContext under PreToolUse is parsed but not supported yet, while additionalContext is supported for events such as SessionStart, PostToolUse, and UserPromptSubmit.
Do not emit hookSpecificOutput.additionalContext from a PreToolUse hook.
If the intent is only to surface a warning/message before tool execution, emit top-level systemMessage for PreToolUse instead.
If the intent is to inject extra developer context, use a supported event such as SessionStart, UserPromptSubmit, or PostToolUse, or rely on AGENTS.md for Codex.
graphify codex install currently writes .codex/hooks.json with a PreToolUse hook whose command emits:
{"hookSpecificOutput":{"hookEventName":"PreToolUse","additionalContext":"graphify: Knowledge graph exists. Read graphify-out/GRAPH_REPORT.md for god nodes and community structure before searching raw files."}}
Codex loads and runs the hook, but rejects the output:
PreToolUse hook (failed)
error: PreToolUse hook returned unsupported additionalContext
So the hook invocation itself is not the problem. The generated hook output is incompatible with current Codex semantics: PreToolUse is a gatekeeping event, while additionalContext is supported on context-injection events such as UserPromptSubmit / SessionStart.
Suggested upstream fix:
For Codex, do not emit hookSpecificOutput.additionalContext from PreToolUse.
If the goal is to inject model-visible graph guidance, install a UserPromptSubmit (or SessionStart) hook instead:
{
"hooks": {
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "[ -f graphify-out/graph.json ] && echo '{\"hookSpecificOutput\":{\"hookEventName\":\"UserPromptSubmit\",\"additionalContext\":\"graphify: Knowledge graph exists. Read graphify-out/GRAPH_REPORT.md for god nodes and community structure before searching raw files.\"}}' || true"
}
]
}
]
}
}
If the goal is only to show a pre-tool warning/status, keep PreToolUse but emit top-level systemMessage instead of hookSpecificOutput.additionalContext.
This would preserve the graphify Codex integration without causing hook failures on every Bash tool call.
Installed it via codex cli. Used $graphify . Opened the codex app. Used the example and this is the output. And even with follow ups, so it is not just the initial conversation.
one question:
Do we actually need this hook? If we are already instructing codex in AGENT.md file to use graphify-out folder for any codebase related question, so why we need to pass the context on every bash tool call.
Also it will waste time and token if the bash command is some install command or anything else.
Your branch fixes the immediate failure by keeping PreToolUse and changing the Codex payload to systemMessage. The PR I opened takes the other route suggested above: for Codex, use UserPromptSubmit for the Graphify reminder.
I think UserPromptSubmit is the better default for this specific Graphify use case:
the reminder is model context, not a pre-tool permission/gatekeeping decision
Codex should see it before deciding whether to search files
it avoids injecting the same reminder before every Bash tool call
the installer cleans up old Graphify PreToolUse hooks while preserving unrelated hooks
Activity
wlb632363 commentedon Apr 24, 2026
same problem
graphifyy:0.5.0
codex-cli: 0.124.0
bratnieks commentedon Apr 25, 2026
Temporary fix for Codex CLI
unsupported additionalContextIf Codex CLI shows:
takeItIzzy commentedon Apr 27, 2026
I can reproduce this on macOS with the current Codex hook behavior.
Environment:
graphify --versionis not supported, checked via Python package metadata)Generated project hook:
{ "hooks": { "PreToolUse": [ { "matcher": "Bash", "hooks": [ { "type": "command", "command": "[ -f graphify-out/graph.json ] && echo '{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"additionalContext\":\"graphify: Knowledge graph exists. Read graphify-out/GRAPH_REPORT.md for god nodes and community structure before searching raw files.\"}}' || true" } ] } ] } }When
graphify-out/graph.jsonexists, every matching Bash tool invocation causes:This is not a shell syntax issue on macOS. The command runs and emits JSON, but the JSON contains an unsupported field for the
PreToolUseevent.According to the current Codex hooks docs,
PreToolUsesupports JSON stdout withsystemMessage, or a hook-specific deny decision. The docs also state thatadditionalContextunderPreToolUseis parsed but not supported yet, whileadditionalContextis supported for events such asSessionStart,PostToolUse, andUserPromptSubmit.Docs: https://developers.openai.com/codex/hooks
Suggested fix:
hookSpecificOutput.additionalContextfrom aPreToolUsehook.systemMessageforPreToolUseinstead.SessionStart,UserPromptSubmit, orPostToolUse, or rely onAGENTS.mdfor Codex.robertmonka commentedon Apr 27, 2026
Additional reproduction from Linux/Codex CLI:
Environment:
graphify codex installcurrently writes.codex/hooks.jsonwith aPreToolUsehook whose command emits:{"hookSpecificOutput":{"hookEventName":"PreToolUse","additionalContext":"graphify: Knowledge graph exists. Read graphify-out/GRAPH_REPORT.md for god nodes and community structure before searching raw files."}}Codex loads and runs the hook, but rejects the output:
So the hook invocation itself is not the problem. The generated hook output is incompatible with current Codex semantics:
PreToolUseis a gatekeeping event, whileadditionalContextis supported on context-injection events such asUserPromptSubmit/SessionStart.Suggested upstream fix:
hookSpecificOutput.additionalContextfromPreToolUse.UserPromptSubmit(orSessionStart) hook instead:{ "hooks": { "UserPromptSubmit": [ { "hooks": [ { "type": "command", "command": "[ -f graphify-out/graph.json ] && echo '{\"hookSpecificOutput\":{\"hookEventName\":\"UserPromptSubmit\",\"additionalContext\":\"graphify: Knowledge graph exists. Read graphify-out/GRAPH_REPORT.md for god nodes and community structure before searching raw files.\"}}' || true" } ] } ] } }PreToolUsebut emit top-levelsystemMessageinstead ofhookSpecificOutput.additionalContext.This would preserve the graphify Codex integration without causing hook failures on every Bash tool call.
Mexflubber commentedon Apr 28, 2026
Happens on the macOs codex app too.
Installed it via codex cli. Used
$graphify .Opened the codex app. Used the example and this is the output. And even with follow ups, so it is not just the initial conversation.deepanshu0304 commentedon Apr 28, 2026
one question:
Do we actually need this hook? If we are already instructing codex in AGENT.md file to use graphify-out folder for any codebase related question, so why we need to pass the context on every bash tool call.
Also it will waste time and token if the bash command is some install command or anything else.
Mexflubber commentedon Apr 29, 2026
@robertmonka @takeItIzzy @inkpark @bratnieks @wlb632363 would you mind pulling my branch and verifying the issue is gone for you too ?
robertmonka commentedon Apr 29, 2026
@Mexflubber I opened an alternative PR here: #614.
Your branch fixes the immediate failure by keeping
PreToolUseand changing the Codex payload tosystemMessage. The PR I opened takes the other route suggested above: for Codex, useUserPromptSubmitfor the Graphify reminder.I think
UserPromptSubmitis the better default for this specific Graphify use case:PreToolUsehooks while preserving unrelated hooksValidation on the PR branch:
python -m py_compile graphify/__main__.py tests/test_install.py tests/test_claude_md.pyuv run --with pytest pytest tests/ -q --tb=short(443 passed)This should address both the hook failure from this issue and the concern about whether Graphify needs to run on every Bash tool call.
Mexflubber commentedon Apr 30, 2026
Like yours better, closed mine ! Thanks Robert
rexkoh425 commentedon May 3, 2026
Please update to v0.6.8 and try. Thanks.
#651