@yandy0725/pi-subagents 0.10.0 → 0.10.1
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/README.md +6 -5
- package/README.zh.md +5 -5
- package/package.json +1 -1
- package/src/config/model-tiers.ts +3 -2
- package/src/tools/agent-tool.ts +28 -7
package/README.md
CHANGED
|
@@ -121,9 +121,10 @@ Send a steering message to a running agent.
|
|
|
121
121
|
## Model Tiers
|
|
122
122
|
|
|
123
123
|
Instead of hardcoding model IDs, you can map capability tiers to concrete models in
|
|
124
|
-
`subagents.json`. The mapping
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
`subagents.json`. The mapping is listed in the `subagent` tool's `model` parameter
|
|
125
|
+
description, alongside a prompt guideline telling the agent to pick the configured
|
|
126
|
+
tier when a task calls for a specific cost or capability level — there is no
|
|
127
|
+
`model_tier` tool parameter.
|
|
127
128
|
|
|
128
129
|
| Tier | Intent |
|
|
129
130
|
|------|--------|
|
|
@@ -147,8 +148,8 @@ override one tier without restating the others:
|
|
|
147
148
|
|
|
148
149
|
Because the agent copies the mapped value into `model`, it goes through the same resolver as
|
|
149
150
|
any other model value: `provider/modelId` and fuzzy names (e.g. `"haiku"`) both work. Tiers
|
|
150
|
-
without a mapping are omitted from the
|
|
151
|
-
them. If an agent type pins `model` in its frontmatter, that model always wins.
|
|
151
|
+
without a mapping are omitted from the description and its guideline — nothing is silently
|
|
152
|
+
substituted for them. If an agent type pins `model` in its frontmatter, that model always wins.
|
|
152
153
|
|
|
153
154
|
## Commands
|
|
154
155
|
|
package/README.zh.md
CHANGED
|
@@ -120,9 +120,9 @@ timeout: 300
|
|
|
120
120
|
|
|
121
121
|
## 模型分层
|
|
122
122
|
|
|
123
|
-
除了直接写模型 ID,还可以在 `subagents.json`
|
|
124
|
-
`subagent` 工具的
|
|
125
|
-
|
|
123
|
+
除了直接写模型 ID,还可以在 `subagents.json` 中把能力档位映射到真实模型。映射表会列在
|
|
124
|
+
`subagent` 工具的 `model` 参数描述里,同时有一条 prompt guideline 提醒代理在任务需要
|
|
125
|
+
特定成本/能力档位时选用对应配置模型——不存在 `model_tier` 工具参数。
|
|
126
126
|
|
|
127
127
|
| 档位 | 定位 |
|
|
128
128
|
|------|------|
|
|
@@ -144,8 +144,8 @@ timeout: 300
|
|
|
144
144
|
```
|
|
145
145
|
|
|
146
146
|
代理会把映射值复制到 `model`,因此与普通 `model` 值走同一套解析:`provider/modelId` 与
|
|
147
|
-
模糊名称(如 `"haiku"
|
|
148
|
-
|
|
147
|
+
模糊名称(如 `"haiku"`)都可以。未配置的档位不会出现在参数描述与提示里——不会有其他
|
|
148
|
+
模型被静默顶替。若代理类型的 frontmatter 固定了 `model`,该模型始终优先。
|
|
149
149
|
|
|
150
150
|
## 命令
|
|
151
151
|
|
package/package.json
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* A tier is a user-facing class of model (`fast` | `standard` | `advanced`).
|
|
5
5
|
* Users map each tier to a real model in `subagents.json` (`modelTiers`); the
|
|
6
|
-
* mapping is surfaced to the agent
|
|
7
|
-
*
|
|
6
|
+
* mapping is surfaced to the agent in the `subagent` tool's `model` parameter
|
|
7
|
+
* description (a fact about that parameter's allowed values), plus one prompt
|
|
8
|
+
* guideline telling it to pick the matching tier when a task warrants it.
|
|
8
9
|
* There is no `model_tier` tool parameter. See README for tier semantics.
|
|
9
10
|
*/
|
|
10
11
|
|
package/src/tools/agent-tool.ts
CHANGED
|
@@ -46,15 +46,35 @@ export type AgentToolSettings = {
|
|
|
46
46
|
readonly modelTiers?: ModelTierMap;
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
/**
|
|
50
|
-
|
|
49
|
+
/**
|
|
50
|
+
* `model` 参数描述的事实部分;配置了 tiers 时再追加档位表。
|
|
51
|
+
*
|
|
52
|
+
* 档位表是 `model` 的**允许值**(R1「允许值」+ R2「参数级细节放参数」),所以落在这里;
|
|
53
|
+
* 之前整段(表 + 纪律)写在 `promptGuidelines` 里有两个问题:自定义 system prompt 时
|
|
54
|
+
* guidelines 被整体丢弃(用户配的 tier 随之静默失效,README 承诺的映射无处可查),
|
|
55
|
+
* 且把配置数据混进了行为纪律列表。纪律侧现在只留 TIER_GUIDELINE。
|
|
56
|
+
*/
|
|
57
|
+
const MODEL_PARAM_DESCRIPTION =
|
|
58
|
+
'Optional model override. Accepts "provider/modelId" or fuzzy name (e.g. "haiku", "sonnet"). Omit to use the agent type\'s default.';
|
|
59
|
+
|
|
60
|
+
/** Tier → model table for the `model` parameter description, or undefined when none configured. */
|
|
61
|
+
function buildTierTable(tiers: ModelTierMap | undefined): string | undefined {
|
|
51
62
|
const configured = MODEL_TIERS.filter((tier) => tiers?.[tier]).map(
|
|
52
63
|
(tier) => `${tier} → ${tiers?.[tier]} (${MODEL_TIER_INTENTS[tier]})`,
|
|
53
64
|
);
|
|
54
65
|
if (configured.length === 0) return undefined;
|
|
55
|
-
return
|
|
66
|
+
return configured.join(", ");
|
|
56
67
|
}
|
|
57
68
|
|
|
69
|
+
/**
|
|
70
|
+
* 纪律侧只点名「按配置档位选模型」,映射表本身在 `model` 参数描述里。
|
|
71
|
+
*
|
|
72
|
+
* 这条同时覆盖了 guidelines 通道的可用性风险:即便自定义 system prompt 让 guidelines 消失,
|
|
73
|
+
* 参数描述里的档位表仍在,模型仍能查到映射(只是少了这条主动提示)。
|
|
74
|
+
*/
|
|
75
|
+
const TIER_GUIDELINE =
|
|
76
|
+
"When a subagent task needs a specific cost or capability level, use the matching configured tier's model rather than the agent type's default.";
|
|
77
|
+
|
|
58
78
|
/**
|
|
59
79
|
* 行为纪律(进 system prompt 的 Guidelines,不进 description)。
|
|
60
80
|
*
|
|
@@ -141,14 +161,14 @@ export class AgentTool {
|
|
|
141
161
|
toToolDefinition() {
|
|
142
162
|
const typeListText = this.typeListText;
|
|
143
163
|
const availableTypesText = this.availableTypesText;
|
|
144
|
-
const
|
|
164
|
+
const tierTable = buildTierTable(this.settings.modelTiers);
|
|
145
165
|
const registry = this.registry;
|
|
146
166
|
|
|
147
167
|
return defineTool({
|
|
148
168
|
name: "subagent" as const,
|
|
149
169
|
label: "Subagent",
|
|
150
170
|
promptSnippet: "Launch a specialized agent for complex, multi-step tasks",
|
|
151
|
-
promptGuidelines:
|
|
171
|
+
promptGuidelines: tierTable ? [...PROMPT_GUIDELINES, TIER_GUIDELINE] : [...PROMPT_GUIDELINES],
|
|
152
172
|
description: `Launch a subagent that works autonomously on a task.
|
|
153
173
|
|
|
154
174
|
Available agent types:
|
|
@@ -165,8 +185,9 @@ ${typeListText}`,
|
|
|
165
185
|
}),
|
|
166
186
|
model: Type.Optional(
|
|
167
187
|
Type.String({
|
|
168
|
-
description:
|
|
169
|
-
|
|
188
|
+
description: tierTable
|
|
189
|
+
? `${MODEL_PARAM_DESCRIPTION} Configured tiers: ${tierTable}.`
|
|
190
|
+
: MODEL_PARAM_DESCRIPTION,
|
|
170
191
|
}),
|
|
171
192
|
),
|
|
172
193
|
thinking: Type.Optional(
|