Skip to content

gateway: keep Gemini affinity when the first turn omits role - #171

Merged
yetone merged 2 commits into
yetone:mainfrom
charan-rathore:gemini-roleless-first-turn-affinity
Sep 28, 2026
Merged

yetone merged 2 commits into
yetone:mainfrom
charan-rathore:gemini-roleless-first-turn-affinity

Conversation

@charan-rathore

Copy link
Copy Markdown
Contributor

Summary

Keep Gemini conversation affinity on the first turn when that contents item has no role. Gemini treats an omitted role as user, but the affinity selector previously skipped it as soon as a later turn had an explicit role: "user" item. This could send one conversation to different keys.

Limit the omitted-role rule to Gemini contents. Chat messages and Responses input still select the first explicitly marked user turn. Add a regression for the two-turn Gemini case, a different first message, and controls for Chat and Responses.

This follows the maintainer's note on #165: #165 (comment)

Tests

  • The new regression failed on bdf3d11 before the fix with two different Gemini IDs.
  • GOPROXY=off GOSUMDB=off go test ./internal/gateway -count=1 passed after the fix.

Instinct assisted with the change and tests.

Add support for Gemini content handling and role omission.
Added tests for role-less content handling and explicit user selection in conversation IDs.
@yetone
yetone merged commit 42a1379 into yetone:main Sep 28, 2026
4 checks passed
@yetone

yetone commented Sep 28, 2026

Copy link
Copy Markdown
Owner

Thanks! Reviewed every line and verified end to end through the gateway (probe tests against scripted upstreams, and the new tests fail without the change). Merged; it'll ship in the next release.

@charan-rathore
charan-rathore deleted the gemini-roleless-first-turn-affinity branch October 1, 2026 09:12
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.

2 participants