AI Agent架构:想清楚再动手

Agent的核心循环 一个Agent本质上在做这件事: 1 感知 → 思考 → 行动 → 反馈 → 继续思考... 用代码表示: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 while not done: # 1. 理解用户要什么 intent = understand(user_input) # 2. 想想怎么做 plan = think(intent, memory) # 3. 动手执行 result = act(plan, tools) # 4. 看看结果对不对 if verify(result): done = True else: memory.add(result) # 记住失败,下次改进 三个关键模块 1. 记忆系统 Agent和普通LLM调用的区别:Agent会记东西。 1 2 3 4 5 6 7 8 9 class Memory: short_term = [] # 当前对话历史 long_term = {} # 跨对话的知识 def remember(self, key, value): self.long_term[key] = value def recall(self, query): return search(self.long_term, query) 实际应用: ...

January 8, 2026 · 2 min · Chico