From 007a8fede54e31e26c96e36bc77aab83d9754956 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Thu, 16 Apr 2026 23:00:18 -0400 Subject: [PATCH] docs(session): explain MAX_HANDOFF_LENGTH/MAX_HANDOFF_RUNS constants --- src/main/session-management-service.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/session-management-service.ts b/src/main/session-management-service.ts index 78125f43..7790c6b4 100644 --- a/src/main/session-management-service.ts +++ b/src/main/session-management-service.ts @@ -17,8 +17,12 @@ export const DEFAULT_THRESHOLDS = { // D-01: Type for per-adapter or company-level threshold overrides export type RotationThresholds = Partial; -// D-04: Handoff size cap to prevent prompt bloat +// D-04: Handoff size cap to prevent prompt bloat. +// 2000 characters ≈ 500 tokens — enough to resume context without crowding +// out the system prompt + user message in an 8k-ish model window. const MAX_HANDOFF_LENGTH = 2000; +// 5 runs of resume context is typically enough to bridge a rotation boundary; +// older runs add diminishing value relative to the token cost. const MAX_HANDOFF_RUNS = 5; export function createSessionManagementService({ db, logger }: SessionManagementDependencies) {