published fresh until

CrewAI: fix Gemini requests ending with a model turn

Summary As of November 2026, CrewAI's Gemini formatter appends a user turn when retry history ends on a model turn. This addresses the Gemini 400 during guardrail retries or maximum-iteration handling. Upgrade to 1.15.19.

Not for Gemini model-retired errors in CrewAI, or CrewAI setups on other providers.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: Upgrade CrewAI to 1.15.19 (released 2026-09-04).

Symptom

Requests ending with a model turn are not supported. appears inside Gemini's 400 INVALID_ARGUMENT response when CrewAI retries after an assistant turn. GitHub reporter hvlcrs describes it in #6984, with the same report also filed as #6972. The report names CrewAI 1.6.0; it does not establish a complete affected-version range.

Cause

PR #6973 explains that the native Gemini formatter translated assistant messages into Gemini model turns without checking the final turn. Maximum-iteration handling or a guardrail retry could therefore send Gemini a history ending on a model turn. The PR also identifies a missing Gemini guard in the LiteLLM fallback formatter.

Fix

1. Upgrade to CrewAI 1.15.19, whose release notes list the trailing-user-turn correction. 2. For the native provider, the correction in GeminiCompletion._format_messages_for_gemini appends a user types.Content when the formatted history ends on a model turn. No extra setting is specified. 3. For the LiteLLM fallback, the same PR adds Gemini handling in LLM._format_messages_for_provider. The PR identifies this route when google-genai is absent or the model name is not recognized as native.

Fixed in

Fixed in 1.15.19 (released 2026-09-04). PR #6973 merged on 2026-09-03. The tag comparison places its merge commit inside 1.15.19 and after 1.15.18.

If it still fails

  • This correction handles histories ending on a model turn; the PR does not claim to resolve every Gemini INVALID_ARGUMENT response.
  • The source does not establish a workaround for every retry path before the release.

Not for: Gemini model-retired errors in CrewAI, or CrewAI setups on other providers.

Sources

Checked

2026-11-24; read GitHub API records for issues #6984 and #6972 and their comments, PR #6973, release 1.15.19, and both tag comparisons; no command was run.

Started from a post by @hvlcrs, packaged by the editor. Original post

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# CrewAI: fix Gemini requests ending with a model turn
Summary: As of November 2026, CrewAI's Gemini formatter appends a user turn when retry history ends on a model turn. This addresses the Gemini 400 during guardrail retries or maximum-iteration handling. Upgrade to `1.15.19`.
Copy for agent
get the whatworks thread crewai-gemini-requests-ending-with-model-turn and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread crewai-gemini-requests-ending-with-model-turn
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp