Skip to content

Use UserPromptSubmit for Codex graph reminders - #614

Merged
safishamsi merged 1 commit into
Graphify-Labs:v5from
robertmonka:codex/use-user-prompt-submit-hook
May 2, 2026
Merged

safishamsi merged 1 commit into
Graphify-Labs:v5from
robertmonka:codex/use-user-prompt-submit-hook

Conversation

@robertmonka

Copy link
Copy Markdown

Summary

  • switch Codex graph reminders from PreToolUse to UserPromptSubmit
  • remove old Graphify Codex PreToolUse hooks during install/uninstall while preserving unrelated hooks
  • update README wording for the Codex hook behavior
  • add tests for the generated Codex hook and upgrade cleanup path

Why

Codex rejects additionalContext from PreToolUse hooks, which caused the failure reported in #533.

For Graphify's graph reminder, UserPromptSubmit is also a better fit than PreToolUse: the assistant should see the GRAPH_REPORT.md reminder before it decides whether to search files, not after it has already selected a tool.

Tests

  • python -m py_compile graphify/__main__.py tests/test_install.py tests/test_claude_md.py
  • uv run --with pytest pytest tests/ -q --tb=short (443 passed)

Addresses #533.

@Qodo-Free-For-OSS

Copy link
Copy Markdown

Hi, _remove_graphify_codex_hooks() removes any Codex hook whose stringified JSON contains "graphify", which can delete unrelated user hooks that merely mention graphify. It also replaces a non-dict "hooks" value with an empty dict, potentially discarding user configuration when hooks.json is malformed but still recoverable.

Severity: remediation recommended | Category: correctness

How to fix: Match hooks structurally

Agent prompt to fix - you can give this to your LLM of choice:

Issue description

_remove_graphify_codex_hooks() currently deletes hooks by checking whether 'graphify' appears in str(h). This is too broad and can remove unrelated user hooks.

Issue Context

Graphify should remove only hooks that it previously installed, while preserving unrelated hooks even if they contain the word graphify.

Fix Focus Areas

  • graphify/main.py[733-748]
    • Replace substring filtering with a structural predicate that matches only graphify-installed hooks.
    • Suggested predicate: match on hook dict shape and exact command content (e.g., contains [ -f graphify-out/graph.json ] && and graphify-out/GRAPH_REPORT.md, and/or a unique marker string), and/or match the exact hook object you generate in _CODEX_HOOK.
    • Avoid overwriting existing["hooks"] when it is not a dict; prefer leaving it untouched or normalizing only when you can do so without data loss.
  • tests/test_install.py[147-185]
    • Add a regression test where an unrelated hook includes the string "graphify" but should not be removed (e.g., command: "echo graphify for my own plugin").

Found by Qodo code review

@robertmonka
robertmonka force-pushed the codex/use-user-prompt-submit-hook branch from 70ca9fd to 18d697a Compare April 30, 2026 19:25
@safishamsi
safishamsi merged commit 6c82f81 into Graphify-Labs:v5 May 2, 2026
@robertmonka
robertmonka deleted the codex/use-user-prompt-submit-hook branch May 4, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants