fix(web): stop marking mixed tool runs as failed (#7893)
This commit is contained in:
1 parent
11f051373e
commit
ce91284f83
7 files changed
+230
-6
No files matched your search
@@ -342,11 +342,17 @@ export function projectActivityPayload(
|
||||
return activity;
|
||||
}
|
||||
|
||||
const itemStatus = asRecord(data.item)?.status;
|
||||
const projectedPayload =
|
||||
payload.status === "completed" && (itemStatus === "failed" || itemStatus === "declined")
|
||||
? { ...payload, status: itemStatus }
|
||||
: payload;
|
||||
|
||||
if (payload.itemType === "mcp_tool_call") {
|
||||
return {
|
||||
...activity,
|
||||
payload: {
|
||||
...payload,
|
||||
...projectedPayload,
|
||||
data: projectMcpToolCallData(data),
|
||||
},
|
||||
};
|
||||
@@ -384,7 +390,7 @@ export function projectActivityPayload(
|
||||
return {
|
||||
...activity,
|
||||
payload: {
|
||||
...payload,
|
||||
...projectedPayload,
|
||||
data: projectedData,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -614,6 +614,66 @@ lifecycleLayer("CodexAdapterLive lifecycle", (it) => {
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("preserves failed and declined outcomes on completed tool items", () =>
|
||||
Effect.gen(function* () {
|
||||
const { adapter, runtime } = yield* startLifecycleRuntime();
|
||||
const items = [
|
||||
{
|
||||
type: "commandExecution",
|
||||
id: "failed-command",
|
||||
command: "vp test run",
|
||||
commandActions: [],
|
||||
cwd: "/tmp",
|
||||
exitCode: 1,
|
||||
status: "failed",
|
||||
},
|
||||
{
|
||||
type: "mcpToolCall",
|
||||
id: "failed-mcp",
|
||||
server: "simulator",
|
||||
tool: "build",
|
||||
arguments: {},
|
||||
error: { message: "Build failed" },
|
||||
status: "failed",
|
||||
},
|
||||
{
|
||||
type: "fileChange",
|
||||
id: "declined-change",
|
||||
changes: [],
|
||||
status: "declined",
|
||||
},
|
||||
] as const;
|
||||
|
||||
for (const item of items) {
|
||||
const firstEventFiber = yield* Stream.runHead(adapter.streamEvents).pipe(Effect.forkChild);
|
||||
|
||||
yield* runtime.emit({
|
||||
id: asEventId(`evt-${item.id}`),
|
||||
kind: "notification",
|
||||
provider: ProviderDriverKind.make("codex"),
|
||||
createdAt: "2026-01-01T00:00:00.000Z",
|
||||
method: "item/completed",
|
||||
threadId: asThreadId("thread-1"),
|
||||
turnId: asTurnId("turn-1"),
|
||||
itemId: asItemId(item.id),
|
||||
payload: {
|
||||
completedAtMs: 1_778_000_000_000,
|
||||
threadId: "thread-1",
|
||||
turnId: "turn-1",
|
||||
item,
|
||||
},
|
||||
});
|
||||
|
||||
const firstEvent = yield* Fiber.join(firstEventFiber);
|
||||
NodeAssert.equal(firstEvent._tag, "Some");
|
||||
if (firstEvent._tag !== "Some" || firstEvent.value.type !== "item.completed") {
|
||||
return;
|
||||
}
|
||||
NodeAssert.equal(firstEvent.value.payload.status, item.status);
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("maps completed plan items to canonical proposed-plan completion events", () =>
|
||||
Effect.gen(function* () {
|
||||
const { adapter, runtime } = yield* startLifecycleRuntime();
|
||||
|
||||
@@ -480,7 +480,9 @@ function mapItemLifecycle(
|
||||
lifecycle === "item.started"
|
||||
? "inProgress"
|
||||
: lifecycle === "item.completed"
|
||||
? "completed"
|
||||
? "status" in item && (item.status === "failed" || item.status === "declined")
|
||||
? item.status
|
||||
: "completed"
|
||||
: undefined;
|
||||
|
||||
return {
|
||||
|
||||
@@ -220,6 +220,40 @@ describe("projectActivityPayload", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("preserves failed stored tool outcomes for web and mobile clients", () => {
|
||||
const activities = [
|
||||
makeActivity("failed-command", "command_execution", {
|
||||
item: {
|
||||
command: "vp test run",
|
||||
exitCode: 1,
|
||||
status: "failed",
|
||||
},
|
||||
}),
|
||||
makeActivity("failed-mcp", "mcp_tool_call", {
|
||||
item: {
|
||||
server: "simulator",
|
||||
tool: "build",
|
||||
arguments: {},
|
||||
status: "failed",
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
for (const activity of activities) {
|
||||
const projected = projectActivityPayload(activity);
|
||||
expect(projected.payload).toMatchObject({ status: "failed" });
|
||||
|
||||
const [webEntry] = deriveWorkLogEntries([projected]);
|
||||
expect(webEntry?.toolLifecycleStatus).toBe("failed");
|
||||
|
||||
const [mobileGroup] = buildThreadFeed(makeThread([projected]));
|
||||
expect(mobileGroup).toMatchObject({ type: "activity-group" });
|
||||
if (mobileGroup?.type === "activity-group") {
|
||||
expect(mobileGroup.activities[0]?.status).toBe("failure");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("projects snapshot and event transports without mutating their sources", () => {
|
||||
const activity = fixtures[0]!;
|
||||
const thread = makeThread([activity]);
|
||||
|
||||
Reference in new issue
Block a user