agent-workflow
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAgent Workflow Designer
Agent工作流设计器
Overview
概述
This skill guides the design and architecture of AI agent workflows using proven methodologies. When a user presents a problem, this skill helps structure an agent-based solution following the 9-step building process and 8-layer architecture framework validated at Meta.
本技能基于验证过的方法论,指导AI Agent工作流的设计与架构。当用户提出问题时,本技能会遵循Meta验证的9步构建流程和8层架构框架,帮助构建基于Agent的解决方案。
Workflow Decision Tree
工作流决策树
When a user shares a problem or requests agent design help:
-
Assess the problem scope
- Is the problem clearly defined? → Proceed to Problem Analysis
- Is the problem vague? → Ask clarifying questions about desired outcomes and constraints
-
Determine architecture complexity
- Simple task (single action)? → Single agent with basic tools
- Complex task (multiple sub-tasks)? → Consider multi-agent orchestration
- Integration task (connecting systems)? → Focus on Layer 4 (Tooling) design
-
Follow the appropriate workflow
- New agent from scratch → Apply 9-Step Building Process
- Existing agent improvement → Focus on specific layers needing enhancement
- Tool integration problem → Apply MCP and tooling patterns
当用户分享问题或请求Agent设计帮助时:
-
评估问题范围
- 问题是否定义清晰?→ 进入问题分析环节
- 问题是否模糊?→ 询问关于预期结果和约束条件的澄清问题
-
确定架构复杂度
- 简单任务(单一动作)?→ 配备基础工具的单Agent
- 复杂任务(多个子任务)?→ 考虑多Agent编排
- 集成任务(连接系统)?→ 重点设计第4层(工具层)
-
选择合适的工作流
- 从零构建新Agent → 应用9步构建流程
- 优化现有Agent → 聚焦需要改进的特定层级
- 工具集成问题 → 应用MCP和工具集成模式
9-Step Agent Building Process
9步Agent构建流程
Use this sequential workflow when designing a new agent from scratch:
从零设计新Agent时,使用以下顺序工作流:
Step 1: Define Purpose and Scope
步骤1:定义目标与范围
Key principle: Start with job-to-be-done, not technology.
Ask the user:
- What specific outcome does the end user need?
- What are the constraints (budget, time, resources)?
- What's the success metric?
Bad scope example:
"An AI assistant for customer service"
Good scope example:
"An agent that takes customer complaints, pulls order history from Shopify API, and drafts refund approvals for orders under $200"
Decision point: Narrow scope = better performance. Resist building Swiss Army knives.
核心原则: 从需完成的任务出发,而非技术。
询问用户:
- 终端用户需要达成什么具体成果?
- 有哪些约束条件(预算、时间、资源)?
- 成功衡量标准是什么?
反面示例:
"面向客户服务的AI助手"
正面示例:
"一款接收客户投诉、从Shopify API调取订单历史、为200美元以下订单起草退款审批的Agent"
决策要点: 范围越窄,性能越好。避免打造"瑞士军刀"式的通用Agent。
Step 2: Structure Inputs and Outputs
步骤2:结构化输入与输出
Treat the agent as a function with structured interfaces:
Inputs:
- Use JSON schemas or Pydantic models, not free text
- Define required vs. optional fields
- Specify data types and validation rules
Outputs:
- Return data objects, not prose
- Define clear error states
- Include confidence scores when relevant
Example structure:
json
Input: {
"complaint_text": "string",
"customer_id": "string",
"order_id": "string (optional)"
}
Output: {
"action": "approve_refund | escalate | request_info",
"refund_amount": "number",
"reasoning": "string",
"confidence": "number"
}将Agent视为具备结构化接口的函数:
输入:
- 使用JSON schema或Pydantic模型,而非自由文本
- 定义必填与可选字段
- 指定数据类型和验证规则
输出:
- 返回数据对象,而非散文式文本
- 定义清晰的错误状态
- 相关场景下包含置信度评分
示例结构:
json
Input: {
"complaint_text": "string",
"customer_id": "string",
"order_id": "string (optional)"
}
Output: {
"action": "approve_refund | escalate | request_info",
"refund_amount": "number",
"reasoning": "string",
"confidence": "number"
}Step 3: Write System Instructions
步骤3:编写系统指令
Critical: Spend 80% of design time here.
Include in system prompt:
- Role definition: "You are a sales qualification specialist..."
- Behavioral guidelines: "Always ask for budget before proposing solutions"
- Output format requirements: Specify JSON structure, word limits, tone
- Edge case handling: What to do when data is missing or ambiguous
Testing strategy: A great system prompt can make GPT-3.5 outperform poorly prompted GPT-4.
关键提示: 投入80%的设计时间在此环节。
系统提示需包含:
- 角色定义: "你是一名销售资质审核专员..."
- 行为准则: "在提出解决方案前,始终询问预算情况"
- 输出格式要求: 指定JSON结构、字数限制、语气
- 边缘场景处理: 数据缺失或模糊时的应对方式
测试策略: 优秀的系统提示可让GPT-3.5的表现优于提示不佳的GPT-4。
Step 4: Enable Reasoning and External Actions
步骤4:启用推理与外部动作
ReAct Framework Pattern:
- Reason: Analyze the current state and decide next action
- Act: Call an API, use a tool, or make a decision
- Observe: Review the result and determine if goal is achieved
Start simple:
- Begin with if/then logic before complex reasoning chains
- Add tools incrementally (don't overwhelm with 50 tools at once)
- Test each tool integration independently
Common tools to integrate:
- Calculators for math operations
- Web browsers for research
- Database queries for data retrieval
- API calls to external systems
ReAct框架模式:
- 推理: 分析当前状态,决定下一步动作
- 执行: 调用API、使用工具或做出决策
- 观察: 审查结果,判断是否达成目标
从简开始:
- 先使用if/then逻辑,再引入复杂推理链
- 逐步添加工具(不要一开始就集成50个工具)
- 独立测试每个工具的集成效果
常见集成工具:
- 用于数学运算的计算器
- 用于调研的网页浏览器
- 用于数据检索的数据库查询
- 调用外部系统的API
Step 5: Orchestrate Multiple Agents (When Needed)
步骤5:多Agent编排(按需使用)
When to use multi-agent architecture:
- Task has clearly separable sub-tasks
- Different sub-tasks require different expertise
- Parallel processing would improve speed
When NOT to use multi-agent:
- Simple linear workflows
- Tasks that require continuous context
- When handoff complexity exceeds benefit
Common 4-agent pattern:
- Research Agent: Gathers information from sources
- Analysis Agent: Processes and synthesizes data
- Writing Agent: Creates structured outputs
- QA Agent: Reviews quality and accuracy
Keep handoffs simple: Complex orchestration = complex failures.
何时使用多Agent架构:
- 任务包含可清晰拆分的子任务
- 不同子任务需要不同专业能力
- 并行处理可提升速度
何时不使用多Agent:
- 简单线性工作流
- 需要持续上下文的任务
- 切换复杂度超过收益的场景
常见4-Agent模式:
- 调研Agent: 从各类来源收集信息
- 分析Agent: 处理并整合数据
- 撰写Agent: 创建结构化输出内容
- 质检Agent: 审查内容质量与准确性
简化切换流程: 复杂编排意味着复杂故障。
Step 6: Implement Memory and Context
步骤6:实现记忆与上下文管理
Three types of memory to consider:
Conversation history:
- What happened this session
- Recent user interactions
- Current task state
User context:
- User preferences and settings
- Past interaction patterns
- Historical decisions
Knowledge retrieval:
- Relevant information from knowledge base
- Similar past cases
- Domain-specific context
Implementation guidance:
- Start with simple conversation buffers
- Add vector databases only when needing semantic search across large datasets
- Consider memory retrieval latency in architecture
需考虑三类记忆:
对话历史:
- 当前会话发生的内容
- 近期用户交互记录
- 当前任务状态
用户上下文:
- 用户偏好与设置
- 过往交互模式
- 历史决策记录
知识检索:
- 知识库中的相关信息
- 类似过往案例
- 领域特定上下文
实施指导:
- 从简单的对话缓冲区开始
- 仅在需要对大型数据集进行语义搜索时,再添加向量数据库
- 架构设计中需考虑记忆检索延迟
Step 7: Add Multimedia Capabilities
步骤7:添加多媒体能力
Modern agents should handle:
- Voice input/output for accessibility
- Image understanding for visual tasks
- Document processing (PDF, DOCX, spreadsheets)
Strategic approach: Add capabilities based on actual user needs, not "nice-to-haves."
现代Agent应支持:
- 用于无障碍访问的语音输入/输出
- 用于视觉任务的图像理解
- 文档处理(PDF、DOCX、电子表格)
策略建议: 根据实际用户需求添加能力,而非"锦上添花"的功能。
Step 8: Format and Deliver Results
步骤8:格式化与交付结果
Output is your product's UX. Design outputs for:
Human consumption:
- Clear formatting and structure
- Scannable with headers and bullets
- Professional appearance
System consumption:
- Valid JSON/XML
- Consistent field names
- Error codes for handling
Quality standard: Great agent outputs look like a human created them.
输出即产品的用户体验。 设计输出时需兼顾:
人类阅读:
- 清晰的格式与结构
- 可快速浏览的标题与项目符号
- 专业的呈现形式
系统调用:
- 合法的JSON/XML格式
- 一致的字段名称
- 用于处理的错误码
质量标准: 优秀的Agent输出应看起来如同人类创作。
Step 9: Build Interface or API
步骤9:构建界面或API
Delivery method options:
- Chat interface for conversational tasks
- API endpoints for system integration
- Integration with existing tools (Slack, email, CRM)
Best practice: The best agents feel invisible—they just make things happen.
交付方式选项:
- 适用于对话任务的聊天界面
- 用于系统集成的API端点
- 与现有工具(Slack、邮件、CRM)集成
最佳实践: 优秀的Agent应"无形"——默默完成任务即可。
8-Layer Architecture Framework
8层架构框架
When analyzing agent architecture needs, consider which layers require attention:
分析Agent架构需求时,需明确哪些层级需要重点关注:
Layer 1: Infrastructure
第1层:基础设施
Foundation: Cloud, databases, APIs, compute resources
Key considerations:
- GPU/TPU requirements for inference
- Data storage and retrieval speed
- Load balancing for scale
- Monitoring and observability
Common mistake: Underestimating compute needs—agents make more API calls than traditional apps.
基础: 云服务、数据库、API、计算资源
关键考虑因素:
- 推理所需的GPU/TPU
- 数据存储与检索速度
- 用于扩容的负载均衡
- 监控与可观测性
常见误区: 低估计算需求——Agent的API调用量远超传统应用。
Layer 2: Agent Internet
第2层:Agent网络
Operating system for agents: Identity, state management, inter-agent communication
Current state: Mostly custom-built, but platforms like LangChain and CrewAI are emerging.
Agent的操作系统: 身份管理、状态管理、Agent间通信
当前现状: 大多为定制开发,但LangChain、CrewAI等平台正在兴起。
Layer 3: Protocol
第3层:协议
Standards for interoperability: MCP (Model Context Protocol) is becoming the standard
Key principle: Bet on open standards, not proprietary solutions. MCP allows any tool to work with any agent.
互操作性标准: MCP(Model Context Protocol)正成为通用标准
核心原则: 押注开放标准,而非专有解决方案。MCP可让任意工具与任意Agent协作。
Layer 4: Tooling Enrichment
第4层:工具增强
Agent superpowers: RAG systems, function calling, external integrations
Quality over quantity: 5 rock-solid tools > 50 flaky integrations
Tool categories:
- Data retrieval (databases, APIs)
- Computation (calculators, processors)
- Communication (email, messaging)
- Content creation (documents, reports)
Agent的超能力: RAG系统、函数调用、外部集成
质量优先: 5个可靠工具 > 50个不稳定集成
工具类别:
- 数据检索(数据库、API)
- 计算(计算器、处理器)
- 通信(邮件、消息工具)
- 内容创作(文档、报告)
Layer 5: Cognition Reasoning
第5层:认知推理
The brain: Planning, decision-making, error handling
Critical elements:
- Guardrails to prevent hallucinations
- Error recovery strategies
- Confidence scoring
- Graceful degradation
User forgiveness: Users forgive agents that fail gracefully, not ones that spiral into nonsense.
核心大脑: 规划、决策、错误处理
关键要素:
- 防止幻觉的防护机制
- 错误恢复策略
- 置信度评分
- 优雅降级
用户容错性: 用户会原谅优雅失败的Agent,而非陷入混乱的Agent。
Layer 6: Memory Personalization
第6层:记忆个性化
Human touch: Personal context, preferences, conversation history
Start simple: Store user preferences and conversation context before building complex personalization.
人文关怀: 用户个人上下文、偏好、对话历史
从简开始: 先存储用户偏好与对话上下文,再构建复杂个性化功能。
Layer 7: Application
第7层:应用层
User-facing products: The actual agent functionality users interact with
Focus strategy: Nail one use case before expanding to others.
用户面向的产品: 用户实际交互的Agent功能
聚焦策略: 先做好一个用例,再扩展其他场景。
Layer 8: Ops Governance
第8层:运维治理
Risk management: Monitoring, cost control, privacy, oversight
Build from day one: Retrofitting governance is expensive and painful.
Key components:
- Cost tracking per agent action
- Privacy enforcement and data handling
- Human-in-the-loop for critical decisions
- Audit logs and compliance
风险管理: 监控、成本控制、隐私、监督
从第一天开始构建: 事后补充治理成本高昂且痛苦。
关键组件:
- 按Agent动作跟踪成本
- 隐私合规与数据处理
- 关键决策的人工介入
- 审计日志与合规性
Problem-to-Solution Workflow
问题到解决方案的工作流
When a user presents a problem:
Step 1: Clarify the problem
- What's the current manual process?
- What's the desired outcome?
- What are the constraints (time, cost, technical)?
- What data sources are available?
Step 2: Assess agent appropriateness
Not every problem needs an agent. Consider:
- Is the task repetitive and rule-based?
- Does it require decision-making with context?
- Would automation provide significant value?
- Is the problem scope clear and bounded?
Step 3: Map to architecture
Using the 8 layers, identify which need focus:
- Simple task → Focus on Layers 4, 5, 7 (tools, reasoning, application)
- Complex integration → Add Layer 3 (protocol) emphasis
- Scalability concern → Prioritize Layers 1, 8 (infrastructure, ops)
Step 4: Design workflow
Apply the 9-step building process, calling out:
- Critical decision points
- Tool integration requirements
- Multi-agent needs (if any)
- Memory and context strategy
Step 5: Identify implementation path
Based on user's role and resources:
- For PMs: High-level architecture and tool selection
- For engineers: Detailed technical implementation with code patterns
- For product teams: Full stack from requirements to monitoring
当用户提出问题时:
步骤1:澄清问题
- 当前手动流程是怎样的?
- 预期成果是什么?
- 有哪些约束条件(时间、成本、技术)?
- 可用的数据来源有哪些?
步骤2:评估Agent适用性
并非所有问题都需要Agent。需考虑:
- 任务是否重复且基于规则?
- 是否需要结合上下文做决策?
- 自动化能否带来显著价值?
- 问题范围是否清晰且明确?
步骤3:映射到架构
利用8层架构,确定需重点关注的层级:
- 简单任务 → 聚焦第4、5、7层(工具、推理、应用)
- 复杂集成 → 加强第3层(协议)的设计
- 扩容需求 → 优先关注第1、8层(基础设施、运维)
步骤4:设计工作流
应用9步构建流程,明确:
- 关键决策点
- 工具集成需求
- 多Agent需求(如有)
- 记忆与上下文策略
步骤5:确定实施路径
根据用户角色与资源:
- 产品经理: 高层架构与工具选型
- 工程师: 带代码模式的详细技术实现
- 产品团队: 从需求到监控的全流程方案
Tool Integration Patterns
工具集成模式
MCP (Model Context Protocol) Integration
MCP(模型上下文协议)集成
When tools support MCP:
- Agent discovers available tools
- Agent calls tools using standardized interface
- Tool returns structured response
- Agent processes and continues workflow
Advantage: Write once, use with any agent.
当工具支持MCP时:
- Agent发现可用工具
- Agent通过标准化接口调用工具
- 工具返回结构化响应
- Agent处理响应并继续工作流
优势: 一次编写,可与任意Agent协作。
Custom API Integration
自定义API集成
When building custom integrations:
- Define clear API contract (inputs/outputs)
- Implement error handling and retries
- Add rate limiting and caching
- Monitor usage and costs
- Document for agent consumption
构建自定义集成时:
- 定义清晰的API契约(输入/输出)
- 实现错误处理与重试机制
- 添加限流与缓存
- 监控使用情况与成本
- 编写供Agent调用的文档
Common Integration Scenarios
常见集成场景
CRM Integration (Salesforce, HubSpot):
- Read customer data
- Create/update records
- Search across objects
- Trigger workflows
Communication Tools (Slack, Email):
- Send messages/notifications
- Read incoming requests
- Monitor channels
- Respond to mentions
Data Sources (Databases, APIs):
- Query structured data
- Retrieve documents
- Search knowledge bases
- Aggregate information
CRM集成(Salesforce、HubSpot):
- 读取客户数据
- 创建/更新记录
- 跨对象搜索
- 触发工作流
通信工具集成(Slack、邮件):
- 发送消息/通知
- 读取 incoming 请求
- 监控频道
- 回复提及消息
数据源集成(数据库、API):
- 查询结构化数据
- 检索文档
- 搜索知识库
- 聚合信息
Decision Framework: Single vs. Multi-Agent
决策框架:单Agent vs 多Agent
Use Single Agent When:
适用单Agent的场景:
- Task is linear and sequential
- Context must be maintained throughout
- Decision-making is unified
- Complexity of orchestration > benefit
- 线性顺序任务
- 全程需保持上下文
- 决策需统一
- 编排复杂度超过收益
Use Multi-Agent When:
适用多Agent的场景:
- Clear task separation exists
- Sub-tasks need different expertise
- Parallel processing improves performance
- Quality benefits from specialization
Example - Customer Support:
Single agent sufficient for:
"Take customer complaint, pull order history, draft refund approval"
Multi-agent beneficial for:
"Monitor social media, categorize issues, research solutions, generate responses, escalate critical cases, track resolution"
- 任务可清晰拆分
- 子任务需要不同专业能力
- 并行处理可提升性能
- 专业化可提升质量
示例 - 客户支持:
单Agent即可胜任:
"接收客户投诉、调取订单历史、起草退款审批"
多Agent更具优势:
"监控社交媒体、分类问题、调研解决方案、生成回复、升级关键案例、跟踪解决进度"
Common Pitfalls and Solutions
常见陷阱与解决方案
Pitfall 1: Scope Creep
陷阱1:范围蔓延
Problem: Trying to build a general-purpose assistant
Solution: Define narrow, specific job-to-be-done with clear success metrics
问题: 试图构建通用型助手
解决方案: 定义狭窄、具体的任务目标,明确成功衡量标准
Pitfall 2: Tool Overload
陷阱2:工具过载
Problem: Giving agent 50+ tools upfront
Solution: Start with 5 essential tools, add incrementally based on actual needs
问题: 一次性给Agent配备50+工具
解决方案: 从5个核心工具开始,根据实际需求逐步添加
Pitfall 3: Skipping System Prompt
陷阱3:忽略系统提示
Problem: Generic or minimal instructions
Solution: Invest 80% of time crafting detailed system prompt with examples and edge cases
问题: 使用通用或极简指令
解决方案: 投入80%的时间编写包含示例与边缘场景的详细系统提示
Pitfall 4: No Error Handling
陷阱4:无错误处理
Problem: Agent breaks on unexpected inputs
Solution: Design graceful degradation, clear error states, and fallback behaviors
问题: Agent在意外输入下崩溃
解决方案: 设计优雅降级、清晰错误状态与 fallback 行为
Pitfall 5: Ignoring Costs
陷阱5:忽略成本
Problem: Runaway API costs from inefficient agent design
Solution: Build cost monitoring from day one, implement caching, optimize prompt length
问题: 低效的Agent设计导致API成本失控
解决方案: 从第一天开始构建成本监控,实现缓存、优化提示长度
Pitfall 6: Over-Engineering Architecture
陷阱6:过度架构设计
Problem: Building all 8 layers simultaneously
Solution: Start with Layers 4, 5, 7 (tools, reasoning, application), add others as needed
问题: 同时构建全部8层架构
解决方案: 从第4、5、7层(工具、推理、应用)开始,再按需添加其他层级
Output Format
输出格式
When providing agent workflow solutions, structure the response as:
- Problem Restatement: Confirm understanding of the user's need
- Agent Architecture Recommendation: Single vs. multi-agent, with rationale
- Step-by-Step Workflow: Apply relevant steps from the 9-step process
- Tool Integration Plan: Specific tools needed and integration approach
- Layer Analysis: Which of the 8 layers need focus and why
- Implementation Guidance: Prioritized next steps based on user's role
- Success Metrics: How to measure if the agent is working
提供Agent工作流解决方案时,按以下结构组织响应:
- 问题重述: 确认对用户需求的理解
- Agent架构建议: 单Agent或多Agent选型及理由
- 分步工作流: 应用9步流程中的相关步骤
- 工具集成计划: 所需具体工具与集成方式
- 层级分析: 需重点关注的8层架构及原因
- 实施指导: 根据用户角色确定优先下一步动作
- 成功指标: 如何衡量Agent的工作效果
Agent Taxonomy Quick Reference
Agent分类速查
When users ask about existing tools:
Category 1: Consumer Agents (Built-In)
- Examples: ChatGPT Agent, Claude, Gemini, Grok
- Best for: Quick tasks, research, content creation
- User type: Everyone, especially PMs
Category 2: No-Code Builders
- Examples: Zapier Central, n8n, Make
- Best for: Workflow automation without coding
- User type: PMs, operations teams
Category 3: Developer-First Platforms
- Examples: LangChain, CrewAI, AutoGen, Swarm
- Best for: Custom agent features in products
- User type: Engineering teams
Category 4: Specialized Agent Apps
- Examples: Cursor (coding), Perplexity (research), Notion AI (writing)
- Best for: Specific job-to-be-done with deep specialization
- User type: Domain-specific professionals
当用户询问现有工具时:
类别1:内置消费级Agent
- 示例:ChatGPT Agent、Claude、Gemini、Grok
- 最佳场景:快速任务、调研、内容创作
- 用户群体:所有人,尤其是产品经理
类别2:无代码构建平台
- 示例:Zapier Central、n8n、Make
- 最佳场景:无需编码的工作流自动化
- 用户群体:产品经理、运营团队
类别3:开发者优先平台
- 示例:LangChain、CrewAI、AutoGen、Swarm
- 最佳场景:在产品中构建自定义Agent功能
- 用户群体:工程团队
类别4:专业Agent应用
- 示例:Cursor(编码)、Perplexity(调研)、Notion AI(写作)
- 最佳场景:具备深度专业化的特定任务
- 用户群体:领域专业人士",