fix: modify recent_activity args to be strings instead of enums · basicmachines-co/basic-memory@3c1cc34 · GitHub
Skip to content

Commit 3c1cc34

Browse files
committed
fix: modify recent_activity args to be strings instead of enums
Signed-off-by: phernandez <paul@basicmachines.co>
1 parent 81616ab commit 3c1cc34

3 files changed

Lines changed: 148 additions & 66 deletions

File tree

src/basic_memory/mcp/tools/recent_activity.py

Lines changed: 37 additions & 15 deletions
Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@
55

66
from mcp.server.fastmcp.exceptions import ToolError
77

8-
from basic_memory.mcp.tools import build_context, recent_activity
8+
from basic_memory.mcp.tools import build_context
99
from basic_memory.schemas.memory import (
1010
GraphContext,
11-
EntitySummary,
12-
ObservationSummary,
13-
RelationSummary,
1411
)
1512

1613

@@ -83,53 +80,6 @@ async def test_get_discussion_context_not_found(client):
8380
]
8481

8582

86-
@pytest.mark.asyncio
87-
async def test_recent_activity_timeframe_formats(client, test_graph):
88-
"""Test that recent_activity accepts various timeframe formats."""
89-
# Test each valid timeframe
90-
for timeframe in valid_timeframes:
91-
try:
92-
result = await recent_activity(
93-
type=["entity"], timeframe=timeframe, page=1, page_size=10, max_related=10
94-
)
95-
assert result is not None
96-
except Exception as e:
97-
pytest.fail(f"Failed with valid timeframe '{timeframe}': {str(e)}")
98-
99-
# Test invalid timeframes should raise ValidationError
100-
for timeframe in invalid_timeframes:
101-
with pytest.raises(ToolError):
102-
await recent_activity(timeframe=timeframe)
103-
104-
105-
@pytest.mark.asyncio
106-
async def test_recent_activity_type_filters(client, test_graph):
107-
"""Test that recent_activity correctly filters by types."""
108-
# Test single type
109-
result = await recent_activity(type=["entity"])
110-
assert result is not None
111-
assert all(isinstance(r, EntitySummary) for r in result.primary_results)
112-
113-
# Test multiple types
114-
result = await recent_activity(type=["entity", "observation"])
115-
assert result is not None
116-
assert all(
117-
isinstance(r, EntitySummary) or isinstance(r, ObservationSummary)
118-
for r in result.primary_results
119-
)
120-
121-
# Test all types
122-
result = await recent_activity(type=["entity", "observation", "relation"])
123-
assert result is not None
124-
# Results can be any type
125-
assert all(
126-
isinstance(r, EntitySummary)
127-
or isinstance(r, ObservationSummary)
128-
or isinstance(r, RelationSummary)
129-
for r in result.primary_results
130-
)
131-
132-
13383
@pytest.mark.asyncio
13484
async def test_build_context_timeframe_formats(client, test_graph):
13585
"""Test that build_context accepts various timeframe formats."""
Lines changed: 110 additions & 0 deletions

0 commit comments

Comments
 (0)