智能体
ai/agent 组件:v0.36.0+ 基于 ReAct(Reasoning + Acting)模式的 AI 智能体节点。通过多轮推理和工具调用循环,自主完成用户任务。支持同步和流式两种执行模式。
智能体作为规则链节点,可以与其他 RuleGo 节点自由组合,构建复杂的 AI 工作流。
# 配置
| 字段 | 类型 | 说明 | 默认值 |
|---|---|---|---|
| url | string | OpenAI API 兼容的请求地址。支持 ${global.xxx} 变量 | |
| key | string | API Key。支持 ${global.xxx} 变量 | |
| model | string | 模型名称,如 deepseek-chat、qwen-plus。支持 ${global.xxx} 变量 | |
| systemPrompt | string | 系统提示词,定义智能体的行为和角色。支持 ${} 占位符和 ${include("路径")} 包含文件 | |
| messages | []ChatMessage | 预设的上下文消息列表 | |
| images | []string | 输入图片列表,需要模型支持视觉能力 | |
| maxStep | int | ReAct 循环最大步数(推理+工具调用算一步) | 150 |
| maxToolOutputLength | int | 工具输出结果的最大截断长度(字节) | 50000 |
| maxRetries | int | LLM 调用失败时的最大重试次数(自动处理 429/5xx/网络错误/超时) | 3 |
| params | ModelParams | 大模型参数 | |
| tools | []Tool | 工具列表配置。详见 工具系统 |
# 大模型参数(Params)
| 字段 | 类型 | 说明 | 默认值 |
|---|---|---|---|
| temperature | float32 | 采样温度,控制输出随机性。范围 [0.0, 2.0] | 0.7 |
| topP | float32 | 核采样概率阈值。范围 [0.0, 1.0] | 0.9 |
| frequencyPenalty | float32 | 频率惩罚,抑制重复内容。范围 [0.0, 1.0] | 0.5 |
| presencePenalty | float32 | 存在惩罚,鼓励话题多样性。范围 [0.0, 1.0] | 0.5 |
| maxTokens | int | 最大输出 token 数,0 表示使用模型默认值 | 0 |
| stop | []string | 停止输出的标记列表 | |
| responseFormat | string | 输出格式:text、json_object、json_schema | text |
| jsonSchema | string | JSON Schema(responseFormat 为 json_schema 时使用) | |
| keepThink | bool | 是否保留思考过程(仅 text 格式生效) | false |
| extraFields | map | 扩展字段,传递模型特定参数,如 thinking_type、thinking_budget_tokens、reasoning_effort 等 |
# ChatMessage 结构
| 字段 | 类型 | 说明 |
|---|---|---|
| role | string | 消息角色:user、assistant、system |
| content | string/array | 消息内容。字符串或 OpenAI 多模态 ContentPart 数组 |
# 执行结果
- 同步模式:执行结果写入
msg.Data,通过Success连接流转到下一个节点 - 流式模式:逐块输出中间结果,每个 chunk 通过
Stream连接流转;最后额外发送一条Success消息(Metadata 中full_content=true),包含完整合并内容 - 失败:错误信息写入
msg.Data,通过Failure连接流转
# Relation Type
| 连接类型 | 说明 |
|---|---|
| Success | 同步模式执行成功 |
| Stream | 流式模式输出 |
| Failure | 执行失败 |
# 配置示例
# 基础对话智能体
{
"id": "node_agent",
"type": "ai/agent",
"name": "智能助手",
"configuration": {
"url": "https://ai.gitee.com/v1",
"key": "sk-xxx",
"model": "deepseek-chat",
"maxStep": 100,
"systemPrompt": "你是一个有帮助的AI助手。",
"params": {
"temperature": 0.7,
"topP": 0.9
},
"tools": [
{"type": "builtin", "name": "bash"},
{"type": "builtin", "name": "read"},
{"type": "builtin", "name": "write"}
]
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 带工作区的智能体
系统提示词从工作区文件动态加载,支持个性化配置:
{
"id": "node_agent",
"type": "ai/agent",
"name": "主智能体",
"configuration": {
"url": "${global.models.providers.default.base_url}",
"key": "${global.models.providers.default.api_key}",
"model": "${global.models.providers.default.model}",
"maxStep": 100,
"systemPrompt": "${include(global.root_dir+'/workspace/IDENTITY.md')}\n${include(global.root_dir+'/workspace/AGENTS.md')}\n${include(global.root_dir+'/workspace/SOUL.md')}\n当前时间:${now()}\n智能体ID:${ruleChain.id}",
"params": {
"temperature": 0.7,
"maxTokens": 16384
},
"tools": [
{"type": "builtin", "name": "bash", "config": {"workDir": "${global.root_dir}/workspace"}},
{"type": "builtin", "name": "read", "config": {"workDir": "${global.root_dir}/workspace"}},
{"type": "builtin", "name": "write", "config": {"workDir": "${global.root_dir}/workspace"}},
{"type": "builtin", "name": "edit", "config": {"workDir": "${global.root_dir}/workspace"}},
{
"type": "builtin", "name": "skill",
"config": {
"globalDirs": ["${global.root_dir}/skills"],
"localDirs": ["${global.root_dir}/workspace/skills"]
}
}
]
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 多工具协作智能体
组合内置工具、MCP 工具和子智能体:
{
"id": "node_agent",
"type": "ai/agent",
"name": "全栈助手",
"configuration": {
"url": "${global.models.providers.default.base_url}",
"key": "${global.models.providers.default.api_key}",
"model": "${global.models.providers.default.model}",
"maxStep": 150,
"systemPrompt": "你是一个全栈开发助手,可以编写代码、运行测试、管理文件。",
"tools": [
{"type": "builtin", "name": "bash", "config": {"workDir": "${global.root_dir}/project", "timeout": 60000}},
{"type": "builtin", "name": "read", "config": {"workDir": "${global.root_dir}/project"}},
{"type": "builtin", "name": "write", "config": {"workDir": "${global.root_dir}/project"}},
{"type": "builtin", "name": "edit", "config": {"workDir": "${global.root_dir}/project"}},
{"type": "mcp", "config": {"server": "self", "tools": ["list_rule_chains", "get_rule_chain"]}},
{"type": "agent", "targetId": "code-reviewer"}
]
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 相关文档
在 GitHub 上编辑此页 (opens new window)
上次更新: 2026/05/28, 01:50:04