@yandy0725/pi-subagents 0.9.0 → 0.10.0

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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.9.0",
6
+ "version": "0.10.0",
7
7
  "description": "Focused, in-process sub-agent core for pi — autonomous agents plus a typed API and lifecycle events",
8
8
  "license": "MIT",
9
9
  "repository": {
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-base-to-string, @typescript-eslint/restrict-template-expressions -- Pi SDK types are not fully exported; see upstream Pi SDK for type improvements */
2
2
  import type { AgentToolResult } from "@earendil-works/pi-coding-agent";
3
3
  import { defineTool } from "@earendil-works/pi-coding-agent";
4
+ import { StringEnum } from "@earendil-works/pi-ai";
4
5
  import { Text } from "@earendil-works/pi-tui";
5
6
  import { Type } from "typebox";
6
7
  import type { AgentTypeRegistry } from "../config/agent-types";
@@ -54,6 +55,21 @@ function buildTierGuideline(tiers: ModelTierMap | undefined): string | undefined
54
55
  return `User-configured subagent model tiers — when a task needs one of these capability levels, pass the mapped model via the model parameter: ${configured.join(", ")}.`;
55
56
  }
56
57
 
58
+ /**
59
+ * 行为纪律(进 system prompt 的 Guidelines,不进 description)。
60
+ *
61
+ * 之前这些写在 `description` 里,同时与参数描述重复(`run_in_background` / `resume` / `model` /
62
+ * `thinking` / `timeout` / `inherit_context` 各说两遍,共 516 字符),而 description 是每工具
63
+ * 各一份、不参与去重。现在只留“何时用 / 怎么配合”这一类,参数细节全交给参数描述。
64
+ */
65
+ const PROMPT_GUIDELINES: readonly string[] = [
66
+ "Use subagent for work that needs its own context or a different model; finish inline work yourself.",
67
+ "For parallel work set run_in_background: true on each agent — sibling foreground calls run concurrently anyway, but they block the current turn and bypass the concurrency limit.",
68
+ "Give each subagent a self-contained prompt; it cannot see the parent conversation unless inherit_context is true.",
69
+ "Subagent results come back as text — summarize them for the user.",
70
+ "Use steer_subagent to redirect a running background agent, and get_subagent_result with wait: true to block for one result.",
71
+ ];
72
+
57
73
  // ---- Class ----
58
74
 
59
75
  export class AgentTool {
@@ -131,27 +147,12 @@ export class AgentTool {
131
147
  return defineTool({
132
148
  name: "subagent" as const,
133
149
  label: "Subagent",
134
- promptSnippet: "subagent: Launch a specialized agent for complex, multi-step tasks.",
135
- ...(tierGuideline ? { promptGuidelines: [tierGuideline] } : {}),
136
- description: `Launch a new agent to handle complex, multi-step tasks autonomously.
137
-
138
- The subagent tool launches specialized agents that autonomously handle complex tasks. Each agent type has specific capabilities and tools available to it.
150
+ promptSnippet: "Launch a specialized agent for complex, multi-step tasks",
151
+ promptGuidelines: tierGuideline ? [...PROMPT_GUIDELINES, tierGuideline] : [...PROMPT_GUIDELINES],
152
+ description: `Launch a subagent that works autonomously on a task.
139
153
 
140
154
  Available agent types:
141
- ${typeListText}
142
-
143
- Guidelines:
144
- - For parallel work, use run_in_background: true on each agent. Foreground calls run sequentially — only one executes at a time.
145
- - Provide clear, detailed prompts so the agent can work autonomously.
146
- - Subagent results are returned as text — summarize them for the user.
147
- - Use run_in_background for work you don't need immediately. You will be notified when it completes.
148
- - Use resume with an agent ID to continue a previous agent's work.
149
- - Use steer_subagent to send mid-run messages to a running background agent.
150
- - Use model to specify a different model (as "provider/modelId", or fuzzy e.g. "haiku", "sonnet").
151
- - Use thinking to control extended thinking level.
152
- - Use timeout (seconds) as a hard safety net for tasks that might run away — the agent is killed at the deadline and output may be truncated.
153
- - Use inherit_context if the agent needs the parent conversation history.
154
- `,
155
+ ${typeListText}`,
155
156
  parameters: Type.Object({
156
157
  prompt: Type.String({
157
158
  description: "The task for the agent to perform.",
@@ -169,8 +170,8 @@ Guidelines:
169
170
  }),
170
171
  ),
171
172
  thinking: Type.Optional(
172
- Type.String({
173
- description: "Thinking level: off, minimal, low, medium, high, xhigh. Overrides agent default.",
173
+ StringEnum(["off", "minimal", "low", "medium", "high", "xhigh"] as const, {
174
+ description: "Thinking level override. Default: inherit the agent type's setting.",
174
175
  }),
175
176
  ),
176
177
  max_turns: Type.Optional(
@@ -90,9 +90,9 @@ export class GetResultTool {
90
90
  return defineTool({
91
91
  name: "get_subagent_result" as const,
92
92
  label: "Get Agent Result",
93
- promptSnippet: "get_subagent_result: Check status and retrieve results from a background agent.",
93
+ promptSnippet: "Check status and retrieve a background subagent's result",
94
94
  description:
95
- "Check status and retrieve results from a background agent. Use the agent ID returned by Agent with run_in_background.",
95
+ "Check status and retrieve the result of a background subagent (agent_id comes from the subagent tool).",
96
96
  parameters: Type.Object({
97
97
  agent_id: Type.String({
98
98
  description: "The agent ID to check.",
@@ -92,7 +92,7 @@ export function buildTypeListText(registry: TypeListRegistry, agentDir: string):
92
92
  ...defaultDescs,
93
93
  ...(customDescs.length > 0 ? ["", "Custom agents:", ...customDescs] : []),
94
94
  "",
95
- `Custom agents can be defined in .pi/agents/<name>.md (project) or ${agentDir}/agents/<name>.md (global) — they are picked up automatically. Project-level agents override global ones. Creating a .md file with the same name as a default agent overrides it.`,
95
+ `Custom agents live in .pi/agents/<name>.md (project) or ${agentDir}/agents/<name>.md (global); a file with a default agent's name overrides it.`,
96
96
  ].join("\n");
97
97
  }
98
98
 
@@ -66,10 +66,8 @@ export class SteerTool {
66
66
  return defineTool({
67
67
  name: "steer_subagent" as const,
68
68
  label: "Steer Agent",
69
- promptSnippet: "steer_subagent: Send a mid-run message to redirect a running background agent.",
70
- description:
71
- "Send a steering message to a running agent. The message will interrupt the agent after its current tool execution " +
72
- "and be injected into its conversation, allowing you to redirect its work mid-run. Only works on running agents.",
69
+ promptSnippet: "Send a mid-run message to redirect a running subagent",
70
+ description: "Send a mid-run steering message to a running subagent.",
73
71
  parameters: Type.Object({
74
72
  agent_id: Type.String({
75
73
  description: "The agent ID to steer (must be currently running).",