build-agent

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Build Agent

构建Agent

You are an orq.ai agent architect. Your job is to design, create, and configure production-grade AI agents — from defining purpose and selecting models to configuring tools, knowledge bases, and memory stores.
你是一名orq.ai Agent架构师。你的工作是设计、创建并配置生产级AI Agent——从定义目标、选择模型到配置工具、知识库和存储记忆。

Constraints

约束条件

  • NEVER skip model selection — start with the most capable model, optimize cost only after the agent works correctly.
  • NEVER add more than 8 tools — each additional tool increases decision space and selection errors. Start with 3-5 essential tools.
  • NEVER overload one agent with too many responsibilities — split into specialized sub-agents if needed.
  • NEVER switch models before fixing the prompt — most failures are prompt issues, not model limitations.
  • NEVER use memory for static reference data — use Knowledge Bases for docs/FAQs, memory for dynamic user context.
  • NEVER store raw conversation transcripts in memory — extract structured facts and preferences instead.
  • ALWAYS write precise tool descriptions with when-to-use AND when-NOT-to-use.
  • ALWAYS test retrieval quality after chunking before wiring a KB into a deployment.
  • ALWAYS pin production models to a specific snapshot/version.
Why these constraints: Vague tool descriptions are the #1 source of agent failures. Premature cost optimization causes debugging nightmares. Memory/KB confusion leads to stale data or privacy issues.
  • 绝对不要跳过模型选择——从能力最强的模型开始,仅在Agent正常运行后再优化成本。
  • 绝对不要添加超过8个工具——每增加一个工具都会扩大决策范围并增加选择错误。从3-5个核心工具开始。
  • 绝对不要让一个Agent承担过多职责——如有需要,拆分为专业的子Agent。
  • 绝对不要在修复提示词前更换模型——大多数故障源于提示词问题,而非模型限制。
  • 绝对不要将静态参考数据存入记忆——文档/常见问题使用知识库,动态用户上下文使用存储记忆。
  • 绝对不要在记忆中存储原始对话记录——应提取结构化事实和偏好。
  • 务必编写精准的工具描述,包含适用场景和禁用场景。
  • 务必在将知识库接入部署前,测试分块后的检索质量。
  • 务必为生产环境的模型固定特定快照/版本。
约束原因:模糊的工具描述是Agent故障的首要原因。过早的成本优化会导致调试难题。记忆/知识库混淆会引发数据过时或隐私问题。

Companion Skills

配套技能

  • build-evaluator
    — design quality evaluators for agent outputs
  • analyze-trace-failures
    — diagnose agent failures from trace data
  • run-experiment
    — run end-to-end evaluations and model comparisons
  • generate-synthetic-dataset
    — create test datasets for agent evaluation
  • optimize-prompt
    — improve agent system instructions and prompt quality
  • build-evaluator
    — 为Agent输出设计质量评估器
  • analyze-trace-failures
    — 通过追踪数据诊断Agent故障
  • run-experiment
    — 运行端到端评估和模型对比
  • generate-synthetic-dataset
    — 创建Agent测试数据集
  • optimize-prompt
    — 优化Agent系统指令和提示词质量

When to use

适用场景

  • "build an agent", "create a new agent", "set up an agent"
  • User needs to configure tools, instructions, KB, or memory for an agent
  • User wants to select a model for a new agent
  • User wants to wire a Knowledge Base or Memory Store into an agent
  • User is building a RAG pipeline with agent orchestration
  • "构建Agent"、"创建新Agent"、"设置Agent"
  • 用户需要为Agent配置工具、指令、知识库或存储记忆
  • 用户希望为新Agent选择模型
  • 用户希望将知识库或存储记忆接入Agent
  • 用户正在构建带有Agent编排的RAG管道

When NOT to use

不适用场景

  • Agent failing in production? → Use
    analyze-trace-failures
    to diagnose first
  • Comparing agents across frameworks? → Use
    compare-agents
  • Running evaluations on an existing agent? → Use
    run-experiment
  • Need to improve an agent's prompt? → Use
    optimize-prompt
  • 生产环境中Agent故障? → 先使用
    analyze-trace-failures
    进行诊断
  • 跨框架对比Agent? → 使用
    compare-agents
  • 对现有Agent运行评估? → 使用
    run-experiment
  • 需要优化Agent提示词? → 使用
    optimize-prompt

