Skip to content

Conversation

@d3xvn
Copy link
Contributor

@d3xvn d3xvn commented Dec 10, 2025

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

  • Improved transcript synchronization to ensure consistent chat history updates for both final and partial transcripts.

✏️ Tip: You can customize this high-level summary in your review settings.

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.
@coderabbitai
Copy link

coderabbitai bot commented Dec 10, 2025

Walkthrough

The pull request refactors transcript synchronization in the Agent class by extracting a new private helper method _sync_user_transcript_to_chat() and redirecting synchronization operations from per-event handlers to a centralized call site in _on_turn_event(), improving logic encapsulation and reducing redundancy.

Changes

Cohort / File(s) Change Summary
Transcript Sync Refactoring
agents-core/vision_agents/core/agents/agents.py
Removed on_stt_transcript_event_sync_conversation() event handler; added private helper _sync_user_transcript_to_chat(transcript, user_id) for centralized syncing; rewired transcript synchronization to invoke the helper from _on_turn_event() for both final and partial transcripts; added documentation clarifying the new flow.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify that the new _sync_user_transcript_to_chat() helper correctly handles both final and partial transcript types
  • Confirm that the removal of the event handler and rewiring in _on_turn_event() maintains identical synchronization semantics
  • Check that all transcript sync code paths (final transcripts, partial transcripts, TurnEndedEvent flow for eager turns) are properly routed through the new helper

Poem

One method withers, another takes light,
Transcripts now whisper through channels made tight,
No scattered event-handler's desperate call,
The center holds them, collecting them all—
A bell jar of order, sealed and precise.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: moving transcript synchronization to occur when a turn ends, ensuring partial transcripts are synced to chat.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/partial-chat

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a 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 sync

The helper looks solid: it safely no-ops when there is no conversation or transcript, wraps the call in a tracing span, and uses upsert_message in 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 with Args: / Returns: sections to match the Google-style docstrings used elsewhere.


1105-1109: Verify eager-turn behavior to avoid duplicate user messages in chat

Syncing 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_chat twice, 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 210b64d and 3f50792.

📒 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 write except 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 logic

The 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.

@Nash0x7E2
Copy link
Member

Hi @d3xvn, running the simple agent example on this branch produced the following:

Example 1 Example 2
CleanShot 2025-12-10 at 11 34 38@2x CleanShot 2025-12-10 at 11 34 27@2x

Copy link
Member

@Nash0x7E2 Nash0x7E2 left a comment

Choose a reason for hiding this comment

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

See previous comment

@d3xvn d3xvn marked this pull request as draft December 11, 2025 17:22
@d3xvn d3xvn closed this Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants