mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 21:32:18 +00:00
fix(coach): drop unused version constants, cap stored summary length
Remove the two never-wired *_PROMPT_VERSION exports the dead-code gate flagged, and consume the summary-length target as a real backstop that caps the stored rolling summary so a misbehaving provider can't bloat the encrypted column or the next prompt's history window. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
9b2b137a6c
commit
7030266220
2 files changed
+12
-10
No files matched your search
@@ -33,13 +33,11 @@ import {
|
||||
import { decryptFromBytes, encryptToBytes } from "./bytes-codec";
|
||||
|
||||
/**
|
||||
* Stable identifier for the summary prompt revision. Bumped whenever the
|
||||
* prompt below changes so quality can be sliced per (provider × prompt).
|
||||
* Safety cap on the stored summary length (~150 tokens). The prompt asks for
|
||||
* a short paragraph; this backstops a misbehaving provider so the encrypted
|
||||
* column + the next prompt's history window stay bounded.
|
||||
*/
|
||||
export const SUMMARY_PROMPT_VERSION = "1.11.1" as const;
|
||||
|
||||
/** Target prose length for the rolling summary (~150 tokens). */
|
||||
export const SUMMARY_TARGET_CHARS = 600;
|
||||
const SUMMARY_TARGET_CHARS = 600;
|
||||
|
||||
/** Re-summarise only once at least this many new turns accumulate. */
|
||||
export const SUMMARY_REFRESH_TURN_DELTA = 6;
|
||||
@@ -204,10 +202,16 @@ export async function refreshConversationSummary(
|
||||
return { status: "skipped" };
|
||||
}
|
||||
|
||||
const text = completion.content.trim();
|
||||
if (text.length === 0) {
|
||||
const trimmed = completion.content.trim();
|
||||
if (trimmed.length === 0) {
|
||||
return { status: "skipped" };
|
||||
}
|
||||
// Backstop the stored length even if the provider over-ran the prompt's
|
||||
// "short paragraph" instruction.
|
||||
const text =
|
||||
trimmed.length > SUMMARY_TARGET_CHARS
|
||||
? trimmed.slice(0, SUMMARY_TARGET_CHARS)
|
||||
: trimmed;
|
||||
|
||||
// 6. Encrypt + persist. Field-by-field data object (no spread).
|
||||
const summaryEncrypted = encryptToBytes(text);
|
||||
|
||||
@@ -44,8 +44,6 @@ export const COACH_FACT_CATEGORIES = [
|
||||
|
||||
export type CoachFactCategory = (typeof COACH_FACT_CATEGORIES)[number];
|
||||
|
||||
/** Background-prompt attribution version (separate from interactive `PROMPT_VERSION`). */
|
||||
export const FACTS_PROMPT_VERSION = "1.11.1";
|
||||
/** Hard cap on active facts per user; at cap, only strictly-higher-confidence facts displace. */
|
||||
export const MAX_FACTS_PER_USER = 50;
|
||||
/** Per-fact text length cap (mirrors the Zod gate + the prompt instruction). */
|
||||
|
||||
Reference in new issue
Block a user