Skip to content

Commit 2efb710

Browse files
committed
fix: align query tool name
1 parent 25fe79c commit 2efb710

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

openkb/agent/query.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"""
3131

3232

33-
def pageindex_retrieve(doc_id: str, question: str, okb_dir: str, model: str) -> str:
33+
def _pageindex_retrieve_impl(doc_id: str, question: str, okb_dir: str, model: str) -> str:
3434
"""Retrieve relevant content from a long document via PageIndex.
3535
3636
Args:
@@ -148,7 +148,7 @@ def read_file(path: str) -> str:
148148
return read_wiki_file(path, wiki_root)
149149

150150
@function_tool
151-
def retrieve(doc_id: str, question: str) -> str:
151+
def pageindex_retrieve(doc_id: str, question: str) -> str:
152152
"""Retrieve relevant content from a long document via PageIndex.
153153
154154
Use this when you need detailed content from a document that was
@@ -158,12 +158,12 @@ def retrieve(doc_id: str, question: str) -> str:
158158
doc_id: PageIndex document identifier (found in index.md).
159159
question: The question you are trying to answer.
160160
"""
161-
return pageindex_retrieve(doc_id, question, okb_dir, model)
161+
return _pageindex_retrieve_impl(doc_id, question, okb_dir, model)
162162

163163
return Agent(
164164
name="wiki-query",
165165
instructions=instructions,
166-
tools=[list_files, read_file, retrieve],
166+
tools=[list_files, read_file, pageindex_retrieve],
167167
model=model,
168168
)
169169

tests/test_query.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import 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
1010
from 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

Comments
 (0)