fix: harden ACP peer disconnect error handling#1108
Open
simple-agent-manager[bot] wants to merge 3 commits into
Open
fix: harden ACP peer disconnect error handling#1108simple-agent-manager[bot] wants to merge 3 commits into
simple-agent-manager[bot] wants to merge 3 commits into
Conversation
…ate double-lock Address Go specialist review findings: - Set HostError status and broadcast StatusError after unrecoverable agent crash, preventing the UI from showing "ready" for a dead agent - Refactor beginCrashRecovery to return agentType and redacted stderr even on the failure path, eliminating redundant lock acquisitions - Add status assertion to the unrecoverable crash test Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
HostErrorstatus and broadcastsStatusErrorto prevent the UI from showing "ready" for a dead agentbeginCrashRecoveryto returnagentTypeand redactedstderreven on the failure path, eliminating redundant lock acquisitions (TOCTOU window fix)Root Cause Investigation
Production D1 showed 24 tasks failing with
peer disconnected before responsebetween 2026-05-15 and 2026-05-22. The crash recovery feature (LoadSession) merged ~5 hours after the last observed failure. Analysis of the code path confirmed:finishPromptWithError→beginCrashRecovery→ restart agent →LoadSession→ resume. This path was already correct.Changes
session_host_prompt.gofinishUnrecoverableCrashPromptmethod with structured logging, crash report, actionable error message, andHostErrorstatus transitionsession_host_crash.gobeginCrashRecoveryreturns(agentType, stderr, ok)instead of(agentType, ok)— eliminates double-lock on failure pathsession_host_test.goHostErrorstatusTest Plan
TestSessionHost_FinishPromptWithPeerDisconnectBeginsCrashRecovery— verifies recoverable path enters crash recoveryTestSessionHost_FinishPromptWithUnrecoverablePeerDisconnectReportsActionableFailure— verifies unrecoverable path produces crash report, actionable error, secret redaction, andHostErrorstatusTestSessionHost_BeginCrashRecoveryRequiresLoadSession— updated for 3-return-value signatureSpecialist Review Evidence
Do NOT Merge
Per task instructions, this PR is ready for human review. Do not merge without explicit authorization.
Agent Preflight
cross-component-change,business-logic-changesession_host_prompt.go→session_host_crash.go. LoadSession merge timestamp verified against failure timestamps. Constitution compliance checked (no hardcoded values).🤖 Generated with Claude Code