fix(core): propagate ASR errors and fail session with partial text#33
Merged
Conversation
Add MockAsrProvider and tests that document two bugs: 1. wait_for_final() swallows AsrEvent::Error and read errors 2. Main loop continues to LLM with truncated text after ASR error Change wait_for_final return type to Option<String> to enable error propagation (implementation still buggy — fixes in next commits).
Handle AsrEvent::Error and read errors explicitly instead of swallowing them via wildcard/silent return. Errors after finish_input() are now returned to the caller and stored in asr_error for proper session failure handling.
Previously, an ASR error (transport failure, provider error) was only surfaced when no text had been accumulated. If interim/definite text existed before the error, the truncated text would still go through LLM correction and get pasted into the user's app. Now check asr_error before inspecting text — any ASR error fails the session immediately, discarding potentially truncated text.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
When an ASR transport error (WebSocket disconnect, provider error) occurred
after interim or definite text had been accumulated, the session continued
to LLM correction and pasted truncated text into the user's app. Additionally,
wait_for_final()silently swallowedAsrEvent::Errorand read errors viaa wildcard match arm.
What changed
wait_for_final()now returnsOption<String>and explicitly handlesAsrEvent::ErrorandErr, propagating the error message to the caller.asr_errorbefore inspecting accumulatedtext — any ASR error now fails the session immediately, discarding
potentially truncated text.
MockAsrProvidertest infrastructure and 8 unit tests coveringerror propagation and session failure behavior.
Test plan
cargo test -p koe-core --lib— 8 new tests passcargo clippycleanshow error, not paste partial text