Repository navigation
Conversation
Contributor
|
Thanks for the pull request. One thing worth sorting out before it is reviewed:
If you think it belongs here anyway, say so and a maintainer will take a look. |
Contributor
Author
|
We filed this before noticing @ffffff55's claim on #3237 — apologies for stepping on it. Their fix in #3239 covers the same behavior (append to the turn's text, keep the attached blocks), so we're withdrawing this PR to leave the claim intact. The issue report stands, and we're happy to review #3239. |
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.
Fixes #3237
PR Title Format
fix(realtime): keep attached blocks when merging a split user turn— conventional commit,fixtype, lowercase description.AgentScope Version
2.0.10.dev0 (main)
Description
Summary
When endpointing splits the user's speech and the second half of the transcript arrives inside the
TurnAggregatormerge window,RealtimeAgent._merge_userrebuilds the previous user turn from its concatenated text alone, dropping every non-text block of that turn — e.g. aDataBlockcarrying an image the user attached between the halves. The merge now appends the text to the turn and leaves the attached blocks in place.Why
_merge_userruns whenever a settled transcript continues the previous user turn (src/agentscope/agent/_realtime/_agent.py:826-828), and its docstring says it appends text to that turn. The implementation instead replaced the turn's whole content:User messages are documented and validated to carry
DataBlocks (_assert_user_content_blocks,src/agentscope/message/_base.py:32-38; theUserMsgdocstring states that onlyTextBlockandDataBlockare allowed for user messages), andRealtimeAgent.sendappends anyMsgit receives tostate.context(src/agentscope/agent/_realtime/_agent.py:528). So the attached image is silently removed from the conversation context once the second half of the split utterance settles — no error, and the loss persists for the rest of the session.Msg.append_eventalready defines the project's pattern for merging streamed text into a block list:TOOL_RESULT_TEXT_DELTAappends to the last block only if it is a text block, otherwise appends a newTextBlock(src/agentscope/message/_base.py:432-435)._merge_usernow follows the same pattern.Changes
src/agentscope/agent/_realtime/_agent.py:_merge_userno longer rebuilds the previous user turn's content. If the turn's last block is aTextBlock, the text is appended to it (unchanged behavior for the plain split-transcript case); otherwise a newTextBlockis appended, and every existing block —DataBlocks included — stays in place. An empty content list still produces a singleTextBlock, as before.tests/realtime_agent_test.py: two tests inRealtimeAgentTranscriptionTest— the halves of a split transcript still merge into one text block, and aDataBlockattached between the halves survives the merge with the second half's text appended after it (both useTurnAggregator(merge_window_ms=60_000)so they do not depend on wall-clock timing).No public API change, no breaking change.
Testing
New regression test on the unpatched tree (fails — the
DataBlockis dropped):With the fix, both new tests pass:
Realtime agent module tests, before (origin/main) vs after:
Tests covering the realtime agent and its turn aggregator:
tests/tui_test.py(the only other file referencingRealtimeAgent) cannot be collected in this environment on either tree:ModuleNotFoundError: No module named 'textual'(thetuiextra is not installed).Lint and type checks with the versions pinned in
.pre-commit-config.yaml:Checklist