You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can this be implemented? Maybe atleast the @ai-sdk-tool/parser package. It offers three middlewares OOB
gemmaToolMiddleware: JSON tool calls inside markdown fences. Best for Gemma-like models.
morphXmlToolMiddleware: Plain XML tool calls. Good fit for GLM/GLM-like models.
hermesToolMiddleware: JSON payload wrapped in <tool_call> XML tags. Hermes/Llama-style prompts.
This will allow Opencode to be compatible with a lot of locally hosted models.
It can be an option to set a middleware as part of custom providers configuration for a model. Initially could be just one of these 3 above, maybe down the line a way of providing our own like plugins / custom tools.
I have a working integration of @ai-sdk-tool/parser with OpenCode. Since upstream integration is still pending, I've published it as an experimental fork:
It adds a toolParser option on provider/model config (hermes | hermes-strict | xml) that gates middleware injection plus the finish-reason/tag cleanup those parsers need. Also includes streaming tag filter, stream deduplication, and document extraction (PDF/DOCX/XLSX).
This is experimental and tracks upstream dev branch. If you're hitting this issue with a gateway or provider that doesn't support native function calling, feel free to try it out.
One additional thing that may be worth documenting: reliability with custom tool parsers seems much more model-dependent than with native function calling.
In our testing, higher-capability models such as GPT-5.4 and Claude Sonnet 4.5 were the first ones that were consistently reliable on multi-step review workflows, while lower-tier models often handled simple cases but degraded on longer runs.
If this support lands, it would be helpful for the docs to note that users should validate parser behavior on a representative multi-step workflow before relying on it in production.
Activity
github-actions commentedon Oct 2, 2025
This issue might be a duplicate of existing issues. Please check:
<|tool_calls_section_end|>) Parsing Failures #1021: Tool parsing failures with various models that custom tool parsers would addressFeel free to ignore if none of these address your specific case.
rekram1-node commentedon Oct 2, 2025
would need to look at it more but it sounds reasonable
minpeter commentedon Feb 11, 2026
I am the maintainer of the ai-sdk-tool-call-middleware project, and I am very willing to support this work.
Thanks for the suggestion, @shantur
okuyam2y commentedon Apr 3, 2026
I have a working integration of
@ai-sdk-tool/parserwith OpenCode. Since upstream integration is still pending, I've published it as an experimental fork:https://github.com/okuyam2y/opencode-nofc
It adds a
toolParseroption on provider/model config (hermes|hermes-strict|xml) that gates middleware injection plus the finish-reason/tag cleanup those parsers need. Also includes streaming tag filter, stream deduplication, and document extraction (PDF/DOCX/XLSX).This is experimental and tracks upstream
devbranch. If you're hitting this issue with a gateway or provider that doesn't support native function calling, feel free to try it out.okuyam2y commentedon Apr 3, 2026
One additional thing that may be worth documenting: reliability with custom tool parsers seems much more model-dependent than with native function calling.
In our testing, higher-capability models such as GPT-5.4 and Claude Sonnet 4.5 were the first ones that were consistently reliable on multi-step review workflows, while lower-tier models often handled simple cases but degraded on longer runs.
If this support lands, it would be helpful for the docs to note that users should validate parser behavior on a representative multi-step workflow before relying on it in production.
github-actions commentedon Jun 3, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.