-
Notifications
You must be signed in to change notification settings - Fork 272
fix: sync partial transcripts to chat when turn ends #250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Previously, chat messages were lost when only STTPartialTranscriptEvent events were received and no final STTTranscriptEvent arrived before the turn ended. The transcript was sent to the LLM but never synced to chat. This fix moves chat sync from the STTTranscriptEvent handler to _on_turn_event, ensuring the accumulated transcript (from partials or finals) is always recorded in chat when a turn completes.
WalkthroughThe pull request refactors transcript synchronization in the Agent class by extracting a new private helper method Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
agents-core/vision_agents/core/agents/agents.py (2)
448-467: Helper cleanly encapsulates user transcript→chat syncThe helper looks solid: it safely no-ops when there is no conversation or transcript, wraps the call in a tracing span, and uses
upsert_messagein a way consistent with the Realtime transcript handlers (new UUID per user message,role="user",completed=True,replace=True). Optional: you could expand the docstring withArgs:/Returns:sections to match the Google-style docstrings used elsewhere.
1105-1109: Verify eager-turn behavior to avoid duplicate user messages in chatSyncing the accumulated transcript to chat at turn-end is the right place to fix the “partials only, no final STT” gap and keeps LLM input and chat history aligned. One thing to double-check: in eager turn flows, if your turn detector emits both an eager
TurnEndedEvent(eager_end_of_turn=True) and a final one (eager_end_of_turn=False), this block will call_sync_user_transcript_to_chattwice, which would create two separate user messages (early partial, then final) instead of updating one.If that’s not desired, you could gate chat sync to non-eager events or introduce a per-turn message_id so the final transcript replaces the eager one rather than appending a new message.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
agents-core/vision_agents/core/agents/agents.py(3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py
📄 CodeRabbit inference engine (.cursor/rules/python.mdc)
**/*.py: Never adjust sys.path in Python code
Never writeexcept Exception as e- use specific exception handling
Avoid using getattr, hasattr, delattr and setattr; prefer normal attribute access in Python
Docstrings should follow the Google style guide for docstrings
Files:
agents-core/vision_agents/core/agents/agents.py
🧬 Code graph analysis (1)
agents-core/vision_agents/core/agents/agents.py (1)
agents-core/vision_agents/core/agents/conversation.py (1)
upsert_message(122-210)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: unit / Mypy
- GitHub Check: unit / Test "not integration"
- GitHub Check: unit / Mypy
- GitHub Check: unit / Test "not integration"
🔇 Additional comments (1)
agents-core/vision_agents/core/agents/agents.py (1)
342-344: Clear note about moved STT→chat sync logicThe inline comment crisply documents that STTTranscriptEvent-driven chat sync now lives in
_on_turn_event/_sync_user_transcript_to_chat, which should help avoid future double-sync implementations or confusion. No change requested.
|
Hi @d3xvn, running the simple agent example on this branch produced the following:
|
Nash0x7E2
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See previous comment


Previously, chat messages were lost when only STTPartialTranscriptEvent events were received and no final STTTranscriptEvent arrived before the turn ended. The transcript was sent to the LLM but never synced to chat.
This fix moves chat sync from the STTTranscriptEvent handler to _on_turn_event, ensuring the accumulated transcript (from partials or finals) is always recorded in chat when a turn completes.
Summary by CodeRabbit
Refactor
✏️ Tip: You can customize this high-level summary in your review settings.