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 {
|
||||
|
||||
Reference in new issue
Block a user