refactor(core): simplify compaction recovery
This commit is contained in:
parent
71751ac339
commit
fb5726baa8
2 changed files with 2 additions and 26 deletions
|
|
@ -232,8 +232,6 @@ const make = (dependencies: Dependencies) => {
|
|||
type: event.classification === "context-overflow" ? "provider.invalid-request" : "provider.error",
|
||||
message: event.message,
|
||||
}
|
||||
if (LLMEvent.is.finish(event) && event.reason === "length")
|
||||
failure = { type: "compaction.failed", message: "Compaction reached the model output limit" }
|
||||
if (LLMEvent.is.textDelta(event)) {
|
||||
chunks.push(event.text)
|
||||
return dependencies.events.publish(SessionEvent.Compaction.Delta, {
|
||||
|
|
@ -311,6 +309,7 @@ const make = (dependencies: Dependencies) => {
|
|||
messages: input.messages,
|
||||
model: input.request.model,
|
||||
reason: "auto",
|
||||
output: input.request.generation?.maxTokens ?? input.request.model.route.defaults.limits?.output ?? 0,
|
||||
})
|
||||
})
|
||||
const compactManual = Effect.fn("SessionCompaction.compactManual")(function* (input: CompactInput) {
|
||||
|
|
|
|||
|
|
@ -1623,28 +1623,6 @@ describe("SessionRunnerLLM", () => {
|
|||
}),
|
||||
)
|
||||
|
||||
it.effect("rejects a manual compaction truncated by the model output limit", () =>
|
||||
Effect.gen(function* () {
|
||||
const session = yield* setup
|
||||
response = reply.text("Earlier answer", "text-manual-length-history")
|
||||
yield* admit(session, "Earlier question")
|
||||
yield* session.resume(sessionID)
|
||||
|
||||
response = [
|
||||
LLMEvent.textDelta({ id: "summary", text: "Partial summary" }),
|
||||
LLMEvent.finish({ reason: "length" }),
|
||||
]
|
||||
const compaction = yield* session.compact({ sessionID })
|
||||
yield* session.resume(sessionID)
|
||||
|
||||
expect((yield* session.messages({ sessionID })).find((message) => message.id === compaction.id)).toMatchObject({
|
||||
type: "compaction",
|
||||
status: "failed",
|
||||
error: { type: "compaction.failed", message: "Compaction reached the model output limit" },
|
||||
})
|
||||
}),
|
||||
)
|
||||
|
||||
it.effect("settles an admitted manual compaction when pre-start resolution throws", () =>
|
||||
Effect.gen(function* () {
|
||||
const session = yield* setup
|
||||
|
|
@ -1770,7 +1748,7 @@ describe("SessionRunnerLLM", () => {
|
|||
}),
|
||||
)
|
||||
|
||||
it.effect("recovers from provider context overflow despite an undersized configured limit", () =>
|
||||
it.effect("recovers from provider context overflow despite an undersized configured context limit", () =>
|
||||
Effect.gen(function* () {
|
||||
const session = yield* setupOverflowRecovery
|
||||
currentModel = undersizedContextModel
|
||||
|
|
@ -1783,7 +1761,6 @@ describe("SessionRunnerLLM", () => {
|
|||
yield* session.resume(sessionID)
|
||||
|
||||
expect(requests).toHaveLength(3)
|
||||
expect(requests[1].generation?.maxTokens).toBe(1_000)
|
||||
expect(yield* session.context(sessionID)).toMatchObject([
|
||||
{ type: "compaction", summary: "## Objective\n- Recover undersized limit" },
|
||||
{ type: "assistant", finish: "stop" },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue