From 70273ecf5bcecc008c50d9479f809d7b9d16c6a0 Mon Sep 17 00:00:00 2001 From: Yiorgis Gozadinos Date: Mon, 2 Mar 2026 17:15:38 +0200 Subject: [PATCH 1/2] Remove filter from the search tool --- haiku_rag_slim/haiku/rag/tools/search.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/haiku_rag_slim/haiku/rag/tools/search.py b/haiku_rag_slim/haiku/rag/tools/search.py index fb0b6a20..87d6d10b 100644 --- a/haiku_rag_slim/haiku/rag/tools/search.py +++ b/haiku_rag_slim/haiku/rag/tools/search.py @@ -5,7 +5,6 @@ from pydantic_ai import FunctionToolset, RunContext from haiku.rag.config.models import AppConfig from haiku.rag.store.models import SearchResult from haiku.rag.tools.context import RAGDeps -from haiku.rag.tools.filters import combine_filters def create_search_toolset( @@ -35,21 +34,19 @@ def create_search_toolset( ctx: RunContext[RAGDeps], query: str, limit: int | None = None, - filter: str | None = None, ) -> str: """Search the knowledge base for relevant documents. Args: query: The search query (what to search for). limit: Number of results to return (default: from config). - filter: Optional SQL WHERE clause to filter documents. Returns: Formatted search results with content and metadata. """ client = ctx.deps.client - effective_filter = combine_filters(base_filter, filter) + effective_filter = base_filter effective_limit = limit or config.search.limit results = await client.search( query, limit=effective_limit, filter=effective_filter From 1a3ea64aa6c012d76ee07ebd0dc5c176b8730735 Mon Sep 17 00:00:00 2001 From: Yiorgis Gozadinos Date: Tue, 3 Mar 2026 10:33:37 +0200 Subject: [PATCH 2/2] Remove filter parameter from search and list_documents tools --- CHANGELOG.md | 4 ++++ haiku_rag_slim/haiku/rag/skills/rag.py | 6 ++---- tests/tools/test_search.py | 13 ------------- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e7445ac..d282aec5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog ## [Unreleased] +### Fixed + +- **Search tool regression**: Removed LLM-facing `filter` parameter from search and list_documents tools. The SQL WHERE clause description confused LLMs, degrading QA accuracy. Document filtering is now handled programmatically via `base_filter` and `state.document_filter` + ## [0.32.2] - 2026-02-28 ### Fixed diff --git a/haiku_rag_slim/haiku/rag/skills/rag.py b/haiku_rag_slim/haiku/rag/skills/rag.py index 776db28a..856b6b30 100644 --- a/haiku_rag_slim/haiku/rag/skills/rag.py +++ b/haiku_rag_slim/haiku/rag/skills/rag.py @@ -140,19 +140,17 @@ def create_skill( ctx: RunContext[SkillRunDeps], limit: int | None = None, offset: int | None = None, - filter: str | None = None, ) -> list[dict[str, Any]]: - """List documents in the knowledge base with optional pagination and filtering. + """List documents in the knowledge base with optional pagination. Args: limit: Maximum number of documents to return. offset: Number of documents to skip. - filter: Optional SQL WHERE clause to filter documents. """ from haiku.rag.client import HaikuRAG async with HaikuRAG(db_path, config=config, read_only=True) as rag: - documents = await rag.list_documents(limit, offset, filter) + documents = await rag.list_documents(limit, offset) result = [ { "id": doc.id, diff --git a/tests/tools/test_search.py b/tests/tools/test_search.py index 69ee447f..33adc1d6 100644 --- a/tests/tools/test_search.py +++ b/tests/tools/test_search.py @@ -67,19 +67,6 @@ class TestSearchToolExecution: assert result == "No results found." - @pytest.mark.asyncio - async def test_search_with_filter(self, search_client, search_config): - """Search tool respects filter parameter.""" - accumulated: list[SearchResult] = [] - toolset = create_search_toolset(search_config, on_results=accumulated.extend) - - search_tool = toolset.tools["search"] - ctx = make_ctx(search_client) - await search_tool.function(ctx, "programming", filter="title LIKE '%Python%'") - - for r in accumulated: - assert "JavaScript" not in (r.document_title or "") - @pytest.mark.asyncio async def test_search_with_base_filter(self, search_client, search_config): """Search toolset respects base_filter parameter."""