opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Can't use Claude Opus 4.5 on opencode using Github Copilot

Open bhadraagada01 opened this issue 3 months ago • 3 comments

Description

This is the error i get when im trying to use claude opus 4.5 with github copilot

⚙ invalid [tool=write, error=Invalid input for tool write: JSON parsing failed: Text: {"filePath": "C:\\Users\\LENOVO\\Desktop\\ntfsnap\\ntfsnap.py".
Error message: JSON Parse error: Expected '}']
Image

and it takes ages to a response out of it and also and it gets endless stuck at preparing write

OpenCode version

1.0.204

Steps to reproduce

No response

Screenshot and/or share link

Image

Operating System

Windows 11

Terminal

Powershell

bhadraagada01 avatar Dec 28 '25 07:12 bhadraagada01

This issue might be a duplicate of existing issues. Please check:

  • #1803: [aws bedrock: anthropic opus 4.1] The arguments provided to the tool are invalid: Invalid input for tool write: JSON parsing failed: Text
  • #5890: Incomplete JSON when writing out files
  • #2188: JSON parsing failed: Text

All of these report the same JSON parsing error when using the write tool with Claude Opus models (4.1 and 4.5). The error appears to be incomplete JSON being generated with missing closing braces.

Feel free to ignore if none of these address your specific case.

github-actions[bot] avatar Dec 28 '25 07:12 github-actions[bot]

can u run this and send me file?

opencode export > session.json

rekram1-node avatar Dec 28 '25 08:12 rekram1-node

this is only happening when i try with python related project, it works fine with my ts project but ill still give you the session.json

session-ses_49c3.json session-ses_49c3.md

bhadraagada01 avatar Dec 29 '25 07:12 bhadraagada01

I am also running into this issue specifically for Python code - no issues if I work with projects in other languages or specify that the agent shouldn't write any Python code.

aaronkyriesenbach avatar Jan 16 '26 16:01 aaronkyriesenbach

@aaronkyriesenbach are u on windows too? Any chance u can send me a session export^^^

rekram1-node avatar Jan 16 '26 16:01 rekram1-node

Nope, tested on both macOS and Linux. Here is a prompt that causes the error on both systems:

I'm building a deep learning model to denoise audio. I have ~5000 hours of each type, noisy and denoised, and many recordings are of the same content but not synchronized.
In a previous session, we designed:
1. An audio pairing pipeline (fingerprinting → coarse alignment via cross-correlation → fine alignment via DTW → quality verification)
2. A Conformer-UNet generator with attention-gated skip connections operating on complex spectrograms
3. A multi-scale PatchGAN discriminator
4. A hybrid training strategy using paired data (supervised losses) and unpaired data (adversarial losses)
5. A phased training schedule
Please write a comprehensive markdown guide to `$HOME/audio_enhancement_guide.md` that includes:
- Complete preprocessing pipeline with technical details
- Audio pairing and alignment procedures
- Model architecture specifications
- Training configuration and loss functions
- Verification steps to validate preprocessing quality
- Verification steps to validate training efficacy
- Evaluation metrics and interpretation
- Troubleshooting guide
Make it detailed enough to serve as a complete implementation reference.

And here are the session logs from each system:

macos_session.json linux_session.json

Updating the above prompt to specify that Python code should not be written results in a successful write:

In a previous session, we designed:
1. An audio pairing pipeline (fingerprinting → coarse alignment via cross-correlation → fine alignment via DTW → quality verification)
2. A Conformer-UNet generator with attention-gated skip connections operating on complex spectrograms
3. A multi-scale PatchGAN discriminator
4. A hybrid training strategy using paired data (supervised losses) and unpaired data (adversarial losses)
5. A phased training schedule
Please write a comprehensive markdown guide to `$HOME/audio_enhancement_guide.md` that includes:
- Complete preprocessing pipeline with technical details
- Audio pairing and alignment procedures
- Model architecture specifications
- Training configuration and loss functions
- Verification steps to validate preprocessing quality
- Verification steps to validate training efficacy
- Evaluation metrics and interpretation
- Troubleshooting guide
Make it detailed enough to serve as a complete implementation reference. Do not include any Python code in the file.

Here's the successful session:

working_session.json

Hopefully this is helpful! Please let me know if there's any other info that I can provide to help troubleshoot. Thanks for your help with this!

aaronkyriesenbach avatar Jan 16 '26 18:01 aaronkyriesenbach

It seems that the error is always the same, the model forgets to close the JSON? I'm seeing the same now in MacOS python too

nalejandroveron avatar Jan 17 '26 17:01 nalejandroveron

I am having the same issue with Claude Sonnet 4.5, Claude Haiku 4.5 using Github Copilot. However, I am not using Python. I am getting the error just trying to create a markdown file. I am on the latest opencode and have removed my Github Copilot auth and re-auth. Still same issue. I should point out I am on Mac.

tyrailleverett avatar Jan 17 '26 18:01 tyrailleverett

Just an update, I came across this issue: https://github.com/anomalyco/opencode/issues/5890, which suggested the error occurs when the model is trying to generate too large of a file, which lines up with the file I was trying to generate. Otherwise, the models work just fine, so it seems when the file is too large (possibly overfilling the smaller context window that Github Copilot provides ) then this error is thrown.

tyrailleverett avatar Jan 17 '26 20:01 tyrailleverett