Skip to content

Mistral Structured handler ignores tools in API requests #963

@CamilleScholtz

Description

@CamilleScholtz

The Mistral Structured handler (src/Providers/Mistral/Handlers/Structured.php) does not include tools or tool_choice in the API request payload, even though the Structured\Request object carries them. This means agents that implement both structured output and tool calling silently lose all tool functionality when using Mistral.

Mistral's API supports response_format and tools in the same request - they are independent parameters. The Mistral Text handler already includes both tools and tool_choice correctly. The Structured handler just needs the same treatment, plus a tool call loop (like Text has) so it can execute tools and continue until the model returns a final structured response.

Expected behavior: When a Structured\Request has tools, the handler should include them in the API request and handle FinishReason::ToolCalls responses by executing the tools and continuing the loop, matching how the Text handler works.

Actual behavior: Tools are silently dropped. The model never sees them and cannot make tool calls. No error is raised.

For reference, the Anthropic Structured handler already supports tools via its ToolStructuredStrategy and tool call loop.

Metadata

Metadata

Assignees

No one assigned

    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