fix: salvage batch — compaction guidance, memory authority, cache eviction after compression

- Fix /compact → /compress in context-overflow tips (closes #20020)
- Evict cached agent after session hygiene and /compress so system
  prompt refreshes with current SOUL.md, memory, and skills
- Restore memory authority across compaction: change 'informational
  background data' to 'authoritative reference data' in memory block
  and SUMMARY_PREFIX, with backward-compatible regex

Based on:
- PR #20027 by @LeonSGP43
- PR #18767 by @MacroAnarchy
- PR #17380 by @vominh1919

PR #17121 boundary marker fix already merged to main (2eef395e1).
PR #9262 user-message anchoring already on main via _ensure_last_user_message_in_tail().
This commit is contained in:
kshitijk4poor 2026-05-06 11:02:50 +05:30 committed by kshitij
parent f27fcb6a82
commit aa88dcc57b
4 changed files with 16 additions and 3 deletions

View file

@ -6322,6 +6322,10 @@ class GatewayRunner:
_werr,
)
finally:
# Evict the cached agent so the next turn
# rebuilds its system prompt from current
# SOUL.md, memory, and skills.
self._evict_cached_agent(session_key)
self._cleanup_agent_resources(_hyg_agent)
except Exception as e:
@ -9505,6 +9509,9 @@ class GatewayRunner:
_aux_fail_model = getattr(compressor, "_last_aux_model_failure_model", None)
_aux_fail_err = getattr(compressor, "_last_aux_model_failure_error", None)
finally:
# Evict cached agent so next turn rebuilds system prompt
# from current files (SOUL.md, memory, etc.).
self._evict_cached_agent(session_key)
self._cleanup_agent_resources(tmp_agent)
lines = [f"🗜️ {summary['headline']}"]
if focus_topic: