[BUG] CLI works fine but every request fails in Xcode with Prompt stream failed: Agent has been closed

Status Open
Reported on v2.1.110
Maintainer reply None cached
Activity 8 comments · opened Apr 16, 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?

CLI works fine but every request fails in Xcode with Prompt stream failed: Agent has been closed

What Should Happen?

I should be able to request in claude code in xcode

Error Messages/Logs

Prompt stream failed: Agent has been closed

error: An unknown error occurred (Unexpected)

Steps to Reproduce

Trigger a Claude Code request from within Xcode (e.g. ask a question)

Claude Model

Not sure / Multiple models

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.110 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

8 Comments

chrisriv0803-beep · 4 months ago

Claude Code: 2.1.110
macOS: 26.4.1 (25E253)
xcode-select: 2416
CLI works fine, extension fails on every request

bbirbeck-dev · 4 months ago

I am also currently trying to figure out how to solve this issue.

bbirbeck-dev · 4 months ago
Claude Code: 2.1.110 macOS: 26.4.1 (25E253) xcode-select: 2416 CLI works fine, extension fails on every request

Did you originally try this below before getting the error you've reported here?

Prompt stream failed: Agent has been closed
error: An unknown error occurred, possibly due to low max file descriptors (Unexpected)
Current limit: 7168

To fix this, try running:

ulimit -n 2147483646

If that still doesn't work, you may need to run:

sudo launchctl limit maxfiles 2147483646

CubusWaw · 3 months ago

I have the same cannot make it running at all.

I reported it to Apple

usagimaru · 3 months ago

My Xcode 26.5 (Claude 2.1.118) has the same issue, and this is not the first time.
For now, I worked around it by falling back to an older agent via a symbolic link. I'm hoping Apple will address this.

cd ~/Library/Developer/Xcode/CodingAssistant/Agents/claude/
mv ./2.1.118/claude ./2.1.118/claude_2.1.118
cd ./2.1.118
ln -s ../2.1.81/claude claude
blackaivengo · 3 months ago

Same issue.

Prompt stream failed: Agent has been closed

