mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-06-03 19:25:19 +02:00
Persist per-message context for prompt caching
Move volatile current time and middle-pane data out of the system prompt and into a hidden userMessageContext stored on each user message. Reconstruct the LLM-facing message from this persisted context so older conversation turns remain stable across later requests while UI-facing content stays unchanged. Keep finite branch instructions such as voice, search, code mode, agent notes, and workdir behavior in the system prompt so each conversation can still benefit from reusable prompt-cache prefixes.
This commit is contained in:
parent
c213274723
commit
129d91dc8d
2 changed files with 129 additions and 31 deletions
|
|
@ -50,9 +50,29 @@ export const UserContentPart = z.union([UserTextPart, UserAttachmentPart]);
|
|||
// Named type for user message content — used everywhere instead of repeating the union
|
||||
export const UserMessageContent = z.union([z.string(), z.array(UserContentPart)]);
|
||||
|
||||
export const UserMessageContext = z.object({
|
||||
currentDateTime: z.string().optional(),
|
||||
middlePane: z.discriminatedUnion("kind", [
|
||||
z.object({
|
||||
kind: z.literal("empty"),
|
||||
}),
|
||||
z.object({
|
||||
kind: z.literal("note"),
|
||||
path: z.string(),
|
||||
content: z.string(),
|
||||
}),
|
||||
z.object({
|
||||
kind: z.literal("browser"),
|
||||
url: z.string(),
|
||||
title: z.string(),
|
||||
}),
|
||||
]).optional(),
|
||||
});
|
||||
|
||||
export const UserMessage = z.object({
|
||||
role: z.literal("user"),
|
||||
content: UserMessageContent,
|
||||
userMessageContext: UserMessageContext.optional(),
|
||||
providerOptions: ProviderOptions.optional(),
|
||||
});
|
||||
|
||||
|
|
@ -86,4 +106,4 @@ export const Message = z.discriminatedUnion("role", [
|
|||
UserMessage,
|
||||
]);
|
||||
|
||||
export const MessageList = z.array(Message);
|
||||
export const MessageList = z.array(Message);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue