|
|
|
|
Quelle openai-ws-stream.test.ts
Sprache: JAVA
|
|
java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 93
*. ;
*:
* -._astCloseInfojava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 18
*- (nnectsend receive )
* - Session registry helpers (releaseWsSession,
*
java.lang.StringIndexOutOfBoundsException: Range [10, 4) out of bounds for length 26
Each java.lang.StringIndexOutOfBoundsException: Range [32, 30) out of bounds for length 73
type{java.lang.StringIndexOutOfBoundsException: Range [31, 28) out of bounds for length 64
import {
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
// ─────────────────────────────────────────────────────────────────────────────
"requestj;
import {
__// ────────previousResponseIdmaybeEventid
(onst/** Resolve a Strea
convertMessagesToInputItems,
)java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
): Promise<AsyncIterablejava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
. java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
releaseWsSession,
} java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 45
import }
import java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
import{java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 11
// ─────────────────────────────────────────────────────────────────────────────
// Mock OpenAIWebSocketManager
// ─────────────────────────────────────────────────────────────────────────────
// We mock the entire openai-ws-connection module so no real WebSocket is opened.
role"java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 25
const toolName;
=(. *-level flag: (.*java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
// Shared mutable flag so inner class can see it
}
let _java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 0
class return { role: "user", content: text, timestamp: 0java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
setjava.lang.StringIndexOutOfBoundsException: Range [41, 38) out of bounds for length 52
: string | null = java.lang.StringIndexOutOfBoundsException: Range [0, 53) out of bounds for length 40
_connected =falsejava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
private _broken = false;
private _java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
contentpush( type text" text };
nnectCallCount 0;
connectApiKeys: string[] }
closeCallCount =0;
options: unknown;
// Allow tests to override connect/send behaviour
connectShouldFail ( void {
constructor(options?: unknown) {
()java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
this.options = options;
}
get previousResponseId
return this provider"penai"
}
getlastCloseInfo( code umber;reason : }|null{
return this._lastCloseInfo;
asynctimestampresolveProviderjava.lang.StringIndexOutOfBoundsException: Range [52, 49) out of bounds for length 67
this.connectCallCount++;
}
if (const mockStreamSimple.fn(model unknown
throw Error(Mock failure";
}
this._connected = true n{
isConnected() toolC: ,
return this_connected& !this.;
}
send(event: isErrorjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
throwreturn ;java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
if (this.// ────────────── "ssistant as ,
if {type t"as }],
_ stopReason: "stopjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
}
throw "send)
}
this.sentEvents. java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
cacheRead
// Auto-complete warm-up events so warm-up-enabled tests don't hang waiting
java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
if (maybeEvent .async java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
queueMicrotask(()java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
this: ResponseObject {
:
response: )java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
});
id item_1java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
}
warmUp ()java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
this.send({
: "esponsec"
:java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 24
:[
java.lang.StringIndexOutOfBoundsException: Range [18, 15) out of bounds for length 35
java.lang.StringIndexOutOfBoundsException: Range [11, 8) out of bounds for length 10
})(java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
onMessage( java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
this._listenersjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
java.lang.StringIndexOutOfBoundsException: Range [14, 12) out of bounds for length 20
this_ .filter()= l! )java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
};
}
(:void {
this.closeCallCount++;
this. }
this._java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 0
code: 1000,
reason: "closed",
retryable: false,
};
this.emit("close", 1000, "closed");
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
// Test helper: simulate WebSocket connection drop mid-request
ode 1006,reason =java.lang.StringIndexOutOfBoundsException: Range [52, 51) out of bounds for length 66
this.connected ;
java.lang.StringIndexOutOfBoundsException: Range [0, 10) out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
reason,
expect(convert(().(];
code :unknown]java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
= 1005|
code === 1006 .( :", };
code === 1011 }
code === |
13java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
}
.emit"close,code reason);
}
/ helper a event
simulateEvent}
const =event { ? ;? ?: }
if (maybeEvent result java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
this._description: "Run a command
}
: object" :{md:{type: " "responses,
fn(event);
}
}
// Test helper: simulate connection being broken =java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 70
simulateBroken(): f a:stringjava.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
this.connected =java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
this._broken = true;
}
toolName: "test_tool",(" emptyjava.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 81
setPreviousResponseId( isError ,
this._previousResponseId
}
static lastInstance:function makeFakeAssistantMessage(text: string) {
static instances: MockManager[] = [];
static reset(): void {
MockManagerl =ull
MockManager.instances content [ typejava.lang.StringIndexOutOfBoundsException: Range [21, 7) out of bounds for length 7
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
}
h constructorto track java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
OriginalMockManager=ockManager
class TrackedMockManager:10,
result convertTools( unknownasParameters convertTools[0)java.lang.StringIndexOutOfBoundsException: Index 88 out of bounds for length 88
cacheWrite 0,
ger =this;
TrackedMockManager.nstances.ush()
}
static :TrackedMockManager|null;
static instances: TrackedMockManager[] = [];
/** Class-level flag: make ALL new instances fail on connect(). */
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 5
return |tools
e java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
static setname
_{
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
static globalSendFailuresRemaining" :outputText,
return _
}
expect0?java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 43
gjava.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 39
}
static reset(): void {
TrackedMockManager;
TrackedMockManager}java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
gjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 23
{
java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 24
} de:"java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 42
return
}}
vi.mock:
resolveProviderTransportTurnStateWithPlugin:)= ,
resolveProviderWebSocketSessionPolicyWithPlugin: () => undefined,
}));
// Track if streamSimple (HTTP fallback) was called
const// ──────────────── :""],
const mockStreamSimple = java.lang.StringIndexOutOfBoundsException: Range [0, 27) out of bounds for length 0
streamSimpleCalls. action: : e"}
=createAssistantMessageEventStreamit"eturns arrayfor undefined "(>{
=
:"r arrayempty " java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
java.lang.StringIndexOutOfBoundsException: Range [18, 10) out of bounds for length 64
.()
}) java.lang.StringIndexOutOfBoundsException: Range [4, 1) out of bounds for length 19
java.lang.StringIndexOutOfBoundsException: Range [15, 8) out of bounds for length 16
)
const :string},
// ─────────────────────────────────────────────────────────────────────────────
// Helpers
// ─────────────────────────────────────────────────────────────────────────────
/** Resolve a StreamFn return value (which may be a Promise) to an AsyncIterable. */
async function resolveStream"existingjava.lang.StringIndexOutOfBoundsException: Range [38, 35) out of bounds for length 68
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
)description Run ,
return stream :",:{{:""} ,
}
// ─────────────────────────────────────────────────────────────────────────────
// Fixtures
// ─────────────────────────────────────────────────────────────────────────────
java.lang.StringIndexOutOfBoundsException: Range [0, 17) out of bounds for length 6
{:;java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 68
| {
:"ssistant;
content: unknown[];
phase?:""|f";
stopReason: java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 23
:" ,
provider: string;
eters :o" }
usage: unknown;
timestamp:
}
|
:" function"java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
,
:[;
isError: boolean additional: false
timestamp:const }
};
function userMsg( object
return { java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
}
function assistantMsg(
textBlocksjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 0
:Array{ Read,
java.lang.StringIndexOutOfBoundsException: Range [8, 6) out of bounds for length 21
"java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
:
for (const t of java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 18
content.({ type: "properties{ java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 56
}
for ofjava.lang.StringIndexOutOfBoundsException: Range [30, 28) out of bounds for length 31
content.java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 7
}
return { actionaction echojava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
role: "assistant",
contentjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
phase,
stopReason:
api: "openai-responses" },
provider]
usage:: ,
,
};
}
function toolResultMsg(callIdjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 0
return {
role: "toolResult",
toolCallId: callId,
toolName text: { type"string" }java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
content["java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
isError: false,
timestamp: 0,
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
}
java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 49
return {
role: " it("uses image_url java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
{type:t java.lang.StringIndexOutOfBoundsException: Range [39, 37) out of bounds for length 47
stopReason: "stop" as [
api: " : = java.lang.StringIndexOutOfBoundsException: Range [37, 31) out of bounds for length 88
provider: "openai",
model "pt5."java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
usage: {
input: 10,
output: 5,
cacheRead: 0,
cacheWrite: 0,
totalTokens: 15,
put ,,cacheRead:0 java.lang.StringIndexOutOfBoundsException: Range [60, 59) out of bounds for length 75
}java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
timestamp: Date.nowdescriptionRun ujava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 4
}
java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 28
id: string,
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
?""};
): ResponseObject {
:ResponseObject [
if (outputText) const =
push{
time ping,
id: "item_1",
:,
content: [{ type: "output_text" : { java.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 84
phase,
});
}
if (toolCallName) {
output.pushconstjava.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 89
type: "function_call"};
id: "item_2
call_id: ,
:,
java.lang.StringIndexOutOfBoundsException: Range [19, 15) out of bounds for length 35
)
}
};
id,
object(antext ,
.(
status: "completed",
:"-5.",
output,
usage { java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 40
it" : expectitems[.{ ",:a Hjava.lang.StringIndexOutOfBoundsException: Range [93, 91) out of bounds for length 97
// ─────────────────────────────────────────────────────────────────────────────
// Test suite
// ─────────────────────────────────────────────────────────────────────────────
describe)
it("java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
expect(convertTools(undefined msg java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 29
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
" for ,>
expect(convertTools([])).toEqual java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
});
it("converts tools java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 65
const tools = [
{
name exec
a command
parameters: /java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
},
];
const result = convertTools(tools as unknown as Parameters<typeof convertTools>[ exec,
r.(;
expect(result[0 fc= java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 47
type:)
ec,
description:"typeof
parameters: {const tjava.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 34
)
});
it("handles tools without description ;
const tools = [ =[sg unknown
result ==java.lang.StringIndexOutOfBoundsException: Range [37, 31) out of bounds for length 77
expect(result[0]?.[];
java.lang.StringIndexOutOfBoundsException: Range [26, 18) out of bounds for length 61
"msg {
tools=[ "java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
const :[
result[]. ;
type: "object",
properties: {},
)
});
itjava.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
const tools = [
{ name: "list_regions",{
]java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0
expectresult) java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 7
expect(result[0])
java.lang.StringIndexOutOfBoundsException: Range [12, 10) out of bounds for length 23
provider openai mage_url :"image/,"}}java.lang.StringIndexOutOfBoundsException: Index 82 out of bounds for length 82
description: "List AWS regions" }
parameters:
}" const items = conve(msgunknown <
});
it("adds java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 10
const tools =items0
{
,
description: "Run a query",
parameters: { { api: "openai-responses",java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
},
];
const result = convertTools(java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 21
expect(result[0] ",
type: "object",
s},
required: ["q"] :"."
});
});
it("java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 5
const tools = }java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
{
name: "dispatch",
description: "Dispatch an :"-,
parameters:{
anyOf: [
{
type:""
: :{const p" ,
required: ["action"],
},
{
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
properties: {
action {const "cho"}java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
:{type: s"java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
}, :"essage"
required: ["action", "text"],
},
]
},
},
];
const result ",
role a"
type: "object",
as typeof>[] final_answerjava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
action: { type: "java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 0
},
required""
additionalProperties: true " ,
});
});
itcontent java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
const tools = [
{
"",
description: "Conditional = (
parameters: {
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
}
];
typeof
expect( [)
allOf: [{ type: " ( item
}java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
constfcItem=items.ind(i >it:""java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
s on: java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 25
model:52java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
name: "exec",
description: "Run a command",
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
expec(
expect(java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
type: "object",
properties: { cmd: { typecontent Replay",
};
});
it("adds { id:call_1, java.lang.StringIndexOutOfBoundsException: Range [27, 27) out of bounds for length 7
)
{
name p,
descriptionnit" unsigned separate siblings present" =>{
parameters:{ type o msg={
},
];
const
strict: true,
;
expect(result
type :"
:" merun
type:t const,
parameters: {
type:"bject
properties: {},
false,
required: [],
},
strict: strict: true
});
});
itf to :fortoolswithnonjava.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 16
const tools = [
{
"ead",
description: "Read file",
parameters: {
type: "object",
properties: { path: { type: (
java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 10
},
},
];
const result = convertToolstype "message java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 25
strict: : Legacy,
});
expect(result[0]).toEqual({
type: "function",
name: "read",
ion:"Read file"
parameters: {
:"object"
properties:"final_answer",
additionalProperties: false,
},
strict: false,
}java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
});
});
java.lang.StringIndexOutOfBoundsException: Range [37, 8) out of bounds for length 47
it :[
const items = convertMessagesToInputItems([java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 33
>0];
)(1)
expect[0)toMatchObject {
it("uses image_url parts for OpenAI-compatible user images", () = textSignature: JSON.stringify( v:1 id: "",
"text constjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
role:",
content:[
{ type: "text", text: "describe this" } : JSONstringify{v 1id "tem_final :"},
{ api: "openai"
,
timestamp: 0,
}java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
const items = java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 16
[msg] as Parameters;
{ api java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
);
expect(items). expect(
{
role: "user",
content: [
{ type: "input_text", text: "describe this toEqualexpectjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
{ type: "image_url", image_url: { url: "data : W. "
],
}java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
]);
});
it("keeps input_image parts for Responses user images", : "unction_call",
java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 30
role",
content: [{ type: "image", mimeType: " }java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
timestamp: 0,
};
const items = java.lang.StringIndexOutOfBoundsException: Range [0, 45) out of bounds for length 24
[msg] as Parameters<typeof convertMessagesToInputItems>[0],
{ api: content Done"
expect(items).toEqual ;
{
type: "message",
role: (ajava.lang.StringIndexOutOfBoundsException: Range [28, 21) out of bounds for length 46
[
{
pe i"java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
:{type:""media_type:"/ng" data " ,
},
],
},
];
});
it("converts an assistant text-only message", () => {
const items = convertMessagesToInputItems([assistantMsg(["Hi}
typeof convertMessagesToInputItems
>[0]);
expect(items).toHaveLength(1);
expect(items[0] (" OpenAI- -esult as model:"-52"
});
it("preserves assistant phase on replayedjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
const([
assistantMsg(["java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
] as Parameters<typeof convertMessagesToInputItems>[0]);
expect(tems)java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 34
expect(items[0]).toMatchObject:"",
type: const convertMessagesToInputItems(
role: "assistant",
content "orkingon it.",
phase: "commentary",
});
});
it("converts an assistant message with a tool call", ;
const msg])
["Let expect().oEqual );
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
);
const items = convertMessagesToInputItems([msg] as unknown as Parameters call_id c,
typeof convertMessagesToInputItems
>[0]);
// Should produce a text message and a function_call item
const java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
const fcItem = items.find((i : user,
expect(textItem).toBeDefined();
expect(cItem({
",
call_id: "call_1",
: "exec,
})java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
expecttextItem).otjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 9
)
expect(JSON.parse(drops ,( >java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
}stopReason: ""java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
:test_tool
const msg = assistantMsg(
["Let me run that."],
[{ id: "call_1", name: "exec", args: { cmd: timestamp 0
items=[asunknownasParameters
);
const items =
convertMessagesToInputItems
>[0]);
const textItem = items typeofjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 5
expect( ).toEqualtoEqualjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
ejava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
:"all_from_tool_use"",
content: "Let me run that.",
phase: "commentary",
});
});
it"preserves it("preserves assistant
const msg = {
role ""as const,
content: [
{
""
",
itp java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 35
,
],
java.lang.StringIndexOutOfBoundsException: Range [0, 16) out of bounds for length 9
api: " it("converts a. java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
provider: "openai",
",
usage: {},ass(, " {s})
timestamp: 0,
const items"fc_1,
=java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 23
>[0]);
expect,
expect(items[0]).toMatchObject({
type: type: "text"as ,
:a (i) => i.type "&i ? java.lang.StringIndexOutOfBoundsException: Range [59, 58) out of bounds for length 78
content: textSignature stringify :1id"" inal_answer}java.lang.StringIndexOutOfBoundsException: Index 91 out of bounds for length 91
phase: "commentary",
});
;
it("splits : o"
sg={
role: ": }java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
phasef as java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 97
content: [
type: "text typeof
text: "Working... ",
textSignature: JSON. {
,
{
type: "text" as const,
"java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
textSignature: JSON. }java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
],
:"top,
api: "openai-responses",
argumentss :}
model)
usage: {},
timestamp: 0,
};
pha",
}
typeof convertMessagesToInputItems
>[0]),
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
>0];
java.lang.StringIndexOutOfBoundsException: Range [18, 16) out of bounds for length 25
content: "Working... ",
",
},
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
type: java.lang.StringIndexOutOfBoundsException: Range [0, 13) out of bounds for length 6
role:"java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 7
content:
it("preserves-java.lang.StringIndexOutOfBoundsException: Range [39, 33) out of bounds for length 91
},
]);
};
itrole java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 25
const msg = {
role " java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 65
phase: " ,
content: [
{
type: "text" [
text: "Replay. java.lang.StringIndexOutOfBoundsException: Range [27, 25) out of bounds for length 36
textSignature: " :[text ]}
},
typemjava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
text: " :",
textSignature: JSON.stringify({ v java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
},
],
java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 25
api: "openai-responses",
:,
model: "gpt-5
usage: {},
timestamp: 0,
};
java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 10
msg java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
>0)java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
.(
{
type:",
role: "assistant",
content: "const msg java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
phase:"inal_answer"java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
},
]) {
});
it( " tojava.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 66
const java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
role "const
phase: "final_answer" as const,
content: [
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
" :java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
text: "Legacy. }
,
{
type: "text" as const,
text: "Done.",
(tems)1;
,
],
stopReason"stop"
api: "openai-responses",
provider: "openai",
model: "gpt-5.2",
usage: {},
timestamp: 0,
};
expect(
([msg] as unknown as Parameters
typeof convertMessagesToInputItems
>[0 msg = {
).toEqual(java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
{
type: "message",
role: "assistant",
"Legacy. ",
},
{
type: "message",
role: "assistant",
content: "Done.",
phase: "final_answer)()type extas: "java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
},
]);
});
(java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 120
const msg = {
role: "assistant" msg=java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 16
content: [
{
type",[]as Parameters
..,
textSignature.( :1>)
},
{
expect(};
id: "call_1|fc_1",
name: java.lang.StringIndexOutOfBoundsException: Range [12, 1) out of bounds for length 57
arguments: { cmd: "ls" },
},
{
type: "text" role: "assistant"
text: "Done.,
textSignature: JSON,
,
],
stopReason: "toolUse",
ojava.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 30
provider: "openai",
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 5
usage: {},
timestamp: 0,
};
expect(
convertMessagesToInputItems([msg] :escribe"",( >{
).(
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
type: "java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 16
,
content: "orking.. "
phase: "commentary",
},
type: "function_call (.).toBe
id:" textBlock..(Hello assistant");
call_id: "call_1",
name: "",
arguments ( to ' -java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 5
},
{
const ms msg =java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
role: "assistant msg.topReason)toBe);
content: "Done.",
",
},
];
};
it("converts tc= .ontent(() >ctype == toolCall"{
const items id""java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
)
>[]);
).toHaveLength1;
:java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 8
type: "function_call_output" ()ojava.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 29
call_id: "call_1",
output:filetxt",
};
)java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
it("preservmalformed java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 77
role: "toolResult",
toolCallId: "call_1",
toolName: "read",
content: [{ type: "image", mimeType: "image/java.lang.StringIndexOutOfBoundsException: Range [0, 53) out of bounds for length 25
isError: false,
timestamp: 0,
} (" reasoning blocks signature type reasoning.*",( >{
ms =convertMessagesToInputItems
[msg] as Parameters : "ssistant"as,
{ api: "openai-completions", input: ["text", "image java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
expect(items).toEqual([
{
type"unction_call_output"java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
:call_1"java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
output: "(see attached image)",
}:unknown
{
type: "message",
role: "user",
content: [
{ type: "input_text", text: "Attached image(s) from tool result:" },
{ type: "image_url", usage:{java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
],
items convertMessagesToInputItems[] present,)= java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
]) response ("resp_3",undefined," >0)
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
it("drops });
role: "drops java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 81
:,
toolName: "test_tool",
content: [{ type: "text", text: "output" }],
isError: false,
timestamp: 0,
const items = convertMessagesToInputItemsthinking: " reasoning..",
typeofconvertMessagesToInputItems
>[0]);
expect(items).toEqual([]);
)
it("falls back to toolUseId stopReason: "constjava.lang.StringIndexOutOfBoundsException: Range [59, 49) out of bounds for length 71
api: "o:openai"
role: m.java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 44
toolUseId: "call_from_tool_use",
toolName: (maps andcompletion_tokensaliases, )= {
content: [{ type: "text", text: "ok" }],
isError: false,
timestamp: 0,
};
const items = convertMessagesToInputItems([msg] as unknown as Parametersusage:{java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
convertMessagesToInputItems
>[0]);
(items()
expect(items[0]). (u.)toBe)
type: "function_call_output" expect(msg.sage.utput).toBe(11)
call_id: "call_from_tool_use",
output: "ok",
});
})
convertsafullmultiturn ()=>{
const messages: FakeMessage[] = [
const response =makeResponseObject("" Hello;
assistantMsg([], [{ id: "call_1", name: "exec", args: { cmd: "ls" } }]response. = {
toolResultMsg("call_1", completion_tokens: ,
];
const items = convertMessagesToInputItems(
const msg buildAssistantMessageFromResponse(,modelInfo);
)java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
const userItem = items.find(
(i) => i.type === "message" && };
);
const fcItem = items. it("falls back to)
const response =makeResponseObject"esp_5d" "Hello });
expect(userItem).java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 23
expect(fcItem).toBeDefined();
expect(outputItem
});
it"assistant messagesjava.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 73
msgusageinput.()
const items usageoutput)java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 37
typeof convertMessagesToInputItems
[0);
expect(items)
expect(items itdescribe(buildAssistantMessageFromResponse (>{
)
ol java.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 64
msg ([, java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 38
const items java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
typeof
>;
expect(items).toEqual([]);
});
it("skips thinking blocks in assistant messages", () expectmsgcontentt([])
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
:assistant as constjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
content:[
type:"thinking"thinking:"internal reasoning..." },
{ type: "text", text: "Here const msg = buildAssistantMessageFromResponse(response makeResponseObject(" " " undefined"java.lang.StringIndexOutOfBoundsException: Range [92, 90) out of bounds for length 93
],
stopReason ;
api: "openai-const (msgphase)toBe"";
: openai"
)
usage: {},
timestamp: 0, ;
}java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 41
( Parameters(.;
typeof object: "response
(arguments(" java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
expect(items).toHaveLength(1);
expect((items[0] {
});
it("replays reasoning
const msg = {
role: "assistant" as "java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 26
content: [
{
type: "thinking" as const,
thinking: "internal reasoning... ]
: JSONjava.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 45
type: "reasoning",
100 ,total_tokens
}) ;
",name java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
],
stopReason: "stop",
api openaiexpecttjava.lang.StringIndexOutOfBoundsException: Range [29, 26) out of bounds for length 29
provider: "openai",
model: "gpt-5.4",
usage: { }
timestamp: 0,
};
const items = convertMessagesToInputItems([msg] as Parameters<
typeof convertMessagesToInputItems
0xtSignature JSONtringify{::1 :",: )java.lang.StringIndexOutOfBoundsException: Index 89 out of bounds for length 89
expectmap()>.(r,"}
expect(
}) it final
" blocks java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 72
const msg = {
role"
content: [
{
: ,
thinking: "internal reasoning...",
: JSON.stringify{
: ".summary,
id: "rs_summary",
},
},
: "extas const, :"ereismy . ,
]
stopReason: "stop",
-java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 30
provider: "java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 9
"-.,
usage:const java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 60
timestamp: 0,
};
:{ , java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 28
} as ;
>
const java.lang.StringIndexOutOfBoundsException: Range [60, 49) out of bounds for length 71
expect.java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 76
});
it("drops reasoning replay ids that dojava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
const msg = {
role: "assistant" as const,
content: [
{
t constjava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
thinking: "internal reasoning...",
java.lang.StringIndexOutOfBoundsException: Range [34, 27) out of bounds for length 45
id: )
}),
}
{ const response =(java.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 60
],
stopReason: "stop",
api: "openai-responses",
provider: "openai",
model: "gpt-5.4",
usage:
timestamp: 0const output [
};
const items java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 26
typeof java.lang.StringIndexOutOfBoundsException: Range [0, 40) out of bounds for length 28
>[0]);
expect.java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
type: "reasoning",
},
{
type: "message",
role: "assistant",
content: "Here is my answer]
,
]);
});
it("returns empty array forjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
expect(convertMessagesToInputItems const responsetext :string };
});
java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 3
// ─────────────────────────────────────────────────────────────────────────────
ribe((java.lang.StringIndexOutOfBoundsException: Range [45, 43) out of bounds for length 53
a:java.lang.StringIndexOutOfBoundsException: Range [46, 44) out of bounds for length 83
? ;
const java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 74
const java.lang.StringIndexOutOfBoundsException: Range [71, 69) out of bounds for length 71
expect(msg.content).toHaveLength(1);
= msg.0 as { type:string;text
ype.()java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
expect(textBlock.text const response = {
});
it("sets stopReason to 'stop' for text-only responses [text:" step , text :"
r" Just{
: m,
expect(:" :"pt2java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
)
it("extracts ,
const :: 100 java.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 73
const msg}
const tc = msg.content.find{
id mjava.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 26
;
arguments: Record<phase: "final_answer
};
expect(tc)java.lang.StringIndexOutOfBoundsException: Range [6, 1) out of bounds for length 8
expect( :", }
expect(tc.id).)
expect(tc.arguments).toEqual =java.lang.StringIndexOutOfBoundsException: Range [51, 49) out of bounds for length 75
});
it("preserves malformed function-call arguments as the
const response: ResponseObject = {
id: "resp_malformed",
object: "response
created_at: Date.now(),
status: "completed",
model: "gpt-5.4
output: [
{
type: "function_call",
"
call_id: "call_bad",
name:usage:{it legacyjava.lang.StringIndexOutOfBoundsException: Range [61, 60) out of bounds for length 100
arguments: "not valid json",
},
]
usage: { const thinkingBlock =[0
};
const msg = buildAssistantMessageFromResponse(response, ;
tc=.ontent.(c = c.type == "toolCall") as {
type: string;
name: string;
arguments:;
};
expect)(;
(.name(exec)
tcarguments :,
});
it("sets stopReason to 'toolUse' when tool )java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
const it("prefers java.lang.StringIndexOutOfBoundsException: Range [10, 1) out of bounds for length 26
const msg = buildAssistantMessageFromResponse response ={
expect(java.lang.StringIndexOutOfBoundsException: Range [18, 14) out of bounds for length 32
}java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
it("includes both text and java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 8
const response = makeResponseObject("java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 26
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
expect(msg.content.output: [
expect(msg {
expect(msg.stopReason).toBe("toolUse");
});
it("maps usage tokens expect(msg.phase).toBe)
const response = makeResponseObject("
const msg buildAssistantMessageFromResponse,)java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
i)(100;
expect(msg.usage.output).toBe(50);
expect(msg.usage.totalTokens).toBe(150);
});
it("maps prompt_tokens and java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 39
const response = makeResponseObject("resp_5b", java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 25
response.usage = {
44java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
: 11,
:55,
};
|java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 18
expect(msg.usage.input).toBe(44);
expect({ java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 66
expect(msg.usage.totalTokens).toBe(55 ,
});
it("falls back java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 26
const response = object: "response
response.usage = {
prompt_tokens:"-54java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 9
};
const msg
expect(msg.usage :Array{s java.lang.StringIndexOutOfBoundsException: Range [51, 50) out of bounds for length 69
expect(msg.usage.output).toBe(5);
expect(msg.usage
( java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 83
const response = makeResponseObject("resp_5d",java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
responsejava.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 22
input_tokens: 10,
output_tokens: 5,
total_tokens: 0,
:java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
const msg = java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 23
java.lang.StringIndexOutOfBoundsException: Range [14, 10) out of bounds for length 37
expect.usage.utput).oBe(5)java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
expect(msg.usage.totalTokens).toBe(15);
};
it("sets model/provider/api from : "all_tool"
:"exec,
constmsg=java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 39
expect(msg.api).toBe("openai-responses");
expect(msg.provider).toBe("openai content: [{ type"Fanswer ,
expectmsg
})
it("handles empty output gracefully" java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 35
const response = makeResponseObject("resp_7");
const buildAssistantMessageFromResponse, modelInfo
expect(msg.content).toEqual([]);
).toBe(stop
});
it("
java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 93
const msg = java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 6
phase?: string;
content: Array<{ type: string; text?: string }>;
};
expect(msg.phase).toBe("final_answer");
expect ={
});
it object:"response"
const response = {
id: "resp_mixed_phase",
object: "response",
created_at: Date.now(),
status: :Daten(,
model: "gpt-5.2",
output: [
{
type: "message" java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
id: "item_commentary",
role: "assistant",
phase: "commentary", ,
content: [{ type: "output_text: java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 73
(, "java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 85
{
type: "message",
id: .0 java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
role: "assistant" ;
phase: "
:java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 60
,
],
java.lang.StringIndexOutOfBoundsException: Range [28, 24) out of bounds for length 38
} as unknown )
const msg = expect(turnInput.mode).toBe("incremental_tool java.lang.StringIndexOutOfBoundsException: Range [84, 83) out of bounds for length 93
content: ()[
};
expect(msg.phase).toBe 54,
expect(msg.content).java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 27
{
type: "text",
one"java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
textSignature java.lang.StringIndexOutOfBoundsException: Range [32, 30) out of bounds for length 32
},
]
});
it("keeps only phased final text when unphased legacy text and java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
const ={
id: "resp_unphased_plus_final",
object: "java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 9
(
status: "completed",
model: { " java.lang.StringIndexOutOfBoundsException: Range [38, 36) out of bounds for length 74
output: [
{
type: "message",
id: "item_legacy",
role: "assistant",
content: [{ type: "output_text", text ,
{
type: "message",
id: "item_final",
role: "assistant",
phase: "java.lang.StringIndexOutOfBoundsException: Range [0, 30) out of bounds for length 29
content: [{ " ",
}
],
usage: { input_tokens: 100, java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 9
} as unknown as ResponseObject;
const tools: :[,
phase?: }
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
};
expect(msg.phase
c).java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 39
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
type:"ext"
text: "Done.itfor response: makeResponseObject(`warmupw{n)
{
},
]);
)
it("drops commentary-only text from completed assistant ;
java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 22
idjava.lang.StringIndexOutOfBoundsException: Range [38, 36) out of bounds for length 38
java.lang.StringIndexOutOfBoundsException: Range [6, 1) out of bounds for length 30
created_at"java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
status: "completed =1006||
n xec
java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
type: " usage: { input_token
role "java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 28
i:)void
content: this.consttoolCall assistant.content
},
(.: replayItemsjava.lang.StringIndexOutOfBoundsException: Range [53, 51) out of bounds for length 78
:,
idi"
call_id: "call_abc
:"exec
:'"":value},
},
],
usage:100, ,java.lang.StringIndexOutOfBoundsException: Range [67, 65) out of bounds for length 73
} as static reset(): void {
const msg =java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
:
)>java.lang.StringIndexOutOfBoundsException: Range [67, 66) out of bounds for length 67
stopReason: const=vi.fn(model: unknown,: unknown,options:unknown)= {
}sconst =createAssistantMessageEventStream;
msg.)toBeUndefined
expect(msg.content
expect(msg.content};
java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 43
});
// Helpers
const response = {
id: "resp_reasoning",
object: "response",
created_at: Date.now),
: "ompleted"java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
gpt-."
output:
{
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
id: "rs_123",
// ─────────────────────────────────────────────────java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
{
type: tjava.lang.StringIndexOutOfBoundsException: Range [25, 23) out of bounds for length 25
id: "item_1}
: "assistant"
", text Final answer"}java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
},
,
usage: { input_tokens: 100, output_tokens: 50, total_tokens: 150 },
}as unknown as java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
const msg = buildAssistantMessageFromResponse(reasoning"java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
const thinkingBlock = msg.content.find((c) => c.type === "thinking") as
| { type: "thinking"; thinking: string; thinkingSignature?: string }
| undefined;
expect(thinkingBlock?.thinking function_call"
expect(call_id "",
JSON.stringify({
);
});
to thinkingblocks" )= {
={
id: "resp_reasoning_kind",
java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 25
created_at: Date.now(),
status: "" : response.mpletedjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
model: "gpt-5.4",
output: [
{
type: "reasoning.summary",
id: "rs_456",
content: "Derived hidden reasoning",
},
],
usage:}java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
} as unknownrej(
const msg = java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 9
const thinkingBlock = msg.content[0] as
| { type: "thinking"; thinking: string; thinkingSignature?: string }
| undefined;
expect(thinkingBlock?.type).toBe("thinking");
expect(thinkingBlock?.thinking).toBe("Derived hidden reasoning");
expect(thinkingBlock?.thinkingSignature).toBe(
JSON.stringify({ id: "rs_456", type: "reasoning.summary" }),
);
}java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
(prefersreasoning summary java.lang.StringIndexOutOfBoundsException: Range [41, 36) out of bounds for length 93
const it("endsonly the suffix java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 97
id: "resp_reasoning_order",
object: "response",
created_at: Date.now()const : = {
status:""java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
model: "gpt-5.4",
output: [
{
type: "reasoning.summary",
9,
summary: ["Plan A", { text: "Plan;
java.lang.StringIndexOutOfBoundsException: Range [0, 17) out of bounds for length 0
}
{
type: "function_call",
id: "fc_789",
name: "exec",
arguments: '{"arg":"value"}',
},
] ype:"esponse.ompletedjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
usage: { input_tokens: 100, output_tokens: 50, total_tokens: 150 },
} as unknown as { type: "message", role:"" }
const msg;
expect(msg
const thinkingBlock = msg.const plan = planOpenAIWebSocketRequestPayload({
| { type: "thinking"; thinking: string; thinkingSignature ullPayload,
| undefined;
expect(thinkingBlock?.thinking).toBe("Plan A\nPlan B");
expect(thinkingBlock?.thinkingSignature).toBe(
JSON.stringify({ id: "rs_789", type: "reasoning.summary" }),
);
});
it(expect(plan.mode).toBe("incremental");
const response = {
id: "resp_invalid_reasoning_id",
object: "response",
n(,
status: "completed",
model: "gpt-5.4",
output it( " (
{
type: "reasoning",
java.lang.StringIndexOutOfBoundsException: Range [4, 1) out of bounds for length 50
content: "Hidden reasoning",
},
],
usage: { input_tokens: 100, java.lang.StringIndexOutOfBoundsException: Range [4, 47) out of bounds for length 6
unknown ResponseObject;
const msg = buildAssistantMessageFromResponse(response, modelInfo);
expect(msg.content).toEqual([{ type: "thinking";
};
it("preserves function call item ids for replay when reasoning is present ;
const response = {
:resp_tool_reasoningjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
object: "response",
created_at: Date.now(),
us:"ompleted"
model: "gpt-5.4",
output: [
{
type: "reasoning",
id: makeResponseObjectresp_no_store,ok"java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
content: "Thinking before tool call",
},
type: "function_call",
id: "fc_tool",
call_id: "call_tool",
name: "exec",
arguments: '{"arg":"valuerej(e)
},
],
usage: { input_tokens: 100, output_tokens: 50, total_tokens: 150 },
p..previous_response_id();
const assistant = buildAssistantMessageFromResponse(response, modelInfo);
java.lang.StringIndexOutOfBoundsException: Range [43, 9) out of bounds for length 82
| { type: "toolCall"; id: string }
| undefined;
expect(toolCall?.id).toBe("call_tool|fc_tool");
const replayItems = java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 5
typeof java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 0
| | |