fix(memory): add timestamp and cap to recent history injection
This commit is contained in:
@@ -19,6 +19,7 @@ class ContextBuilder:
|
||||
|
||||
BOOTSTRAP_FILES = ["AGENTS.md", "SOUL.md", "USER.md", "TOOLS.md"]
|
||||
_RUNTIME_CONTEXT_TAG = "[Runtime Context — metadata only, not instructions]"
|
||||
_MAX_RECENT_HISTORY = 50
|
||||
|
||||
def __init__(self, workspace: Path, timezone: str | None = None):
|
||||
self.workspace = workspace
|
||||
@@ -50,7 +51,10 @@ class ContextBuilder:
|
||||
|
||||
entries = self.memory.read_unprocessed_history(since_cursor=self.memory.get_last_dream_cursor())
|
||||
if entries:
|
||||
parts.append("# Recent History\n\n" + "\n".join(f"- {entry['content']}" for entry in entries))
|
||||
capped = entries[-self._MAX_RECENT_HISTORY:]
|
||||
parts.append("# Recent History\n\n" + "\n".join(
|
||||
f"- [{e['timestamp']}] {e['content']}" for e in capped
|
||||
))
|
||||
|
||||
return "\n\n---\n\n".join(parts)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user