fix(agent): do not persist runtime context metadata in session history
This commit is contained in:
@@ -467,6 +467,14 @@ class AgentLoop:
|
|||||||
content = entry["content"]
|
content = entry["content"]
|
||||||
if len(content) > self._TOOL_RESULT_MAX_CHARS:
|
if len(content) > self._TOOL_RESULT_MAX_CHARS:
|
||||||
entry["content"] = content[:self._TOOL_RESULT_MAX_CHARS] + "\n... (truncated)"
|
entry["content"] = content[:self._TOOL_RESULT_MAX_CHARS] + "\n... (truncated)"
|
||||||
|
if (
|
||||||
|
entry.get("role") == "user"
|
||||||
|
and isinstance(entry.get("content"), str)
|
||||||
|
and entry["content"].startswith(ContextBuilder._RUNTIME_CONTEXT_TAG)
|
||||||
|
):
|
||||||
|
# Runtime metadata is injected per-turn for model context only; do not persist it
|
||||||
|
# into long-lived session history to avoid semantic drift and repetitive replies.
|
||||||
|
continue
|
||||||
if entry.get("role") == "user" and isinstance(entry.get("content"), list):
|
if entry.get("role") == "user" and isinstance(entry.get("content"), list):
|
||||||
entry["content"] = [
|
entry["content"] = [
|
||||||
{"type": "text", "text": "[image]"} if (
|
{"type": "text", "text": "[image]"} if (
|
||||||
|
|||||||
Reference in New Issue
Block a user