claude-code - 💡(How to fix) Fix [BUG] Agent worktree subprocesses frequently require re-authentication on Max plan (OAuth) [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#45129Fetched 2026-04-09 08:12:34
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×4commented ×1

Error Message

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.

Fix Action

Fix / Workaround

  • Workaround: running /login each time the agent fails, but this

Code Example

{

      "loggedIn": true,
      "authMethod": "claude.ai",
      "apiProvider": "firstParty",                                                                                                    
      "subscriptionType": "max"
    }

---

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.
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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                                                                                                                 
1. Log in via `/login` (OAuth, Max plan)

2. Run a workflow that spawns multiple agents with `isolation: "worktree"`                                                        

3. 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

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

1. Authenticate via `/login` (OAuth, claude.ai Max plan, Organization account)                                                    

2. Confirm auth is valid: `claude auth status` shows `loggedIn: true`                                                             
3. Start a workflow that uses the Agent tool with `isolation: "worktree"`:                                                      
                                                                                                                                  
   - Example: any multi-step task that delegates subtasks to worktree agents
                                                                                                                                  
4. The first agent may succeed, but subsequent agents (or agents after                                                          

   some elapsed time) return:                                                                                                     

   "Not logged in · Please run /login"                                                                                            
                                                                                                                                
5. Run `/login` again — agent works

6. 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 `/login` each time the agent fails, but this                                                                

  breaks automated pipelines and requires constant user intervention

extent analysis

TL;DR

The most likely fix is to implement a mechanism for automatically refreshing and propagating the OAuth token to child processes, ensuring it remains valid across agent subprocesses spawned within the same session.

Guidance

  • Investigate the OAuth token refresh mechanism to determine why it's not propagating to child processes, and consider implementing a custom solution to handle token refresh for worktree agents.
  • Verify that the claude auth status command returns loggedIn: true before spawning new agents, and explore ways to persist this authentication state across subprocesses.
  • Consider modifying the workflow to run /login before each agent spawn, although this may not be ideal for automated pipelines.
  • Review the Claude Code documentation and OAuth implementation to ensure that the authentication flow is correctly handling token refresh and propagation to child processes.

Example

No specific code example can be provided without more information on the Claude Code API and OAuth implementation. However, a potential approach might involve creating a custom authentication handler that refreshes the OAuth token and propagates it to child processes before spawning new agents.

Notes

The exact solution may depend on the specifics of the Claude Code OAuth implementation and the requirements of the workflow. It's also unclear whether this is a regression or a long-standing issue, which could impact the approach to resolving the problem.

Recommendation

Apply a workaround, such as running /login before each agent spawn, until a more robust solution can be implemented to handle OAuth token refresh and propagation to child processes. This is because the current behavior is causing significant friction and disrupting automated pipelines.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING