Skip to content

Your lightweight open-source personal agent.

fix(agent): do not persist runtime context metadata in session history

Kim45ae410f0517
diff --git a/nanobot/agent/loop.py b/nanobot/agent/loop.py
index 3e513cb92..eb34b312c 100644
--- a/nanobot/agent/loop.py
+++ b/nanobot/agent/loop.py
@@ -467,6 +467,14 @@ class AgentLoop:
content = entry["content"]
if len(content) > self._TOOL_RESULT_MAX_CHARS:
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):
entry["content"] = [
{"type": "text", "text": "[image]"} if (