fix(compression): hygiene and gateway /compress keep the seeded system prompt

Gateway hygiene and the gateway /compress handler compact with a detached
AIAgent(enabled_toolsets=["memory"]) seeded with the session's stored prompt
(_seed_hygiene_system_prompt, 76a17046e2 / 678916b427). Since #98426 the
commit boundary always rebuilds the prompt, so the seed was discarded and the
reduced-toolset build was persisted over the live session's snapshot: the
skills index (## Skills (mandatory) / <available_skills>) and Skill Safety
Rule vanish, and every later fresh agent for that session restores the
degraded bytes verbatim (_stored_prompt_matches_runtime does not compare
platform).

The seed now marks the agent (_retain_seeded_system_prompt) and the
commit-boundary rebuild keeps the seeded bytes for it. A live agent's own
compaction still rebuilds, so builder updates keep reaching long sessions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit dd5c8ef4e845b2d34e826e4d92afad73a12eefa6)
This commit is contained in:
Regina
2026-09-25 19:09:09 +03:00
committed by kshitij
parent 4575597a3e
commit 556b8427b7
3 changed files with 77 additions and 0 deletions

View File

@@ -509,6 +509,8 @@ def _seed_hygiene_system_prompt(agent: Any, session_row: Optional[Dict[str, Any]
stored_prompt = raw_prompt
agent._cached_system_prompt = stored_prompt
# Compaction otherwise rebuilds the prompt at the commit boundary from this agent's reduced toolset.
agent._retain_seeded_system_prompt = True
return bool(stored_prompt)