diff --git a/agent/deferred.go b/agent/deferred.go index d846b6e2..b21f1c0c 100644 --- a/agent/deferred.go +++ b/agent/deferred.go @@ -16,13 +16,16 @@ import ( // placed as the LAST system-prompt segment, with DynamicBoundary set so the whole // (session-fixed) system prompt โ€” including the block โ€” is cached (design doc // ยง2.1 / C1). Skill-gated MCP names are NOT in this block; they surface when their -// skill loads. Returns a single plain segment + boundary 0 when there is no global -// block to add. +// skill loads. With no global block the system prompt is the single session-fixed +// segment; boundary 1 (== len) keeps it cacheable instead of disabling the cache +// breakpoint entirely (#809: planner/mainagent/chat rebilled the whole prompt +// every round on instances without global MCP servers). func deferredSystem(sysText string, def DeferredInfo) (system []string, boundary int) { sysText += def.FindingGuidance + def.SkillIndex block := actool.RenderDeferredToolsBlock(def.GlobalNames) if block == "" { - return []string{sysText}, 0 + s := []string{sysText} + return s, len(s) } system = []string{sysText, block} boundary = len(system) // b >= len โ†’ whole system prompt cached (SDK guard)