🧠 Build Knowledge Agents Without Embeddings
EngineeringAI
⭐⭐⭐⭐⭐ 5星内容
问题: Embedding Stack的局限性
Most knowledge agents start the same way: pick a vector database, build a chunking pipeline, choose an embedding model, tune retrieval parameters.
但几周后,agent回答错误,你甚至不知道它检索到了哪个chunk,为什么那个chunk得分最高。
The embedding stack works for semantic similarity, but it falls short when you need a specific value from structured data. The failure mode is silent.
新方案: Filesystem + Bash
他们尝试了一种不同的方法: 用文件系统替代向量数据库,给agent bash。
结果:
- 销售通话摘要agent: 从 ~$1.00 降到 ~$0.25 per call
- 输出质量提高
工作原理
- 通过管理界面添加源,存储在Postgres中
- 内容通过Vercel Workflow同步到快照仓库
- 当agent需要搜索时,Vercel Sandbox加载快照
- agent的bash和bash_batch工具执行文件系统命令
- agent返回带有可选引用的答案
优势对比
❌ Embeddings
- Black-box scoring
- Hard to debug
- Requires tuning
- 无法解释为什么选择那个chunk
✅ Filesystem
- Transparent commands
- Inspect actual files
- Works out of the box
- 直接看到执行了什么命令
为什么可行?
"LLMs already understand filesystems. They've been trained on massive amounts of code: navigating directories, grepping through files, managing state across complex codebases."
你不是在教模型新技能,而是用它最擅长的。
Chat SDK: 一个Agent,多个平台
你的agent有一个知识库、一个代码库、一个真相来源。但你的工程师分散在Slack,社区在Discord,bug报告埋在GitHub。
Chat SDK将你的知识agent连接到用户所在的每个平台。
import { Chat } from "chat";
import { createSlackAdapter } from "@chat-adapter/slack";
import { createDiscordAdapter } from "@chat-adapter/discord";
const bot = new Chat({
userName: "knowledge-agent",
adapters: {
slack: createSlackAdapter(),
discord: createDiscordAdapter(),
},
});
bot.onNewMention(async (thread, message) => {
const result = await agent.stream({ prompt: message.text });
await thread.post(result);
});
支持的平台
- Slack
- Discord
- Microsoft Teams
- Google Chat
- GitHub
智能复杂度路由
模板包含智能复杂度路由。每个传入的问题按复杂度分类,并路由到合适的模型:
- 简单问题 → 快速、便宜的模型
- 困难问题 → 强大的模型
- 成本优化自动进行,无需手动规则
成本降低
从 $1.00 降到 $0.25 per call
同时输出质量提高
同时输出质量提高
核心洞察
"If agents excel at filesystem operations for code, they excel at them for anything. That's the insight behind the filesystem and bash approach."
"You're not teaching the model a new skill; you're using the one it's best at."
技术栈
- Vercel Sandbox - 隔离执行环境
- AI SDK - AI模型集成
- Chat SDK - 多平台聊天集成
- Postgres - 源数据存储
- Vercel Workflow - 内容同步