Skip to content

fix(google): use role=system for Vertex update_instructions - #7802

Merged
davidzhao merged 1 commit into
livekit:mainfrom
Li-john1021:fix-7785-vertex-update-instructions
Oct 22, 2026
Merged

davidzhao merged 1 commit into
livekit:mainfrom
Li-john1021:fix-7785-vertex-update-instructions

Conversation

@Li-john1021

Copy link
Copy Markdown
Contributor

Summary

Thanks to @rajgarg021 for the clear repro and proposed fix.

Test plan

  • pytest tests/test_plugin_google_realtime.py::test_update_instructions_role_for_api -v --unit (2 passed: Vertex → system, Gemini → model)
  • Nearby unit tests (model_api_compatibility, tool_response_carries_the_call_id) still pass (13 selected passed)

@Li-john1021
Li-john1021 requested a review from a team as a code owner October 14, 2026 05:09
@Li-john1021

Copy link
Copy Markdown
Contributor Author

Note: this branch is based on a slightly stale fork tip (behind main by ~48 commits). Tip-to-tip file content vs current main is only the intended change (role="system" on Vertex + the unit test)—happy to rebase if a maintainer prefers, once the fork can be synced (OAuth token here lacks the workflow scope needed to fast-forward).

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔍 Devin Review: 1 flag

Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

@rajgarg021

Copy link
Copy Markdown

@Li-john1021 can you please fix the failing test here

@Li-john1021

Copy link
Copy Markdown
Contributor Author

@rajgarg021 Thanks for the ping — happy to help.

The red check is tests/test_transcription_delay_anchor.py::test_skewed_provider_timestamp[stt] (a wall-clock timing assertion, ~0.44s over a ±0.05s budget). This PR only changes the Google realtime update_instructions role for Vertex (realtime_api.py + its unit test); it does not touch the transcription-delay path.

I've re-triggered the failed unit-tests job. The branch is also a bit behind main; my OAuth token lacks the workflow scope so I can't sync the fork / push a rebase from here. If the re-run still flakes, would you mind using Update branch on this PR (or rebasing once), and I'll fix anything that remains? Thanks again for the clear report on #7785.

@Li-john1021

Copy link
Copy Markdown
Contributor Author

Follow-up: I pushed a small commit to retrigger checks, but Actions did not start on the new head (likely waiting on workflow approval for the fork PR, or the branch being behind main). An Update branch / approving workflows on your side would help — thank you.

@rajgarg021

Copy link
Copy Markdown

@russellmartin-livekit @longcw could one of you please help unblock this? I opened #7785.

Thanks @Li-john1021 for picking this up.

Why it's stuck:

@Li-john1021 can't push a rebase (their token lacks the workflow scope), so which would you prefer?

  1. Resolve the conflict on this branch, or
  2. I open a clean PR from current main with just the role= change and the test, crediting @Li-john1021, and we close this one.

Happy to do option 2 right away if that's easier.

@Li-john1021
Li-john1021 force-pushed the fix-7785-vertex-update-instructions branch from 7064eda to 2fafd71 Compare October 15, 2026 11:12
@Li-john1021

Copy link
Copy Markdown
Contributor Author

@rajgarg021 Thanks again for the clear write-up — that helped a lot.

I've rebased / resolved against current main while keeping #7673's generate_reply behavior and test_reply_instructions_turns_follow_the_model intact. The remaining diff is just:

  • role="system" if self._opts.vertexai else "model" in update_instructions
  • test_update_instructions_role_for_api

GitHub now reports the PR as mergeable. My token still can't sync the fork / approve workflow runs, so if checks stay pending, an Update branch (or approving workflows) on your side would be much appreciated. Happy to take any further feedback — and option 2 is still fine with me if you'd rather land a clean maintainer PR.

@Li-john1021
Li-john1021 force-pushed the fix-7785-vertex-update-instructions branch from 2fafd71 to c8a5616 Compare October 16, 2026 15:30

Copy link
Copy Markdown
Contributor Author

Sorry about the ruff F811 failure — a rebase left a duplicate test_reply_instructions_turns_follow_the_model at the end of the file. I've removed the trailing copy so CI should be clean again. Thanks for your patience!

On Vertex AI Live, mid-session update_instructions() now sends role="system"
so the server replaces the system instruction. The Gemini API path keeps
role="model" (it still rejects role="system").

Fixes livekit#7785.
@Li-john1021
Li-john1021 force-pushed the fix-7785-vertex-update-instructions branch from 6291bed to 7edefc9 Compare October 16, 2026 17:07
@davidzhao
davidzhao merged commit 164b4eb into livekit:main Oct 22, 2026
15 checks passed
@Li-john1021

Copy link
Copy Markdown
Contributor Author

Thank you @davidzhao for the review and for merging this — much appreciated. And thanks again to @rajgarg021 for the clear repro and proposed fix on #7785.

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.

Google Realtime (Vertex AI): update_instructions() appends a model turn instead of replacing the system instruction

3 participants