fix: record Codex edits made through the unified exec tool#85
Conversation
…cripts Why Codex CLI 0.142.5 records unified-executor edits as JavaScript nested inside custom_tool_call exec entries instead of direct apply_patch tool calls. The transcript parser only recognized direct tool calls, so nested edits produced no file or mutation evidence and commits were left without an Agent Note git note. User impact Codex commits made through the unified exec tool now record git notes with file attribution and an AI ratio. Nested apply_patch calls whose patch text is built dynamically still count as mutation evidence, and read-only or quoted nested references do not create false attribution. Verification npm run build --prefix packages/cli npm run typecheck --prefix packages/cli npm run lint --prefix packages/cli npm test --prefix packages/cli (491 passed) Release note: Codex edits made through the unified exec tool are now recorded with file attribution and an AI ratio. Agentnote-Session: 4a6d322d-5afe-45e3-a11b-cf15d0e740a9
📝 WalkthroughWalkthroughThis PR adds static-analysis recovery of nested tool calls (tools.apply_patch, tools.exec_command) embedded in JavaScript source passed to Codex's exec tool invocations. extractInteractions now attributes nested tools, mutation markers, and file/line evidence accordingly, with new unit and integration test coverage. ChangesNested exec tool call attribution
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Transcript
participant extractInteractions
participant NestedEvidenceHelper
participant Interaction
participant GitNote
Transcript->>extractInteractions: custom_tool_call "exec" with input source
extractInteractions->>NestedEvidenceHelper: scan source for tools.apply_patch/exec_command
NestedEvidenceHelper-->>extractInteractions: nested tool names, patch/command inputs
extractInteractions->>Interaction: append nested tools & mutation markers
extractInteractions->>Interaction: attribute files_touched/line_stats
Interaction->>GitNote: record ai_ratio and file attribution
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/cli/src/agents/codex.ts`:
- Around line 249-256: The inline regex inside the stringLiterals filter in
codex.ts should be hoisted into a named module-level const with a short intent
comment, matching the existing style of SHELL_MUTATION_COMMAND_RE. Move the
`cmd:`/quoted `cmd` key matcher out of the callback, give it a descriptive name
like NESTED_CMD_KEY_RE, and update the filter in commandInputs to reference that
constant so the mutation-evidence heuristic is easier to read and maintain.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 451e7b86-640e-4aa9-8dd1-c24ca07777e7
⛔ Files ignored due to path filters (1)
packages/cli/dist/cli.jsis excluded by!**/dist/**,!**/dist/**
📒 Files selected for processing (3)
packages/cli/src/agents/codex.test.tspackages/cli/src/agents/codex.tspackages/cli/src/commands/codex.test.ts
Hoist the inline mutation-evidence regex into NESTED_CMD_KEY_RE with an intent comment, matching how SHELL_MUTATION_COMMAND_RE is declared. Addresses CodeRabbit review feedback on PR #85. Release note: skip Agentnote-Session: 4a6d322d-5afe-45e3-a11b-cf15d0e740a9
Summary
tools.apply_patch(...)/tools.exec_command(...)calls insidecustom_tool_call: exectranscript entries with a bounded JavaScript tokenizer (string literals and comments are skipped, so quoted or commented tool references never attribute)cmd:string arguments as shell-mutation evidenceapply_patchcalls as mutating even when the patch text is built dynamically, so commit-level attribution can still recover the commitapply_patch/exec_commandtranscript formats unchangedRoot cause
Codex CLI 0.142.5 (unified executor) records file edits as JavaScript nested inside
custom_tool_call: execinstead of directapply_patchtool calls. The transcript parser only recognized direct tool calls, so nested edits produced neitherfiles_touchednor mutation evidence, and Agent Note safely declined to write a git note.User impact
Codex commits made through the unified exec tool now record git notes with file attribution and an AI Ratio in PR Report and Dashboard. Read-only nested calls do not create false-positive attribution.
Validation
attribution.method: lineandai_ratio: 100from a Codex 0.142.5-shaped transcriptCloses #83
🧑💬🤖 Agent Note
Total AI Ratio: █░░░░░░░ 9%
Model:
claude-fable-575023aafix(codex): attribute nested exec tool calls from current Codex transcripts41996c0refactor(codex): name the nested cmd key regex💬 Prompts & Responses (3 total)
75023aafix(codex): attribute nested exec tool calls from current Codex transcripts🧑 Prompt
🧑 Prompt
41996c0refactor(codex): name the nested cmd key regex🧑 Prompt
Summary by CodeRabbit
New Features
execcalls.Bug Fixes