
当 Stripe 宣布其内部知识 AI 平台 Kai 时,标题引人注目:在一周内构建出完整的 AI 助手,并在一个月内被 5,000 名员工采用。其秘诀是什么?一套紧密耦合的开源项目堆栈——LangChain、LangGraph 以及新发布的 Deep Agents 框架。对开发者而言,Kai 是一个案例,展示了现代代理工具包如何在无需大规模工程投入的情况下,将全公司 AI 同事的宏大愿景变为现实。
该架构围绕三层展开。核心是 Deep Agents,这个轻量级编排库抽象掉了构建多步骤、带状态代理的样板代码。其上,LangChain 提供与 LLM 无关的原语,用于提示模板、记忆和工具集成。最后,LangGraph 增加了可视化工作流引擎,使工程师能够通过简单的 DAG 定义来建模复杂的决策树。三者共同构成一个流水线:用户查询触发 LangChain 链,可调用外部服务、检索 Stripe 内部知识库中的文档,或调用自定义 Python 工具。结果再回馈到 LangGraph 的状态机,确保确定性的路由和错误处理。
from deep_agents import Agent, Step
from langchain import LLMChain, PromptTemplate
from langgraph import Graph
# Prompt that asks the LLM to decide which tool to use
prompt = PromptTemplate.from_template(
"""You are a Stripe knowledge assistant. Question: {question}\n\nIf you need data, call the appropriate tool."""
)
llm_chain = LLMChain(llm="gpt-4o", prompt=prompt)
# Define a tool that queries the internal FAQ index
def faq_tool(query: str) -> str:
# placeholder for actual Elasticsearch call
return "FAQ result for {query}"
# Build the agent steps
steps = [
Step(name="decide", chain=llm_chain),
Step(name="call_faq", tool=faq_tool, condition=lambda ctx: "FAQ" in ctx["decide"].output),
Step(name="final", chain=llm_chain)
]
agent = Agent(steps=steps)
graph = Graph(agent)
def handle_query(q: str):
return graph.run({"question": q})Stripe 的工程团队利用这套脚手架,在首 48 小时内快速创建了 12 个不同的工具集成——从支付状态查询到政策检索不等。通过使用 Deep Agents 的声明式步骤定义,他们避免了纠结的异步代码,并保持状态机对后续贡献者透明。
除了立竿见影的生产力提升,Kai 还标志着 AI 生态系统的更广泛转变。首先,它表明开源代理框架已经成熟到“单周 MVP”不再是夸大其词,而是可复现的结果。其次,快速上线凸显了可组合性的重要性:开发者可以自由搭配 LLM 后端、记忆存储和自定义工具,而无需重写核心逻辑。最后,LangChain 和 Deep Agents 的社区驱动特性意味着在 Stripe 所做的改进——例如新的错误恢复步骤或可复用的支付状态工具——可以上游贡献,惠及整个开源生态。
对于构建者而言,Kai 既是灵感也是实用的蓝图。该堆栈的开放性邀请社区贡献,而成功案例验证了企业级 AI 助手如今已触手可及,只要团队愿意采用这些模块化框架。
图片:Saradasish Pradhan / Unsplash (https://unsplash.com/@saradasish)
LangChain’s latest blog argues that businesses must own their agents, governance, context, and feedback loops to turn generic AI into a durable advantage.

评论