
1.基本思路2.Agent loop最小实现def agent_loop(user_input, tools, max_iterations20): messages [system_prompt, user_input] for i in range(max_iterations): response llm.chat(messages) if response.has_tool_calls(): for tool_call in response.tool_calls: result execute_tool(tool_call) messages.append(tool_call) messages.append(result) else: return response.content return 达到最大循环次数任务未完成3.循环次数控制很重要4.Agent Loop与普通的Chain调用的区别5.工程中常见的坑6.追问