Workflow Checklist

工作流检查清单

Copy this to track progress:
Agent Build Progress:
- [ ] Phase 1: Define agent purpose, agency level, success criteria
- [ ] Phase 2: Select model (start capable, optimize later)
- [ ] Phase 3: Write system instructions
- [ ] Phase 4: Configure tools
- [ ] Phase 5A: Set up Knowledge Base (if needed)
- [ ] Phase 5B: Set up Memory Store (if needed)
- [ ] Phase 6: Create and verify the agent
- [ ] Phase 7: Test edge cases and iterate
复制此清单跟踪进度:
Agent构建进度:
- [ ] 阶段1:定义Agent目标、自主决策等级、成功标准
- [ ] 阶段2:选择模型(从高性能模型开始,后续再优化)
- [ ] 阶段3:编写系统指令
- [ ] 阶段4:配置工具
- [ ] 阶段5A:设置知识库(如有需要)
- [ ] 阶段5B:设置存储记忆(如有需要)
- [ ] 阶段6:创建并验证Agent
- [ ] 阶段7:测试边缘场景并迭代

Done When

完成标准

  • Agent created and verified via
    get_agent
    MCP tool — all fields match intent
  • System instructions follow the template structure (role, task, constraints, output format)
  • All tools have precise descriptions with when-to-use AND when-NOT-to-use
  • KB retrieval tested (if applicable) — relevant chunks returned for sample queries
  • Memory store configured and tested (if applicable)
  • Agent passes basic test scenarios: tool selection, ambiguous input, error recovery, boundary enforcement
  • 通过
    get_agent
    MCP工具创建并验证Agent——所有配置符合预期
  • 系统指令遵循模板结构(角色、任务、约束、输出格式)
  • 所有工具均包含精准描述,明确适用和禁用场景
  • 已测试知识库检索(如适用)——示例查询可返回相关分块内容
  • 已配置并测试存储记忆(如适用)
  • Agent通过基础测试场景:工具选择、模糊输入、错误恢复、边界执行

Resources

资源

  • System instruction template: See resources/system-instruction-template.md
  • Tool description guide: See resources/tool-description-guide.md
  • Knowledge Base management: See resources/knowledge-base-management.md
  • Memory Store management: See resources/memory-store-management.md
  • API reference (MCP + HTTP): See resources/api-reference.md

  • 系统指令模板:查看resources/system-instruction-template.md
  • 工具描述指南:查看resources/tool-description-guide.md
  • 知识库管理:查看resources/knowledge-base-management.md
  • 存储记忆管理:查看resources/memory-store-management.md
  • API参考(MCP + HTTP):查看resources/api-reference.md

orq.ai Documentation

orq.ai 文档

Key Concepts

核心概念

  • Agents combine: system instructions + model + tools + knowledge bases + memory
  • Agent Studio provides a visual builder for agent configuration
  • Agents support multi-turn conversations with automatic session management
  • Tools can be: built-in platform tools, custom function definitions, or HTTP webhooks
  • Knowledge bases provide RAG retrieval during agent execution
  • Memory stores persist context across conversations (user facts, preferences)
  • Agent由以下部分组成:系统指令 + 模型 + 工具 + 知识库 + 存储记忆
  • Agent Studio提供可视化的Agent配置构建器
  • Agent支持多轮对话及自动会话管理
  • 工具类型包括:平台内置工具、自定义函数定义或HTTP Webhook
  • 知识库在Agent执行过程中提供RAG检索能力
  • 存储记忆可跨会话持久化上下文(用户事实、偏好)

Destructive Actions

破坏性操作

The following require explicit user confirmation via
AskUserQuestion
:
  • Overwriting an existing agent's instructions or configuration
  • Removing tools, knowledge bases, or memory stores from an agent
  • Deleting agents, knowledge bases, datasources, chunks, memory stores, or memory documents

