claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

JSON Parsing Error in /agents Feature When Creating Custom Agent

Open mjstelly opened this issue 5 months ago • 27 comments

Bug Description The new /agents feature is throwing JSON parsing errors when trying to create a custom agent, even with clean text input.

Error message: "Bad control character in string literal in JSON at position [X] (line 3 column [Y])"

Steps to reproduce:

  1. Use /agents command to create new agent
  2. Paste any text into the agent description field (even simple text like "You are a helpful assistant")
  3. Error occurs consistently at various character positions

Expected behavior: Should accept clean text input without JSON parsing errors

Actual behavior: Fails with JSON control character error

Additional context: Error persists even with:

  • Single line text with no special characters
  • Very short prompts (under 50 characters)
  • Text typed directly vs copy-pasted
  • Different browsers/devices

This suggests the issue is in how the system processes the input text, not the content itself.

Environment Info

  • Platform: darwin
  • Terminal: vscode
  • Version: 1.0.60
  • Feedback ID: ca2267f4-d9a7-49a3-b8db-2e03400bc461

Errors

[{"error":"Error: Command failed: security find-generic-password -a $USER -w -s \"Claude Code\"\nsecurity: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.\n\n    at genericNodeError (node:internal/errors:983:15)\n    at wrappedFn (node:internal/errors:537:14)\n    at checkExecSyncError (node:child_process:892:11)\n    at execSync (node:child_process:964:15)\n    at i7 (file:///Users/mjstelly/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:865:5196)\n    at file:///Users/mjstelly/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:777:49014\n    at Q (file:///Users/mjstelly/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:674:14420)\n    at kJ (file:///Users/mjstelly/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:777:46725)\n    at XH (file:///Users/mjstelly/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:777:45592)\n    at I9 (file:///Users/mjstelly/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:777:51640)","timestamp":"2025-07-25T01:46:01.726Z"},{"error":"Error: Command failed: security delete-generic-password -a $USER -s \"Claude Code\"\nsecurity: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.\n\n    at genericNodeError (node:internal/errors:983:15)\n    at wrappedFn (node:internal/errors:537:14)\n    at checkExecSyncError (node:child_process:892:11)\n    at execSync (node:child_process:964:15)\n    at i7 (file:///Users/mjstelly/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:865:5196)\n    at FaA (file:///Users/mjstelly/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:777:50130)\n    at GaA (file:///Users/mjstelly/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:777:50002)\n    at C$0 (file:///Users/mjstelly/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1902:2567)\n    at fZ1.startOAuthFlow (file:///Users/mjstelly/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1902:3766)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)","timestamp":"2025-07-25T01:46:10.487Z"},{"error":"Error: Command failed: security find-generic-password -a $USER -w -s \"Claude Code\"\nsecurity: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.\n\n    at genericNodeError (node:internal/errors:983:15)\n    at wrappedFn (node:internal/errors:537:14)\n    at checkExecSyncError (node:child_process:892:11)\n    at execSync (node:child_process:964:15)\n    at i7 (file:///Users/mjstelly/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:865:5196)\n    at file:///Users/mjstelly/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:777:49014\n    at Q (file:///Users/mjstelly/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:674:14420)\n    at kJ (file:///Users/mjstelly/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:777:46725)\n    at XH (file:///Users/mjstelly/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:777:45592)\n    at I9 (file:///Users/mjstelly/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:777:51640)","timestamp":"2025-07-25T01:46:10.555Z"}]

mjstelly avatar Jul 25 '25 02:07 mjstelly

I am getting the same error

ppalladino avatar Jul 25 '25 16:07 ppalladino

I'm encountering the same error with the Claude Code CLI when attempting to generate the agent using Option 1: 'Generate with Claude (recommended)

nexium0 avatar Jul 25 '25 19:07 nexium0

I'm getting an error "No JSON object found in response" when I do this

advdrone avatar Jul 25 '25 19:07 advdrone

same error occured when Claude Code hit limit rate (usage limit)

aoki-h-jp avatar Jul 26 '25 15:07 aoki-h-jp

If I use Option 1 "Generate with Claude" it fails as described above. If I use Option 2 "Manual configuration", it works.

│ ❯ 1. Generate with Claude (recommended)                                                                                                                                                             
│   2. Manual configuration

ruflin avatar Jul 27 '25 13:07 ruflin

I have the same problem.

azdolinski avatar Jul 29 '25 08:07 azdolinski

Same issue here. │ Bad control character in string literal in JSON at position 1782 (line 4 │ │ column 335)

