Skip to content

Commit 543edbe

Browse files
committed
Revert query_wiki cap in skill compile agent
The QUERY_WIKI_MAX_CALLS=3 limit added in 2b94014 was over-engineered defence: - It was based on a theoretical worst-case bound (80 outer turns × 50 inner turns) from a perf review, not on observed misuse. - There's no telemetry showing real compiles ever approach pathological query_wiki usage. - The prompt's "narrow follow-ups only" guidance plus the docstring ("nested LLM call, prefer direct reads") are already the right primary control. Adding a structural hard-cap on top of that says "we trust the agent to make 80 reasoning steps but not to count to 3", which is inconsistent. - The cap had a real cost: a legitimately complex cross-document intent that genuinely needed a 4th query_wiki got cut off and forced back to direct reads, silently degrading skill quality. Also fixes the docstring bug a reviewer flagged on 2b94014: the docstring referenced the literal Python name `QUERY_WIKI_MAX_CALLS` rather than the value, so the model saw a meaningless symbol. Removing the cap removes the docstring claim too. If runaway compiles ever show up in telemetry, prefer a logged warning (observe-and-tune) over a silent block.
1 parent 2b94014 commit 543edbe

1 file changed

Lines changed: 7 additions & 23 deletions

File tree

openkb/skill/creator.py

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
from openkb.schema import get_agents_md
3232

3333
MAX_TURNS = 80 # higher than query (50) because compile can write multiple files
34-
QUERY_WIKI_MAX_CALLS = 3 # bound nested-LLM tail latency; agents should prefer direct reads
3534

3635

3736
def build_skill_create_agent(
@@ -104,33 +103,18 @@ def get_image(image_path: str) -> ToolOutputImage | ToolOutputText:
104103
return ToolOutputImage(image_url=result["image_url"])
105104
return ToolOutputText(text=result["text"])
106105

107-
# Per-compile counter for query_wiki. Each invocation spawns a nested
108-
# Runner.run(max_turns=50), so an agent that leans on this tool can
109-
# blow up wall-clock and token cost. The docstring already nudges
110-
# toward direct reads; this hard cap is the structural backstop.
111-
query_wiki_calls = 0
112-
113106
@function_tool
114107
async def query_wiki(question: str) -> str:
115108
"""Semantic search over the wiki — narrow follow-ups only.
116109
117-
This is a nested LLM call. Use ONLY when you have a specific
118-
sub-question that direct file reads can't easily answer (e.g. "what
119-
does the book say about X across multiple chapters?"). For primary
120-
traversal, use list/read/get_page_content instead — they are
121-
cheaper and give you the raw text, not another LLM's summary.
122-
123-
Capped at ``QUERY_WIKI_MAX_CALLS`` invocations per compile.
110+
This is a nested LLM call: each invocation spawns a separate
111+
query agent with its own turn budget. Use ONLY when you have a
112+
specific sub-question that direct file reads can't easily answer
113+
(e.g. "what does the book say about X across multiple
114+
chapters?"). For primary traversal, use list/read/get_page_content
115+
instead — they are cheaper and give you the raw text, not
116+
another LLM's summary.
124117
"""
125-
nonlocal query_wiki_calls
126-
query_wiki_calls += 1
127-
if query_wiki_calls > QUERY_WIKI_MAX_CALLS:
128-
return (
129-
f"query_wiki call cap reached "
130-
f"({QUERY_WIKI_MAX_CALLS} per compile). Use direct file "
131-
f"reads (read_wiki_file / get_page_content) for further "
132-
f"investigation."
133-
)
134118
# Lazy import to avoid a circular dependency at module load time.
135119
from openkb.agent.query import run_query
136120
kb_dir = Path(wiki_root).parent

0 commit comments

Comments
 (0)