Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/local-agent-codex.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ readline.createInterface({ input: process.stdin }).on("line", (line) => {
output({ method: "turn/completed", params: { threadId: message.params.threadId, turn: { id: turnId, status: "completed", items: [] } } });
return;
}
if (message.params.input[0].text === "notLoaded") {
const item = { type: "agentMessage", text: "CODEXOK" };
output({ method: "item/completed", params: { threadId: message.params.threadId, turnId, item } });
output({ method: "turn/completed", params: { threadId: message.params.threadId, turn: { id: turnId, status: "completed", items: [], itemsView: "notLoaded" } } });
return;
}
const item = { type: "agentMessage", text: message.params.input[0].text === "policy"
? JSON.stringify(message.params.sandboxPolicy)
: "fake response " + turn };
Expand Down Expand Up @@ -135,6 +141,14 @@ readline.createInterface({ input: process.stdin }).on("line", (line) => {
assert.ok(protocolFailure.error.cause, "provider protocol cause remains available internally");
assert.equal("cause" in toAgentErrorPayload(protocolFailure.error), false);
}
const notLoaded = await runtime.run({
prompt: "notLoaded",
workspaceRoot: "/tmp/project",
providerSessionId: first.providerSessionId ?? undefined,
});
assert.equal(notLoaded.isOk(), true, "empty turn.items must fall back to item/completed stream items");
if (notLoaded.isErr()) throw notLoaded.error;
assert.equal(notLoaded.value.finalResponse, "CODEXOK");
const policy = await runtime.run({
prompt: "policy",
workspaceRoot: "/tmp/project",
Expand Down
3 changes: 2 additions & 1 deletion src/local-agent-codex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,8 @@ function parseCompletedTurn(params: unknown, items: unknown[]): {
failure?: string;
} {
const turn = asRecord(asRecord(params)?.turn);
const completedItems = (Array.isArray(turn?.items) ? turn.items : items).slice(-MAX_TURN_ITEMS);
const turnItems = turn?.items;
const completedItems = (Array.isArray(turnItems) && turnItems.length > 0 ? turnItems : items).slice(-MAX_TURN_ITEMS);
let finalResponse = "";
for (const item of completedItems) {
const record = asRecord(item);
Expand Down