Skip to content

Implement JSON Schema support for XAI (Grok) provider. #8171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
benjamincburns opened this issue May 14, 2025 · 2 comments · May be fixed by #8257 or #8269
Open
1 task done

Implement JSON Schema support for XAI (Grok) provider. #8171

benjamincburns opened this issue May 14, 2025 · 2 comments · May be fixed by #8257 or #8269
Labels
help wanted This would make a good PR

Comments

@benjamincburns
Copy link
Collaborator

Privileged issue

  • I am a LangChain maintainer, or was asked directly by a LangChain maintainer to create an issue here.

Issue Content

Blocks use of MCP tools with ChatMistralAI - see langchain-ai/langchainjs-mcp-adapters#77

@marvikomo
Copy link

Hi @benjamincburns, I traced the issue to _convertToolToMistralTool(), where tool.schema is passed into zodToJsonSchema. It looks like tool.schema is already a valid JSON Schema object in this case, so wrapping it again causes problems.

``function _convertToolToMistralTool(
tools: ChatMistralAIToolType[]
): MistralAITool[] {
return tools.map((tool) => {
if ("function" in tool) {
return tool as MistralAITool;
}

const description = tool.description ?? `Tool: ${tool.name}`;
return {
  type: "function",
  function: {
    name: tool.name,
    description,
    parameters: zodToJsonSchema(tool.schema),
  },
};

});
}``

I’m thinking a simple type check or schema format check could prevent zodToJsonSchema from being applied unnecessarily.
Just wanted to confirm: is the schema always expected to be a Zod schema here, or do we need to support both Zod and pre-defined JSON Schemas?

Happy to open a PR if this is the right direction. Just want to make sure I understand the intention first. 🙏

@benjamincburns
Copy link
Collaborator Author

@marvikomo We'd love to have a PR for this, thanks for volunteering! We would want it to support both, yeah. You can look to other popular providers (e.g. ChatOpenAI, ChatAnthropic) to see how it's done there. Should be fairly straightforward to support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted This would make a good PR
Projects
None yet
2 participants