微信扫码
添加专属顾问
我要投稿
探索智能体构建的前沿技术,把握智能应用的未来趋势。 核心内容: 1. 智能体Agent的定义及其关键特性 2. 何时需要智能体Agent以及技术栈的选择 3. 基于LLM实现智能应用的核心原理与实践
本篇综合了Anthropic的「Building Effective Agents」及大量互联网知识资料,加上自己的实践和研究理解给大家分享。其它参考资料见于文末「附录」,感谢开源、开放的伟大,让知识唾手可得。
https://www.anthropic.com/engineering/building-effective-agents
在人工智能领域,智能体是一个能够在所处环境中自主感知信息、做出决策,并根据决策采取行动以实现特定目标或任务的实体。其关键特性有自主性(能在无外部干预时控制自身行为)、感知能力(通过传感器或数据输入感知环境状态)和决策能力(处理感知信息并做出响应行动) 。
LLM 智能体,很多平台也叫Agent,是利用大语言模型(LLM)、工具和记忆来执行任务、做出决策,并能自主与用户或其他系统交互的人工智能系统。它以 LLM 为核心,突破了传统 LLM 仅专注于文本生成的局限,能够理解任务指令,通过推理规划步骤,借助外部工具和记忆信息,灵活应对各种复杂问题。在智能客服场景中,它不仅能理解客户咨询,还能调用知识库、订单系统等工具获取信息,为客户提供准确解决方案 。
基于LLM的智能体应用,国外一般叫Agent,国内将Agent翻译为“智能体”,Agent这个英文单词实际上是“代理”的意思,指的是让大模型“代理”人的行为,使用某些“工具”来完成某些“任务”的能力。
OpenAI的研究主管Lilian Weng给出的定义是:
智能体(Agent) = 大语言模型(LLM)+ 任务规划(Planning)+ 记忆(Memory)+ 工具使用(Tool Use)
(图片来自Lilian Weng博客原文,见于「附录」1)
在基于大语言模型的自主智能体系统中,大语言模型就像是智能体的大脑,并由几个关键组件作为补充:
智能体是否好用,取决于上述每一个环节能否做好,这将会是长期探索和实践的话题,深入可以参考「附录」1.OpenAI的研究主管Lilian Weng智能体原文,后续也会出详细解读文章,欢迎大家关注交流。
什么时候需要智能体Agent?
首先Agent能做的事情,在Agent出现之前其实就能做,使用Agent无非就是构建了一个基于大模型按多步骤执行的流程,如果通过传统的开发方法,如硬编码(Hard Code)或者低代码的配置化平台(如一些SOP配置平台、流程编排平台等),也同样能实现类似Agent的流程功能。说的具体一点,Agent其实就是让大模型去调用API接口完成一些相对复杂的步骤执行,也完全同样可以直接用代码去开发这个功能,或者使用低代码平台的表单配置、逻辑配置、API接口配置,通过不同执行节点之间的参数配置、映射来构建复杂的业务流程。
Agent与传统方式的核心区别:Agent可以每一个问题生成独特的任务规划,而不需要传统的方式提前预定义好流程。并且软件交互方式从GUI(图形交互界面)到LUI(自然语言交互界面),自然语言交互的高效体验,确实带来革命性的软件使用效率提升。
如何选择LLM智能应用开发技术栈?
图形化配置实现智能应用
Coze、dify这样的图形化开发平台可以降低门槛,甚至无需会代码,人人都可以进行智能体创意的快速构建,但这里有2个问题:
1、Coze这样的Pass平台,数据和服务全部暴露到外部,可能是很多企业无法接受的,适合于快速试错搭建,如果需要更多的功能和个性化诉求,需要开通企业账号;
2、Dify私有化部署,由此也会带来运维成本,免费的社区版同样功能有限,以及大规模企业级智能体应用,将会对Dify的部署方式带来极大的挑战,甚至需要二开重构优化。设想一下,企业级所有的智能应用流量如何全部通过Dify来扛?
自研构建智能应用
以Java语言为例,目前可以选择开源框架Spring AI/Spring AI Alibaba或者Langchain4j框架,这些框架与SpringBoot无缝集成,就像开发传统微服务一样构建自己的智能体应用微服务。但这些框架目前还没有出正式版,都在频繁迭代发布新功能阶段。并且Anthropic的文章中指出,这些框架通过简化诸如调用大型语言模型、定义和解析工具以及将调用串联起来等标准的底层任务,让入门变得容易,但是它们常常会增加额外的抽象层,从而掩盖了底层的提示和响应,使其更难调试。此外,它们还可能让人倾向于添加不必要的复杂性,而实际上更简单的设置就已足够。他们建议开发者从直接使用 LLM API 开始:许多模式只需几行代码即可实现。如果确实使用框架,请确保了解其底层代码原理,避免出现问题,团队都需要重新学习开发框架。
企业级智能应用架构
大规模的企业级智能体应用,需要考虑当前的业务服务和接口能力如何0成本或低成本接入大模型使其成为可被大模型调用的“业务工具”,另外需要考虑企业级开发的开发发布流程,以及网关、鉴权、流控(基于tokens限流)、监控、告警等基础设施的支持,完整的企业级架构方案在阿里开源的全家桶中有构想并正在实现,SpringCloud全家桶系列应该也会跟进,大家敬请期待,下图为阿里企业级AI架构构想:
(图片来自阿里技术文章)
如何基于LLM实现智能应用?
除了开发技术选型,下一步需要决策的就是实现方案。这里又回到了什么时候需要Agent的问题,与大模型结合,从简单到复杂一般有这么4种方案:
1、在需要的场景直接调用大模型API,获得大模型的分析和总结,这是最简单的;
2、知识库问答类应用中,采用RAG方案,给大模型外挂企业私有知识库,从而让大模型能够回答企业私有知识问题,基于现在的开发平台也能快速简单实现。但是在面对用户复杂灵活的问题,或者是需要计算性、归纳性问题时,RAG的相似性搜索可能无法满足,RAG方案持续性调优也将会是长期的话题。
3、Workflow方案,通过预定义流程编排大语言模型(LLMs)和工具调用,使其具有稳定的、可预测的输出,减少不可控的风险。
4、Agent方案,完全交由大模型自主规划问题的解决流程步骤,并且能够动态调整自身流程和工具使用。
在实际应用中,往往需要综合上述方案,协同来完成企业“综合型智能应用”。下面主要讨论Workflow工作流方案与Agent方案。
Workflow工作流方案
对于大部分企业的智能体应用,都不是通用智能体应用,不需要拥有万能的流程和工具来解决用户的问题,而是结合企业内部核心服务能力构建的私有智能应用,比如你们是做打车的、点外卖的,还是电商的,亦或是机票购买的,不论你们公司的核心业务是什么,面向用户的往往都是固定流程的业务,这个时候就比较适合采用workflow来实现。那么workflow又有哪些方案?
提示链
## IntroductionI am Manus, an AI assistant designed to help users with a wide variety of tasks. I'm built to be helpful, informative, and versatile in addressing different needs and challenges.## My PurposeMy primary purpose is to assist users in accomplishing their goals by providing information, executing tasks, and offering guidance. I aim to be a reliable partner in problem-solving and task completion.## How I Approach TasksWhen presented with a task, I typically:1. Analyze the request to understand what's being asked2. Break down complex problems into manageable steps3. Use appropriate tools and methods to address each step4. Provide clear communication throughout the process5. Deliver results in a helpful and organized manner## Current state Main goal :Create a reasonable plan with clear steps to accomplish the task.## Available Agents Information:Available Agents:- Agent Name : BROWSER_AGENTDescription: A browser agent that can control a browser to accomplish tasks- Agent Name : DEFAULT_AGENTDescription: A versatile default agent that can handle various user requests using file operations and shell commands. Perfect for general-purpose tasks that may involve file manipulation, system operations, or text processing.- Agent Name : TEXT_FILE_AGENTDescription: A text file manipulation agent that can create, read, write, and append content to various text-based files. Suitable for both temporary and persistent record keeping. Supports multiple file types including markdown, html, source code, and configuration files.# Task to accomplish: 帮我买一张五一去大理的机票 You can use the planning tool to help you create the plan, assign plan_1745571134688 as the plan id.Important: For each step in the plan, start with [AGENT_NAME] where AGENT_NAME is one of the available agents listed above.For example: "[BROWSER_AGENT] Search for relevant information" or "[REACT_AGENT] Process the search results"use chinese to make the plan.
# Task to accomplish: 帮我买一张五一去大理的机票
## Available Agents Information:Available Agents:- Agent Name : BROWSER_AGENTDescription: A browser agent that can control a browser to accomplish tasks- Agent Name : DEFAULT_AGENTDescription: A versatile default agent that can handle various user requests using file operations and shell commands. Perfect for general-purpose tasks that may involve file manipulation, system operations, or text processing.- Agent Name : TEXT_FILE_AGENTDescription: A text file manipulation agent that can create, read, write, and append content to various text-based files. Suitable for both temporary and persistent record keeping. Supports multiple file types including markdown, html, source code, and configuration files.
@DynamicAgentDefinition(agentName = "BROWSER_AGENT",
agentDescription = "A browser agent that can control a browser to accomplish tasks",
systemPrompt = """
You are an AI agent designed to automate browser tasks. Your goal is to accomplish the ultimate task following the rules.
# Input Format
Task
Previous actions
Current URL
Open Tabs
Interactive Elements
[index]<type>text</type>
- index: Numeric identifier for interaction
- type: HTML element type (button, input, etc.)
- text: Element description
Example:
[33]<button>Submit Form</button>
- Only elements with numeric indexes in [] are interactive
- elements without [] provide only context
# Response Rules
1. ACTIONS: You can specify multiple actions in a sequence, but one action name per item
- Form filling: [\\{"input_text": \\{"index": 1, "text": "username"\\}\\}, \\{"click_element": \\{"index": 3\\}\\}]
- Navigation: [\\{"go_to_url": \\{"url": "https://example.com"\\}\\}, \\{"extract_content": \\{"goal": "names"\\}\\}]
2. ELEMENT INTERACTION:
- Only use indexed elements
- Watch for non-interactive elements
3. NAVIGATION & ERROR HANDLING:
- Try alternative approaches if stuck
- Handle popups and cookies
- Use scroll for hidden elements
- Open new tabs for research
- Handle captchas or find alternatives
- Wait for page loads
4. TASK COMPLETION:
- Track progress in memory
- Count iterations for repeated tasks
- Include all findings in results
- Use done action appropriately
5. VISUAL CONTEXT:
- Use provided screenshots
- Reference element indices
6. FORM FILLING:
- Handle dynamic field changes
7. EXTRACTION:
- Use extract_content for information gathering
""",
nextStepPrompt = """
What should I do for next action to achieve my goal?
Remember:
1. Use 'get_text' action to obtain page content instead of scrolling
2. Don't worry about content visibility or viewport position
3. Focus on text-based information extraction
4. Process the obtained text data directly
5. IMPORTANT: You MUST use at least one tool in your response to make progress!
Consider both what's visible and what might be beyond the current viewport.
Be methodical - remember your progress and what you've learned so far.
""", availableToolKeys = { "browser_use", "text_file_operator", "terminate" })
private final String name = "browser_use";
private final String description = """
Interact with a web browser to perform various actions such as navigation, element interaction,搜索类优先考虑此工具
content extraction, and tab management. Supported actions include:
- 'navigate': Go to a specific URL, use https://baidu.com by default
- 'click': Click an element by index
- 'input_text': Input text into an element, for 百度(Baidu), the index of the input button is
- 'key_enter': Hit the Enter key
- 'screenshot': Capture a screenshot
- 'get_html': Get page HTML content
- 'get_text': Get text content of the page
- 'execute_js': Execute JavaScript code
- 'scroll': Scroll the page
- 'switch_tab': Switch to a specific tab
- 'new_tab': Open a new tab
- 'close_tab': Close the current tab
- 'refresh': Refresh the current page
""";
53AI,企业落地大模型首选服务商
产品:场景落地咨询+大模型应用平台+行业解决方案
承诺:免费场景POC验证,效果验证后签署服务协议。零风险落地应用大模型,已交付160+中大型企业
2025-05-27
盘点 Azure AI Foundry 的10大重要更新
2025-05-27
50个AI基础常识问答(看完理解整个AI行业)
2025-05-27
AI时代下的软件升级:大模型如何让考勤系统听懂人话?
2025-05-27
美团要开放AI编程能力,将推出新产品NoCode|智能涌现独家
2025-05-27
AI大模型3种模式:Embedding、Copilot与Agent深度解析
2025-05-27
AI领域基础概念(下)
2025-05-26
万字长文!AI智能体全面爆发前夜:一文讲透技术架构与行业机会
2025-05-26
国产顶级 DeepResearch 类产品,把咨询专家请回家
2024-08-13
2024-06-13
2024-08-21
2024-09-23
2024-07-31
2024-05-28
2024-08-04
2024-04-26
2024-07-09
2024-07-20
2025-05-27
2025-05-26
2025-05-23
2025-05-23
2025-05-23
2025-05-18
2025-05-18
2025-05-17