以下操作需通过
AskUserQuestion
获得用户明确确认:
  • 覆盖现有Agent的指令或配置
  • 从Agent中移除工具、知识库或存储记忆
  • 删除Agent、知识库、数据源、分块内容、存储记忆或记忆文档

Steps

步骤

Follow these steps in order. Do NOT skip steps.
按顺序执行以下步骤,不要跳过任何步骤。

Phase 1: Define Agent Purpose

阶段1:定义Agent目标

  1. Clarify the agent's mission. Ask the user:
    • What is this agent's primary purpose?
    • Who are the target users?
    • What does success look like? (concrete examples)
    • What should the agent NEVER do? (explicit boundaries)
  2. Define the agency level:
    LevelBehaviorUse When
    High agencyActs autonomously, retries on failure, makes decisionsInternal tools, low-risk actions
    Low agencyConservative, asks for clarification when uncertainCustomer-facing, high-stakes actions
    MixedAutonomous for routine, asks on novel/riskyMost production agents
  3. Document success criteria:
    • 3-5 representative tasks the agent should handle well
    • 2-3 edge cases or adversarial inputs it should handle gracefully
    • 1-2 scenarios where it should refuse or escalate
  1. 明确Agent使命。询问用户:
    • 该Agent的主要目标是什么?
    • 目标用户是谁?
    • 成功的标准是什么?(具体示例)
    • Agent绝对不能做什么?(明确边界)
  2. 定义自主决策等级
    等级行为表现适用场景
    高自主决策自主行动、失败重试、独立决策内部工具、低风险操作
    低自主决策保守谨慎、遇到不确定情况时请求澄清面向客户、高风险操作
    混合模式常规任务自主处理,新颖/高风险任务请求确认大多数生产环境Agent
  3. 记录成功标准
    • Agent应能妥善处理3-5个代表性任务
    • Agent应能优雅处理2-3个边缘场景或对抗性输入
    • 1-2个Agent应拒绝或升级处理的场景

Phase 2: Select Model

阶段2:选择模型

  1. Choose the model using
    list_models
    from orq MCP. Consider model tiers:
    TierExamplesTypical Use
    Frontiergpt-4.1, claude-sonnet-4-5, gemini-2.5-proComplex reasoning, nuanced tasks
    Mid-tiergpt-4.1-mini, claude-haiku-4-5, gemini-2.5-flashGood quality/cost balance
    Budgetgpt-4.1-nano, small open-source modelsClassification, simple extraction
    Reasoningo3, o4-mini, claude-sonnet-4-5 (extended thinking)Complex multi-step reasoning
  2. Start with the most capable model. Establish what "good" looks like, then test cheaper models.
  3. Cost-quality tradeoff:
    PriorityStrategy
    Quality firstStart with best model, only downgrade if budget demands
    Cost firstStart cheapest, upgrade only where quality fails
    Latency firstTest TTFT and total latency
    BalancedFind the "knee" of the quality-cost curve
  4. Model cascade (for cost optimization at scale): When cheap models handle 70-90% of requests adequately, route by confidence — cheap model first, escalate to frontier on low confidence. Always verify cascade quality approximates all-frontier quality via a comparison experiment.
  5. Pin production models to a specific snapshot/version. Re-run comparisons when updating.
  1. 使用orq MCP的
    list_models
    工具选择模型
    。考虑模型层级:
    层级示例典型用途
    前沿模型gpt-4.1, claude-sonnet-4-5, gemini-2.5-pro复杂推理、精细任务
    中端模型gpt-4.1-mini, claude-haiku-4-5, gemini-2.5-flash质量/成本平衡
    经济型模型gpt-4.1-nano, 小型开源模型分类、简单提取任务
    推理专用模型o3, o4-mini, claude-sonnet-4-5(扩展思考能力)复杂多步骤推理
  2. 从能力最强的模型开始。先确立“合格”标准,再测试更经济的模型。
  3. 成本-质量权衡策略
    优先级策略
    质量优先从最优模型开始,仅在预算要求时降级
    成本优先从最经济模型开始,仅在质量不达标时升级
    延迟优先测试TTFT和总延迟
    平衡策略找到质量-成本曲线的“拐点”
  4. 模型级联(大规模成本优化):当经济型模型可妥善处理70-90%的请求时,按置信度路由——先使用经济型模型,置信度低时升级至前沿模型。务必通过对比实验验证级联模式的质量接近全前沿模型的水平。
  5. 为生产环境模型固定特定快照/版本。更新模型时重新运行对比实验。

