Skip to content

bug fix for multimodal-dialog agent and add parameter speaker_id in asr result #240

Closed
songguocola wants to merge 2 commits into
dashscope:mainfrom
songguocola:dev/audio_0701
Closed

bug fix for multimodal-dialog agent and add parameter speaker_id in asr result #240
songguocola wants to merge 2 commits into
dashscope:mainfrom
songguocola:dev/audio_0701

Conversation

@songguocola

Copy link
Copy Markdown
Contributor

No description provided.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces graceful shutdown and force-close mechanisms to prevent deadlocks and ensure proper resource cleanup in MultiModalDialog and OkHttpWebSocketClient. It also refactors the streaming request logic in OkHttpWebSocketClient to reduce duplication in its subclasses, and adds a speaker_id field to Sentence. The review feedback highlights two important issues: first, the closed flag in MultiModalDialog needs to be reset to false when start() is called to support restarts; second, the responseEmitter field in OkHttpWebSocketClient should be marked as volatile to prevent potential thread visibility issues and data races.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

BackpressureStrategy.BUFFER);

stopLatch = new AtomicReference<>(new CountDownLatch(1)); // Initializes stop signal latch
stopLatch.set(new CountDownLatch(1)); // Initializes stop signal latch

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.

high

If the MultiModalDialog is restarted by calling start() again after being closed, the closed flag remains true. As a result, any subsequent call to close() will return immediately due to the closed.compareAndSet(false, true) check, preventing the new session from being properly closed or cancelled. Resetting closed to false in start() ensures that the idempotent close guard works correctly across multiple sessions of the same dialog instance.

Suggested change
stopLatch.set(new CountDownLatch(1)); // Initializes stop signal latch
closed.set(false);
stopLatch.set(new CountDownLatch(1)); // Initializes stop signal latch

Comment on lines +690 to +692
if (responseEmitter != null && !responseEmitter.isCancelled()) {
responseEmitter.onError(ex);
}

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.

medium

The responseEmitter field is accessed and modified across multiple threads (e.g., the subscribing thread, the async stream request thread, and the WebSocket callback threads). To ensure proper thread visibility and prevent potential data races when checking responseEmitter != null and !responseEmitter.isCancelled(), the responseEmitter field should be declared as volatile.

@songguocola songguocola closed this Jul 1, 2026
@songguocola songguocola deleted the dev/audio_0701 branch July 1, 2026 13:07
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.

1 participant