Skip to content

Support Codex pre-tool-use targets#1016

Draft
nikitakarimoffaipro-png wants to merge 1 commit into
rohitg00:mainfrom
nikitakarimoffaipro-png:codex/codex-pretooluse-adapter
Draft

Support Codex pre-tool-use targets#1016
nikitakarimoffaipro-png wants to merge 1 commit into
rohitg00:mainfrom
nikitakarimoffaipro-png:codex/codex-pretooluse-adapter

Conversation

@nikitakarimoffaipro-png

Copy link
Copy Markdown

Summary

Fixes Codex PreToolUse enrichment so Codex-native tool payloads can produce file-scoped memory context instead of falling through the Claude-only tool-name filter.

What changed

  • Keeps the existing Claude/Copilot Edit/Read/Grep behavior unchanged.
  • Adds conservative Codex adapters for:
    • apply_patch, parsing *** Add/Update/Delete File: patch headers from tool_input.command (the shape observed from Codex Desktop), patch, or input.
    • exec_command / shell_command / Bash, parsing only simple single-command read/search/list forms.
  • Rejects compound shell commands containing shell control characters so the hook stays silent when it cannot safely infer a file target.
  • Updates hooks.codex.json so Codex-native tool names route to PreToolUse.
  • Adds focused tests for Codex patch and shell payloads plus manifest/connect matcher coverage.

Why

The Codex plugin currently registers PreToolUse, but the hook script only recognizes Claude-style tool names (edit, write, read, glob, grep). In a live Codex Desktop session, apply_patch arrived as:

{
  "tool_name": "apply_patch",
  "tool_input": {
    "command": "*** Begin Patch\n*** Update File: ..."
  }
}

That meant the hook exited before /agentmemory/enrich, so file-scoped context injection was effectively inert for Codex patch edits.

Validation

  • npm run build
  • npx vitest run test/context-injection.test.ts test/codex-plugin.test.ts test/codex-connect-hooks.test.ts
  • Live host shadow test against a running agentmemory server:
    • real Codex apply_patch event recorded files: ["/tmp/agentmemory-pretool-live-proof.txt"], wouldInject: true, filteredWouldInject: true, exitCode: 0
    • direct host-wrapper Codex exec_command payload recorded files: ["/tmp/agentmemory-pretool-live-proof.txt"], terms: ["command-shape"], wouldInject: true, filteredWouldInject: true, exitCode: 0

I also ran npm test; it reached 1408 passing tests but failed on pre-existing/environment-sensitive cases unrelated to this change:

  • provider/auto-compress defaults in this install environment
  • Minimax default-model expectation mismatch
  • hook-project tests expecting the checkout basename to be exactly agentmemory while this local clone resolved as agentmemory-upstream

@vercel

vercel Bot commented Jul 5, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the rohitg00's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5cfbe876-0508-4780-8e0b-92a3cfdc264a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant