Files
tmp/harness-properties.md
T
2026-09-21 15:52:05 +08:00

362 lines
13 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# AgentProperties 配置文档
本文档描述 `AgentProperties` 类及其内部静态类的配置字段。每个字段都通过 `@Schema` 注解提供了描述信息。
## 主类:AgentProperties
| 字段名 | 类型 | 描述 |
|--------|------|------|
| mainAgentSpec | MainAgentSpec | 主智能体规格 |
| workspace | Workspace | 工作区配置 |
| compaction | Compaction | 上下文压缩配置 |
| skillRepository | SkillRepository | SKILL相关配置 |
| a2sMcpProvider | McpProvider | AaaS的MCP供应商配置 |
| mcpServerConfigs | List\<McpServerConfig\> | MCP服务配置列表 |
| permissionContext | PermissionContext | 权限上下文配置 |
| memoryConfig | MemoryConfig | 长期记忆配置 |
| subagentSpec | List\<SubagentSpec\> | 子智能体清单 |
## 内部类:MainAgentSpec
主智能体规格配置。
| 字段名 | 类型 | 描述 | 默认值 |
|--------|------|------|--------|
| name | String | 智能体名字 | - |
| description | String | 智能体描述 | - |
| systemPrompt | String | 系统提示词 | - |
| chatModel | NewApiModelProperties | 聊天模型 | - |
| enablePlanMode | Boolean | 是否启用计划模式 | - |
| enableShell | Boolean | 是否启用SHELL | - |
| enableAgentTraceLog | Boolean | 是否打印TraceLog | - |
| asyncToolTimeout | int | 异步工具执行超时(单位:秒) | - |
| maxContextTokens | int | 最大上下文(默认:8000) | 8000 |
| maxIter | int | 最大迭代次数(默认:10) | 10 |
| maxRetries | int | 最大重试次数(默认:3) | 3 |
## 内部类:Workspace
工作区配置。
| 字段名 | 类型 | 描述 |
|--------|------|------|
| stateStoreType | String | 状态存储(mysql/redis) |
| isolationScope | String | 隔离级别 |
| anonymousUserId | String | 当上下文没有用户ID使用的默认值 |
## 内部类:Compaction
上下文压缩配置。
| 字段名 | 类型 | 描述 | 默认值 |
|--------|------|------|--------|
| triggerMessages | int | 触发压缩的消息数量阈值(0表示不按消息数触发) | 50 |
| triggerTokens | int | 触发压缩的token数量阈值(0表示动态模式:根据模型上下文窗口减去reserved计算) | 0 |
| reserved | int | 预留的token数量(仅动态模式使用) | 20000 |
| keepMessages | int | 压缩后保留的消息数量 | 20 |
| keepTokens | int | 压缩后保留的token数量(-1表示动态模式,0表示使用keepMessages) | -1 |
| keepTokensMin | int | 最小保留token数量(动态模式) | 2000 |
| keepTokensMax | int | 最大保留token数量(动态模式) | 8000 |
| keepTokensRatio | Double | 保留token的比例(动态模式) | 0.25 |
| summaryPrompt | String | 摘要提示词,'default'表示使用默认提示词 | - |
| flushBeforeCompact | Boolean | 压缩前是否刷新消息到存储 | true |
| offloadBeforeCompact | Boolean | 压缩前是否卸载消息到外部存储 | true |
| prune | PruneConfig | 剪枝配置 | - |
| truncate | TruncateArgs | 截断配置 | - |
| model | NewApiModelProperties | 压缩使用的模型,不设置则使用智能体主模型 | - |
## 内部类:McpProvider
AaaS的MCP供应商配置。
| 字段名 | 类型 | 描述 | 示例 |
|--------|------|------|------|
| apiGateway | String | API网关 | https://misdev.lcfuturecenter.com/prod-api |
| apiQueryMcpServerInfoUri | String | 查询MCP连接信息(批量) | /mcp/server/openapi/list |
| httpClient | HttpClientConfig | HTTP客户端配置 | - |
## 内部类:McpServerConfig
MCP服务配置。
| 字段名 | 类型 | 描述 | 默认值 |
|--------|------|------|--------|
| serverName | String | MCP服务名称 | - |
| transport | String | 协议(stdio/sse/http) | - |
| enableTools | List\<String\> | 启用的工具列表 | - |
| initializationTimeout | int | 多少秒初始化超时(默认10秒) | 10 |
| timeout | int | 多少秒执行超时(默认600秒) | 600 |
## 内部类:SkillRepository
SKILL相关配置。
| 字段名 | 类型 | 描述 |
|--------|------|------|
| mysql | MysqlSkillRepository | 从MySQL加载 |
| classPath | ClassPathSkillRepository | 从classpath加载 |
| a2s | A2sSkillRepository | 从AaaS加载 |
| httpClient | HttpClientConfig | HTTP客户端配置 |
## 内部类:HttpClientConfig
HTTP客户端配置。
| 字段名 | 类型 | 描述 | 示例 |
|--------|------|------|------|
| version | String | HTTP协议版本,仅支持:HTTP/1.1、HTTP/2 | HTTP/1.1 |
| connectTimeout | int | 连接超时(单位:秒) | - |
| requestTimeout | int | 单个请求超时(单位:秒) | - |
| enableRequestLogger | Boolean | 是否开启请求日志打印 | - |
| enableResponseLogger | Boolean | 是否开启响应日志打印(下载或流式传输会忽略掉) | - |
| defaultHeaders | Map\<String, String\> | 自定义的默认请求头 | - |
## 内部类:A2sSkillRepository
从AaaS加载SKILL的配置。
| 字段名 | 类型 | 描述 | 示例 |
|--------|------|------|------|
| enable | Boolean | 是否启用 | - |
| directory | String | 从A2s下载到服务器本地的目录 | - |
| apiGateway | String | API网关 | https://misdev.lcfuturecenter.com/prod-api |
| apiDebugSkillInfoUri | String | 查询调试版SKILL信息的URI | /mcp/skill/openapi/debug/{skill_name} |
| apiReleaseSkillInfoUri | String | 查询正式版SKILL信息的URI(支持占位符) | /mcp/skill/openapi/release/{skill_name} |
| apiDownloadSkillUri | String | 下载SKILL的地址(支持占位符) | /resource/oss/download/{oss_id} |
| availableSkills | Set\<String\> | 可用SKILL名称列表 | - |
## 内部类:ClassPathSkillRepository
从classpath加载SKILL的配置。
| 字段名 | 类型 | 描述 |
|--------|------|------|
| enable | Boolean | 是否启用 |
| directory | String | 目录名称 |
## 内部类:MysqlSkillRepository
从MySQL加载SKILL的配置。
| 字段名 | 类型 | 描述 |
|--------|------|------|
| enable | Boolean | 是否启用 |
| databaseName | String | 数据库名称 |
| skillsTableName | String | SKILL表名称 |
| resourcesTableName | String | SKILL资源表名称 |
| createIfNotExist | Boolean | 没有表是否框架自行创建表 |
| writeable | Boolean | 平台统一管理 skill 时常用,设置为true后可以从 agent 侧写回,只读分发就设置为false |
## 内部类:PruneConfig
剪枝配置。
| 字段名 | 类型 | 描述 | 默认值 |
|--------|------|------|--------|
| protectTokens | int | 保护的token数量,剪枝时不会删除这些token | 40000 |
| minimumTokens | int | 最小token数量,剪枝后不会低于此值 | 20000 |
| maxOutputChars | int | 工具输出的最大字符数,超过则截断 | 2000 |
| excludedTools | Set\<String\> | 排除的工具列表,这些工具的输出不会被剪枝 | ["read_file", "memory_search", "memory_get", "session_search"] |
## 内部类:TruncateArgs
截断配置。
| 字段名 | 类型 | 描述 | 默认值 |
|--------|------|------|--------|
| triggerMessages | int | 触发截断的消息数量阈值 | 25 |
| triggerTokens | int | 触发截断的token数量阈值 | 40000 |
| keepMessages | int | 截断后保留的消息数量 | 20 |
| keepTokens | int | 截断后保留的token数量 | 0 |
| maxArgLength | int | 工具参数的最大长度,超过则截断 | 2000 |
| truncationText | String | 截断时显示的提示文本 | ...(argument truncated) |
## 内部类:PermissionContext
权限上下文配置。
| 字段名 | 类型 | 描述 | 默认值 | 示例 |
|--------|------|------|--------|------|
| mode | String | 工作区权限上下文模式 | default | default/accept_edits/explore/bypass/dont_ask |
| allow | Set\<String\> | 运行执行的工具列表 | - | - |
| deny | Set\<String\> | 拒绝执行的工具列表 | - | - |
| ask | Set\<String\> | 需要询问用户的工具列表 | - | - |
## 内部类:MemoryConfig
长期记忆配置。
| 字段名 | 类型 | 描述 | 默认值 | 示例 |
|--------|------|------|--------|------|
| model | NewApiModelProperties | 记忆操作(刷新 + 归纳)专用模型,不设置则使用智能体主模型 | - | - |
| flushPrompt | String | 刷新记忆的提示词,null表示使用默认值 | - | - |
| consolidationPrompt | String | 归纳记忆的提示词,必须包含两个%d占位符(max-tokens, max-chars),null表示使用默认值 | - | - |
| consolidationMaxTokens | int | 归纳时的最大token数 | 4000 | 4000 |
| consolidationMinGap | int | 归纳的最小间隔(单位:分钟) | 30 | 30 |
| dailyFileRetentionDays | int | 每日记忆文件保留天数 | 30 | 30 |
| sessionRetentionDays | int | 会话记忆JSONL日志保留天数 | 30 | 30 |
| flushTrigger | String | 每次调用后flush的触发策略(ALWAYS/NEVER) | ALWAYS | ALWAYS |
## 内部类:SubagentSpec
子智能体规格配置。
| 字段名 | 类型 | 描述 | 默认值 |
|--------|------|------|--------|
| name | String | 子智能体名称 | - |
| description | String | 子智能体描述 | - |
| systemPrompt | String | 子智能体的系统提示词 | - |
| workspaceMode | String | 工作区模式:SHARED=共享主智能体的工作区,ISOLATED=独立的工作区 | SHARED |
| model | NewApiModelProperties | 子智能体使用的模型,不设置则使用主智能体的模型 | - |
| steps | int | 这个子智能体单次最大迭代次数,不填或者设置0则使用主智能体最大迭代次数的1/2 | 0 |
| mode | String | 默认 subagent,可选:primary/subagent/all;primary 不允许被 spawn | subagent |
| hidden | Boolean | 默认false,设为 true 时不出现在 agent 可见列表(仍可程序化 spawn) | false |
---
## 示例 JSON
```json
{
"mainAgentSpec": {
"name": "main-agent",
"description": "主智能体",
"systemPrompt": "你是一个有用的助手。",
"chatModel": {
"model": "gpt-4",
"apiKey": "your-api-key"
},
"enablePlanMode": true,
"enableShell": false,
"enableAgentTraceLog": true,
"asyncToolTimeout": 30,
"maxContextTokens": 8000,
"maxIter": 10,
"maxRetries": 3
},
"workspace": {
"stateStoreType": "mysql",
"isolationScope": "USER",
"anonymousUserId": "anonymous"
},
"compaction": {
"triggerMessages": 50,
"triggerTokens": 0,
"reserved": 20000,
"keepMessages": 20,
"keepTokens": -1,
"keepTokensMin": 2000,
"keepTokensMax": 8000,
"keepTokensRatio": 0.25,
"summaryPrompt": "default",
"flushBeforeCompact": true,
"offloadBeforeCompact": true,
"prune": {
"protectTokens": 40000,
"minimumTokens": 20000,
"maxOutputChars": 2000,
"excludedTools": ["read_file", "memory_search", "memory_get", "session_search"]
},
"truncate": {
"triggerMessages": 25,
"triggerTokens": 40000,
"keepMessages": 20,
"keepTokens": 0,
"maxArgLength": 2000,
"truncationText": "...(argument truncated)"
},
"model": {
"model": "gpt-4",
"apiKey": "your-api-key"
}
},
"skillRepository": {
"mysql": {
"enable": true,
"databaseName": "skill_db",
"skillsTableName": "skills",
"resourcesTableName": "skill_resources",
"createIfNotExist": true,
"writeable": false
},
"classPath": {
"enable": true,
"directory": "skills"
},
"a2s": {
"enable": true,
"directory": "/app/skills",
"apiGateway": "https://misdev.lcfuturecenter.com/prod-api",
"apiDebugSkillInfoUri": "/mcp/skill/openapi/debug/{skill_name}",
"apiReleaseSkillInfoUri": "/mcp/skill/openapi/release/{skill_name}",
"apiDownloadSkillUri": "/resource/oss/download/{oss_id}",
"availableSkills": ["skill1|debug", "skill2|release"]
},
"httpClient": {
"version": "HTTP/1.1",
"connectTimeout": 10,
"requestTimeout": 30,
"enableRequestLogger": true,
"enableResponseLogger": false,
"defaultHeaders": {
"Authorization": "Bearer token123"
}
}
},
"a2sMcpProvider": {
"apiGateway": "https://misdev.lcfuturecenter.com/prod-api",
"apiQueryMcpServerInfoUri": "/mcp/server/openapi/list",
"httpClient": {
"version": "HTTP/1.1",
"connectTimeout": 10,
"requestTimeout": 30,
"enableRequestLogger": true,
"enableResponseLogger": false,
"defaultHeaders": {}
}
},
"mcpServerConfigs": [
{
"serverName": "weather-server",
"transport": "sse",
"enableTools": ["get_weather", "get_forecast"],
"initializationTimeout": 10,
"timeout": 600
}
],
"permissionContext": {
"mode": "default",
"allow": ["read_file", "list_files"],
"deny": ["delete_file"],
"ask": ["write_file"]
},
"memoryConfig": {
"model": {
"model": "gpt-4",
"apiKey": "your-api-key"
},
"flushPrompt": "刷新记忆提示词",
"consolidationPrompt": "归纳记忆提示词,最大token数:%d,最大字符数:%d",
"consolidationMaxTokens": 4000,
"consolidationMinGap": 30,
"dailyFileRetentionDays": 30,
"sessionRetentionDays": 30,
"flushTrigger": "ALWAYS"
},
"subagentSpec": [
{
"name": "research-agent",
"description": "研究智能体",
"systemPrompt": "你是一个研究助手。",
"workspaceMode": "SHARED",
"model": {
"model": "gpt-4",
"apiKey": "your-api-key"
},
"steps": 5,
"mode": "subagent",
"hidden": false
}
]
}
```