feat: local model tool call reliability (PRs #19000 + #16531 + nudge recovery)#1
Merged
andrewgwoodruff merged 5 commits intoMay 1, 2026
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
- 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
…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
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.
Summary
includeUsageinjection — User-configured providers (Ollama, oMLX, etc.) no longer getstream_options: {include_usage: true}injected, which was causing request failures. Only non-config-source providers receive it.openai-compatible-compat.ts— NewtoolParserpipeline with three parser types:json— converts{"name":"...","arguments":{...}}plain-text output into proper tool-call partsraw-function-call— rewrites moderntoolsAPI to legacyfunctionsAPI for models that need itsingle-tool-text— maps bare text responses to a named tooltool-callstream part.{"name":"...","arguments":...}JSON, injects a synthetic user message telling it to call the tool directly and re-enters the loop (capped at 3 nudges per session).Configuration
To enable the
jsontool parser for a local provider, addtoolParserto its options in~/.config/opencode/opencode.json:{ "provider": { "omlx": { "npm": "@ai-sdk/openai-compatible", "options": { "baseURL": "http://127.0.0.1:8000/v1", "apiKey": "local", "toolParser": [{"type": "json"}] } } } }Test plan
"Find all files in apps/platform/src/api that contain the word 'merchant', then read the first one you find and tell me what it does."— should chain grep → read without stallingstream_optionsregression)includeUsagestill injected for bundled/env-source openai-compatible providers🤖 Generated with Claude Code