diff --git a/nanobot/agent/autocompact.py b/nanobot/agent/autocompact.py index 71cf262ff..3181dce74 100644 --- a/nanobot/agent/autocompact.py +++ b/nanobot/agent/autocompact.py @@ -102,11 +102,7 @@ class AutoCompact: finally: self._archiving.discard(key) - def prepare_session( - self, - session: Session, - key: str, - ) -> tuple[Session, SessionSummary | None]: + def prepare_session(self, session: Session, key: str) -> tuple[Session, SessionSummary | None]: if self._is_internal_session(key): self._archiving.discard(key) self._summaries.pop(key, None) diff --git a/tests/agent/test_autocompact_unit.py b/tests/agent/test_autocompact_unit.py index e33e903d9..7ceefcf7e 100644 --- a/tests/agent/test_autocompact_unit.py +++ b/tests/agent/test_autocompact_unit.py @@ -686,10 +686,7 @@ class TestPrepareSession: ac.sessions = mock_sm key = "dream:20260602-155256" ac._archiving.add(key) - ac._summaries[key] = SessionSummary( - "Hot summary.", - datetime(2026, 6, 2, 15, 52, 56), - ) + ac._summaries[key] = SessionSummary("Hot summary.", datetime(2026, 6, 2, 15, 52, 56)) session = _make_session( key=key, updated_at=datetime.now() - timedelta(minutes=20), diff --git a/tests/agent/test_context_builder.py b/tests/agent/test_context_builder.py index 333f990b5..d30a4941d 100644 --- a/tests/agent/test_context_builder.py +++ b/tests/agent/test_context_builder.py @@ -332,24 +332,16 @@ class TestBuildSystemPrompt: def test_includes_session_summary(self, tmp_path): builder = _builder(tmp_path) - result = builder.build_system_prompt( - session_summary=SessionSummary( - text="Previous chat about Python.", - last_active=datetime(2026, 8, 19, 10, 0), - ) - ) + summary = SessionSummary("Previous chat about Python.", datetime(2026, 8, 19, 10, 0)) + result = builder.build_system_prompt(session_summary=summary) assert "Previous chat about Python." in result assert "[Archived Context Summary]" in result def test_sections_separated_by_separator(self, tmp_path): (tmp_path / "AGENTS.md").write_text("Rules.", encoding="utf-8") builder = _builder(tmp_path) - result = builder.build_system_prompt( - session_summary=SessionSummary( - text="Summary.", - last_active=datetime(2026, 8, 19, 10, 0), - ) - ) + summary = SessionSummary("Summary.", datetime(2026, 8, 19, 10, 0)) + result = builder.build_system_prompt(session_summary=summary) assert "\n\n---\n\n" in result def test_no_bootstrap_no_summary(self, tmp_path): diff --git a/tests/agent/test_context_prompt_cache.py b/tests/agent/test_context_prompt_cache.py index c07f51e84..39dc8fb1b 100644 --- a/tests/agent/test_context_prompt_cache.py +++ b/tests/agent/test_context_prompt_cache.py @@ -121,10 +121,7 @@ def test_session_summary_replaces_matching_recent_history_entry(tmp_path) -> Non builder.memory.append_history("another session event", session_key=session_key) summary_cursor = builder.memory.append_history(overview, session_key=session_key) - summary = SessionSummary( - text=overview, - last_active=real_datetime(2026, 8, 19, 10, 0), - ) + summary = SessionSummary(overview, real_datetime(2026, 8, 19, 10, 0)) prompt = builder.build_system_prompt( session_key=session_key, diff --git a/tests/agent/test_loop_consolidation_tokens.py b/tests/agent/test_loop_consolidation_tokens.py index b5549351d..d0685f83d 100644 --- a/tests/agent/test_loop_consolidation_tokens.py +++ b/tests/agent/test_loop_consolidation_tokens.py @@ -213,13 +213,7 @@ async def test_preflight_consolidation_receives_pending_summary(tmp_path) -> Non loop = _make_loop(tmp_path, estimated_tokens=100, context_window_tokens=200) session = loop.sessions.get_or_create("cli:test") loop.auto_compact.prepare_session = MagicMock( - return_value=( - session, - SessionSummary( - text="earlier context", - last_active=session.updated_at, - ), - ) + return_value=(session, SessionSummary("earlier context", session.updated_at)) ) # type: ignore[method-assign] loop.consolidator.maybe_consolidate_by_tokens = AsyncMock(return_value=None) # type: ignore[method-assign] loop.schedule_background = lambda coro: coro.close() # type: ignore[method-assign]