Skip to content

feat(cli,agent): expose tiered search + taxonomy via CLI and wire into query/chat agent - #261

Open
sebastianbraun25 wants to merge 5 commits into
VectifyAI:mainfrom
sebastianbraun25:feat/issue-258-cli-agent-wiring
Open

feat(cli,agent): expose tiered search + taxonomy via CLI and wire into query/chat agent#261
sebastianbraun25 wants to merge 5 commits into
VectifyAI:mainfrom
sebastianbraun25:feat/issue-258-cli-agent-wiring

Conversation

@sebastianbraun25

Copy link
Copy Markdown

Note

This PR was created in collaboration between a human and AI: implementation, tests, and
PR text were created by an AI assistant under the guidance and review of the human author.

Problem

search_wiki/list_taxonomy_items/get_taxonomy_item (#258/#259) are only reachable from
inside the openkb query/openkb chat agent's Python process. There is no way for a
script, a CI job, or an external AI assistant (GitHub Copilot, Claude Code, etc.) that isn't
running the OpenKB agent itself to browse the taxonomy or run the tiered search — the only
options today are re-implementing keyword search with grep, or paying for a full
openkb query LLM round-trip just to get a list of candidate pages. Separately, the
query/chat agent itself still navigated concepts/entities via ad-hoc index.md reads
rather than the new, purpose-built taxonomy tools.

Solution / Changes

  • openkb/cli.py:
    • openkb list-taxonomy [--kind concept|entity] [--json] — lists persisted
      concept/entity pages with their one-line briefs (semantic browsing, not keyword
      search).
    • openkb search <query> [--scope briefs,summaries,sources] [--top-k N] [--json] — tiered
      BM25 search over summaries/sources, grouped by tier, printing each hit's
      line/page locator when present.
  • openkb/agent/tools.py:
  • openkb/agent/query.py (and chat.py, which extends the query agent's tools):
    • build_query_agent now exposes 5 tools: read_file, get_page_content,
      list_taxonomy, search_wiki, get_image.
    • Search-strategy instructions rewritten: browse list_taxonomy for concept/entity
      questions (pick a slug by meaning, then read_file the page), fall back to
      search_wiki(query, scope) for buried details in summaries/sources, narrowing scope
      to ["sources"] for source-only facts (author, date, exact field name) a generated
      summary would likely omit.
  • README.md: updated hybrid-retrieval paragraph and the wiki-commands table with the two
    new CLI commands.

Testing

  • tests/test_agent_tools.py: TestSearchWiki updated (concepts/entities no longer
    matched, tier-grouped output, scope param, locator in output, invalid-scope error
    message) + new TestListTaxonomy (3 tests: wikilink formatting, kind filter, empty
    case).
  • tests/test_query.py: tool count/name assertions updated for the new 5-tool set
    (list_taxonomy added).
  • Manual CLI smoke test: list-taxonomy (plain + --json + --kind), search (plain +
    --json + --scope + invalid-scope error path) all verified against a throwaway KB.
  • ruff check, ruff format --check, mypy openkb, pytest all green — full suite: 1274
    passed (18 pre-existing, environment-specific Windows failures unrelated to this change
    are unaffected and unchanged in count).

Dependencies

Issues

Resolves #260

Sebastian Braun added 5 commits August 28, 2026 16:25
Adds a dependency-free BM25 full-text index (openkb/fulltext_index.py) over concepts/entities/summaries pages, exposed as a new search_wiki tool alongside index.md-driven navigation in build_query_agent. Additive hybrid retrieval: surfaces pages whose one-line index summary omits a buried detail, without replacing existing navigation. Resolves VectifyAI#233.
…axonomy accessors

- fulltext_index.py: extract shared _BM25Scorer from WikiFullTextIndex
  (no behavior change), add Locator (line/page) on SearchHit, add
  TieredWikiSearch with three independent tiers over summaries/ (briefs +
  full body) and sources/ (whole-file .md + per-page PageIndex .json,
  never the whole long doc as one BM25 unit).
- frontmatter.py: add resolve_description()/body_only() shared helpers
  (kept separate from agent.compiler._resolve_description, which is under
  active unrelated development).
- agent/tools.py: add list_taxonomy_items()/get_taxonomy_item() for
  semantic browsing of persisted concepts/entities (pending candidates
  in PendingTopicsStore are structurally excluded).
- No wiring into CLI/MCP/query-agent yet (follow-up PRs); WikiFullTextIndex
  and agent.tools.search_wiki keep their existing signature/behavior.
…o query/chat agent

- cli.py: new 'openkb list-taxonomy [--kind concept|entity] [--json]' and
  'openkb search <query> [--scope briefs,summaries,sources] [--top-k N]
  [--json]' commands.
- agent/tools.py: search_wiki now searches the new tiered
  briefs/summaries/sources index instead of the old combined
  concepts+entities+summaries index (concepts/entities move to the new
  list_taxonomy tool - semantic browsing, not keyword search); new
  list_taxonomy() text-formatting wrapper over list_taxonomy_items().
- agent/query.py (+ chat.py via tool inheritance): wires list_taxonomy and
  the retiered search_wiki in as agent tools; search strategy instructions
  updated to browse taxonomy first, then use scope-restricted search_wiki
  as a keyword fallback.
- README.md: updated hybrid-retrieval paragraph and command table.
- Intentional behavior change to agent.tools.search_wiki (scope param,
  concepts/entities out of scope, output grouped by tier) - safe since
  VectifyAI#234/VectifyAI#259, which introduced it, are not yet merged upstream; existing
  tests updated to the new contract.
sebastianbraun25 pushed a commit to sebastianbraun25/OpenKB that referenced this pull request Sep 11, 2026
- skills/openkb/SKILL.md: 'See what's available' now leads with
  list_taxonomy (MCP) / 'openkb list-taxonomy' (CLI) before falling back
  to reading the full index.md.
- 'Read content' table adds search_wiki (MCP) / 'openkb search' (CLI)
  rows ahead of the existing grep fallback, with a note on why BM25
  ranking beats raw grep occurrence count.
- 'When the KB doesn't have the answer' and the openkb-query guidance
  updated to reference the new search options alongside grep.
- Documentation-only change; no behavior change to the underlying
  tools/CLI/MCP server (VectifyAI#259/VectifyAI#261/VectifyAI#263).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(cli,agent): expose tiered search + taxonomy via CLI and wire into query/chat agent

1 participant