fix: prevent SSH error pattern false positives on agent response text#794
fix: prevent SSH error pattern false positives on agent response text#794pedramamini merged 1 commit intorcfrom
Conversation
SSH error patterns (e.g., "command not found") were matched against raw JSONL stdout lines and combined stdout+stderr at exit. When an agent's response text quoted shell commands or error patterns, the regex would match across the JSON structure and incorrectly classify the entire response as an SSH error. - StdoutHandler: skip SSH pattern check when line parses as valid JSON - ExitHandler: check only stderr for SSH patterns, not stdout (which contains structured JSONL agent output) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe changes refine SSH error detection logic in the process manager's handlers to prevent false positives. SSH pattern matching now targets only Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
Greptile SummaryThis PR fixes false-positive SSH error detection by scoping pattern matching to non-JSON stdout lines in Confidence Score: 5/5Safe to merge — the fix is correct, well-scoped, and backed by new test coverage. All findings are P2 or lower. The core logic change is sound: SSH transport errors (bash 'command not found', connection drops) always come from the shell's stderr, never from JSONL agent responses on stdout. The No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[stdout line received] --> B{isStreamJsonMode?}
B -- No batch mode --> C[Accumulate in jsonBuffer\nno SSH check during stream]
B -- Yes --> D[JSON.parse line]
D --> E{parsed !== null?}
E -- Yes valid JSON --> F[Agent parser: detectErrorFromParsed\nSSH check SKIPPED ← fix]
E -- No plain text --> G[Agent parser: detectErrorFromLine\nSSH matchSshErrorPattern line]
G --> H{SSH pattern match?}
H -- Yes --> I[emit agent-error]
H -- No --> J[emit as data]
subgraph ExitHandler at process exit
K{errorEmitted?} -- No --> L{sshRemoteId set AND\ncode≠0 OR stderrBuffer?}
L -- Yes --> M[matchSshErrorPattern stderrBuffer ONLY ← fix]
M --> N{match?}
N -- Yes --> O[emit agent-error]
N -- No --> P[log warn if code≠0]
end
style F fill:#f9c,stroke:#c66
style M fill:#f9c,stroke:#c66
Reviews (1): Last reviewed commit: "fix: prevent SSH error pattern false pos..." | Re-trigger Greptile |
…RunMaestro#794) SSH error patterns (e.g., "command not found") were matched against raw JSONL stdout lines and combined stdout+stderr at exit. When an agent's response text quoted shell commands or error patterns, the regex would match across the JSON structure and incorrectly classify the entire response as an SSH error. - StdoutHandler: skip SSH pattern check when line parses as valid JSON - ExitHandler: check only stderr for SSH patterns, not stdout (which contains structured JSONL agent output) Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
bash:.*opencode.*command not foundwhen the agent quoted shell commands or error patterns in its response.stderr, not the combinedstdout+stderr. Stdout contains all accumulated JSONL which includes the full agent response — scanning it caused false positives when response text mentioned SSH error keywords.Root Cause
When running over SSH (
sshRemoteIdset), error patterns were matched against raw JSONL lines and combined output buffers. The.*wildcards in patterns like/bash:.*opencode.*command not found/imatched across the JSON structure, hitting keywords embedded in the agent's response text. This caused the entire response to be classified as an SSHagent_crashederror.Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests