Skip to content

Commit d498daa

Browse files
authored
test(core): remove duplicate stream cases (#122190)
1 parent 3d76246 commit d498daa

2 files changed

Lines changed: 0 additions & 308 deletions

File tree

‎src/agents/openai-transport-stream.streaming.test.ts‎

Lines changed: 0 additions & 297 deletions
Original file line numberDiff line numberDiff line change
@@ -690,303 +690,6 @@ describe("openai transport stream", () => {
690690
).toEqual(["call_click|fc_click", "call_type|fc_type"]);
691691
});
692692

693-
it("routes indexed Responses tool arguments when item ids rotate", async () => {
694-
const model = createAzureResponsesModel();
695-
const output = createResponsesAssistantOutput(model);
696-
const events: CapturedStreamEvent[] = [];
697-
698-
await testing.processResponsesStream(
699-
streamChunks([
700-
{
701-
type: "response.output_item.added",
702-
output_index: 0,
703-
item: {
704-
type: "function_call",
705-
id: "fc_read",
706-
call_id: "call_read",
707-
name: "read",
708-
arguments: "",
709-
},
710-
},
711-
{
712-
type: "response.function_call_arguments.delta",
713-
output_index: 0,
714-
item_id: "encrypted_delta_1",
715-
delta: '{"path":',
716-
},
717-
{
718-
type: "response.function_call_arguments.delta",
719-
output_index: 0,
720-
item_id: "encrypted_delta_2",
721-
delta: '"README.md"}',
722-
},
723-
{
724-
type: "response.function_call_arguments.done",
725-
output_index: 0,
726-
item_id: "encrypted_done",
727-
arguments: '{"path":"README.md"}',
728-
},
729-
{
730-
type: "response.output_item.done",
731-
output_index: 0,
732-
item: {
733-
type: "function_call",
734-
id: "fc_read",
735-
call_id: "call_read",
736-
name: "read",
737-
arguments: "",
738-
},
739-
},
740-
{
741-
type: "response.completed",
742-
response: { id: "resp_read", status: "completed" },
743-
},
744-
]),
745-
output,
746-
{ push: (event) => events.push(event as CapturedStreamEvent) },
747-
model,
748-
);
749-
750-
expect(output.content).toMatchObject([
751-
{
752-
type: "toolCall",
753-
id: "call_read|fc_read",
754-
name: "read",
755-
arguments: { path: "README.md" },
756-
},
757-
]);
758-
expect(events.map((event) => event.type)).toEqual([
759-
"toolcall_start",
760-
"toolcall_delta",
761-
"toolcall_delta",
762-
"toolcall_end",
763-
]);
764-
});
765-
766-
it("rejects indexed Responses completions when call ids change", async () => {
767-
const model = createAzureResponsesModel();
768-
const output = createResponsesAssistantOutput(model);
769-
const events: CapturedStreamEvent[] = [];
770-
771-
await expect(
772-
testing.processResponsesStream(
773-
streamChunks([
774-
{
775-
type: "response.output_item.added",
776-
output_index: 0,
777-
item: {
778-
type: "function_call",
779-
id: "fc_read",
780-
call_id: "call_read_a",
781-
name: "read",
782-
arguments: "",
783-
},
784-
},
785-
{
786-
type: "response.function_call_arguments.delta",
787-
output_index: 0,
788-
item_id: "encrypted_delta",
789-
delta: '{"path":"README.md"}',
790-
},
791-
{
792-
type: "response.output_item.done",
793-
output_index: 0,
794-
item: {
795-
type: "function_call",
796-
id: "fc_read_done",
797-
call_id: "call_read_b",
798-
name: "read",
799-
arguments: '{"path":"README.md"}',
800-
},
801-
},
802-
{
803-
type: "response.completed",
804-
response: { id: "resp_read", status: "completed" },
805-
},
806-
]),
807-
output,
808-
{ push: (event) => events.push(event as CapturedStreamEvent) },
809-
model,
810-
),
811-
).rejects.toThrow("Responses stream completed with unresolved tool calls");
812-
expect(events.map((event) => event.type)).toEqual(["toolcall_start", "toolcall_delta"]);
813-
});
814-
815-
it("rejects reuse of an active Responses tool-call output index", async () => {
816-
const model = createAzureResponsesModel();
817-
const output = createResponsesAssistantOutput(model);
818-
const events: Array<{ type?: string }> = [];
819-
820-
await expect(
821-
testing.processResponsesStream(
822-
streamChunks([
823-
{
824-
type: "response.output_item.added",
825-
output_index: 0,
826-
item: {
827-
type: "function_call",
828-
id: "fc_first_index_owner",
829-
call_id: "call_first_index_owner",
830-
name: "computer",
831-
arguments: "",
832-
},
833-
},
834-
{
835-
type: "response.output_item.added",
836-
output_index: 0,
837-
item: {
838-
type: "function_call",
839-
id: "fc_second_index_owner",
840-
call_id: "call_second_index_owner",
841-
name: "computer",
842-
arguments: "",
843-
},
844-
},
845-
]),
846-
output,
847-
{ push: (event) => events.push(event as (typeof events)[number]) },
848-
model,
849-
),
850-
).rejects.toThrow("Responses stream reused active tool-call output index 0");
851-
expect(events.filter((event) => event.type === "toolcall_start")).toHaveLength(1);
852-
expect(events.filter((event) => event.type === "toolcall_end")).toHaveLength(0);
853-
});
854-
855-
it("keeps parallel unindexed Responses calls bound by identity without orphans", async () => {
856-
const model = createAzureResponsesModel();
857-
const output = createResponsesAssistantOutput(model);
858-
const events: Array<{
859-
type?: string;
860-
contentIndex?: number;
861-
toolCall?: { id?: string; arguments?: unknown };
862-
}> = [];
863-
const firstItem = {
864-
type: "function_call",
865-
id: "fc_first_unindexed",
866-
call_id: "call_first_unindexed",
867-
name: "computer",
868-
arguments: '{"slot":1}',
869-
status: "completed",
870-
};
871-
const secondItem = {
872-
type: "function_call",
873-
id: "fc_second_unindexed",
874-
call_id: "call_second_unindexed",
875-
name: "computer",
876-
arguments: '{"slot":2}',
877-
status: "completed",
878-
};
879-
880-
await testing.processResponsesStream(
881-
streamChunks([
882-
{
883-
type: "response.output_item.added",
884-
item: { ...firstItem, arguments: "", status: "in_progress" },
885-
},
886-
{
887-
type: "response.output_item.added",
888-
item: { ...secondItem, arguments: "", status: "in_progress" },
889-
},
890-
{
891-
type: "response.function_call_arguments.delta",
892-
item_id: secondItem.id,
893-
delta: secondItem.arguments,
894-
},
895-
{
896-
type: "response.function_call_arguments.delta",
897-
item_id: firstItem.id,
898-
delta: firstItem.arguments,
899-
},
900-
{
901-
type: "response.function_call_arguments.done",
902-
item_id: firstItem.id,
903-
arguments: firstItem.arguments,
904-
},
905-
{
906-
type: "response.function_call_arguments.done",
907-
item_id: secondItem.id,
908-
arguments: secondItem.arguments,
909-
},
910-
{ type: "response.output_item.done", item: firstItem },
911-
{ type: "response.output_item.done", item: secondItem },
912-
{
913-
type: "response.completed",
914-
response: {
915-
id: "resp_parallel_unindexed",
916-
status: "completed",
917-
output: [firstItem, secondItem],
918-
},
919-
},
920-
]),
921-
output,
922-
{ push: (event) => events.push(event as (typeof events)[number]) },
923-
model,
924-
);
925-
926-
expect(output.content).toEqual([
927-
{
928-
type: "toolCall",
929-
id: "call_first_unindexed|fc_first_unindexed",
930-
name: "computer",
931-
arguments: { slot: 1 },
932-
},
933-
{
934-
type: "toolCall",
935-
id: "call_second_unindexed|fc_second_unindexed",
936-
name: "computer",
937-
arguments: { slot: 2 },
938-
},
939-
]);
940-
expect(
941-
events
942-
.filter((event) => event.type === "toolcall_end")
943-
.map((event) => [event.contentIndex, event.toolCall?.id, event.toolCall?.arguments]),
944-
).toEqual([
945-
[0, "call_first_unindexed|fc_first_unindexed", { slot: 1 }],
946-
[1, "call_second_unindexed|fc_second_unindexed", { slot: 2 }],
947-
]);
948-
expect(events.filter((event) => event.type === "toolcall_start")).toHaveLength(2);
949-
});
950-
951-
it("fails closed on ambiguous unindexed parallel argument events", async () => {
952-
const model = createAzureResponsesModel();
953-
const output = createResponsesAssistantOutput(model);
954-
const events: Array<{ type?: string }> = [];
955-
const firstItem = {
956-
type: "function_call",
957-
id: "fc_ambiguous_first",
958-
call_id: "call_ambiguous_first",
959-
name: "computer",
960-
};
961-
const secondItem = {
962-
type: "function_call",
963-
id: "fc_ambiguous_second",
964-
call_id: "call_ambiguous_second",
965-
name: "computer",
966-
};
967-
968-
await expect(
969-
testing.processResponsesStream(
970-
streamChunks([
971-
{ type: "response.output_item.added", item: { ...firstItem, arguments: "" } },
972-
{ type: "response.output_item.added", item: { ...secondItem, arguments: "" } },
973-
{ type: "response.function_call_arguments.delta", delta: '{"slot":1}' },
974-
{ type: "response.output_item.done", item: firstItem },
975-
{ type: "response.output_item.done", item: secondItem },
976-
{
977-
type: "response.completed",
978-
response: { id: "resp_ambiguous_unindexed", status: "completed" },
979-
},
980-
]),
981-
output,
982-
{ push: (event) => events.push(event as (typeof events)[number]) },
983-
model,
984-
),
985-
).rejects.toThrow("Responses stream completed with unresolved tool calls");
986-
expect(events.filter((event) => event.type === "toolcall_start")).toHaveLength(2);
987-
expect(events.filter((event) => event.type === "toolcall_end")).toHaveLength(0);
988-
});
989-
990693
it("recovers parallel Responses arguments from done events and preserves opening names", async () => {
991694
const model = createAzureResponsesModel();
992695
const output = createResponsesAssistantOutput(model);

‎src/utils/utils-misc.test.ts‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import { describe, expect, it } from "vitest";
33
import { z } from "zod";
44
import { asBoolean, parseBooleanValue } from "./boolean.js";
5-
import { chunkItems } from "./chunk-items.js";
65
import { splitShellArgs } from "./shell-argv.js";
76
import { safeParseJsonWithSchema, safeParseWithSchema } from "./zod-parse.js";
87

@@ -77,16 +76,6 @@ describe("splitShellArgs", () => {
7776
});
7877
});
7978

80-
describe("chunkItems", () => {
81-
it("splits items into fixed-size chunks", () => {
82-
expect(chunkItems([1, 2, 3, 4, 5], 2)).toEqual([[1, 2], [3, 4], [5]]);
83-
});
84-
85-
it("keeps one row when the requested size is not positive", () => {
86-
expect(chunkItems([1, 2, 3], 0)).toEqual([[1, 2, 3]]);
87-
});
88-
});
89-
9079
describe("zod parse helpers", () => {
9180
const schema = z.object({ name: z.string() });
9281

0 commit comments

Comments
 (0)