Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
feat(memory): enable idle auto compact by default
chengyongru4c5e340186f5
diff --git a/docs/configuration.md b/docs/configuration.mdindex d34a6cd30..503972130 100644--- a/docs/configuration.md+++ b/docs/configuration.md@@ -1865,7 +1865,7 @@ When a user is idle for longer than a configured threshold, nanobot **proactivel| Option | Default | Description ||--------|---------|-------------|-| `agents.defaults.idleCompactAfterMinutes` | `0` (disabled) | Minutes of idle time before auto-compaction starts. Set to `0` to disable. Recommended: `15` — close to a typical LLM KV cache expiry window, so stale sessions get compacted before the user returns. |+| `agents.defaults.idleCompactAfterMinutes` | `15` | Minutes of idle time before auto-compaction starts. Set to `0` to disable. The default is close to a typical LLM KV cache expiry window, so stale sessions get compacted before the user returns. |`sessionTtlMinutes` remains accepted as a legacy alias for backward compatibility, but `idleCompactAfterMinutes` is the preferred config key going forward.@@ -1880,7 +1880,7 @@ How it works:>> Concretely, auto compact rewrites `sessions/<key>.jsonl` in place: older messages (including their structured `tool_calls` / `tool_call_id` / `reasoning_content`) are replaced by just the retained recent suffix (currently 8 messages), while the archived prefix is preserved only as a plain-text summary appended to `memory/history.jsonl` (or a `[RAW] ...` flattened dump if LLM summarization fails). The original structured JSON of those turns is no longer recoverable from the session file.>-> This differs from the **token-driven soft consolidation** that fires when a prompt exceeds the context budget: that path only advances an internal `last_consolidated` cursor and leaves the session file untouched, so the raw tool-call trail stays on disk and can still be replayed or audited. If you rely on that trail for debugging or auditing, leave `idleCompactAfterMinutes` at the default `0` and let only the token-driven path run.+> This differs from the **token-driven soft consolidation** that fires when a prompt exceeds the context budget: that path only advances an internal `last_consolidated` cursor and leaves the session file untouched, so the raw tool-call trail stays on disk and can still be replayed or audited. If you rely on that trail for debugging or auditing, set `idleCompactAfterMinutes` to `0` and let only the token-driven path run.## Timezonediff --git a/nanobot/config/schema.py b/nanobot/config/schema.pyindex bc0b13491..9980d3094 100644--- a/nanobot/config/schema.py+++ b/nanobot/config/schema.py@@ -145,7 +145,7 @@ class AgentDefaults(Base):unified_session: bool = False # Share one session across all channels (single-user multi-device)disabled_skills: list[str] = Field(default_factory=list) # Skill names to exclude from loading (e.g. ["summarize", "skill-creator"])session_ttl_minutes: int = Field(- default=0,+ default=15,ge=0,validation_alias=AliasChoices("idleCompactAfterMinutes", "sessionTtlMinutes"),serialization_alias="idleCompactAfterMinutes",diff --git a/tests/agent/test_auto_compact.py b/tests/agent/test_auto_compact.pyindex e6293ebed..398cbc95f 100644--- a/tests/agent/test_auto_compact.py+++ b/tests/agent/test_auto_compact.py@@ -151,9 +151,14 @@ async def _drain_background_tasks(loop: AgentLoop) -> None:class TestSessionTTLConfig:"""Test session TTL configuration."""- def test_default_ttl_is_zero(self):- """Default TTL should be 0 (disabled)."""+ def test_default_ttl_is_fifteen_minutes(self):+ """Default TTL should proactively compact stale sessions."""defaults = AgentDefaults()+ assert defaults.session_ttl_minutes == 15++ def test_explicit_zero_disables_ttl(self):+ """Explicit 0 should still disable idle auto-compact."""+ defaults = AgentDefaults(session_ttl_minutes=0)assert defaults.session_ttl_minutes == 0def test_custom_ttl(self):