Skip to content

feature: Support custom tool parsers #2917

@shantur

Description

@shantur

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions