Xcode Intelligence Chat Agent Changes Overwrite Entire File

I have this local agent using Qwen 3.6 (the version that is ~17 GB). Last time I tried using this a couple months ago it worked ok.

Now the agent frequently does not know how to edit a file. It takes its proposed changes and completely overwrites the entire source file with the change instead of just modifying the portion of the source code. Sometimes the agent thinks it doesn't have permission to make a change and wants me to copy and paste code.

Is there an Xcode skill provided somewhere that I can use with the Agent so it knows how to work in this environment properly? Currently I have it set up via "Chat" with "Tools Enabled" and "Automatically apply changes" is on.

Answered by Developer Tools Engineer in 899884022

The good news is that this “chat” agent built into Xcode has not changed. It should be virtually identical to how it was the last time you tried it — although I’m sorry to hear you had bad luck with it recently.

The bad news is also that this “chat” agent built into Xcode hasn’t changed! As the industry has shifted toward much more sophisticated coding agents, our focus has moved toward supporting those agents with our ACP support on the client side and MCP support on the tools side.

I’d recommend trying either Codex, which supports a custom model configuration, or an open source ACP agent, which should make these models that want much more sophisticated sets of tools than anyone could support a year ago behave much better.

Accepted Answer

The good news is that this “chat” agent built into Xcode has not changed. It should be virtually identical to how it was the last time you tried it — although I’m sorry to hear you had bad luck with it recently.

The bad news is also that this “chat” agent built into Xcode hasn’t changed! As the industry has shifted toward much more sophisticated coding agents, our focus has moved toward supporting those agents with our ACP support on the client side and MCP support on the tools side.

I’d recommend trying either Codex, which supports a custom model configuration, or an open source ACP agent, which should make these models that want much more sophisticated sets of tools than anyone could support a year ago behave much better.

Thanks for the recommendation!

I just set this up as a custom ACP Agent in Xcode. Hoping to get better results now.

So I have my agent in a Docker container which makes set up with Xcode more difficult I think.

Also hermes agent + Xcode fails every time on the second turn with:

** JSON-RPC global stream failed: The operation couldn’t be completed. (IDEIntelligenceProtocol.JSONRPCElement.Error error 1.) **

This may be a bug in Hermes and not Xcode. Not sure. But either way I think I'm throwing in the towel for now though. If anyone has pointers on getting Hermes (in Docker) + Xcode to work properly let me know. I don't want to move the agent out of the container.

I am able to get the agent to work though it gets confused about its environment and responds with things like:

"The files aren't found. Let me check if this is a macOS project and the files might be in a different location. The working directory is on Linux but the paths look like macOS. Let me check what's actually in the current directory."

The agent is able to find the files mounted in the container with a little bit of effort though.

But still the second message I send from Xcode causes a failure every time with that error: *** JSON-RPC global stream failed: The operation couldn’t be completed. (IDEIntelligenceProtocol.JSONRPCElement.Error error 1.)**

I have not investigated the Hermes code myself but I did feed the error log to an LLM (so take this diagnosis for whatever it's worth:

Quote below is from AI:

**"Your log proves Xcode sent a cancel:

14:46:42 Cancelled session b05d... 14:46:43 Prompt on session b05d... 14:46:43 Turn ended: reason=interrupted_by_user

The previous turn had completed at 14:41:35, more than five minutes earlier. ACP defines session/cancel as cancelling an ongoing prompt turn. Since no turn was running, Xcode’s cancellation appears stale, unnecessary, or part of its cleanup behavior.

However, Hermes should safely tolerate that. Its current cancellation handler:

  1. Sets cancel_event.
  2. Calls agent.interrupt().
  3. Does so even when state.is_running is false.

The is_running check only controls whether Hermes saves current_prompt_text; it does not prevent the interrupt.

When the next prompt begins, Hermes clears:

state.cancel_event.clear() but does not clear the internal agent interrupt state.

That explains why the second turn immediately reports: reason=interrupted_by_user and then throws: acp.exceptions.RequestError: Internal error

Responsibility Xcode is the trigger: it sent a cancellation when Hermes apparently had no active prompt. Hermes is responsible for the failure: an idle or stale cancellation should not poison the next prompt or terminate the JSON-RPC request with an internal error. Xcode’s displayed error is only the consequence: its ACP peer returned an unhandled internal error, so Xcode reported the generic “JSON-RPC global stream failed.” I would report this primarily as a Hermes ACP bug, while explicitly noting that Xcode sends an idle session/cancel immediately before the next session/prompt. A robust fix is for Hermes to ignore cancellation when state.is_running is false and clear any stale internal interrupt state at the beginning of a new prompt. "**

Figured I'd share. Would be cool to have a working local AI set up in Xcode. So close.

Xcode Intelligence Chat Agent Changes Overwrite Entire File
 
 
Q