From d225ea4bd5f95d39a910704fe45acdf847c953fa Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Wed, 24 Jun 2026 00:08:47 +0900 Subject: feat(system-prompt): wire into turn flow + compaction + API routes session-orchestrator: - Wire systemPromptService as optional dep (lazy via host.getService) - Regular turn: construct on first turn (new conversation), get on subsequent turns, set on providerOpts.systemPrompt (cache-safe) - Compaction: construct (fresh resolve) + append COMPACTION_SYSTEM_PROMPT - 12 new tests (construct/get/service-unavailable/compaction) transport-http: - GET /system-prompt (returns template or DEFAULT_TEMPLATE) - PUT /system-prompt (validate + setTemplate, 503 when unavailable) - GET /system-prompt/variables (static catalog, always available) - 6 new tests system-prompt service: added getTemplate/setTemplate to interface + impl. 1396 vitest pass. typecheck + biome clean. --- packages/system-prompt/src/service.ts | 9 +++++++++ packages/system-prompt/src/types.ts | 6 ++++++ 2 files changed, 15 insertions(+) (limited to 'packages/system-prompt') diff --git a/packages/system-prompt/src/service.ts b/packages/system-prompt/src/service.ts index 45645b9..4b4436f 100644 --- a/packages/system-prompt/src/service.ts +++ b/packages/system-prompt/src/service.ts @@ -63,5 +63,14 @@ export function createSystemPromptService(deps: SystemPromptServiceDeps): System async get(conversationId) { return deps.storage.get(resolvedKey(conversationId)); }, + + async getTemplate() { + const stored = await deps.storage.get(TEMPLATE_KEY); + return stored ?? DEFAULT_TEMPLATE; + }, + + async setTemplate(template) { + await deps.storage.set(TEMPLATE_KEY, template); + }, }; } diff --git a/packages/system-prompt/src/types.ts b/packages/system-prompt/src/types.ts index 9e87512..dd6aa69 100644 --- a/packages/system-prompt/src/types.ts +++ b/packages/system-prompt/src/types.ts @@ -29,6 +29,12 @@ export interface SystemPromptService { /** Read the persisted resolved system prompt, or `null` if never constructed. */ get(conversationId: string): Promise; + + /** Read the global template (or `DEFAULT_TEMPLATE` when none is stored). */ + getTemplate(): Promise; + + /** Set (upsert) the global template. An empty string means "no system prompt". */ + setTemplate(template: string): Promise; } /** -- cgit v1.2.3