fix(agent): keep _serialize_for_summary byte-identical to main
The record split added .rstrip("\n") to every serialized record. That
changes the bytes _serialize_for_summary returns for legacy tail_mode
and for agent/micro_compaction.py's _micro_summarize_one, which never
sample and never needed it: a message with trailing newlines was no
longer reproduced verbatim in the summarizer prompt. Sampling receives
records structurally, so an empty pseudo-record can no longer become the
tail anchor and the strip has no remaining purpose.
This commit is contained in:
@@ -3320,11 +3320,11 @@ class ContextCompressor(SummaryDispatchMixin, MicroCompactionMixin, ContextEngin
|
||||
if len(content) > self._CONTENT_MAX:
|
||||
content = content[:self._CONTENT_HEAD] + "\n...[truncated]...\n" + content[-self._CONTENT_TAIL:]
|
||||
if role == "tool":
|
||||
parts.append(f"[TOOL RESULT {msg.get('tool_call_id', '')}]: {content.rstrip(chr(10))}")
|
||||
parts.append(f"[TOOL RESULT {msg.get('tool_call_id', '')}]: {content}")
|
||||
continue
|
||||
if role == "assistant" and msg.get("tool_calls", []):
|
||||
content += "\n[Tool calls:\n" + "\n".join(map(self._render_tool_call_for_summary, msg["tool_calls"])) + "\n]"
|
||||
parts.append(f"[{role.upper()}]: {content.rstrip(chr(10))}")
|
||||
parts.append(f"[{role.upper()}]: {content}")
|
||||
return parts
|
||||
|
||||
def _serialize_for_summary(self, turns: List[Dict[str, Any]]) -> str:
|
||||
|
||||
Reference in New Issue
Block a user