feature: Support custom tool parsers #1917

Open
opened 2026-02-16 17:33:13 -05:00 by yindo · 3 comments
Owner

Originally created by @shantur on GitHub (Oct 2, 2025).

Originally assigned to: @thdxr on GitHub.

AI SDK provides a capability to allow custom tool parsers documented - https://ai-sdk.dev/docs/ai-sdk-core/middleware#custom-tool-call-parser

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.

Originally created by @shantur on GitHub (Oct 2, 2025). Originally assigned to: @thdxr on GitHub. AI SDK provides a capability to allow custom tool parsers documented - https://ai-sdk.dev/docs/ai-sdk-core/middleware#custom-tool-call-parser 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.
Author
Owner

@github-actions[bot] commented on GitHub (Oct 2, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #1122: Specifically mentions hermes tool parser with vllm server not working with OpenCode, which is one of the exact middlewares you mentioned
  • #234: Addresses tool calling compatibility issues with open source models, which custom tool parsers would solve
  • #1034: Another local model tool calling issue that custom parsers could help resolve
  • #1021: Tool parsing failures with various models that custom tool parsers would address

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Oct 2, 2025): This issue might be a duplicate of existing issues. Please check: - #1122: Specifically mentions hermes tool parser with vllm server not working with OpenCode, which is one of the exact middlewares you mentioned - #234: Addresses tool calling compatibility issues with open source models, which custom tool parsers would solve - #1034: Another local model tool calling issue that custom parsers could help resolve - #1021: Tool parsing failures with various models that custom tool parsers would address Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Oct 2, 2025):

would need to look at it more but it sounds reasonable

@rekram1-node commented on GitHub (Oct 2, 2025): would need to look at it more but it sounds reasonable
Author
Owner

@minpeter commented on GitHub (Feb 10, 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

@minpeter commented on GitHub (Feb 10, 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
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1917