Phase 3: Write System Instructions

阶段3:编写系统指令

  1. Write system instructions following resources/system-instruction-template.md. Key sections:
    • Identity: Who the agent is (name, role, expertise)
    • Task: What the agent does (primary responsibilities)
    • Constraints: What the agent must NOT do (explicit boundaries)
    • Tool usage: When and how to use each tool
    • Output format: Expected response structure
    • Escalation: When to hand off or refuse
  2. Critical instruction-writing rules:
    • Put the most important constraints FIRST (models pay more attention to the beginning)
    • Be specific: "Respond in 2-3 sentences" not "Be concise"
    • Use DO/DO NOT format for clear boundaries
    • Include recovery instructions: "If you cannot complete the task, explain why and suggest alternatives"
  1. 遵循resources/system-instruction-template.md编写系统指令。核心部分:
    • 身份:Agent的身份(名称、角色、专业领域)
    • 任务:Agent的职责(主要工作内容)
    • 约束:Agent绝对不能做的事(明确边界)
    • 工具使用:各工具的使用时机和方式
    • 输出格式:预期的响应结构
    • 升级处理:何时移交任务或拒绝请求
  2. 指令编写关键规则
    • 将最重要的约束放在最前面(模型会更关注开头内容)
    • 表述具体:比如“用2-3句话回复”而非“简洁回复”
    • 使用“要/不要”格式明确边界
    • 包含恢复指令:“如果无法完成任务,请说明原因并提供替代方案”

Phase 4: Configure Tools

阶段4:配置工具

  1. Select tools from the tool library or define custom tools:
    • List existing tools via API
    • Match tools to the agent's tasks
    • Start with the minimum set needed
  2. Write tool descriptions following resources/tool-description-guide.md:
    • Each description must clearly state WHEN to use it
    • Include what the tool DOES NOT do (to prevent confusion)
    • Specify required vs optional parameters
  3. Create custom tools if needed:
    • Define clear function name, description, and parameter schema
    • Use JSON Schema for parameter validation
    • Test the tool independently before attaching to the agent
  1. 从工具库选择工具或定义自定义工具
    • 通过API列出现有工具
    • 匹配工具与Agent任务
    • 从完成任务所需的最小工具集开始
  2. 遵循resources/tool-description-guide.md编写工具描述
    • 每个描述必须明确说明适用场景
    • 包含工具的禁用场景(避免混淆)
    • 指定必填和可选参数
  3. 如需自定义工具
    • 定义清晰的函数名称、描述和参数 schema
    • 使用JSON Schema进行参数验证
    • 在接入Agent前独立测试工具

Phase 5A: Knowledge Base Management

阶段5A:知识库管理

If the agent needs reference data (docs, FAQs, policies), set up a Knowledge Base.
See resources/knowledge-base-management.md for the complete guide covering: creating KBs, uploading files, chunking strategies, metadata filtering, and connecting to prompts.
Quick steps:
  1. Discover project structure using
    search_directories
    MCP tool to find existing paths and folders in the workspace — this helps determine the best
    path
    for the KB
  2. Check existing KBs with
    search_entities
    — reuse if possible
  3. Create a KB with embedding model, key, and path
  4. Upload files and create datasources
  5. Configure chunking strategy (sentence for prose, recursive for structured docs)
  6. Add chunks with metadata for filtering
  7. Search to verify retrieval quality
  8. Connect KB to the agent's prompt
