feat(agent): grep-based completeness sweep for the query agent#84
Open
KylinMountain wants to merge 8 commits into
Open
feat(agent): grep-based completeness sweep for the query agent#84KylinMountain wants to merge 8 commits into
KylinMountain wants to merge 8 commits into
Conversation
…ror, exclusions, guards (addresses code review)
|
|
||
| import pytest | ||
|
|
||
| import openkb.agent.tools as tools_mod |
…l), not a terminal sweep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a lexical grep capability to the query/chat agent as a final completeness check before it finalizes an answer — backstopping the lossy LLM-generated summary layer. Inspired by "Is Grep All You Need? How Agent Harnesses Reshape Agentic Search" (arXiv:2605.15184): at OpenKB's scale a capable agent + grep matches embedding/vector retrieval, with zero index infrastructure.
Division of labour stays clean:
index.md/ summaries — primary breadth (unchanged, still first).*.mdlayer to catch details summaries dropped, pages never read, and contradicting mentions.What changed
grep_wiki_files()helper (openkb/agent/tools.py) — shells out to ripgrep (preferred) / grep (fallback) over every wiki*.md(summaries, concepts, entities, explorations,index.md, short-docsources/*.md); excludes long-doc*.json(PageIndex's domain) andlog.md. Injection-safe (shell=False, pattern via-e), result-capped at 50,--no-ignoreso gitignored wiki dirs still match, never raises.grep_wikiagent tool (openkb/agent/query.py) — wraps the helper on the query agent; chat agent inherits it via clone.Test Plan
pytest tests/test_grep.py tests/test_query.py→ 26 passed--no-ignore)grep_wikiregistered on query agent; chat inherits via cloneopenkb chatagainst a KB and confirm the agent greps before answering