Problem/Motivation
When using the Mistral provider with Canvas AI, requests fail with "422 Unprocessable Entity" while the same request works correctly with the OpenAI provider.
The error originates from the php-mistral client. The failure appears to be caused by a tool definition that does not include parameters, which Mistral seems to reject, while other providers accept it. In my case such tool was "ai_agent_verify_task_completion".
Steps to reproduce
1. Enable canvas_ai.
2. Enable all Canvas AI components so they are available to the agent.
4. In the Canvas editor/agent UI, run a prompt that triggers a tool call, e.g.: "calling the page builder tool first, add a card component with title hello world to the content area"
The response we get is the following, which suggests the problem outlined in this ticket.
{
"detail" : [ {
"type" : "missing",
"loc" : [ "body", "tools", "list[Tool]", 4, "function", "parameters" ],
"msg" : "Field required",
"input" : {
"name" : "ai_agent_verify_task_completion",
"description" : "This tool MUST be called ONLY after invoking canvas_page_builder_agent or canvas_template_builder_agent to verify that title and metadata were properly generated if they were empty. DO NOT call this tool for any other operations including canvas_component_agent, general questions, or non-page-building tasks."
}
}, {
"type" : "string_type",
"loc" : [ "body", "tools", "list[str]", 0 ],
"msg" : "Input should be a valid string",
"input" : {
"type" : "function",
"function" : {
"name" : "canvas_component_agent",
"description" : "This agent can manipulate things in Drupal Canvas. Since it outputs a very specific JSON format, please do not use this in other contexts.",
"parameters" : {
"type" : "object",
"properties" : {
"prompt" : {
"name" : "prompt",
"type" : "string",
"description" : "Prompt The prompt in natural language on how to invoke this agent."
},
"files" : {
"name" : "files",
"type" : "array",
"description" : "Files The files using file id.",
"items" : {
"type" : "string"
}
}
},
"required" : [ "prompt" ]
}
}
}
}, {
"type" : "string_type",
"loc" : [ "body", "tools", "list[str]", 1 ],
"msg" : "Input should be a valid string",
"input" : {
"type" : "function",
"function" : {
"name" : "canvas_metadata_generation_agent",
"description" : "This agent focuses on generating metadata(meta description) for Drupal Canvas content, as well as for any user-provided content",
"parameters" : {
"type" : "object",
"properties" : {
"prompt" : {
"name" : "prompt",
"type" : "string",
"description" : "Prompt The prompt in natural language on how to invoke this agent."
},
"files" : {
"name" : "files",
"type" : "array",
"description" : "Files The files using file id.",
"items" : {
"type" : "string"
}
}
},
"required" : [ "prompt" ]
}
}
}
}, {
"type" : "string_type",
"loc" : [ "body", "tools", "list[str]", 2 ],
"msg" : "Input should be a valid string",
"input" : {
"type" : "function",
"function" : {
"name" : "canvas_page_builder_agent",
"description" : "This agent can insert one or many existing components or sections into a specific location on a page. Use this to place a previously created component or section on a layout or page.",
"parameters" : {
"type" : "object",
"properties" : {
"prompt" : {
"name" : "prompt",
"type" : "string",
"description" : "Prompt The prompt in natural language on how to invoke this agent."
},
"files" : {
"name" : "files",
"type" : "array",
"description" : "Files The files using file id.",
"items" : {
"type" : "string"
}
}
},
"required" : [ "prompt" ]
}
}
}
}, {
"type" : "string_type",
"loc" : [ "body", "tools", "list[str]", 3 ],
"msg" : "Input should be a valid string",
"input" : {
"type" : "function",
"function" : {
"name" : "canvas_title_generation_agent",
"description" : "This agent focuses solely on generating new title and editing existing title for Drupal Canvas. It ensures that the created or edited title matches user-provided guidelines and specifications.",
"parameters" : {
"type" : "object",
"properties" : {
"prompt" : {
"name" : "prompt",
"type" : "string",
"description" : "Prompt The prompt in natural language on how to invoke this agent."
},
"files" : {
"name" : "files",
"type" : "array",
"description" : "Files The files using file id.",
"items" : {
"type" : "string"
}
}
},
"required" : [ "prompt" ]
}
}
}
}, {
"type" : "string_type",
"loc" : [ "body", "tools", "list[str]", 4 ],
"msg" : "Input should be a valid string",
"input" : {
"type" : "function",
"function" : {
"name" : "ai_agent_verify_task_completion",
"description" : "This tool MUST be called ONLY after invoking canvas_page_builder_agent or canvas_template_builder_agent to verify that title and metadata were properly generated if they were empty. DO NOT call this tool for any other operations including canvas_component_agent, general questions, or non-page-building tasks."
}
}
} ]
}
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | Screenshot from 2026-01-14 15-11-44.png | 72.56 KB | marcus_johansson |
Issue fork ai_provider_mistral-3567467
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
marcus_johansson commentedTesting this in their playground it is possible, so lets see where the changes occur in the API request.
Comment #3
yautja_cetanu commentedComment #4
marcus_johansson commentedComment #6
marcus_johansson commentedI have a fix for the AI module here #3567784: Tools Function Input should give back an empty json schema skeleton. But I don't know what affects it will have, so it comes in 2.0.x.
I have added a fix for this specifically for Mistral.
Comment #7
marcus_johansson commentedComment #8
ademarco commentedThis works correctly now, I was able to get a hero placed on the page without having to fiddle with the default agent configuration.
Comment #9
ademarco commentedComment #10
marcus_johansson commentedLets do it.
Comment #13
arianraeesi commentedComment #14
arianraeesi commented