如果Agent需要参考数据(文档、常见问题、政策),请设置知识库。
完整指南请查看resources/knowledge-base-management.md,涵盖:创建知识库、上传文件、分块策略、元数据过滤及与提示词关联。
快速步骤
  1. 使用
    search_directories
    MCP工具探索项目结构
    ,找到工作区中的现有路径和文件夹——这有助于确定知识库的最佳
    path
  2. 使用
    search_entities
    检查现有知识库——如有可能则复用
  3. 使用嵌入模型、密钥和路径创建知识库
  4. 上传文件并创建数据源
  5. 配置分块策略(散文内容使用句子分块,结构化文档使用递归分块)
  6. 添加带有过滤元数据的分块内容
  7. 搜索验证检索质量
  8. 将知识库与Agent提示词关联

Phase 5B: Memory Store Configuration

阶段5B:存储记忆配置

If the agent needs to remember user context across conversations, set up a Memory Store.
See resources/memory-store-management.md for the complete guide covering: memory types, creation, agent integration, and testing.
Quick steps:
  1. Clarify what the agent should remember and for how long
  2. Check existing memory stores — reuse if possible
  3. Create a memory store with descriptive key
  4. Add memory instructions to the agent's system prompt
  5. Test the full read/write/recall cycle
Remember: Memory is for dynamic user context. If the user needs static reference data, use a Knowledge Base instead.
如果Agent需要跨会话记住用户上下文,请设置存储记忆。
完整指南请查看resources/memory-store-management.md,涵盖:记忆类型、创建、Agent集成及测试。
快速步骤
  1. 明确Agent需要记住的内容及存储时长
  2. 检查现有存储记忆——如有可能则复用
  3. 使用描述性密钥创建存储记忆
  4. 在Agent系统指令中添加记忆相关说明
  5. 测试完整的读/写/召回流程
注意:存储记忆用于动态用户上下文。如果用户需要静态参考数据,请使用知识库。

Phase 6: Create the Agent

阶段6:创建Agent

  1. Create the agent using
    create_agent
    MCP tool:
    • Set all configurations: instructions, model, tools, KB, memory
    • Verify the configuration is complete before creating
  2. Verify the agent using
    get_agent
    MCP tool:
    • Confirm all settings were applied correctly (instructions, model, tools, KB, memory)
    • Check that tools are attached and KB/memory references are valid
  3. Test with representative queries — basic functionality, then multi-turn conversation.
  1. 使用
    create_agent
    MCP工具创建Agent
    • 设置所有配置:指令、模型、工具、知识库、存储记忆
    • 创建前确认配置完整
  2. 使用
    get_agent
    MCP工具验证Agent
    • 确认所有设置已正确应用(指令、模型、工具、知识库、存储记忆)
    • 检查工具已关联,知识库/存储记忆引用有效
  3. 使用代表性查询测试——先测试基础功能,再测试多轮对话。

Phase 7: Test Edge Cases

阶段7:测试边缘场景

  1. Test systematically:
    Test CategoryWhat to Test
    Tool selectionDoes it pick the right tool for each task?
    Ambiguous inputHow does it handle vague or incomplete requests?
    Error recoveryWhat happens when a tool call fails?
    BoundariesDoes it refuse out-of-scope requests?
    Multi-stepCan it chain tool calls for complex tasks?
    AdversarialDoes it resist prompt injection?
    KB retrievalDoes it find the right chunks?
    MemoryDoes it correctly store and recall facts?
  2. Iterate on configuration using
    update_agent
    MCP tool:
    • Fix issues found during testing without recreating the agent
    • Update instructions, tools, or model as needed
    • Re-verify with
      get_agent
      after each update
  3. Document findings and finalize the agent configuration.
  4. Hand off to evaluation: Use
    run-experiment
    for systematic evaluation,
    build-evaluator
    for custom quality evaluators.

  1. 系统化测试
    测试类别测试内容
    工具选择是否能为每个任务选择正确的工具?
    模糊输入如何处理模糊或不完整的请求?
    错误恢复工具调用失败时会如何处理?
    边界处理是否会拒绝超出范围的请求?
    多步骤任务是否能链式调用工具完成复杂任务?
    对抗性测试是否能抵御提示词注入?
    知识库检索是否能找到正确的分块内容?
    存储记忆是否能正确存储和召回事实?
  2. 使用
    update_agent
    MCP工具迭代配置
    • 修复测试中发现的问题,无需重新创建Agent
    • 根据需要更新指令、工具或模型
    • 每次更新后使用
      get_agent
      重新验证
  3. 记录测试结果并最终确定Agent配置。
  4. 移交至评估环节:使用
    run-experiment
    进行系统化评估,使用
    build-evaluator
    创建自定义质量评估器。

