[BUG] Cloud session clone fails with mismatched branch reference after API error mid-session
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?
During an active cloud-hosted Claude Code session working on a private repo (branch: claude/linkedin-icp-outreach-agent-2hpu2n), an API error occurred mid-session ("An API error occurred - Try sending your message again"). After this, the session attempted to recover and showed a "Cloned repository" step that failed with:
"The requested branch or commit was not found in the repository 'collinsjames2106-design/LinkedIn-Agent'. Check the spelling of the branch name, verify it exists on the remote, and ensure it hasn't been deleted or renamed."
This is confusing because:
- The session's own branch indicator (visible in the UI breadcrumb) showed the correct branch: main → claude/linkedin-icp-outreach-agent-2hpu2n
- That branch exists and is the only branch in the repo
- "collinsjames2106-design/LinkedIn-Agent" was never a valid branch name — it looks like an owner/repo string got substituted into the branch field during the recovery/re-clone attempt
- I made no changes to the repo myself before this occurred
After this error, the session became completely unresponsive - I couldn't type any further messages into it, and there was no way to resume or recover it from within the session.
What Should Happen?
The session should either recover gracefully from the transient API error and continue working on the correct branch, or fail with an accurate error message. It should not reconstruct an invalid clone target (mixing up owner/repo and branch) during recovery, and it should not leave the session in a permanently unresponsive state with no way to resume or restart from within the UI.
Error Messages/Logs
Steps to Reproduce
- Start or resume a cloud-hosted Claude Code session on a private GitHub repo, working on a feature branch (e.g. claude/linkedin-icp-outreach-agent-2hpu2n)
- Continue working in the session over multiple turns (in this case, confirming two LinkedIn outreach follow-ups had been sent and tracked)
- Trigger or encounter a transient API error ("An API error occurred - Try sending your message again") mid-session
- Observe the session automatically attempt a "Cloned repository" step as part of recovery
- The clone step fails, referencing an invalid target ("collinsjester2106-design/LinkedIn-Agent") that does not match the branch shown in the session's own UI breadcrumb
- Session becomes unresponsive - "Session couldn't start / This session hit an error it can't recover from" - with no way to type further messages or resume from within the session
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
N/A - cloud-hosted session, no local CLI install
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Other
Additional Information
<img width="542" height="701" alt="Image" src="https://github.com/user-attachments/assets/7ff5aad0-9ac6-44a0-b649-8724a04d84db" />