Skip to content

Commit 24ca5f6

Browse files
authored
fix: recent_activity prompt defaults (#533)
Signed-off-by: phernandez <paul@basicmachines.co>
1 parent f1d50c2 commit 24ca5f6

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

src/basic_memory/mcp/prompts/recent_activity.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ async def recent_activity_prompt(
4242
Returns:
4343
Formatted summary of recent activity
4444
"""
45+
timeframe = timeframe or "7d"
4546
logger.info(f"Getting recent activity, timeframe: {timeframe}, project: {project}")
4647

4748
# Call the tool function - it returns a well-formatted string
48-
# Pass type as string values (not enum) to match the tool's expected input
49-
activity_summary = await recent_activity.fn(project=project, timeframe=timeframe, type="entity")
49+
activity_summary = await recent_activity.fn(project=project, timeframe=timeframe)
5050

5151
# Build the prompt response
5252
# The tool already returns formatted markdown, so we use it directly

tests/mcp/test_recent_activity_prompt_modes.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,21 @@ async def fake_fn(**kwargs):
8888

8989
assert captured_kwargs["timeframe"] == "2d"
9090
assert captured_kwargs["project"] == "test-proj"
91-
assert captured_kwargs["type"] == "entity"
91+
assert "type" not in captured_kwargs
92+
93+
94+
@pytest.mark.asyncio
95+
async def test_recent_activity_prompt_defaults_timeframe(monkeypatch):
96+
"""Prompt should fall back to 7d when timeframe omitted or falsy."""
97+
captured_kwargs = {}
98+
99+
async def fake_fn(**kwargs):
100+
captured_kwargs.update(kwargs)
101+
return "## Recent Activity"
102+
103+
monkeypatch.setattr("basic_memory.mcp.prompts.recent_activity.recent_activity.fn", fake_fn)
104+
105+
await recent_activity_prompt.fn(timeframe=None, project=None) # pyright: ignore[reportGeneralTypeIssues]
106+
107+
assert captured_kwargs["timeframe"] == "7d"
108+
assert captured_kwargs["project"] is None

0 commit comments

Comments
 (0)