Anthropic Adapter does not always return valid JSON
Open
@tombeckenham is already working on this.
Since Sep 17, 2026.
needs-repro
waiting-on: author
- Dominant language
- TypeScript
- Stars
- 3.1k
- Forks
- 331
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 160
Description
TanStack AI version
0.4.2
Framework/Library version
bun 1.3.6
Describe the bug and the steps to reproduce it
With some prompts you get malformed JSON so zod cannot validate it. However Anthropic itself offers structured outputs, we should use those insteadof forcing the LLM to use a tool for responding.
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
none
Screenshots or Videos (Optional)
No response
Do you intend to try to help solve this bug with your own PR?
Yes, I am also opening a PR that solves the problem along side this issue
Terms & Code of Conduct
- I agree to follow this project's Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.