delete(K)}}createCanUseTool(H){return async(_,q,K,O,T,$)=>{let A=$??await Sj(_,q,K,O,T);if(A.behavior==="allow"||A.behavior==="deny")return A;let z=ne

AbortError:
at T (/$bunfs/root/src/entrypoints/cli.js:8488:473)
at $ (/$bunfs/root/src/entrypoints/cli.js:7961:8868)

Error in hook callback IDEIntelligenceAgents.pre_tool_use: 8483 | ).map((f)=>{if(!f)return f;try{return uH(ZT_(Q_(f)))}catch{return um(f)}}).join(
8484 | ),z={...ZT_({trigger:_,version:{ISSUES_EXPLAINER:"report the issue at https://github.com/anthropics/claude-code/issues",PACKAGE_URL:"@anthropic-ai/claude-code",README_URL:"https://code.claude.com/docs/en/overview",VERSION:"2.1.118",FEEDBACK_CHANNEL:"https://github.com/anthropics/claude-code/issues",BUILD_TIME:"2026-04-22T21:04:38Z",GIT_SHA:"ef88b5f0a79aac989f53fd18178939a54a48624a"}.VERSION,platform:"darwin",transcript:K,subagentTranscripts:Object.keys(T).length>0?T:void 0}),rawTranscriptJsonl:A},Y=M66(z,_83,q83,{extraOuterFields:{appearance_id:q}});await i3();let w=XM();if(w.error)return{success:!1};let D={"Content-Type":"application/json","User-Agent":ZE(),...w.headers},j=await J6.post("https://api.anthropic.com/api/claude_code_shared_session_transcripts",Y,{headers:D,timeout:30000});if(j.status===200||j.status===201){let f=j.data;return V("Transcript shared successfully",{level:"info"}),{success:!0,transcriptId:f?.transcript_id}}return{success:!1}}catch(K){return V(bH(K),{level:"error"}),{success:!1}}}var
8485 | ${a8("suggestion",H.theme)(
/plugin install frontend-design@${SJ})}},cooldownSessions:3,isRelevant:async(H)=>wOK("frontend-design",H,{filePath:/\.(html|css|htm)$/i})},{id:"vercel-plugin",content:async(H)=>{returnWorking with Vercel? Install the vercel plugin:
8486 | ${a8("suggestion",H.theme)(
/plugin install vercel@${SJ})}},cooldownSessions:3,isRelevant:async(H)=>wOK("vercel",H,{filePath:/(?:^|[/\\])vercel\.json$/i,cli:["vercel"]})},{id:"effort-high-nudge",content:async(H)=>{let q=a8("suggestion",H.theme)("/effort high");return S_("tengu_tide_elm","off")==="copy_b"?Use ${q} for better one-shot answers. Claude thinks it through first.:Working on something tricky? ${q} gives better first answers},cooldownSessions:3,isRelevant:async()=>{if(!ODH())return!1;if(!QE(IK()))return!1;if(G6("policySettings")?.effortLevel!==void 0)return!1;if(BjH()!==void 0)return!1;let H=u8().effortLevel;if(H==="high"||H==="xhigh"||H==="max")return!1;return S_("tengu_tide_elm","off")!=="off"}},{id:"subagent-fanout-nudge",content:async(H)=>{let _=a8("suggestion",H.theme);return S_("tengu_tern_alloy","off")==="copy_b"?For big tasks, tell Claude to ${_("use subagents")}. They work in parallel and keep your main thread clean.:Say ${_('"fan out subagents"')} and Claude sends a team. Each one d
8487 |
)}asyncread(){let H="",_=async function(){for(;;){if(this.prependedLines.length>0)H=this.prependedLines.join("")+H,this.prependedLines=[];let q=H.indexOf(
8488 |
)}async sendRequest(H,_,q,K=A56.randomUUID()){let O={type:"control_request",request_id:K,request:H};if(this.inputClosed)throw Error("Stream closed");if(q?.aborted)throw Error("Request aborted");if(this.outbound.enqueue(O),H.subtype==="can_use_tool"&&this.onControlRequestSent)this.onControlRequestSent(O);let T=()=>{this.outbound.enqueue({type:"control_cancel_request",request_id:K});let A=this.pendingRequests.get(K);if(A)this.trackResolvedToolUseId(A.request),A.reject(new y3)};if(q)q.addEventListener("abort",T,{once:!0});let $=Date.now();try{return await new Promise((A,z)=>{this.pendingRequests.set(K,{request:{type:"control_request",request_id:K,request:H},resolve:(Y)=>{A(Y)},reject:z,schema:_})})}finally{if(Q("tengu_sdk_control_roundtrip",{subtype:H.subtype,duration_ms:Date.now()-$,aborted:q?.aborted??!1}),q)q.removeEventListener("abort",T);this.pendingRequests.delete(K)}}createCanUseTool(H){return async(_,q,K,O,T,$)=>{let A=$??await Sj(_,q,K,O,T);if(A.behavior==="allow"||A.behavior==="deny")return A;let z=ne

AbortError:
at T (/$bunfs/root/src/entrypoints/cli.js:8488:473)
at $ (/$bunfs/root/src/entrypoints/cli.js:7961:8868)

irolleduplikethis · 2 months ago

I am experiencing a critical blocking issue with the Xcode Claude Agent integration that is directly impacting a time-sensitive, high-stakes project. The error I am receiving differs from what is described in this thread:

"Failed to initialize Claude Agent: The code signing identity for the agent did not match expectations, or the agent violated sandboxing rules. Please delete the currently selected agent in the Components section of Settings and download it again."

I have followed the instructions in the error message — deleting and re-downloading the agent from Xcode Settings → Components — and the issue persists. The integration is completely non-functional.

I am working against a three-week hard deadline on a multi-million dollar deal. This is not a minor inconvenience — it is a full development bottleneck that is costing real time and real money every day it goes unresolved.

I want to be transparent: the reliability of this integration is a significant factor in whether I continue building on these tools long-term. I have invested considerable time and resources into this ecosystem, and issues like this — with no documented fix, no official acknowledgment, and no ETA — make it very difficult to justify that commitment.

I would strongly appreciate either a confirmed workaround or a clear timeline for a patch. This needs to be treated as a priority.

ItisPratham · 1 month ago

Same error, root cause of it was because of permission denial to the root folder where the project is situated.
Changing the permission helped claude in xcode to work again.
But existing conversation seems to have died, tried to find it with claude --resume but it is wiped away somehow.

some debugging code that might help:

ulimit -n output should be less than ~7k
pgrep claude
lsof -p <p_id> | wc -l upto couple thousand is file, it is no.of descriptors
log stream --info --predicate 'eventMessage CONTAINS "claude"'