66
77import pytest
88
9- from openkb .agent .query import build_query_agent , pageindex_retrieve , run_query
9+ from openkb .agent .query import _pageindex_retrieve_impl , build_query_agent , run_query
1010from openkb .schema import SCHEMA_MD
1111
1212
@@ -24,7 +24,13 @@ def test_agent_tool_names(self, tmp_path):
2424 names = {t .name for t in agent .tools }
2525 assert "list_files" in names
2626 assert "read_file" in names
27- assert "retrieve" in names
27+ assert "pageindex_retrieve" in names
28+
29+ def test_instructions_reference_registered_pageindex_tool (self , tmp_path ):
30+ agent = build_query_agent (str (tmp_path ), str (tmp_path / "pi" ), "gpt-4o-mini" )
31+ tool_names = {t .name for t in agent .tools }
32+ assert "pageindex_retrieve" in agent .instructions
33+ assert "pageindex_retrieve" in tool_names
2834
2935 def test_schema_in_instructions (self , tmp_path ):
3036 agent = build_query_agent (str (tmp_path ), str (tmp_path / "pi" ), "gpt-4o-mini" )
@@ -63,7 +69,7 @@ def test_returns_page_content(self, tmp_path):
6369 mock_llm .return_value = MagicMock (
6470 choices = [MagicMock (message = MagicMock (content = "1-2" ))]
6571 )
66- result = pageindex_retrieve ("doc123" , "What is the intro?" , "/db" , "gpt-4o-mini" )
72+ result = _pageindex_retrieve_impl ("doc123" , "What is the intro?" , "/db" , "gpt-4o-mini" )
6773
6874 assert "Introduction text here." in result
6975 assert "More intro content." in result
@@ -76,7 +82,7 @@ def test_handles_empty_structure(self, tmp_path):
7682 mock_client .collection .return_value = mock_col
7783
7884 with patch ("openkb.agent.query.PageIndexClient" , return_value = mock_client ):
79- result = pageindex_retrieve ("doc456" , "What?" , "/db" , "gpt-4o-mini" )
85+ result = _pageindex_retrieve_impl ("doc456" , "What?" , "/db" , "gpt-4o-mini" )
8086
8187 assert "No structure found" in result
8288
@@ -88,7 +94,7 @@ def test_handles_structure_error(self, tmp_path):
8894 mock_client .collection .return_value = mock_col
8995
9096 with patch ("openkb.agent.query.PageIndexClient" , return_value = mock_client ):
91- result = pageindex_retrieve ("doc789" , "What?" , "/db" , "gpt-4o-mini" )
97+ result = _pageindex_retrieve_impl ("doc789" , "What?" , "/db" , "gpt-4o-mini" )
9298
9399 assert "Error" in result
94100
0 commit comments