You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
prepare_messages_context discards the overwrite flag set by the history sanitizer #374
prepare_messages_context (base.py:1054) threads a full_overwrite flag through its steps so that a maintained history is written back to state instead of appended. The sanitizer added in #339 sets that flag whenever it drops something (_sanitize_history, base.py:859), and the _ensure_system_first branch sets it too. The summarization step then assigns rather than combines: new_state, full_overwrite = self._summarize_context(...), and _summarize_context has no incoming flag and returns False whenever it does not summarize (base.py:973, :979, :988, :1001). So the sanitizer's flag survives only when summarization or dangling-tool patching happens to fire on the same turn.
Two consequences follow. First, the request and the stored thread diverge: the sanitizer removes the same messages again on every turn, and the stored thread keeps them. The resumed named ChatAgent in #331 shows the shape: the request is system, human, ai, human while the stored thread still holds the duplicated system prompt. Second, when summarization or dangling patching does fire, the flag is honored and the drops are written into the persistent thread, so whether a persisted history is rewritten depends on an unrelated trigger.
In v0.17.0 the same assignment was harmless because nothing ran before it; #339 added two flag-setting steps in front of it. (Line references are as of current main, 128b811.)
This should land after #372: honoring the flag while the first-turn drop is still in place would write the system-prompt-less history into persistent threads for good.
Whether sanitizer drops should persist at all is your call. The method's docstring and the flag the sanitizer sets say the maintained history is meant to be written back; the alternative is a request-only sanitizer that never sets the flag. Happy to PR either shape.
Activity