fix: use JSON skill serialization by default for non-Anthropic models#24852
Open
andrewgwoodruff wants to merge 2 commits intoanomalyco:devfrom
Open
fix: use JSON skill serialization by default for non-Anthropic models#24852andrewgwoodruff wants to merge 2 commits intoanomalyco:devfrom
andrewgwoodruff wants to merge 2 commits intoanomalyco:devfrom
Conversation
The skills system prompt block was always serialized as XML (`<available_skills>`), a Claude-specific convention. Non-Anthropic models (Ollama, etc.) interpret dense XML in the system prompt as a signal to respond in XML format, breaking JSON tool calls. Controlled testing across 50 runs each showed: - XML: 68% tool-call success - Markdown: 74% tool-call success - JSON: 86% tool-call success Changes: - `skill/index.ts`: replace `verbose: boolean` with `format: "xml" | "json" | "markdown"` in `fmt()`; add JSON serialization path - `session/system.ts`: pass model to `skills()`; default to JSON for non-Anthropic models, XML for Anthropic; read `skills.format` config override - `config/skills.ts`: add optional `format` field so users can override per-project - `tool/registry.ts`: update call site to use explicit `format: "markdown"` (tool description path, unchanged behavior) Fixes anomalyco#24824
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
- Fix Schema.Union call in config/skills.ts to use array syntax - Update system.test.ts to pass model argument to skills() and add a second test covering JSON output for non-Anthropic models
Bojun-Vvibe
added a commit
to Bojun-Vvibe/oss-contributions
that referenced
this pull request
Apr 29, 2026
- anomalyco/opencode#24877: session directory routing fix (merge-after-nits) - anomalyco/opencode#24852: JSON skill serialization for non-Anthropic models (merge-after-nits) - openai/codex#20113: heredoc file_redirect sandbox bypass fix (merge-after-nits) - openai/codex#20096: remote installed plugin cache for skills/MCP (merge-after-nits)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #24824
Type of change
What does this PR do?
When a project has skills loaded, OpenCode serializes them into the system prompt as XML (
<available_skills>,<skill>, etc.). This is fine for Claude, which is trained to parse XML-structured prompts, but non-Anthropic models — especially local models via Ollama — interpret the dense XML as a signal to respond in XML format. That breaks JSON tool calls.I ran 50 tests each against devstral:24b with the same prompt and tools, varying only the skills serialization format:
JSON and XML are nearly the same size, so it's the format itself that matters. The fix defaults to JSON for non-Anthropic models and leaves XML in place for Anthropic/Claude. There's also a
skills.formatconfig option for anyone who wants to override it explicitly.How did you verify your code works?
Validated the format hypothesis by running 50 direct Ollama API calls per format against devstral:24b using manually constructed system prompts matching what OpenCode produces. Results are in the table above.
Also ran the project test suite locally (
bun test test/session/system.test.ts) — updated the existing system prompt test to pass the required model argument, and added a second test verifying JSON output for non-Anthropic models. Both pass. Full typecheck clean (pre-existing failures inconfig.test.tsunrelated to this change).Screenshots / recordings
N/A
Checklist