Problem/Motivation

Mistral provider does not support "thinking" models and it fails when trying to construct a new \Drupal\ai\OperationType\Chat\ChatMessage(), since that constructor expects a string parameter, but Mistral returns an array of "thinking" steps.

Steps to reproduce

- Visit /admin/config/ai/agents
- Click on the "Explore" operation for "Taxonomy Agent"
- Run the agent with "mistral-medium" model
- Agent will hung, submit button stays on "Running..."

Recent logs will show the following message:

TypeError: Drupal\ai\OperationType\Chat\ChatMessage::__construct(): Argument #2 ($text) must be of type string, array given, called in /var/www/html/web/modules/contrib/ai_provider_mistral/src/Plugin/AiProvider/MistralProvider.php on line 318 in Drupal\ai\OperationType\Chat\ChatMessage->__construct() (line 64 of /var/www/html/web/modules/contrib/ai/src/OperationType/Chat/ChatMessage.php).

Everything works correctly for non-thinking models, such as "mistral-tiny".

Proposed resolution

- Support Mistral "thinking" models
- Make sure that we display an error on the agent explorer, when things fail

Command icon 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

ademarco created an issue. See original summary.

ademarco’s picture

Issue summary: View changes
yautja_cetanu’s picture

Issue tags: +priority
marcus_johansson’s picture

Assigned: Unassigned » marcus_johansson
Issue tags: +AI Initiative Sprint

marcus_johansson changed the visibility of the branch 3567184-add-support-for to hidden.

marcus_johansson’s picture

Status: Active » Needs review

I can only replicate this if I use Magistral and according to documentation this is the only model that supports it at the moment, see: https://docs.mistral.ai/capabilities/reasoning

This might need an upstream fix, but I have added a solution that will work. What is happening is that they are giving back the thinking array, but we only need the text. But in this case there is no text because the order is:

1. Thinking
2. Give back tool response

And we are trying to fill in string where we have an array.

marcus_johansson’s picture

Assigned: marcus_johansson » Unassigned
ademarco’s picture

Status: Needs review » Reviewed & tested by the community

I've tested it with mistral-large 2 agents, one that adds taxonomy terms to a vocabulary and another that add fields to a content type, and it worked in both cases, repeatedly.

marcus_johansson’s picture

Status: Reviewed & tested by the community » Fixed

Thank you for finding and reviewing, this is getting merged.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

arianraeesi’s picture

Issue tags: +AI Product Development
arianraeesi’s picture

Issue tags: -AI Product Development

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.