Skip to content

Conversation

@silenceforest
Copy link

@silenceforest silenceforest commented Dec 21, 2025

  • Provider: Scaleway AI (OpenAI Chat Completions compatible)
  • Model: mistral-small-3.2-24b-instruct-2506
  • Fix: normalize tool_calls[].function.arguments to always be a JSON string ("{}" when empty) and ensure tool outputs are sent as strings.
  • Reason: Scaleway/OpenAI schema rejects non‑string arguments (Lua empty table was encoded as []), causing 400 errors during MCP/tool usage.
  • Also treats Scaleway endpoint as Mistral‑like for message ordering fixes (avoids tool -> user invalid sequence).
  • Suppress assistant content when tool_calls are present to avoid duplicate final messages.

@silenceforest silenceforest changed the title Fix tool_calls serialization for Scaleway Mistral (OpenAI Chat Completions) fix tool_calls serialization for Scaleway Mistral (OpenAI Chat Completions) Dec 21, 2025
function M.is_openrouter(url) return url:match("^https://openrouter%.ai/") end

function M.is_mistral(url) return url:match("^https://api%.mistral%.ai/") end
function M.is_mistral(url) return url:match("^https://api%.mistral%.ai/") or url:match("^https://api%.scaleway%.ai/") end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@silenceforest The behavior does not match the function name. Can it be optimized?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, is the new name (is_mistral_like) better?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you create a new function such as is_scaleway? And separate the processing of mistral and scaleway instead of sharing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants