Skip to content

fix(google): only block generate_reply when instructions passed to immutable-context model#5715

Open
d42f wants to merge 1 commit into
livekit:mainfrom
d42f:fix/google-generate-reply-immutable-context
Open

fix(google): only block generate_reply when instructions passed to immutable-context model#5715
d42f wants to merge 1 commit into
livekit:mainfrom
d42f:fix/google-generate-reply-immutable-context

Conversation

@d42f
Copy link
Copy Markdown

@d42f d42f commented May 12, 2026

Models like gemini-3.1-flash-live-preview have mutable_chat_context=False because injecting a role=model turn via instructions= causes a 1007 error from the Google API.

The previous guard blocked all generate_reply calls for such models, but the role=model injection only happens when instructions is given (line 737). Calling generate_reply() or generate_reply(user_input=...) without instructions sends only a role=user placeholder turn, which works correctly on gemini-3.1.

Narrow the guard to raise only when instructions is provided.

Fixes: #5260

…mutable-context model

Models like gemini-3.1-flash-live-preview have mutable_chat_context=False because
injecting a role=model turn via `instructions=` causes a 1007 error from the Google API.

The previous guard blocked all generate_reply calls for such models, but the role=model
injection only happens when `instructions` is given (line 737). Calling generate_reply()
or generate_reply(user_input=...) without instructions sends only a role=user placeholder
turn, which works correctly on gemini-3.1.

Narrow the guard to raise only when instructions is provided.

Fixes: livekit#5260
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 12, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

Copy link
Copy Markdown
Member

@theomonnom theomonnom left a comment

Choose a reason for hiding this comment

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

thanks!

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.

generate_reply times out on first dialogue with gemini-3.1-flash-live-preview — works fine with gemini-2.5-flash-

3 participants