From e30e61f6ffb49110663c97ffffc1a72a47f5faa1 Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Sat, 26 Sep 2026 21:52:17 +0530 Subject: [PATCH] refactor(compression): return the seeded prompt without re-normalizing it The retain early return coerced agent._cached_system_prompt with `or ""` and wrote it back. The only setter of _retain_seeded_system_prompt, gateway.run._seed_hygiene_system_prompt, always stores a str ("" or the stored prompt) in the same call, and nothing between the seed and the commit boundary resets it on the detached hygiene / manual-compress agent (the only None writers are invalidate_system_prompt, which this branch returns before, and switch_model, which those agents never run). So the normalize/write-back was dead defence; the empty-seed case still returns "". --- agent/conversation_compression.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/agent/conversation_compression.py b/agent/conversation_compression.py index 08e5d124da..ed7c9ce39b 100644 --- a/agent/conversation_compression.py +++ b/agent/conversation_compression.py @@ -3150,12 +3150,10 @@ def _rebuild_system_prompt_at_boundary(agent: Any, system_message: str) -> str: # the next fresh agent). Keep the seeded bytes; the live agent's own compaction propagates updates. # Returning here also deliberately skips _refresh_agent_tool_definitions: its MCP refresh persists # the agent's tool names, which would overwrite the session's saved tools[] with the memory-only set. - seeded_system_prompt = agent._cached_system_prompt or "" - agent._cached_system_prompt = seeded_system_prompt - if seeded_system_prompt: + if agent._cached_system_prompt: from agent.system_prompt import reconstruct_static_prefix reconstruct_static_prefix(agent, system_message=system_message, log_label="compression seeded-prompt") - return seeded_system_prompt + return agent._cached_system_prompt cached_system_prompt = agent._cached_system_prompt agent._invalidate_system_prompt()