From 8ead740fa1e1eb1f1cc4a56445cfc206497c43c8 Mon Sep 17 00:00:00 2001 From: phernandez Date: Sat, 31 Jan 2026 20:15:20 -0600 Subject: [PATCH] fix: align recent activity prompt defaults Signed-off-by: phernandez --- .../mcp/prompts/recent_activity.py | 4 ++-- .../mcp/test_recent_activity_prompt_modes.py | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/basic_memory/mcp/prompts/recent_activity.py b/src/basic_memory/mcp/prompts/recent_activity.py index 10a07f7a..3daa50e9 100644 --- a/src/basic_memory/mcp/prompts/recent_activity.py +++ b/src/basic_memory/mcp/prompts/recent_activity.py @@ -42,11 +42,11 @@ async def recent_activity_prompt( Returns: Formatted summary of recent activity """ + timeframe = timeframe or "7d" logger.info(f"Getting recent activity, timeframe: {timeframe}, project: {project}") # Call the tool function - it returns a well-formatted string - # Pass type as string values (not enum) to match the tool's expected input - activity_summary = await recent_activity.fn(project=project, timeframe=timeframe, type="entity") + activity_summary = await recent_activity.fn(project=project, timeframe=timeframe) # Build the prompt response # The tool already returns formatted markdown, so we use it directly diff --git a/tests/mcp/test_recent_activity_prompt_modes.py b/tests/mcp/test_recent_activity_prompt_modes.py index 8d200186..44dcec00 100644 --- a/tests/mcp/test_recent_activity_prompt_modes.py +++ b/tests/mcp/test_recent_activity_prompt_modes.py @@ -88,4 +88,21 @@ async def fake_fn(**kwargs): assert captured_kwargs["timeframe"] == "2d" assert captured_kwargs["project"] == "test-proj" - assert captured_kwargs["type"] == "entity" + assert "type" not in captured_kwargs + + +@pytest.mark.asyncio +async def test_recent_activity_prompt_defaults_timeframe(monkeypatch): + """Prompt should fall back to 7d when timeframe omitted or falsy.""" + captured_kwargs = {} + + async def fake_fn(**kwargs): + captured_kwargs.update(kwargs) + return "## Recent Activity" + + monkeypatch.setattr("basic_memory.mcp.prompts.recent_activity.recent_activity.fn", fake_fn) + + await recent_activity_prompt.fn(timeframe=None, project=None) # pyright: ignore[reportGeneralTypeIssues] + + assert captured_kwargs["timeframe"] == "7d" + assert captured_kwargs["project"] is None