π€― LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
π fix(hetero): stop cross-message text duplication in server-ingest mode (#15585)
Arvin Xub295265f25cd
diff --git a/apps/cli/src/commands/hetero.test.ts b/apps/cli/src/commands/hetero.test.tsindex bbd7d8775df..2ddf89c52a8 100644--- a/apps/cli/src/commands/hetero.test.ts+++ b/apps/cli/src/commands/hetero.test.ts@@ -645,4 +645,75 @@ describe('hetero exec command', () => {'finish',]);});++ it('resets the per-message text accumulator at message boundaries (no cross-message duplication)', async () => {+ // LOBE-10157 Bug 3: the `replace` snapshot accumulator must not span+ // message boundaries. Two assistant messages separated by a+ // stream_end/stream_start boundary must each snapshot only their OWN+ // text β otherwise the second message re-emits the first's text verbatim.+ const textSnapshots: string[] = [];+ mockHeteroIngestMutate.mockImplementation(async ({ events }: any) => {+ for (const e of events) {+ if (e.type === 'stream_chunk' && e.data?.chunkType === 'text') {+ textSnapshots.push(e.data.content);+ }+ }+ return { ack: true };+ });++ mockSpawnAgent.mockReturnValue(+ createFakeHandle({+ events: [+ {+ data: { chunkType: 'text', content: 'first message' },+ operationId: 'op-server',+ stepIndex: 0,+ timestamp: 1,+ type: 'stream_chunk',+ },+ { data: {}, operationId: 'op-server', stepIndex: 0, timestamp: 2, type: 'stream_end' },+ {+ data: { newStep: true, provider: 'claude-code' },+ operationId: 'op-server',+ stepIndex: 1,+ timestamp: 3,+ type: 'stream_start',+ },+ {+ data: { chunkType: 'text', content: 'second message' },+ operationId: 'op-server',+ stepIndex: 1,+ timestamp: 4,+ type: 'stream_chunk',+ },+ {+ data: { reason: 'success' },+ operationId: 'op-server',+ stepIndex: 1,+ timestamp: 5,+ type: 'agent_runtime_end',+ },+ ],+ exitCode: 0,+ }),+ );++ await runCmd([+ 'hetero',+ 'exec',+ '--type',+ 'claude-code',+ '--prompt',+ 'hi',+ '--topic',+ 'topic-1',+ '--operation-id',+ 'op-server',+ '--render',+ 'none',+ ]);++ // Second snapshot carries ONLY the second message β not "first messagesecond message".+ expect(textSnapshots).toEqual(['first message', 'second message']);+ });});diff --git a/apps/cli/src/commands/hetero.ts b/apps/cli/src/commands/hetero.tsindex f86ad76f45e..58da0bba6f0 100644--- a/apps/cli/src/commands/hetero.ts+++ b/apps/cli/src/commands/hetero.ts@@ -233,6 +233,17 @@ class SerialServerIngester {}this.queuePendingTextSnapshot();+ // `accumulatedText` is a PER-MESSAGE accumulator: it coalesces the text+ // deltas of the current assistant message into one `replace` snapshot.+ // A new message boundary (`stream_start` / `stream_end`, emitted by the+ // adapter's `openMainMessage`) must reset it β otherwise it spans the+ // whole run and every later message's snapshot re-emits all prior+ // messages' text verbatim, which the server then persists into the new+ // DB message (LOBE-10157 Bug 3: cross-message text duplication). Reset+ // AFTER flushing the just-ended message's pending snapshot above.+ if (event.type === 'stream_start' || event.type === 'stream_end') {+ this.accumulatedText = '';+ }this.enqueue(async () => {await this.sink.ingest([event]);});