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 "".
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user