记忆回路 — 智能体自我改进
记忆回路:规划前先在记忆库检索相似经验,任务结束后再把新经验写回记忆库。
完整 FlowZap 代码
将以下 FlowZap 代码复制并粘贴到您的 FlowZap 账户的项目中,即可查看此模板图。
user { # User
n1: circle label:"Start task"
n2: rectangle label:"Submit complex task"
n4: rectangle label:"Receive acknowledgement"
n26: rectangle label:"Receive improved result"
n1.handle(right) -> n2.handle(left)
n2.handle(bottom) -> planner.n3.handle(top) [label="Task"]
}
planner { # Planner
n3: rectangle label:"Acknowledge task"
n5: rectangle label:"Ask for similar lessons"
n8: rectangle label:"Receive prior lessons"
n9: rectangle label:"Build plan"
n10: rectangle label:"Dispatch execution"
n13: rectangle label:"Receive execution output"
n14: rectangle label:"Request evaluation"
n17: rectangle label:"Receive evaluation"
n18: diamond label:"Good enough?"
n19: rectangle label:"Store new lesson"
n22: rectangle label:"Confirm lesson saved"
n23: rectangle label:"Send retry plan"
n25: rectangle label:"Send improved result"
n3.handle(top) -> user.n4.handle(bottom) [label="Ack"]
n3.handle(right) -> n5.handle(left)
n5.handle(bottom) -> memory.n6.handle(top) [label="Retrieve lessons"]
n8.handle(right) -> n9.handle(left)
n9.handle(right) -> n10.handle(left)
n10.handle(bottom) -> executor.n11.handle(top) [label="Execute plan"]
n13.handle(right) -> n14.handle(left)
n14.handle(bottom) -> evaluator.n15.handle(top) [label="Evaluate output"]
n17.handle(right) -> n18.handle(left)
n18.handle(right) -> n19.handle(left) [label="Yes"]
n18.handle(bottom) -> n23.handle(top) [label="No"]
n19.handle(bottom) -> memory.n20.handle(top) [label="Save lesson"]
n22.handle(right) -> n25.handle(left)
n23.handle(bottom) -> executor.n24.handle(top) [label="Retry with lessons"]
n25.handle(top) -> user.n26.handle(bottom) [label="Improved result"]
}
memory { # Memory Store
n6: rectangle label:"Search memory"
n7: rectangle label:"Return best lessons"
n20: rectangle label:"Persist new lesson"
n21: rectangle label:"Confirm persistence"
n6.handle(right) -> n7.handle(left)
n7.handle(top) -> planner.n8.handle(bottom) [label="Lessons"]
n20.handle(right) -> n21.handle(left)
n21.handle(top) -> planner.n22.handle(bottom) [label="Saved"]
}
executor { # Executor
n11: rectangle label:"Run first attempt"
n12: rectangle label:"Return output"
n24: rectangle label:"Run improved attempt"
n27: rectangle label:"Return improved output"
n11.handle(right) -> n12.handle(left)
n12.handle(top) -> planner.n13.handle(bottom) [label="Output"]
n24.handle(right) -> n27.handle(left)
n27.handle(top) -> evaluator.n28.handle(bottom) [label="Improved output"]
}
evaluator { # Evaluator
n15: rectangle label:"Judge first output"
n16: rectangle label:"Return verdict"
n28: rectangle label:"Judge improved output"
n29: rectangle label:"Return final verdict"
n15.handle(right) -> n16.handle(left)
n16.handle(top) -> planner.n17.handle(bottom) [label="Verdict"]
n28.handle(right) -> n29.handle(left)
n29.handle(top) -> planner.n19.handle(bottom) [label="Pass"]
}
安装 MCP 包npm install -g flowzap-mcpMCP 文档