diff --git a/nanobot/agent/loop.py b/nanobot/agent/loop.py index a66b6fe9..7ddb9bc0 100644 --- a/nanobot/agent/loop.py +++ b/nanobot/agent/loop.py @@ -201,7 +201,7 @@ class AgentLoop: timezone: str | None = None, session_ttl_minutes: int = 0, consolidation_ratio: float = 0.5, - max_messages: int = 120, + max_messages: int = 500, hooks: list[AgentHook] | None = None, unified_session: bool = False, disabled_skills: list[str] | None = None, @@ -292,7 +292,7 @@ class AgentLoop: llm_wall_timeout_for_session=lambda sk: runner_wall_llm_timeout_s(self.sessions, sk), ) self._unified_session = unified_session - self._max_messages = max_messages if max_messages > 0 else 120 + self._max_messages = max_messages if max_messages > 0 else 500 self._running = False self._mcp_servers = mcp_servers or {} self._mcp_stacks: dict[str, AsyncExitStack] = {} diff --git a/nanobot/config/schema.py b/nanobot/config/schema.py index feb2d62e..e6212323 100644 --- a/nanobot/config/schema.py +++ b/nanobot/config/schema.py @@ -155,9 +155,9 @@ class AgentDefaults(Base): serialization_alias="idleCompactAfterMinutes", ) # Auto-compact idle threshold in minutes (0 = disabled) max_messages: int = Field( - default=120, + default=500, ge=0, - ) # Max messages to replay from session history (0 = use default 120, respects token budget) + ) # Last-resort max messages to replay from session history (0 = use default 500) consolidation_ratio: float = Field( default=0.5, ge=0.1, diff --git a/nanobot/session/manager.py b/nanobot/session/manager.py index c4d39446..44e64c96 100644 --- a/nanobot/session/manager.py +++ b/nanobot/session/manager.py @@ -132,7 +132,7 @@ class Session: def get_history( self, - max_messages: int = 120, + max_messages: int = 500, *, max_tokens: int = 0, extend_to_user: bool = False, @@ -143,7 +143,7 @@ class Session: token budget from the tail (``max_tokens``) when provided. """ unconsolidated = self.messages[self.last_consolidated:] - max_messages = max_messages if max_messages > 0 else 120 + max_messages = max_messages if max_messages > 0 else 500 start_idx = recent_message_start_index( unconsolidated, max_messages, diff --git a/tests/agent/test_max_messages_config.py b/tests/agent/test_max_messages_config.py index e7adccec..ff2b48b9 100644 --- a/tests/agent/test_max_messages_config.py +++ b/tests/agent/test_max_messages_config.py @@ -13,7 +13,7 @@ from nanobot.bus.queue import MessageBus from nanobot.providers.base import LLMResponse from nanobot.session.manager import Session -DEFAULT_MAX_MESSAGES = 120 +DEFAULT_MAX_MESSAGES = 500 def _make_loop(tmp_path: Path, max_messages: int = DEFAULT_MAX_MESSAGES) -> AgentLoop: