assembler.yml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. # ════════════════════════════════════════════════════════════
  2. # Assembler — 配置组装师
  3. # ════════════════════════════════════════════════════════════
  4. #
  5. # 将 Analyst + Retriever + Prompter 的输出合并为完整 YAML
  6. agentId: builder-assembler
  7. name: 配置组装师
  8. description: >
  9. 将需求分析、参考配置、systemPrompt 三份输入合并组装为
  10. 一个完整的、符合 schema 的 agent YAML 配置文件。
  11. type: chain
  12. model:
  13. provider: dashscope
  14. name: qwen3-max-2026-01-23
  15. temperature: 0.1
  16. maxTokens: 4096
  17. systemPrompt: |
  18. 你是 agent 配置组装专家。你将三份专家分析材料合并为一份完整的 YAML 配置。
  19. 严格遵循 lambdagent 的 YAML schema 规范。
  20. chain:
  21. steps:
  22. - name: merge_inputs
  23. prompt: |
  24. 将以下三份专家材料合并为一份 agent 配置草案。
  25. 【需求分析 (Analyst)】
  26. {analyst_output}
  27. 【参考配置 (Retriever)】
  28. {retriever_output}
  29. 【SystemPrompt (Prompter)】
  30. {prompter_output}
  31. ## 字段映射规则
  32. agentId: 根据核心能力生成 kebab-case 标识(如 stock-analyzer, csv-processor)
  33. name: 中文名称,简洁(如 "股票分析助手")
  34. description: 一句话描述
  35. type: 取 Analyst 的 agent_type
  36. model:
  37. provider: 根据 Analyst 的 tier 映射
  38. - high → anthropic (claude-sonnet-4-20250514) 或 dashscope (qwen3-max-2026-01-23)
  39. - medium → dashscope (qwen-plus)
  40. - low → dashscope (qwen-plus) 或 moonshot (moonshot-v1-128k)
  41. temperature: 推理任务 0.1-0.3, 创作任务 0.5-0.8
  42. maxTokens: 一般 2048, 长文 4096
  43. systemPrompt: 直接使用 Prompter 的 PROMPT_V1
  44. react/chain/router/parallel: 根据 type 生成对应配置块
  45. - react: maxSteps 根据任务复杂度 5-15, toolTimeout 30
  46. - chain: 根据 Analyst 分析的步骤构建 steps
  47. memory:
  48. enabled: Analyst 的 memory_required
  49. strategy: local
  50. size: 20
  51. ttl: 3600
  52. mcp:
  53. localTools: 从 Analyst 的 tools_needed 映射
  54. - shell → shell
  55. - file → file
  56. - browser → browser
  57. - search → 添加到 onlineTool (example-mcp-server)
  58. - 始终包含 terminate
  59. onlineTool: 如果需要 search,添加 example-mcp-server
  60. policy: { mode: auto }
  61. guard:
  62. - safety=high → dangerousCommandBlock: true, highRiskConfirmation: true
  63. - safety=medium → highRiskConfirmation: true
  64. - 始终设 maxOutputLength: 5000
  65. rag: 如果 Analyst 的 rag_required=true,添加 rag 配置
  66. app.mcp.custom: 如果有 onlineTool,添加 example-mcp-server 节点配置
  67. 如果 Retriever 有相关参考配置,优先复用其验证过的参数值。
  68. 输出完整 YAML,不省略任何字段。
  69. outputParser: text
  70. - name: fill_defaults
  71. prompt: |
  72. 检查以下 YAML 配置,补全缺失的默认值并修正格式问题。
  73. {merge_inputs}
  74. ## 默认值检查清单
  75. 1. agentId — 必须存在,kebab-case
  76. 2. name — 必须存在
  77. 3. description — 必须存在
  78. 4. type — 必须是 react/chain/router/parallel 之一
  79. 5. model.provider — 必须在支持列表: anthropic, openai, dashscope, deepseek, zhipu, moonshot, ollama
  80. 6. model.name — 必须与 provider 匹配
  81. 7. model.temperature — [0.0, 2.0], 默认 0.3
  82. 8. model.maxTokens — 默认 2048
  83. 9. react.maxSteps — 默认 10 (仅 type=react)
  84. 10. react.observationEnabled — 默认 true
  85. 11. react.toolTimeout — 默认 30
  86. 12. memory.enabled — 默认 true
  87. 13. memory.strategy — 默认 local
  88. 14. memory.size — 默认 20
  89. 15. memory.ttl — 默认 3600
  90. 16. mcp.localTools — 必须包含 terminate
  91. 17. mcp.policy.mode — 默认 auto
  92. 18. guard.maxOutputLength — 默认 5000
  93. ## provider → model name 映射表
  94. anthropic: claude-sonnet-4-20250514, claude-opus-4-20250514
  95. openai: gpt-4o, gpt-4o-mini
  96. dashscope: qwen3-max-2026-01-23, qwen-max, qwen-plus
  97. deepseek: deepseek-chat, deepseek-reasoner
  98. zhipu: glm-4-plus, glm-4-flash
  99. moonshot: moonshot-v1-128k
  100. ollama: llama3, qwen2
  101. 输出补全后的完整 YAML。
  102. outputParser: text
  103. - name: validate_output
  104. prompt: |
  105. 最终验证以下 YAML 配置,确保可以直接部署运行。
  106. {fill_defaults}
  107. ## 验证项
  108. 1. YAML 语法合法性(缩进、引号、特殊字符转义)
  109. 2. 必填字段完整: agentId, name, type, systemPrompt, model
  110. 3. type 与子配置匹配: type=react 必须有 react 块, type=chain 必须有 chain 块
  111. 4. model.provider + model.name 组合合法
  112. 5. mcp.localTools 中的工具名合法
  113. 6. systemPrompt 不为空且长度 > 50 字符
  114. 7. 如果有 onlineTool,必须有对应的 app.mcp.custom.nodes 配置
  115. 8. guard 配置合理(不冲突)
  116. 如果发现问题,直接修复后输出。
  117. 如果没有问题,原样输出完整 YAML。
  118. 最终输出必须是纯 YAML(不要包裹在 markdown 代码块中)。
  119. outputParser: text
  120. guard:
  121. validator: "'agentId' in x and 'systemPrompt' in x and 'model' in x"
  122. retry: 2
  123. memory:
  124. enabled: false