Skip to content

feat: add codex agent adapter#319

Open
tumberger wants to merge 1 commit into
refactor/agent-hook-installerfrom
feat/codex-agent-adapter
Open

feat: add codex agent adapter#319
tumberger wants to merge 1 commit into
refactor/agent-hook-installerfrom
feat/codex-agent-adapter

Conversation

@tumberger

@tumberger tumberger commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Register Codex as a first-class agent adapter.
  • Add Codex hook decoding/encoding for session, tool, prompt, and turn-stop events.

Review notes

  • UserPromptSubmit is intentionally treated as a blocking event in the shared hook domain. In enforce mode, runtime/socket failures fail closed for UserPromptSubmit, matching Codex's ability to block prompts. Claude Guard user hooks still only install PreToolUse/PostToolUse, so this does not add a Claude user-hook install path.
  • Codex Stop is treated as turn-scoped telemetry, not as a session-finalization event. Codex does not emit Claude's SessionEnd.

Verification

  • go test ./...

tumberger commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@tumberger tumberger changed the base branch from refactor/agent-hook-installer to graphite-base/319 June 20, 2026 08:30
@tumberger tumberger force-pushed the feat/codex-agent-adapter branch from 8bb272c to 8814da9 Compare June 24, 2026 11:53
@tumberger tumberger force-pushed the graphite-base/319 branch from 329d0ef to 8bf26eb Compare June 24, 2026 11:53
@tumberger tumberger changed the base branch from graphite-base/319 to refactor/agent-hook-installer June 24, 2026 11:53
@tumberger tumberger force-pushed the refactor/agent-hook-installer branch from 35c5022 to 4fef034 Compare June 24, 2026 13:11
@tumberger tumberger force-pushed the feat/codex-agent-adapter branch from 8814da9 to e573160 Compare June 24, 2026 13:11
@tumberger tumberger marked this pull request as ready for review June 24, 2026 14:17
@greptile-apps

greptile-apps Bot commented Jun 24, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds Codex as a supported agent path. The main changes are:

  • Codex agent registration in the CLI binary.
  • Codex hook decoding for session, tool, lifecycle, and prompt events.
  • Codex hook result encoding for allow, deny, updates, and context.
  • Shared hook alias parsing for CLI hook event names.
  • Prompt-submit routing through the synchronous enforcement path.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
internal/hookruntime/codex.go Adds Codex event decoding, supported-event checks, input normalization, and result encoding.
internal/agent/codex/codex.go Registers the Codex agent and wires it to the Codex hook runtime codec.
internal/hook/domain.go Adds shared hook alias helpers and marks prompt-submit hooks as blockable.
internal/localruntime/service.go Routes async ingestion based on normalized hook names and hook blockability.
cmd/kontext/main.go Loads the Codex adapter and switches hook argument parsing to the shared alias parser.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Codex hook JSON] --> B[Codex adapter]
  B --> C[Decode Codex event]
  C --> D[Shared hook event]
  D --> E{Can this hook block?}
  E -->|PreToolUse or UserPromptSubmit| F[Evaluate synchronously]
  E -->|Other hooks| G[Ingest as telemetry]
  F --> H[Hook result]
  G --> H
  H --> I[Encode Codex result]
  I --> J[Codex response JSON]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
  A[Codex hook JSON] --> B[Codex adapter]
  B --> C[Decode Codex event]
  C --> D[Shared hook event]
  D --> E{Can this hook block?}
  E -->|PreToolUse or UserPromptSubmit| F[Evaluate synchronously]
  E -->|Other hooks| G[Ingest as telemetry]
  F --> H[Hook result]
  G --> H
  H --> I[Encode Codex result]
  I --> J[Codex response JSON]
Loading

Reviews (2): Last reviewed commit: "feat: add codex agent adapter" | Re-trigger Greptile

Comment thread internal/hookruntime/codex.go
Comment thread internal/hookruntime/codex.go Outdated
Comment thread internal/hookruntime/codex.go Outdated
@tumberger tumberger force-pushed the feat/codex-agent-adapter branch from e573160 to 67914ca Compare June 24, 2026 14:26
@tumberger tumberger force-pushed the refactor/agent-hook-installer branch from 4fef034 to 23caa4d Compare June 24, 2026 14:26
@tumberger tumberger force-pushed the feat/codex-agent-adapter branch from 67914ca to 9bd0124 Compare June 24, 2026 15:40
@tumberger

Copy link
Copy Markdown
Contributor Author

@greptile check again

@tumberger tumberger force-pushed the feat/codex-agent-adapter branch from 9bd0124 to 7b65108 Compare June 24, 2026 16:26

@hasandemirkiran hasandemirkiran left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few notes on the adapter — the main one (the event set) ties into the codexmanaged side in #320. Details inline.

Comment thread internal/hook/domain.go
Comment thread internal/hookruntime/codex.go
@tumberger tumberger force-pushed the feat/codex-agent-adapter branch from 7b65108 to 9c59eee Compare June 25, 2026 10:03
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