WordPress / WordPress/php-ai-client

Parallel tool call and client error

Open
#286 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
308
Forks
84
Avg merge
7d 21h
Merged PRs (30d)
2

Description

Hi,
Using the Mistral AI Provider by @saarnilauri and providing the prompt builder with a set of abilities, the Mistral model can return multiple tool call requests in a single answer (if not disabled with a model custom config key).

Detecting the function call request using WP_AI_Client_Ability_Function_Resolver, I execute the requested abilities with the class method execute_abilities getting back a Message. Everything fine.

When I try to send that message to the model, the operation is blocked by the AI Client with the error "The API only allows a single function response, as the only content of the message" from the AbstractOpenAiCompatibleTextGenerationModel::getMessagePartContentData().

Looking at the whole process, the method prepareMessagesParam() of the same class seems to process only a single function response within a message.

I don't know if it's something that should be extended or if it's a required behavior.

Thank you, Stefano.
PS: with WP 7.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing prepareMessagesParam() and AbstractOpenAiCompatibleTextGenerationModel::getMessagePartContentData() with a Message containing multiple function responses. Reproduce the Mistral parallel tool-call flow described in the issue and inspect how execute_abilities() constructs that Message. Done means the expected handling of multiple function responses is established and the client no longer rejects a valid message, or the required single-response behavior is clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.