search_notes Demo Shows a Source-Grounded Knowledge-Base Agent
An article presents search_notes as a simple knowledge-base agent demo for retrieving personal notes. A model calls the search_notes tool, an executor validates and dispatches the request, and the retrieval layer filters notes by a backend-derived user ID, scores keyword matches, and returns snippets and sources for a cited answer. The in-memory version is described as an educational spike rather than a production design. The author recommends keeping backend-enforced user filtering in production and discusses replacing keyword retrieval with embeddings and pgvector, while noting that the broader RAG pipeline also requires chunking, query rewriting, context assembly, citations, refusal, and evaluation.
The demo explicitly separates the model, tool, executor, and retrieval layers. It also shows why server-derived user IDs and runtime parameter validation are necessary when agents can retrieve user-specific material.
search_notes:Agent 的检索与查找
目标:用户提问 → 模型输出
tool_call→ 执行器路由 →search_notes检索 → 结果回填 → 模型基于笔记回答。 这一篇只讲“检索工具”这一层;循环、错误观察、重试在另一篇。
0. 它在 Agent 里的位置
用户问题
→ 模型看到 tools 菜单
→ 模型返回 tool_call: search_notes(query, top_k)
→ 执行器解析参数、校验、分发
→ search_notes 在笔记里检索
→ snippets + sources 作为 tool 消息回填
→ 模型基于 snippets 回答,并给出处
它属于 工具层 + 检索层:
- 工具层:schema、参数校验、分发;
- 检索层:过滤、打分、排序、取 top-k;
- 模型层:根据返回的片段生成答案。