mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
core: extract overflow check logic into separate function for better code organization
This commit is contained in:
parent
5dde596aa1
commit
bbcb7a2821
1 changed files with 8 additions and 15 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue