Session management and prompt handling improvements (#2577)

Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
Dax
2025-09-13 05:46:14 -04:00
committed by GitHub
parent 535230dce4
commit 9bb25a9260
9 changed files with 1755 additions and 1682 deletions

View File

@@ -331,6 +331,12 @@ export namespace MessageV2 {
),
}
export const WithParts = z.object({
info: Info,
parts: z.array(Part),
})
export type WithParts = z.infer<typeof WithParts>
export function fromV1(v1: Message.Info) {
if (v1.role === "assistant") {
const info: Assistant = {
@@ -552,4 +558,10 @@ export namespace MessageV2 {
return convertToModelMessages(result)
}
export function filterSummarized(msgs: { info: MessageV2.Info; parts: MessageV2.Part[] }[]) {
const i = msgs.findLastIndex((m) => m.info.role === "assistant" && !!m.info.summary)
if (i === -1) return msgs.slice()
return msgs.slice(i)
}
}