@ai-zen/agents-sdk 0.2.5 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.2.6] - 2026-07-20
|
|
4
|
+
|
|
5
|
+
### 🔧 修复
|
|
6
|
+
|
|
7
|
+
- **默认 SubAgent 函数名和描述不足以让 LLM 识别为子 Agent** — `function.name` 从 `general_assistant` 改为 `sub_agent_default`,`function.description` 重写为详细描述,明确子 Agent 身份和能力边界。参数名 `query` → `task` 与设计规范统一,system prompt 明确角色定位
|
|
8
|
+
- **`DEFAULT_SUBAGENT_ID` 从 `general-assistant` 改为 `sub-agent-default`** — 文件名与函数名对应,便于识别
|
|
9
|
+
|
|
3
10
|
## [0.2.5] - 2026-07-20
|
|
4
11
|
|
|
5
12
|
### 🔧 修复
|
|
@@ -4,7 +4,7 @@ export declare const DEFAULT_AGENT_ID = "default";
|
|
|
4
4
|
/** 默认 Agent 定义(不含时间戳) */
|
|
5
5
|
export declare const DEFAULT_AGENT_DEFINITION: Omit<AgentDefinition, "createdAt" | "updatedAt">;
|
|
6
6
|
/** 默认 SubAgent ID */
|
|
7
|
-
export declare const DEFAULT_SUBAGENT_ID = "
|
|
7
|
+
export declare const DEFAULT_SUBAGENT_ID = "sub-agent-default";
|
|
8
8
|
/** 默认 SubAgent 定义(不含时间戳) */
|
|
9
9
|
export declare const DEFAULT_SUBAGENT_DEFINITION: Omit<AgentDefinition, "createdAt" | "updatedAt">;
|
|
10
10
|
/** SDK 出厂默认 AppConfig。CLI/Desktop 首次初始化时使用。 */
|
package/dist/config/constants.js
CHANGED
|
@@ -26,7 +26,7 @@ export const DEFAULT_AGENT_DEFINITION = {
|
|
|
26
26
|
// 默认 SubAgent
|
|
27
27
|
// ---------------------------------------------------------------------------
|
|
28
28
|
/** 默认 SubAgent ID */
|
|
29
|
-
export const DEFAULT_SUBAGENT_ID = "
|
|
29
|
+
export const DEFAULT_SUBAGENT_ID = "sub-agent-default";
|
|
30
30
|
/** 默认 SubAgent 定义(不含时间戳) */
|
|
31
31
|
export const DEFAULT_SUBAGENT_DEFINITION = {
|
|
32
32
|
id: DEFAULT_SUBAGENT_ID,
|
|
@@ -35,9 +35,9 @@ export const DEFAULT_SUBAGENT_DEFINITION = {
|
|
|
35
35
|
messages: [
|
|
36
36
|
{
|
|
37
37
|
role: AgentNS.Role.System,
|
|
38
|
-
content: "
|
|
38
|
+
content: "你是一个通用助手子 Agent,被父 Agent 委派来独立完成具体任务。请根据给定的任务描述,主动调用你的工具(文件读写、执行命令、搜索等)来分析和完成任务。完成任务后直接返回结果,不需要解释你的思考过程。",
|
|
39
39
|
},
|
|
40
|
-
{ role: AgentNS.Role.User, content: "{{
|
|
40
|
+
{ role: AgentNS.Role.User, content: "{{task}}" },
|
|
41
41
|
],
|
|
42
42
|
permissions: {
|
|
43
43
|
tools: { allow: ["*"] },
|
|
@@ -46,14 +46,14 @@ export const DEFAULT_SUBAGENT_DEFINITION = {
|
|
|
46
46
|
subagents: { deny: ["*"] },
|
|
47
47
|
},
|
|
48
48
|
function: {
|
|
49
|
-
name: "
|
|
50
|
-
description: "
|
|
49
|
+
name: "sub_agent_default",
|
|
50
|
+
description: "通用子 Agent,可独立完成各类任务。将任务委派给它后,它会自主调用自身工具(文件读写、代码执行、搜索等)来完成任务并返回结果。适合处理需要多步骤执行、工具调用的复杂任务。",
|
|
51
51
|
parameters: {
|
|
52
52
|
type: "object",
|
|
53
53
|
properties: {
|
|
54
|
-
|
|
54
|
+
task: { type: "string", description: "任务描述" },
|
|
55
55
|
},
|
|
56
|
-
required: ["
|
|
56
|
+
required: ["task"],
|
|
57
57
|
additionalProperties: false,
|
|
58
58
|
},
|
|
59
59
|
},
|
|
@@ -29,7 +29,7 @@ export function createAgent(provider, agentId) {
|
|
|
29
29
|
: undefined,
|
|
30
30
|
},
|
|
31
31
|
});
|
|
32
|
-
|
|
32
|
+
const agent = new SdkAgent({
|
|
33
33
|
provider,
|
|
34
34
|
definition,
|
|
35
35
|
model,
|
|
@@ -38,4 +38,18 @@ export function createAgent(provider, agentId) {
|
|
|
38
38
|
permissions: definition.permissions,
|
|
39
39
|
caps,
|
|
40
40
|
});
|
|
41
|
+
// 设置 onUnknownTool 钩子:当 LLM 调用不存在的工具时,给出智能提示
|
|
42
|
+
agent.onUnknownTool = (ctx) => {
|
|
43
|
+
const toolName = ctx.toolCall.function?.name ?? "未知";
|
|
44
|
+
const hasMcpConfig = provider.mcpPaths.length > 0;
|
|
45
|
+
const hasCallMcpTool = tools.some((t) => t.function.name === "call_mcp_tool");
|
|
46
|
+
if (hasMcpConfig && !hasCallMcpTool) {
|
|
47
|
+
return `工具 "${toolName}" 不存在。当前有 MCP 服务器配置,但 call_mcp_tool 权限已被禁用,如需使用 MCP 工具请调整权限。`;
|
|
48
|
+
}
|
|
49
|
+
if (hasMcpConfig && hasCallMcpTool) {
|
|
50
|
+
return `工具 "${toolName}" 不存在。如果要调用 MCP 工具,请使用 call_mcp_tool。`;
|
|
51
|
+
}
|
|
52
|
+
return `工具 "${toolName}" 不存在。`;
|
|
53
|
+
};
|
|
54
|
+
return agent;
|
|
41
55
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-zen/agents-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "AI-Zen Agents SDK — shared business logic for CLI and Desktop",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
20
20
|
"dayjs": "^1.11.21",
|
|
21
|
-
"@ai-zen/agents-core": "3.0.0-alpha.
|
|
21
|
+
"@ai-zen/agents-core": "3.0.0-alpha.4"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/node": "^24.12.2",
|