refactor(core): polish runner drain and coordinator readability (#35051)

This commit is contained in:
Kit Langton 2026-07-02 22:01:53 -04:00 committed by GitHub
commit e65477ab1d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 70 additions and 61 deletions

View file

@ -2863,14 +2863,12 @@ describe("SessionRunnerLLM", () => {
input: Schema.Struct({}),
output: Schema.Struct({}),
execute: (_, context) =>
forms
.ask({ sessionID: context.sessionID, mode: "form", fields: [] })
.pipe(
Effect.orDie,
Effect.flatMap((state) =>
state.status === "answered" ? Effect.succeed({}) : Effect.die(new QuestionTool.RejectedError()),
),
forms.ask({ sessionID: context.sessionID, mode: "form", fields: [] }).pipe(
Effect.orDie,
Effect.flatMap((state) =>
state.status === "answered" ? Effect.succeed({}) : Effect.die(new QuestionTool.RejectedError()),
),
),
}),
})
yield* session.prompt({ sessionID, prompt: Prompt.make({ text: "Ask then stop" }), resume: false })
@ -3033,6 +3031,8 @@ describe("SessionRunnerLLM", () => {
yield* session.prompt({ sessionID, prompt: Prompt.make({ text: "Interrupt tool settlement" }), resume: false })
executions.length = 0
toolExecutionGate = yield* Deferred.make<void>()
toolExecutionsStarted = yield* Deferred.make<void>()
toolExecutionsReady = 1
response = [
LLMEvent.stepStart({ index: 0 }),
LLMEvent.toolCall({ id: "call-await-interrupt", name: "echo", input: { text: "blocked" } }),
@ -3042,7 +3042,7 @@ describe("SessionRunnerLLM", () => {
const runner = yield* SessionRunner.Service
const run = yield* runner.run({ sessionID, force: true }).pipe(Effect.forkChild)
while (executions.length === 0) yield* Effect.yieldNow
yield* Deferred.await(toolExecutionsStarted)
yield* Fiber.interrupt(run)
toolExecutionGate = undefined