is there any update or workaround for this problem?

travis-jorge avatar Jul 29 '25 14:07 travis-jorge

Someone on claude subreddit posted a workable solution. Rather than choose the option for claude to auto-generate, tell claude -- before running /agents -- to output the agents content/structure, then during manual creation when prompted to input the instructions, copy/paste it into the text area. I've attached an example that claude helped me build. Feel free to use it if you like.

session-manager.md

mjstelly avatar Jul 29 '25 14:07 mjstelly

same issue

jame-earnin avatar Jul 30 '25 14:07 jame-earnin

I have the same issue

Adam-Langevin avatar Aug 01 '25 13:08 Adam-Langevin

I got this error when my balance at anthropic was 0$, adding a few bucks seems to have solved the json error.

avnersender avatar Aug 02 '25 15:08 avnersender

Same issue (No JSON object found in response). For context, I am on Pro plan, I did not hit my limit, I used option 1 (generate with claude), this is the first time I try to create an agent.

What I did was that I went back to my project files, I created new folder named .claude and create another new folder inside .claude named agents. It worked for me.

18h32n avatar Aug 03 '25 11:08 18h32n

same issue(not only English but also Chinese)

bourne-3 avatar Aug 05 '25 06:08 bourne-3

Same issue. Tried rolling back to a previous version, also tried what @18h32n did to resolve, did not work for me. The description I give it doesn't seem to change anything. On MacOS 15.2, apple M2 chip.

Image

Update: I fixed it, heres how

Background: I'm using NVM to manage node installs on my machine.

  1. I used nvm to install node v22.18.0 and and switched to using that (my previous version was v22.18.0)
  2. I then had to reinstall claude code because my new node installation didn't have it.
  3. After reauthenticating with claude code, I tried creating subagents again, and it worked this time.

So it seems like there's either something going on where claude code needs to be completely uninstalled and reinstalled, or there's some issue that's in the node environment (idk maybe some file claude stores somewhere thats in the node env) that doesn't allow for this to work.

ceckenrode avatar Aug 06 '25 17:08 ceckenrode

I was having the "No JSON object found in response" isse and asked to Claude Code how to create an agent and it gave me the following answer: "Claude Opus is not available with the Claude Pro plan. If you have updated your subscription plan recently, run /logout and /login for the plan to take effect.". So I've logged out and logged in and now it works.

joaovictorjoao avatar Aug 08 '25 13:08 joaovictorjoao

Problem: Pro plan users may encounter Opus model execution failures and JSON generation errors when using default settings.

Solution: Use the /model command to verify your current plan, then select Sonnet model if needed to resolve compatibility issues.

Image

Skyryo avatar Aug 09 '25 04:08 Skyryo

https://github.com/anthropics/claude-code/issues/4351#issuecomment-3170208980 @Skyryo I was facing the same problem, and thanks — this worked for me!

testkun08080 avatar Aug 11 '25 08:08 testkun08080

Although trying things like logging in and out or changing the /model setting may help, in my case I’ve found that this error mainly occurs when the limit is nearly reached or already exceeded. Usually, you just have to wait until it resets.

aifirstd3v avatar Sep 13 '25 07:09 aifirstd3v

Claude Code Pro plan using sonnet. I'm getting this error at the start of my work day so I know it is not related to token limits. It only seems to happen when I use the option for Claude to auto-generate a subagent. It always happens when I paste text and only sometimes when I enter the text by typing.

lnedry avatar Sep 28 '25 14:09 lnedry

Same issue here. Creating an agent for the first time, but in my case I was not logged in to my recently created pro account. So a message saying you don't have balance or account type for this operation would be much less confusing than what you get now.

limoragni avatar Oct 08 '25 10:10 limoragni

Hit same issue

showonlady avatar Nov 04 '25 01:11 showonlady

Same issue here

zackarno avatar Nov 24 '25 20:11 zackarno

same issue here

Image

trinanda avatar Dec 03 '25 05:12 trinanda

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] avatar Jan 02 '26 10:01 github-actions[bot]

No longer an issue for me as of today. The creation now works.

GanizaniSitara avatar Jan 02 '26 10:01 GanizaniSitara

I am still having the problem of getting the message "No JSON object found in response".

tkm5 avatar Jan 06 '26 06:01 tkm5

Issue still persists

sankhlaofficial avatar Jan 10 '26 13:01 sankhlaofficial

The issue goes away if I change from Sonnet to Opus....

nikoethonai avatar Jan 12 '26 16:01 nikoethonai