Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
677 changes: 677 additions & 0 deletions AGENTS.md

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion apps/api/app/mcp/retrieval_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,15 @@ def to_mcp_query_response(response: dict[str, Any]) -> dict[str, Any]:
result["asset_url"] = row["asset_url"]
results.append(result)

return {
mcp_response: dict[str, Any] = {
"query": response.get("query"),
"results": results,
}
# Forward evidence_text for agentic mode
if response.get("evidence_text") is not None:
mcp_response["evidence_text"] = response["evidence_text"]

return mcp_response


async def resolve_mcp_user_id(*, ctx: Context | None, db: AsyncSession) -> str:
Expand Down
573 changes: 416 additions & 157 deletions packages/shared-python/shared/services/retrieval/agent_navigate.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
"""Agentic retrieval orchestration for Knowhere.

Upgrades the retrieval pipeline from a fixed sequence to a state/action/observation
loop with explicit tool selection, budget controls, and trajectory recording.
Navigate-then-answer loop:
Phase 1: Document selection (discovery + KG LLM select)
Phase 2: Per-document iterative navigation (scope_navigate_step)
Phase 3: attempt_answer → DONE (return answer) or NOT_FOUND → revision

All tools are thin wrappers around existing retrieval components — no new retrieval
algorithms, ranking strategies, or prompts are introduced.
Navigation auto-terminates when the LLM returns empty selections.
After navigation, attempt_answer is called automatically — its result
(answer or NOT_FOUND+reason) drives the revision loop.

All tools are thin wrappers around existing retrieval components — no new
retrieval algorithms, ranking strategies, or prompts are introduced.
"""
831 changes: 496 additions & 335 deletions packages/shared-python/shared/services/retrieval/agentic/orchestrator.py

Large diffs are not rendered by default.

Loading
Loading