feat(agent): auto compact — proactive session compression to reduce token cost and latency (#2982)
When a user is idle for longer than a configured TTL, nanobot **proactively** compresses the session context into a summary. This reduces token cost and first-token latency when the user returns — instead of re-processing a long stale context with an expired KV cache, the model receives a compact summary and fresh input.
This commit is contained in:
1 parent
e392c27f7e
commit
fb6dd111e1
10 files changed
+1091
-7
No files matched your search
@@ -374,6 +374,10 @@ class Consolidator:
|
||||
weakref.WeakValueDictionary()
|
||||
)
|
||||
|
||||
def get_last_history_entry(self) -> dict[str, Any] | None:
|
||||
"""Return the most recent entry from history.jsonl."""
|
||||
return self.store._read_last_entry()
|
||||
|
||||
def get_lock(self, session_key: str) -> asyncio.Lock:
|
||||
"""Return the shared consolidation lock for one session."""
|
||||
return self._locks.setdefault(session_key, asyncio.Lock())
|
||||
|
||||
Reference in new issue
Block a user