Skip to content

feat: add skills.format config option for skill serialization format#24852

Closed
andrewgwoodruff wants to merge 5 commits into
anomalyco:devfrom
andrewgwoodruff:fix/skill-serialization-format-for-local-models
Closed

feat: add skills.format config option for skill serialization format#24852
andrewgwoodruff wants to merge 5 commits into
anomalyco:devfrom
andrewgwoodruff:fix/skill-serialization-format-for-local-models

Conversation

@andrewgwoodruff

@andrewgwoodruff andrewgwoodruff commented Apr 28, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #24824

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds a skills.format config 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.ts are unrelated to this change).

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

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
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Apr 28, 2026
@github-actions

Copy link
Copy Markdown
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.
@andrewgwoodruff andrewgwoodruff changed the title fix: use JSON skill serialization by default for non-Anthropic models feat: add skills.format config option for skill serialization format Apr 30, 2026
…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
@github-actions

Copy link
Copy Markdown
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:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add skills.format config option to control skill serialization format

1 participant