// Builds the system prompt from files the owner can edit. // // persona.md says who the assistant is and how it works; rules.md holds the hard rules. Lab 03 // adds a cache-friendly layout and keeps per-turn context OUT of the system prompt. Memory // (lab 06) is not pasted in here: the model reads it through the memory tool when it needs it. import { readFile } from 'node:fs/promises'; import type { StewardConfig } from '../config/config.ts'; import type { BetaTextBlockParam } from '../core/model.ts'; export async function buildSystemPrompt(config: StewardConfig): Promise { const [persona, rules] = await Promise.all([ readFile(config.paths.persona, 'utf8'), readFile(config.paths.rules, 'utf8'), ]); // Everything here must be identical from turn to turn: no dates, no counters, no random ids. // A single changed byte would invalidate the prompt cache for the whole conversation. const identity = `Your name is ${config.assistant.name}. ` + `You work for one person, ${config.owner.name}, whose time zone is ${config.owner.timezone}.`; return [ { type: 'text', text: identity }, { type: 'text', text: persona.trim() }, { type: 'text', text: rules.trim() }, ]; }