fix(server): an agent can settle its own thread when its turn ends (#17145)
Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
8597558557
commit
37eaf5d293
7 files changed
+187
-14
No files matched your search
@@ -473,3 +473,40 @@ it.effect("waitForThread reads the run again only when the run updates", () =>
|
||||
expect(reads).toBe(2);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect.each([
|
||||
{ status: "completed" as const, settles: true },
|
||||
{ status: "failed" as const, settles: false },
|
||||
{ status: "interrupted" as const, settles: false },
|
||||
])("settleAfterRun settles only when the run $status", ({ status, settles }) =>
|
||||
Effect.gen(function* () {
|
||||
const projectId = ProjectId.make("project:thread-management:settle-after-run");
|
||||
const threadId = ThreadId.make("thread:thread-management:settle-after-run");
|
||||
const runId = RunId.make("run:thread-management:settle-after-run");
|
||||
const dispatched: Array<string> = [];
|
||||
const layerTest = ThreadManagementService.layer.pipe(
|
||||
Layer.provide(
|
||||
Layer.mock(Orchestrator.OrchestratorV2)({
|
||||
getThreadEventSequence: () => Effect.succeed(0),
|
||||
getThreadRecords: () =>
|
||||
Effect.succeed({
|
||||
thread: { id: threadId, projectId, deletedAt: null },
|
||||
runs: [{ id: runId, status }],
|
||||
} as unknown as OrchestrationV2ThreadProjection),
|
||||
dispatch: (command) =>
|
||||
Effect.sync(() => {
|
||||
dispatched.push(command.type);
|
||||
return { sequence: 1, storedEvents: [] } as never;
|
||||
}),
|
||||
}),
|
||||
),
|
||||
);
|
||||
const service = yield* ThreadManagementService.ThreadManagementService.pipe(
|
||||
Effect.provide(layerTest),
|
||||
);
|
||||
|
||||
yield* service.settleAfterRun({ projectId, threadId, runId });
|
||||
|
||||
expect(dispatched).toEqual(settles ? ["thread.settle"] : []);
|
||||
}),
|
||||
);
|
||||
Reference in new issue
Block a user