core: extract overflow check logic into separate function for better code organization

This commit is contained in:
Dax Raad 2025-11-16 20:41:44 -05:00
parent 5dde596aa1
commit bbcb7a2821

View file

@ -320,6 +320,14 @@ export namespace SessionPrompt {
}
step++
if (step === 1)
ensureTitle({
session: await Session.get(sessionID),
modelID: lastUser.model.modelID,
providerID: lastUser.model.providerID,
message: msgs.find((m) => m.info.role === "user")!,
history: msgs,
})
const model = await Provider.getModel(lastUser.model.providerID, lastUser.model.modelID)
const task = tasks.pop()
@ -644,21 +652,6 @@ export namespace SessionPrompt {
throw new Error("Impossible")
})
async function checkOverflow(input: {
sessionID: string
msgs: MessageV2.WithParts[]
model: ModelsDev.Model
abort: AbortSignal
}) {
const lastAssistant = input.msgs.findLast((msg) => msg.info.role === "assistant" && msg.info.time.completed)
?.info as MessageV2.Assistant
if (!lastAssistant) return false
return SessionCompaction.isOverflow({
tokens: lastAssistant.tokens,
model: input.model,
})
}
async function resolveModel(input: { model: PromptInput["model"]; agent: Agent.Info }) {
if (input.model) {
return input.model