diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c4fdb72..8bc39fef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Added - **Chat Agent Document Awareness Tools**: Two new tools for browsing and understanding the knowledge base - - `list_documents` — Browse available documents with title, URI, and creation date; respects session document filter; paginated with total count + - `list_documents` — Returns `DocumentListResponse` with paginated documents (50 per page), page number, total pages, and total count; respects session document filter - `summarize_document` — Generate LLM-powered summaries of specific documents - **Document Count API**: New `count_documents(filter)` method on `HaikuRAG` client for efficient document counting - **Read-Only Initial Context**: Initial context is now locked after the first message, providing consistent session context diff --git a/tests/agents/chat/test_chat_agent.py b/tests/agents/chat/test_chat_agent.py index 407ba901..98d1e30f 100644 --- a/tests/agents/chat/test_chat_agent.py +++ b/tests/agents/chat/test_chat_agent.py @@ -1137,6 +1137,31 @@ async def test_summarize_document_not_found(allow_model_requests, temp_db_path): # Should indicate the document wasn't found +# ============================================================================= +# count_documents Tests +# ============================================================================= + + +@pytest.mark.asyncio +async def test_count_documents(temp_db_path): + """Test count_documents method.""" + async with HaikuRAG(temp_db_path, create=True) as client: + # Empty database + assert await client.count_documents() == 0 + + # Add documents + await client.create_document(content="Doc 1", uri="test/doc1.pdf") + await client.create_document(content="Doc 2", uri="test/doc2.pdf") + await client.create_document(content="Doc 3", uri="other/doc3.txt") + + # Count all + assert await client.count_documents() == 3 + + # Count with filter + assert await client.count_documents(filter="uri LIKE '%.pdf'") == 2 + assert await client.count_documents(filter="uri LIKE '%.txt'") == 1 + + def test_citation_index_fallback_without_session_state(): """Test that citation indices fall back to sequential numbering without session_state.