fix: preserve synthetic transcript attachment order
This commit is contained in:
parent
bac89c2ec8
commit
d6648e77bc
@ -532,6 +532,7 @@ export async function applyMediaUnderstanding(params: {
|
||||
(output) => !audioOutputAttachmentIndexes.has(output.attachmentIndex),
|
||||
);
|
||||
outputs.push(...syntheticSkippedAudioOutputs);
|
||||
outputs.sort((left, right) => left.attachmentIndex - right.attachmentIndex);
|
||||
|
||||
if (decisions.length > 0) {
|
||||
ctx.MediaUnderstandingDecisions = [...(ctx.MediaUnderstandingDecisions ?? []), ...decisions];
|
||||
|
||||
@ -88,4 +88,29 @@ describe("formatMediaUnderstandingBody", () => {
|
||||
});
|
||||
expect(body).toBe("[Image]\nDescription:\na cat");
|
||||
});
|
||||
|
||||
it("labels audio transcripts by their attachment order", () => {
|
||||
const body = formatMediaUnderstandingBody({
|
||||
outputs: [
|
||||
{
|
||||
kind: "audio.transcription",
|
||||
attachmentIndex: 0,
|
||||
text: "first clip was silent",
|
||||
provider: "openclaw",
|
||||
},
|
||||
{
|
||||
kind: "audio.transcription",
|
||||
attachmentIndex: 1,
|
||||
text: "second clip has speech",
|
||||
provider: "groq",
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(body).toBe(
|
||||
[
|
||||
"[Audio 1/2]\nTranscript:\nfirst clip was silent",
|
||||
"[Audio 2/2]\nTranscript:\nsecond clip has speech",
|
||||
].join("\n\n"),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user