|
@@ -308,7 +308,10 @@ export const layer = Layer.effect(
|
|
|
yield* withPublication(publisher.failUnsettledTools("Provider did not return a tool result", true))
|
|
yield* withPublication(publisher.failUnsettledTools("Provider did not return a tool result", true))
|
|
|
if (stream._tag === "Failure") return yield* Effect.failCause(stream.cause)
|
|
if (stream._tag === "Failure") return yield* Effect.failCause(stream.cause)
|
|
|
if (settled._tag === "Failure") return yield* Effect.failCause(settled.cause)
|
|
if (settled._tag === "Failure") return yield* Effect.failCause(settled.cause)
|
|
|
- return { needsContinuation: !publisher.hasProviderError() && needsContinuation, step: currentStep }
|
|
|
|
|
|
|
+ return {
|
|
|
|
|
+ outcome: publisher.hasProviderError() ? "failed" : needsContinuation ? "continue" : "complete",
|
|
|
|
|
+ step: currentStep,
|
|
|
|
|
+ } as const
|
|
|
}),
|
|
}),
|
|
|
)
|
|
)
|
|
|
}, Effect.scoped)
|
|
}, Effect.scoped)
|
|
@@ -316,7 +319,10 @@ export const layer = Layer.effect(
|
|
|
sessionID: SessionSchema.ID,
|
|
sessionID: SessionSchema.ID,
|
|
|
promotion: SessionInput.Delivery | undefined,
|
|
promotion: SessionInput.Delivery | undefined,
|
|
|
step: number,
|
|
step: number,
|
|
|
- ) => Effect.Effect<{ readonly needsContinuation: boolean; readonly step: number }, RunError>
|
|
|
|
|
|
|
+ ) => Effect.Effect<
|
|
|
|
|
+ { readonly outcome: "continue" | "complete" | "failed"; readonly step: number },
|
|
|
|
|
+ RunError
|
|
|
|
|
+ >
|
|
|
|
|
|
|
|
const runAfterOverflowCompaction: RunTurn = Effect.fnUntraced(function* (sessionID, promotion, step) {
|
|
const runAfterOverflowCompaction: RunTurn = Effect.fnUntraced(function* (sessionID, promotion, step) {
|
|
|
return yield* runTurnAttempt(sessionID, promotion, step).pipe(
|
|
return yield* runTurnAttempt(sessionID, promotion, step).pipe(
|
|
@@ -361,7 +367,8 @@ export const layer = Layer.effect(
|
|
|
let step = 1
|
|
let step = 1
|
|
|
while (needsContinuation) {
|
|
while (needsContinuation) {
|
|
|
const result = yield* runTurn(input.sessionID, promotion, step)
|
|
const result = yield* runTurn(input.sessionID, promotion, step)
|
|
|
- needsContinuation = result.needsContinuation
|
|
|
|
|
|
|
+ if (result.outcome === "failed") return
|
|
|
|
|
+ needsContinuation = result.outcome === "continue"
|
|
|
step = result.step + 1
|
|
step = result.step + 1
|
|
|
promotion = "steer"
|
|
promotion = "steer"
|
|
|
if (!needsContinuation) needsContinuation = yield* SessionInput.hasPending(db, input.sessionID, "steer")
|
|
if (!needsContinuation) needsContinuation = yield* SessionInput.hasPending(db, input.sessionID, "steer")
|