From df8fd0267da17d78ebd94476bc045c07a77c8bcb Mon Sep 17 00:00:00 2001 From: simple-minded <191973953+hakarrr@users.noreply.github.com> Date: Wed, 2 Dec 2026 18:25:40 +0530 Subject: [PATCH] fix(agent): keep the no-MCP system prompt cacheable Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com> --- agent/deferred.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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)