Repository navigation
[AI-3259] Judge only prompts Claude would raise and warm the judge scan - #1502
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
PR Summary by QodoJudge only Claude-raised prompts and warm session transcripts
AI Description
Diagram
High-Level Assessment
Files changed (13)
|
Code Review by Qodo
1. Interrupts break server judge context
|
| while (more && reads < MaxWarmReads && !ct.IsCancellationRequested) { | ||
| Read(transcriptPath, null, cwd, statePath, maxBytesPerRead, out more); | ||
| reads++; |
There was a problem hiding this comment.
4. Concurrent scans can lose saved progress 🐞 Bug ➹ Performance
Warm repeatedly reads and replaces the same scanner state file used by hook consultations, without coordinating their load-and-save operations. If a hook saves a newer cursor after warm-up loads an older state but before warm-up saves it, the next consultation must rescan transcript bytes it had already processed, potentially losing the intended first-call speedup.
Agent Prompt
## Issue description
Warm-up and consultations independently load and replace one scanner state file. A warm-up write based on an older load can overwrite cursor progress saved by a hook.
## Fix Focus Areas
- src/Capacitor.Cli.Core/Harness/Claude/ClaudeJudgeDeclarationReader.cs[69-74]
- src/Capacitor.Cli.Core/Harness/Claude/ClaudeJudgeDeclarationReader.cs[85-104]
- src/Capacitor.Cli.Core/Harness/Claude/ClaudeJudgeDeclarationReader.cs[349-359]
## Recommended Fix
Serialize scan-state read/modify/write operations across watcher and hook processes, or reject a stale write and retry against the newer state. Test an interleaving in which a consultation saves while warm-up is scanning.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
|
||
| if (IsWhollyTaskNotification(text) || ClaudeAgentMessageFrame.IsMatch(text)) return true; | ||
|
|
||
| if (InterruptMarkers.Contains(text.Trim(), StringComparer.Ordinal)) return true; |
There was a problem hiding this comment.
1. Interrupts break server judge context 🔗 Cross-repo conflict ≡ Correctness
ClaudeHarnessPayload.IsHarnessPayload now excludes both interrupt markers from declared turns, but kcap-server’s UserPromptDisplay.IsHarnessPayload still treats them as human messages. When a marker appears in the consultation window, the server’s turn-anchor check fails and the judge runs without the session’s turn context.
Agent Prompt
## Issue description
The CLI excludes Claude interrupt markers from judge turns, while kcap-server still counts them as human turns. This makes affected consultations windowless.
## Fix Focus Areas
- src/Capacitor.Cli.Core/Harness/Claude/ClaudeHarnessPayload.cs[18-32]
- /cross_repos/kcap-server/src/Capacitor.Server.Core/UserPromptDisplay.cs[16-49]
## Recommended Fix
Update kcap-server’s harness-payload predicate to recognize both exact interrupt markers, test its agreement with the CLI predicate, and coordinate deployment of the two changes.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4e58bb6424
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| public static bool PromptsAtPreToolUse(string? permissionMode) => | ||
| permissionMode is null or "default" or "acceptEdits"; |
There was a problem hiding this comment.
Skip auto-approved calls in the PreToolUse judge lane
This mode-only predicate still consults the judge for calls Claude would never prompt for: in acceptEdits, Edit, Write, and common filesystem commands are automatically accepted, while in default mode read-only commands and calls covered by native allow rules also run without approval. The official Claude Code permission documentation confirms these exemptions. Because PreToolUse runs before native permission evaluation, an unmatched call in these categories can now receive a judge deny or ask, defeating the stated human-prompt-only behavior; this lane must also account for the action/tool's native auto-approval or defer consultation until PermissionRequest.
Useful? React with 👍 / 👎.
A hook allow overrides the permission mode, so the judge is not consulted where Claude asks nobody, nor on a question or plan approval. Interrupt markers are not declared as turns: kcap-server's harness-payload filter must drop them in lockstep. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4e58bb6 to
4b7cdee
Compare
AI-3259 — no GitHub issue exists.
What & why
The judge stands in for a human at a prompt, but PreToolUse consulted it in every permission mode, and a hook allow overrides the mode (probed on Claude Code 2.1.301: under
dontAskit ran a call the mode refuses). PreToolUse now consults only indefault/acceptEdits; PermissionRequest, which fires only for a real prompt, consults in any mode; neither ever answersAskUserQuestionorExitPlanMode, hosted bridge included. The watcher reads a judged session's transcript backlog at start, so the first consultation of a long resumed session is incremental.[Request interrupted by user…]lines are not declared as turns: Claude Code writes them, the human's no is already a declared refusal.Where to look
UserPromptDisplay.IsHarnessPayloadshould treat both interrupt markers as harness payloads. Until then a consultation whose newest user line is a marker fails the anchor check and runs windowless.agent_idwith the maintranscript_path, so they already reach the judge with the session's turns (now pinned). Rendered sessions stay tighten-only at PreToolUse; the daemon bridge judges their prompts.isCompactSummary) still count as human turns on both sides, and the ACP bridge.Verification
Before/after on a real 26 MB transcript (+69 MB of subagent transcripts), each read in a new process, 3 runs:
The ~0.7 s cold read reported earlier did not reproduce on this machine with a warm page cache.
KCAP_DAEMON_ID,AGY_ADC_AUTH), and one passes with them unset.dotnet publish -c Release: no IL2026/IL3050;scripts/check-linear-ids.shclean.🤖 Generated with Claude Code
Summary by CodeRabbit
auto,dontAsk,bypassPermissions, andplanmodes aren’t checked unless Claude raises a prompt.