Repository navigation
fix(dashscope): preserve AudioBlock in merged text conversation history - #4305
Merged
Merged
Conversation
The careful/text merge path (mergeToMessage) handled Text, Hint, Image, Video, Data, Document, Thinking and ToolResult blocks but silently dropped AudioBlock. A multi-agent conversation containing audio therefore lost that audio entirely from the model-visible history, with no log or placeholder. The multimodal path in the same class already converts audio to a DashScope content part. Add an AudioBlock branch to the text merger that appends the converted URL as an [Audio: ...] placeholder (or a processing-failed placeholder), mirroring the existing VideoBlock handling. Fixes the long-standing omission where the multimodal audio branch has existed since 7155832 but the text path never caught up.
jujn
approved these changes
Nov 21, 2026
xzxiaoshan
added a commit
that referenced
this pull request
Nov 26, 2026
…#4435) ## Background Swept the last 125 PRs (#4434→#4239), every single-OS-failed CI run since 2026-11-19 and the main-branch push runs for `mvn -B -T1C clean verify` failures (one build OS red and the other green on the same commit = flake suspect). Four test classes still fail on current main: three fail on windows-latest only, and the fourth sits at its deadline on both OSes. All fixes are test-side only (no `src/main` changes). ## Fixes and evidence | Test class | Victims | Signature | Fix | |---|---|---|---| | `HarnessAgentStructuredOutputStreamEventsTest` | #4296, #4349, #4071, main run 44879286932 (2026-11-20 to 11-23), all windows-latest | `streamEvents(...).block(10s)` timed out at 10.2-11.3s per call; the class takes 3.7-9.6s on windows-latest when green and 1-1.5s on ubuntu | ephemeral `InMemoryThreadJournalStore` in the three workspace-backed tests (the fourth already used one) | | `HarnessAgentOverflowRecoveryTest` | #4042, #4426 (2026-11-26), both windows-latest; the journal rows were added by #4399 on 11-25 | row `[3]` (journal=true) crossed `block(30s)` at 36.3-38.1s and row `[4]` passed with 33.8s; the same rows take 0.4-1.3s on ubuntu, and main's own run 45595615922 needed 61s for the class on windows-latest | ephemeral `InMemoryThreadJournalStore` in `newAgent` | | `DashScopeMultiModalEmbeddingTest` | #4413 (2026-11-25), windows-latest | the first SDK request in the fork hit the 5s latch (7.29s elapsed); the class takes 1.4-4.2s on windows-latest even when green | first-request latch 5s→15s | | `AnthropicAutoConfigurationTest` | #2363, run 45137197507 (2026-11-23), windows-latest | the first gateway test crossed `block(10s)` at 15.66s; the other three take under 1s, and this one already takes 5-11s on windows-latest and 9-12s on ubuntu when green | block 10s→30s | The first two share one cause: since #4154 the default workspace journal is `SqliteJournalStorage` on Windows, which opens a JDBC connection per storage operation and commits every CAS as a durable transaction (DELETE journal, synchronous EXTRA). A journaled turn issues about 20 such writes at roughly 8ms each on a fast local disk. Neither class asserts journal persistence, so they now use the ephemeral backend the repository already documents for tests. Locally on Windows the overflow-recovery class dropped from 17.9s to 5.6s and the structured-output class from 3.2s to 1.6s. ## Constraint compliance - Happy path zero cost: the journal swap removes work, the two relaxations only move failure deadlines, and no sleeps or weakened assertions were added. - Structural hardening first: the journal swap is structural. For the two cold-start waits the structural alternative, a warm-up request before the timed section, would add a request to every run, so the deadline was relaxed instead. - Minimal widening anchored to measured data: each relaxation is 3x the deadline that was crossed, and every comment cites its victims and measured values. - No `src/main` changes. ## Observed but deliberately not fixed here - `WorkerRuntimeTest.saturatedStartsDoNotBlockRecoveryAndDrainPreservesActiveLeases` (#4294, windows-latest, 36.19s at the `renewed` latch): with the test's 4s worker lease a heartbeat delayed by more than 2.7s finds the lease already expired and fails with `Worker lease lost` instead of arriving late, so widening the latch (as #4274 did to 30s) cannot help. That latch is the only place asserting the runtime renews leases, and a longer lease would delay the first heartbeat by lease/3, so the fix needs a design decision. - `SubagentFactoryDeclarationTest.declaredFactory_persistSessionIsolatesUsers` (main run 45172445003, 2026-11-23, 31.45s) and `ChatControllerTest.httpUsesExplicitCreationAndTargetedIdempotentControls` (main run 44566773929 and #4255, both 2026-11-19): no recurrence since. - Two windows-latest hangs that ended at the 2h job timeout: `AgentSpawnToolPermissionTest` (#4305, run 44760439728) and `AgentSpawnToolPlanModeTest` (main run 45739005058 on the current head). Both classes wait with unbounded `.block()`; the root cause is not established, and the 30-minute Surefire fork timeout in the root pom did not end either run. - The cost of the Windows default journal itself (one JDBC connection and one durable transaction per storage operation) is a production concern that deserves its own `src/main` change. - Already fixed upstream, victims predate the fix: `JevEvidenceProcessorTest` (13 runs, fixed by #4346), `ChatSessionsTest`, `RocketMqExecutionTest` and `AgentScopeAdapterTest` (fixed by #4274).
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.
AgentScope-Java Version
2.1.0-SNAPSHOT (
main@21be74a8)Description
Problem.
DashScopeConversationMerger.mergeToMessage— the careful/text merge path used byDashScopeMultiAgentFormatter— handlesTextBlock,HintBlock,ImageBlock,VideoBlock,DataBlock,DocumentBlock,ThinkingBlockandToolResultBlock, but has no branch forAudioBlock. An audio block therefore falls off the end of the if-else chain and is silently dropped from the merged text history: the model never sees it and no log or placeholder is emitted.This is a long-standing omission, not an intentional restriction. The multimodal path in the same class (
mergeToMultiModalMessage) has convertedAudioBlockinto a DashScope content part since7155832e3(2025-11-05), andDashScopeMediaConverter.convertAudioBlockToUrlalready exposes a pure, local URL conversion (no network I/O).Change. Add an
AudioBlockbranch tomergeToMessage, mirroring the adjacentVideoBlockbranch: convert the audio to its URL and appendname: [Audio: <url>]to the text accumulator; on conversion failure, appendname: [Audio - processing failed]and log a warning. No behavior changes for any other block type, no new dependencies, no API changes.Why not just leave text mode audio-free. Every other media block (image, video, data, document) already leaves a trace in the merged text; audio was the single outlier. Silently discarding user input is the failure mode, whereas a visible
[Audio: ...]placeholder keeps the turn intact for both models that can consume audio and those that cannot.Regression evidence. New
DashScopeConversationMergerTest:textMergePreservesAudioBlock— on the unmodified source it fails withAssertionFailedError: an AudioBlock must not be silently dropped ... <history>\nalice: listen\n</history>(audio absent); after the fix it passes and the content contains[Audio: https://example.com/audio1.mp3].textMergeKeepsPlainTextUnchanged— passes both before and after, pinning the existing plain-text output.Verification (module
agentscope-extensions-model-dashscope):mvn -q -pl ... -Dtest=DashScopeConversationMergerTest test— before fix: 1 failed / 1 passed; after fix: 2 passed.mvn -q -pl ... test(full module) —tests=523 failures=0 errors=0 skipped=2.mvn -q -pl ... spotless:check— passed;git diff --cached --checkclean; all files LF.Scope is confined to one source file and one new test file; no open PR touches either.
Checklist
mvn spotless:apply(verified viamvn spotless:check)mvn testfor the affected module: 523 passed, 0 failed, 2 skipped)