Summary
Claude Code's Remote Control (/rc) feature fails inside sandboxes with repeated 401/403 errors. The initial session creation succeeds, but subsequent SSE streaming and worker registration calls are rejected, suggesting the sandbox HTTP proxy is interfering with authentication headers on these requests.
Reproduction steps
- Start a Claude Code session inside a sandbox
- Run a successful /login with the "Claude account with subscription" method
- Run /debug to make Claude Code write debug logs to a file
- Run /rc or /remote-control
- Connection fails with "Remote Control failed · Transport closed (code 4091)" in the bottom right of the terminal and "worker_register_failed" in the debug log
Observed behavior
The CCR bridge session is created successfully, and bridge credentials are fetched. However, immediately after:
- The SSE event stream to api.anthropic.com/v1/code/sessions/{id}/worker/events/stream returns HTTP 403 (permanent)
- The worker registration PUT to api.anthropic.com/v1/code/sessions/{id}/worker returns HTTP 401
- GET polls to the same worker endpoint return 401 on every retry (up to 10 attempts), then exhausts retries
Relevant log entries:
[DEBUG] [remote-bridge] Created session cse_014jGpDmeKLwnuMcGT4UxWx3
[DEBUG] [remote-bridge] Fetched bridge credentials (expires_in=14400s)
[DEBUG] [remote-bridge] v2 session URL: https://api.anthropic.com/v1/code/sessions/cse_014jGpDmeKLwnuMcGT4UxWx3
[ERROR] SSETransport: HTTP 403 (permanent)
[DEBUG] [remote-bridge] v2 transport closed (code=403)
[WARN] CCRClient: GET .../worker returned 401 (attempt 1/10)
[WARN] CCRClient: PUT worker (init) returned 401
[ERROR] [bridge:repl] CCR v2 initialize failed: CCRClient init failed: worker_register_failed
[WARN] CCRClient: GET .../worker returned 401 (attempt 2/10)
...
[ERROR] CCRClient: GET retries exhausted
Expected behavior
The remote control bridge should connect successfully after session creation and credential fetch both succeed.
Analysis
The session creation (POST .../sessions) and credential fetch work fine through the proxy, so basic API auth is passing through. However, the bridge endpoints (/worker/events/stream, /worker, /worker/events) fail with 401/403, which suggests the proxy may be:
- Stripping or rewriting the Authorization header on SSE/streaming requests specifically
- Not forwarding the bridge-specific bearer token (which differs from the main API OAuth token)
- Treating long-lived SSE connections differently from standard request/response calls
The bridge credentials are fetched successfully (line: Fetched bridge credentials (expires_in=14400s)), so the token itself is valid — it's just not arriving at the upstream server intact.
Environment
- Claude Code version: 2.1.89
- sbx version: 0.23.0
- default balanced network policy (api.anthropic.com:443 allowed)
Summary
Claude Code's Remote Control (/rc) feature fails inside sandboxes with repeated 401/403 errors. The initial session creation succeeds, but subsequent SSE streaming and worker registration calls are rejected, suggesting the sandbox HTTP proxy is interfering with authentication headers on these requests.
Reproduction steps
Observed behavior
The CCR bridge session is created successfully, and bridge credentials are fetched. However, immediately after:
Relevant log entries:
Expected behavior
The remote control bridge should connect successfully after session creation and credential fetch both succeed.
Analysis
The session creation (POST .../sessions) and credential fetch work fine through the proxy, so basic API auth is passing through. However, the bridge endpoints (/worker/events/stream, /worker, /worker/events) fail with 401/403, which suggests the proxy may be:
The bridge credentials are fetched successfully (line: Fetched bridge credentials (expires_in=14400s)), so the token itself is valid — it's just not arriving at the upstream server intact.
Environment