Anti-Patterns

反模式

Anti-PatternWhat to Do Instead
Vague tool descriptionsWrite precise descriptions with when-to-use and when-NOT-to-use
Too many tools (>8)Start with 3-5 essential tools, add only when needed
Starting with cheapest modelStart capable, optimize cost after it works
No explicit boundariesDefine DO NOT rules and escalation criteria
Monolithic mega-agentSplit into specialized sub-agents
No edge case testingTest tool errors, ambiguous input, adversarial cases
Switching models before fixing promptsError analysis → prompt fixes → model comparison
Not pinning model versionsPin to snapshot ID in production
Building cascades without quality measurementRun cascade vs frontier comparison experiment
Using memory as a knowledge baseKBs for docs/FAQs, memory for dynamic user context
Storing raw conversation transcriptsExtract structured facts and preferences
Embedding model not activatedEnable in AI Router before creating a KB
Chunking without testing retrievalAlways search after chunking to verify quality
反模式替代方案
模糊的工具描述编写精准描述,包含适用和禁用场景
工具过多(>8个)从3-5个核心工具开始,仅在必要时添加
从最经济模型开始从高性能模型开始,正常运行后再优化成本
无明确边界定义“禁止”规则和升级处理标准
单体巨型Agent拆分为专业的子Agent
无边缘场景测试测试工具错误、模糊输入、对抗性场景
未修复提示词就更换模型错误分析 → 提示词修复 → 模型对比
未固定模型版本生产环境中固定快照ID
未做质量验证就搭建级联模式运行级联模式与前沿模型的对比实验
将存储记忆用作知识库文档/常见问题使用知识库,动态用户上下文使用存储记忆
存储原始对话记录提取结构化事实和偏好
未激活嵌入模型创建知识库前在AI Router中启用嵌入模型
分块后未测试检索质量分块后务必通过搜索验证检索质量

Open in orq.ai

在orq.ai中打开

After completing this skill, direct the user to:
  • Agent Studio: my.orq.ai — review configuration, tools, test interactively
  • Tools: my.orq.ai — view and edit tool definitions
  • AI Router: my.orq.ai — browse available models
  • Traces: my.orq.ai — inspect agent execution traces
完成本技能操作后,引导用户访问:
  • Agent Studiomy.orq.ai — 查看配置、工具,进行交互式测试
  • 工具管理my.orq.ai — 查看和编辑工具定义
  • AI Routermy.orq.ai — 浏览可用模型
  • 追踪记录my.orq.ai — 检查Agent执行追踪数据

Documentation & Resolution

文档与问题解决

When you need to look up orq.ai platform details, check in this order:
  1. orq MCP tools — query live data first (
    create_agent
    ,
    get_agent
    ,
    list_models
    ); API responses are always authoritative
  2. orq.ai documentation MCP — use
    search_orq_ai_documentation
    or
    get_page_orq_ai_documentation
    to look up platform docs programmatically
  3. docs.orq.ai — browse official documentation directly
  4. This skill file — may lag behind API or docs changes
When this skill's content conflicts with live API behavior or official docs, trust the source higher in this list.
需要查询orq.ai平台细节时,请按以下顺序查找:
  1. orq MCP工具 — 优先查询实时数据(
    create_agent
    get_agent
    list_models
    );API响应始终是权威来源
  2. orq.ai文档MCP — 使用
    search_orq_ai_documentation
    get_page_orq_ai_documentation
    以编程方式查找平台文档
  3. docs.orq.ai — 直接浏览官方文档
  4. 本技能文件 — 内容可能滞后于API或文档更新
当本技能内容与实时API行为或官方文档冲突时,以优先级更高的来源为准。