fix(server): recover after Claude capability probe failures #21042
main fromrefs/pull/21042/head·merged by juliusmarminge View on GitHubProblem#
One failed Claude capability probe becomes a successful empty result cached for five minutes. Status refreshes then lose the known account and commands while continuing to reuse the failed result. This is the cache and error-handling defect accepted in #13635's triage.
Change#
Keep initialization failures typed and log only their error tag. Reuse the last successful account and commands for one failed refresh, without restamping old usage windows. A failure or fallback has zero cache TTL, so the next refresh probes again; repeated failure warns and a later success recovers.
Re-read the configured organization before fallback. An organization change discards the old account data and surfaces the original failure. A same-organization identity change may still use the single fallback.
This rebuilds #13838 at 8e57177debc2c2fe8ba362e3247030e60c290c75, by Wout Stiens with Claude Opus 5.5, on the current driver layout. Both are credited in the commit. That older version gave a successful fallback the normal five-minute TTL; this version retries on the next refresh. The existing PR is left open for maintainers to reconcile.
Scope and approval#
Addresses #13635's accepted cache/error-handling scope and the lost commands from the same probe in #7111. Retries use the existing refresh loop and client-demand gate, as the triage requires. There is no new timer, timeout increase or authentication flow. Codex and Cursor use different probe contracts.
Verification#
- Pinned upstream base: 16918b57d6754d6f145e9b6367c825aa31a740da.
- With the new tests and unchanged production code, both regressions failed: initialization timeout was swallowed, and the registry published a generic auth warning after a failed probe.
- At a2deeb3, all 81 tests passed across ClaudeCapabilitiesProbe.test.ts, ProviderInstanceRegistry.test.ts and ProviderRegistry.test.ts. After the one-line test-clock correction, the affected regression passed again; production is unchanged. Fixtures check typed timeout at the existing 25-second deadline, good-result caching, organization changes, one-time fallback, unchanged usage timestamps, an actual probe on the next refresh, repeated failure and recovery.
- Changed-file formatting and lint pass. Server-package typecheck passes after installing its cross-imported script dependencies.
- This is the behavior already carried in Signalbox #909, adapted without fork branding. Its earlier independent Opus review's organization guard and redundant-test-collector findings are resolved.
Independent upstream review: GPT 6.1 Sol xhigh (Opus unavailable: rate-limited at 2026-10-17 15:47:05 UTC). Standards and input reviews found no remaining issues at a89ad696e09b752ed80f504a059b4af4eb3b82a2. The test-clock finding is fixed and the strengthened timestamp assertion was shown to fail when stale usage was deliberately returned as fresh. The original production code was restored before the passing run.
Not checked: a real Claude provider under host load, browser or installed desktop behavior. SDK fixtures establish cache and status behavior without sending a provider turn.
Implemented with GPT 6.0 Luna and GPT 6.1 Sol through the Codex harness in T3 Code, adapting Wout Stiens and Claude Opus 5.5's original patch.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
Approvability#
Verdict: Approved at
a89ad69Macroscope's review found this PR approvable — This is a localized Claude server bug fix that prevents failed capability probes from being cached indefinitely, safely limits stale-account fallback, and retries on subsequent refreshes. Production changes are confined to the existing provider path and are accompanied by targeted timeout, organization, recovery, and usage-window tests.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Advanced
- Run ID:
29c04a63-73cc-4c06-ae35-8aac3edf146a
📥 Commits
-
Reviewing files that changed from the base of the PR and between 16918b57d6754d6f145e9b6367c825aa31a740da and a89ad696e09b752ed80f504a059b4af4eb3b82a2.
📒 Files selected for processing: 5
-
apps/server/src/provider/ClaudeCapabilitiesProbe.test.tsapps/server/src/provider/ClaudeProvider.tsapps/server/src/provider/Drivers/ClaudeDriver.tsapps/server/src/provider/ProviderInstanceRegistry.test.tsapps/server/src/provider/ProviderRegistry.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
-
📝 Walkthrough
-
Claude capability probes now propagate failures to provider status checks. Status warnings distinguish timeouts from other probe failures. The driver caches successful results and can reuse a matching last-good result after a failed probe.
Changes: Claude probe recovery
Layer / File(s) Summary Probe failures and status reporting
apps/server/src/provider/ClaudeProvider.ts,apps/server/src/provider/ClaudeCapabilitiesProbe.test.ts,apps/server/src/provider/ProviderRegistry.test.tsThe probe propagates failures. Workspace snapshot creation continues when a probe fails, and status warnings distinguish timeouts from other failures. Tests cover timeout behavior. Cached probe fallback
apps/server/src/provider/Drivers/ClaudeDriver.ts,apps/server/src/provider/ProviderInstanceRegistry.test.tsThe driver caches successful fresh probes. After a failure, it reuses the last-good result without usage data only when the current organization ID matches. Tests cover organization changes and repeated failures. Priority: ➖ Normal
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Sequence Diagram(s)#
sequenceDiagram participant ClaudeDriver participant probeClaudeCapabilities participant ClaudeAgentSDK participant LastGoodState ClaudeDriver->>probeClaudeCapabilities: Request capabilities probeClaudeCapabilities->>ClaudeAgentSDK: Initialize and probe ClaudeAgentSDK-->>probeClaudeCapabilities: Return capabilities or failure probeClaudeCapabilities-->>ClaudeDriver: Return result ClaudeDriver->>LastGoodState: Store successful fresh result ClaudeDriver->>LastGoodState: Read prior result after failure ClaudeDriver-->>ClaudeDriver: Reuse only when organization IDs matchSuggested reviewers:
juliusmarminge
Merge Risk: ⚪ Minimal · up to
a89ad-
Claude capability checks can retry after failures without retaining a fallback for the next refresh. No issue identified here requires a fix before merging.
Security architecture risk: 🔵 Low · up to
a89ad-
Recovery is limited to one fallback within a provider instance and does not supply execution credentials. However, missing organization identifiers are treated as a match, so a failed refresh can display previous account information as authenticated without confirming that it still belongs to the current account.
Retained concerns
- Low · security · inferred: The fallback does not require a known organization identity: two undefined identifiers compare equal. After a successful probe without a readable organization ID, a later failed probe can therefore publish the previous account and commands as ready/authenticated without confirming ownership. Cross-account consequences remain conditional on an external identity transition; no execution-authorization bypass was established.
Security review details
-
Security Blast Radius
- inferred — The identified concern is bounded to retained account and command metadata for one provider instance. The fallback state is not shared across instances, and the changed resolver feeds status construction rather than execution credentials.
Security Findings and Attack Paths
- inferred — A conditional stale-identity path exists when a successful probe has no organization ID, external account identity subsequently changes, and the next probe fails while the organization remains unknown. The prior metadata can then be advertised as authenticated for one fallback. The code establishes the acceptance path, but neither an unprivileged remote trigger nor unauthorized downstream execution was demonstrated.
Trust Boundaries and Controls
- observed — The existing initialization probe disables hooks, allows no tools, and supplies a never-yielding prompt. New failure logging includes only an error tag, while client-facing failures use fixed generic or timeout messages rather than raw SDK causes.
Resilience and Maintainability Implications
- observed — Fallback removes usage data instead of restamping old measurements. Added test assertions cover rejection after a known organization change, immediate recovery, one matching-organization fallback, and warning on the following failure; these assertions were inspected but not executed.
Pre-merge checks:
4-
Check name Status Explanation Title check The title clearly and concisely describes the main change: recovery after Claude capability probe failures. Description check The description includes all required sections. It explains the problem, implementation, scope and approval basis, verification results, limitations, and agent usage. Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
juliusmarminge merged this76ff0eb
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes