continue-custom/packages
Dallin Romney 1dca5bd116
fix(gemini): merge consecutive same-role messages to fix ordering errors (#11805)
* fix(gemini): merge consecutive same-role messages to fix ordering errors

Gemini API requires strict role alternation between "user" and "model".
When multiple tool responses (mapped to "user" role) appear consecutively,
or when consecutive assistant messages exist, the alternation breaks causing:
- "function call turn comes immediately after a user turn or after a function response turn"
- "number of function response parts is equal to the number of function call parts"

Fix: merge consecutive messages with the same role by combining their parts
arrays, applied as a post-processing step after message conversion in both
the core Gemini LLM and the openai-adapters Gemini API.

Fixes #11047, fixes #9562

* chore: remove verbose comments

* refactor: deduplicate mergeConsecutiveGeminiMessages into openai-adapters

Export from openai-adapters gemini-types and import in core, removing
the duplicate private method from both Gemini classes.

* fix: resolve TS2345 by removing explicit nullable type annotation on contents

* fix: keep mergeConsecutiveGeminiMessages in each package's own gemini-types

The core test suite mocks @continuedev/openai-adapters entirely, which
replaces the imported function with a no-op returning undefined. Define
the function in both packages' gemini-types to avoid this coupling.
2026-03-25 12:27:06 -07:00
..
config-types feat: add MiniMax as a new LLM provider with M2.7 default (#11367) 2026-03-24 13:06:19 -07:00
config-yaml fix: respect contextLength from YAML model config (#11807) 2026-03-25 12:26:52 -07:00
continue-sdk [Snyk] Security upgrade @openapitools/openapi-generator-cli from 2.30.0 to 2.31.0 (#11764) 2026-03-24 10:57:28 -07:00
fetch fix: handle thinking/assistant messages at end of chat history (#11791) 2026-03-24 20:26:51 -07:00
hub chore(deps): bump minimatch in /packages/hub (#10955) 2026-03-09 11:57:55 -07:00
llm-info fix(gemini): update model catalog for retired/new Gemini models (#11793) 2026-03-24 20:22:47 -07:00
openai-adapters fix(gemini): merge consecutive same-role messages to fix ordering errors (#11805) 2026-03-25 12:27:06 -07:00
terminal-security style: run prettier on terminal security code 2025-10-30 00:56:55 +00:00
shared-release.config.js fix prettier 2025-07-18 19:20:13 +02:00