[BUG] Agent worktree subprocesses frequently require re-authentication on Max plan (OAuth)
### 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?
## Environment
- Claude Code version: 2.1.85
- OS: macOS 15 (Darwin 25.3.0)
- Auth method: claude.ai OAuth (first-party)
- Subscription: Max plan (Organization)
## Problem
Agent tool with isolation: "worktree" frequently fails with
"Not logged in · Please run /login", requiring re-authentication
~10 times per day during normal usage.
## Reproduction
- Log in via
/login(OAuth, Max plan)
- Run a workflow that spawns multiple agents with
isolation: "worktree"
- After some time (sometimes within minutes), the agent subprocess
returns "Not logged in" without executing any work
## Expected behavior
OAuth token should persist across agent subprocesses within a session,
or token refresh should propagate to child processes automatically.
## Actual behavior
Each worktree agent spawn can independently fail auth, even immediately
after a successful /login in the main session. The token seems to
expire frequently and is not shared/refreshed for subprocesses.
## Auth status (redacted)
```json
{
"loggedIn": true,
"authMethod": "claude.ai",
"apiProvider": "firstParty",
"subscriptionType": "max"
}
```
## Notes
- No ANTHROPIC_API_KEY is set (company account, no individual API key access)
- This is a significant friction point for workflows that rely heavily
on agent worktrees (e.g., processing multiple Jira tickets in parallel)
### What Should Happen?
OAuth token should remain valid across agent subprocesses spawned
within the same session. Token refresh should propagate automatically
to child processes (worktree agents), so that a single /login at
session start is sufficient for the entire session duration.
### Error Messages/Logs
```shell
Agent worktree returned the following instead of executing the task:
"Not logged in · Please run /login"
No stack trace or additional error logs are produced.
The agent simply exits without performing any work.
```
### Steps to Reproduce
- Authenticate via
/login(OAuth, claude.ai Max plan, Organization account)
- Confirm auth is valid:
claude auth statusshowsloggedIn: true - Start a workflow that uses the Agent tool with
isolation: "worktree":
- Example: any multi-step task that delegates subtasks to worktree agents
- The first agent may succeed, but subsequent agents (or agents after
some elapsed time) return:
"Not logged in · Please run /login"
- Run
/loginagain — agent works
- Repeat steps 3-5 throughout the day (~10 times)
Note: Exact token expiry timing is unpredictable. Sometimes fails
within minutes of login, sometimes after longer intervals.
### Claude Model
Opus
### Is this a regression?
I don't know
### Last Working Version
_No response_
### Claude Code Version
2.1.85 (Claude Code)
### Platform
Claude App (claude.ai)
### Operating System
macOS
### Terminal/Shell
Terminal.app (macOS)
### Additional Information
- This occurs on a company Organization account (not personal)
- No ANTHROPIC_API_KEY environment variable is set — the organization
does not provide individual API keys, so OAuth is the only auth method
- The workflow that triggers this most frequently uses multiple
sequential Agent calls with isolation: "worktree", each spawning
a new subprocess that needs to read the OAuth token
- Workaround: running
/logineach time the agent fails, but this
breaks automated pipelines and requires constant user intervention
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