feat: add skills.format config option for skill serialization format#24852
Closed
andrewgwoodruff wants to merge 5 commits into
Closed
feat: add skills.format config option for skill serialization format#24852andrewgwoodruff wants to merge 5 commits into
andrewgwoodruff wants to merge 5 commits into
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)
…havior Remove the non-Anthropic auto-detection logic. The default remains XML for all models — the config option is an opt-in escape hatch for users who need a different format, not an opinionated default change. Also reverts the model parameter from skills() since it's no longer needed for format detection.
…ool call reliability - Fix includeUsage injection to skip user-configured providers (PR anomalyco#19000) — Ollama/oMLX reject stream_options.include_usage; only inject for non-config-source providers where undefined - Add wrapStream middleware for config-source providers to detect raw JSON tool call text and repair it into proper tool-call stream parts (PR anomalyco#19000) - Add openai-compatible-compat.ts with toolParser pipeline (PR anomalyco#16531) — json parser: converts {"name":"...","arguments":{...}} text to tool_calls — raw-function-call parser: rewrites tools API to legacy functions API — single-tool-text parser: maps bare text to a named tool - Integrate toolParsers into provider fetch handler; buffers SSE/JSON responses and rewrites them when toolParser config is present Coding-Agent: OpenCode Model: gpt-oss-20b via oMLX
…lling it
When a config-source provider's model (e.g. gpt-oss-20b) finishes a turn
with no tool calls but its text output contains {"name":"...","arguments":...}
JSON, inject a synthetic user message telling it to call the tool directly
and re-enter the loop. Caps at 3 nudges per session to prevent infinite loops.
This addresses the failure mode where the model expresses tool-call intent
in its thinking text but emits no actual tool-call stream part.
Coding-Agent: OpenCode
Model: gpt-oss-20b via oMLX
Contributor
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
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?
Adds a
skills.formatconfig option ("xml","json", or"markdown") that lets users control how skills are serialized into the system prompt. The default remains"xml"— no existing behavior changes.The motivation: when a project has many skills loaded, the XML skills block can cause some local models (Ollama-hosted models in particular) to switch into XML output mode, breaking JSON tool calls. This config option gives those users an escape hatch without making any opinionated assumptions about which format is better for which model.
How did you verify your code works?
Updated the existing system prompt test to reflect the simplified signature and confirmed it passes. Full typecheck clean (pre-existing failures in
config.test.tsare unrelated to this change).Screenshots / recordings
N/A
Checklist