[BUG] Spawning subagents with isolation: "worktree" immediately fails auth
Resolved 💬 3 comments Opened Mar 21, 2026 by shaivyamahajan Closed Mar 31, 2026
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Spawning subagents with isolation: "worktree" immediately fails with:
Not logged in ·
Please run /login on the latest Claude Code build.
The parent session is fully authenticated but also starts throwing 400 errors after this.
Regular subagents without worktree isolation do not have this issue, so its likely due to the auth credentials getting masked by the isolation.
What Should Happen?
Subagents with worktree isolation should still have access to parent session auth / credentials.
Error Messages/Logs
--debug logs during subagent auth failure:
2026-03-21T21:30:50.018Z [DEBUG] Tool search disabled: ToolSearchTool is not available (may have been disallowed via disallowedTools).
2026-03-21T21:30:50.018Z [DEBUG] attribution header x-anthropic-billing-header: cc_version=2.1.81.b68; cc_entrypoint=cli; cch=00000;
2026-03-21T21:30:50.018Z [DEBUG] [API:request] Creating client, ANTHROPIC_CUSTOM_HEADERS present: false, has Authorization header: false
2026-03-21T21:30:50.018Z [DEBUG] [API:auth] OAuth token check starting
2026-03-21T21:30:50.018Z [DEBUG] [API:auth] OAuth token check complete
2026-03-21T21:30:50.019Z [ERROR] API error (attempt 1/11): Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted
2026-03-21T21:30:50.019Z [ERROR] Error in API request: Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted
2026-03-21T21:30:50.019Z [ERROR] Error: Error: Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted
at validateHeaders (/$bunfs/root/src/entrypoints/cli.js:244:1013)
at buildHeaders (/$bunfs/root/src/entrypoints/cli.js:244:8580)
at processTicksAndRejections (native:7:39)
Steps to Reproduce
A basic prompt to create a subagent with isolate worktree reproduces the issue:
$ claude --version
2.1.81 (Claude Code)
$ claude -p "create a subagent with isolate worktree, and have it echo hello world"
Not logged in · Please run /login
Previous version succeeds
$ claude --version
2.1.80 (Claude Code)
$ claude -p "create a subagent with isolate worktree, and have it echo hello world"
The subagent ran in an isolated worktree at `.worktree/agent-a7693acf` and output:
hello world
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.1.80
Claude Code Version
2.1.81
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