refactor(core): name the unsettled-tool sweep scope and untangle hosted settlement (#38724)

This commit is contained in:
Kit Langton 2026-07-24 13:32:14 -04:00 committed by GitHub
parent 68ef893818
commit 2200d100d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 28 deletions

View file

@ -364,32 +364,17 @@ const layer = Layer.effect(
// these sweeps only close calls that could not produce a truthful settlement.
if (providerFailed)
yield* serialized(publisher.failUnsettledTools({ type: "aborted", message: "Tool execution interrupted" }))
if (llmFailure && !providerFailed)
yield* serialized(
publisher.failUnsettledTools(
{
type: "tool.result-missing",
message: "Provider did not return a tool result",
},
true,
),
)
const hostedResultMissing =
stream._tag === "Success" && !providerFailed
? yield* serialized(
publisher.failUnsettledTools(
{ type: "tool.result-missing", message: "Provider did not return a tool result" },
true,
),
)
: false
if (hostedResultMissing && !publisher.stepSettlement())
yield* serialized(
publisher.failAssistant({
type: "tool.result-missing",
message: "Provider did not return a tool result",
}),
)
const resultMissing = {
type: "tool.result-missing",
message: "Provider did not return a tool result",
} as const
if (llmFailure && !providerFailed) yield* serialized(publisher.failUnsettledTools(resultMissing, "hosted"))
// A clean stream that still left hosted calls unresolved fails the step itself.
if (stream._tag === "Success" && !providerFailed) {
const hostedResultMissing = yield* serialized(publisher.failUnsettledTools(resultMissing, "hosted"))
if (hostedResultMissing && !publisher.stepSettlement())
yield* serialized(publisher.failAssistant(resultMissing))
}
const stepFailure = publisher.stepFailure()
const stepSettlement = publisher.stepSettlement()

View file

@ -277,9 +277,9 @@ export const createLLMEventPublisher = (events: Pick<EventV2.Interface, "publish
const failUnsettledTools = Effect.fn("SessionRunner.failUnsettledTools")(function* (
error: SessionError.Error,
hostedOnly = false,
scope: "hosted" | "all" = "all",
) {
return yield* failTools(error, hostedOnly ? "hosted" : "all")
return yield* failTools(error, scope)
})
const assistantMessageIDForTool = (callID: string) => {