Skip to content

codex-agent-hooks#13651

Closed
robertmonka wants to merge 3 commits intogitbutlerapp:masterfrom
robertmonka:codex-agent-hooks
Closed

codex-agent-hooks#13651
robertmonka wants to merge 3 commits intogitbutlerapp:masterfrom
robertmonka:codex-agent-hooks

Conversation

@robertmonka
Copy link
Copy Markdown

@robertmonka robertmonka commented May 6, 2026

🧢 Changes

  • Adds a new but-codex crate with native Codex hook handling.
  • Adds hidden legacy CLI commands for Codex lifecycle hooks:
    • but codex pre-tool
    • but codex post-tool
    • but codex stop
  • Tracks Codex-originated actions separately via Source::Codex.
  • Reuses the shared Claude hook workflow for agent file locking, hunk assignment, and stop/autocommit handling.
  • Parses Codex hook payloads from JSON, including session_id/sessionId, turn_id/turnId, cwd, tool input, tool response, transcript path, and the last assistant message.
  • Detects changed files from direct file-path tool inputs and apply_patch payloads.
  • Normalizes hook-provided working directories for WSL, including UNC paths and Windows drive paths.
  • Reads the last user prompt from Codex transcripts when available and uses Codex's final assistant message as the autocommit summary.
  • Makes Codex hook errors non-fatal to the Codex process while still emitting the error.
  • Updates Claude hook internals so Claude and Codex can share the same agent stop, pre-tool, and post-tool plumbing.
  • Uses the configured GitButler LLM provider for hook rewording and branch renaming instead of hard-coding OpenAI.
  • Adds repository config snapshot support for LLM provider lookup.
  • Adds default model selection per provider and a bounded HTTP connect timeout for LLM clients.

☕️ Reasoning

Codex needs the same automatic GitButler behavior that Claude hooks already have: lock files during tool use, assign resulting hunks to the active agent session, and autocommit/reword changes when the session stops. This PR adds a native Codex hook path while keeping the existing Claude behavior intact by extracting shared agent-hook helpers.

The rewording path also needs to respect the user's configured GitButler AI provider. If Codex autocommit depends on generated commit messages and branch names, failures should be surfaced instead of silently producing weak defaults, and configured providers such as Anthropic, OpenAI, OpenRouter, Ollama, or LM Studio should be used consistently.

🧪 Testing

  • Adds but codex command tests for:
    • using the hook payload cwd when the process current directory is not the project,
    • avoiding context initialization from the wrong current directory,
    • accepting turn_id when session_id is absent,
    • keeping hook errors non-fatal to Codex.
  • Updates Claude hook command tests for the shared hook behavior.
  • Adds unit coverage for Codex structured patch parsing.
  • Not run locally while updating this PR description.

@robertmonka robertmonka force-pushed the codex-agent-hooks branch from 02f2954 to e73cec1 Compare May 6, 2026 20:08
@Byron
Copy link
Copy Markdown
Collaborator

Byron commented May 7, 2026

I'm very sorry, but I have to close all of your PRs on the basis of them being fully automated coming from a profile that doesn't show much related history.

Thanks a lot for your understanding.

@Byron Byron closed this May 7, 2026
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.

2 participants