Skip to content

fix(claude-local): rotate session after consecutive adapter_failed runs#201

Open
om952 wants to merge 2 commits into
OpenScanAI:masterfrom
om952:fix/issue-28-claude-connection-refused
Open

fix(claude-local): rotate session after consecutive adapter_failed runs#201
om952 wants to merge 2 commits into
OpenScanAI:masterfrom
om952:fix/issue-28-claude-connection-refused

Conversation

@om952

@om952 om952 commented Jun 30, 2026

Copy link
Copy Markdown

Closes #28

This PR adds session rotation for claude_local after N consecutive adapter_failed runs, complementing the existing ConnectionRefused-as-transient fix.

Changes:

  • Add maxConsecutiveAdapterFailed to SessionCompactionPolicy.
  • Default claude_local to 2 consecutive adapter_failed rotations.
  • Extract evaluateSessionCompactionFromRuns for testability.
  • Count adapter_failed stop reason, adapter_failed error code, and transient_upstream error family toward rotation.
  • Add heartbeat-session-compaction.test.ts with 10 tests.
  • Update heartbeat-workspace-session.test.ts expectations.

Test results:

  • heartbeat-session-compaction.test.ts: 10 passed
  • parse.test.ts: 10 passed
  • heartbeat-workspace-session.test.ts: 38 passed

closes #28

om952 added 2 commits June 26, 2026 17:00
…ation

Adds ConnectionRefused / ECONNREFUSED detection to the transient upstream
error regex in parse.ts. When a Claude connection is refused, the execute
flow now rotates to a fresh session instead of failing the run.

Changes:
- CLAUDE_TRANSIENT_UPSTREAM_RE now matches 'connection refused',
  'econnrefused', and 'connect error'
- execute.ts retries with a fresh session when transient errors occur
  (same pattern as unknown-session retry)
- Added test cases for ConnectionRefused classification

Fixes OpenScanAI#28
- Add maxConsecutiveAdapterFailed to SessionCompactionPolicy.
- Default claude_local to 2 consecutive adapter_failed rotations.
- Extract evaluateSessionCompactionFromRuns for testability.
- Count adapter_failed / transient_upstream runs toward rotation.
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.

bug: claude-local — treat ConnectionRefused as transient + rotate session after N adapter_failed

1 participant