diff --git a/src/basic_memory/mcp/tools/recent_activity.py b/src/basic_memory/mcp/tools/recent_activity.py index 2de3a80f..a09cb221 100644 --- a/src/basic_memory/mcp/tools/recent_activity.py +++ b/src/basic_memory/mcp/tools/recent_activity.py @@ -495,7 +495,7 @@ def _format_project_output( # Show entities (notes/documents) if entities: lines.append(f"\n**📄 Recent Notes & Documents ({len(entities)}):**") - for entity in entities[:5]: # Show top 5 + for entity in entities: title = entity.title or "Untitled" # Get folder from file_path folder = "" @@ -510,7 +510,7 @@ def _format_project_output( lines.append(f"\n**🔍 Recent Observations ({len(observations)}):**") # Group by category by_category = {} - for obs in observations[:10]: # Limit to recent ones + for obs in observations: category = obs.category if category not in by_category: by_category[category] = [] @@ -528,7 +528,7 @@ def _format_project_output( # Show relations (connections) if relations: lines.append(f"\n**🔗 Recent Connections ({len(relations)}):**") - for rel in relations[:5]: # Show top 5 + for rel in relations: rel_type = rel.relation_type from_entity = rel.from_entity or "Unknown" to_entity = rel.to_entity diff --git a/tests/mcp/test_tool_recent_activity.py b/tests/mcp/test_tool_recent_activity.py index 630de849..fbd9c944 100644 --- a/tests/mcp/test_tool_recent_activity.py +++ b/tests/mcp/test_tool_recent_activity.py @@ -534,3 +534,54 @@ def test_format_project_output_no_more_pages(): ) assert "1 items found." in out assert "Use page=" not in out + + +def test_format_project_output_shows_all_entities_beyond_five(): + """Formatter must not cap entity or relation display at 5 regardless of page_size. + + Regression test for: https://github.com/basicmachines-co/basic-memory/issues/784 + The API already paginates by page_size; the formatter should not impose a lower cap. + """ + import importlib + import uuid + + recent_activity_module = importlib.import_module("basic_memory.mcp.tools.recent_activity") + + now = datetime.now(timezone.utc) + + def make_entity(idx: int) -> ContextResult: + return ContextResult( + primary_result=EntitySummary( + external_id=str(uuid.uuid4()), + entity_id=idx, + permalink=f"notes/note-{idx:02d}", + title=f"Note {idx:02d}", + content=None, + file_path=f"notes/note-{idx:02d}.md", + created_at=now, + ), + observations=[], + related_results=[], + ) + + # Build 9 entity results — more than the old hardcoded cap of 5 + results = [make_entity(i) for i in range(1, 10)] + activity = GraphContext( + results=results, + metadata=MemoryMetadata(depth=1, generated_at=now), + has_more=False, + ) + + out = recent_activity_module._format_project_output( + project_name="proj", + activity_data=activity, + timeframe="today", + type_filter="entity", + page=1, + ) + + # All 9 titles must appear in the output + for i in range(1, 10): + assert f"Note {i:02d}" in out, f"Note {i:02d} missing from output" + + assert "9 items found." in out