Skip to content

Commit 7d475dc

Browse files
committed
♻️ 移除子代理 to 参数,Agent 管理页面添加文档链接
- 移除 sub_agent 的 to/恢复上下文功能及相关代码 - 删除 sub_agent_context repo(不再需要) - 各 Agent 管理页面(模型/Skill/MCP/任务/OPFS/设置)添加文档跳转按钮 - 新增 AgentDocLink 通用组件
1 parent 94b533d commit 7d475dc

19 files changed

+95
-422
lines changed

src/app/repo/agent_task.test.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,21 @@ describe("AgentTaskRunRepo", () => {
141141

142142
it("appendRun 超过 MAX_RUNS_PER_TASK 时裁剪最老记录", async () => {
143143
const taskId = "task-ring";
144-
for (let i = 0; i < 105; i++) {
144+
// 预填 500 条数据(最新在前),避免逐条 append 超时
145+
const prefilled: AgentTaskRun[] = [];
146+
for (let i = 499; i >= 0; i--) {
147+
prefilled.push(makeRun({ id: `rr-${i}`, taskId, starttime: i }));
148+
}
149+
await (repo as any).writeJsonFile(`${taskId}.json`, prefilled);
150+
151+
// 再 append 5 条(id rr-500 ~ rr-504),触发裁剪
152+
for (let i = 500; i < 505; i++) {
145153
await repo.appendRun(makeRun({ id: `rr-${i}`, taskId, starttime: i }));
146154
}
147-
const runs = await repo.listRuns(taskId, 200);
148-
expect(runs.length).toBe(100);
155+
const runs = await repo.listRuns(taskId, 600);
156+
expect(runs.length).toBe(500);
149157
// 最新的在前,最老 5 条被裁剪掉(rr-0 ~ rr-4)
150-
expect(runs[0].id).toBe("rr-104");
151-
expect(runs[99].id).toBe("rr-5");
158+
expect(runs[0].id).toBe("rr-504");
159+
expect(runs[499].id).toBe("rr-5");
152160
});
153161
});

src/app/repo/agent_task.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class AgentTaskRepo extends Repo<AgentTask> {
2828
}
2929
}
3030

31-
const MAX_RUNS_PER_TASK = 100;
31+
const MAX_RUNS_PER_TASK = 500;
3232

3333
export class AgentTaskRunRepo extends OPFSRepo {
3434
constructor() {

src/app/repo/sub_agent_context.test.ts

Lines changed: 0 additions & 106 deletions
This file was deleted.

src/app/repo/sub_agent_context.ts

Lines changed: 0 additions & 55 deletions
This file was deleted.

src/app/service/agent/core/system_prompt.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ The sub-agent starts fresh — it has zero context from this conversation. Brief
136136
- **Launch multiple agents concurrently** whenever possible — call \`agent\` multiple times **in the same response**.
137137
- Sub-agent results are not visible to the user. Summarize the results for the user after sub-agents complete.
138138
- Sub-agents share the parent's task list — they can call \`update_task\` to report progress.
139-
- To continue a previously completed sub-agent, use the \`to\` parameter with the agentId.
140139
141140
### When NOT to Use
142141

src/app/service/agent/core/tools/sub_agent.test.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ describe("sub_agent", () => {
1515
prompt: "Search for X",
1616
description: "Searching X",
1717
type: undefined,
18-
to: undefined,
1918
});
2019
expect(result).toContain("[agentId: test-id]");
2120
expect(result).toContain("Sub-agent result");
@@ -30,20 +29,18 @@ describe("sub_agent", () => {
3029
prompt: "Do something",
3130
description: "Sub-agent task",
3231
type: undefined,
33-
to: undefined,
3432
});
3533
});
3634

37-
it("should pass type and to parameters", async () => {
35+
it("should pass type parameter", async () => {
3836
const mockRunSubAgent = vi.fn().mockResolvedValue({ agentId: "id3", result: "ok" });
3937
const { executor } = createSubAgentTool({ runSubAgent: mockRunSubAgent });
4038

41-
await executor.execute({ prompt: "Research X", type: "researcher", to: "prev-agent-id" });
39+
await executor.execute({ prompt: "Research X", type: "researcher" });
4240
expect(mockRunSubAgent).toHaveBeenCalledWith({
4341
prompt: "Research X",
4442
description: "Sub-agent task",
4543
type: "researcher",
46-
to: "prev-agent-id",
4744
});
4845
});
4946

src/app/service/agent/core/tools/sub_agent.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export type SubAgentRunOptions = {
88
prompt: string;
99
description: string;
1010
type?: string;
11-
to?: string; // 延续已有子代理
1211
tabId?: number; // 父代理传递的标签页上下文
1312
};
1413

@@ -26,30 +25,24 @@ const SUB_AGENT_TYPE_NAMES = Object.keys(SUB_AGENT_TYPES);
2625
export const SUB_AGENT_DEFINITION: ToolDefinition = {
2726
name: "agent",
2827
description:
29-
"Launch a sub-agent to handle a subtask autonomously. Sub-agents run in their own conversation context. Use the `type` parameter to select a specialized sub-agent, or use `to` to continue a previous sub-agent with follow-up instructions.",
28+
"Launch a sub-agent to handle a subtask autonomously. Sub-agents run in their own conversation context. Use the `type` parameter to select a specialized sub-agent.",
3029
parameters: {
3130
type: "object",
3231
properties: {
3332
prompt: {
3433
type: "string",
35-
description: "The task description or follow-up message for the sub-agent. Be specific about what you need.",
34+
description: "The task description for the sub-agent. Be specific about what you need.",
3635
},
3736
description: {
3837
type: "string",
39-
description:
40-
"A short (3-5 word) description of what the sub-agent will do, shown in the UI. Optional when resuming a previous sub-agent via `to`.",
38+
description: "A short (3-5 word) description of what the sub-agent will do, shown in the UI.",
4139
},
4240
type: {
4341
type: "string",
4442
enum: SUB_AGENT_TYPE_NAMES,
4543
description:
4644
"Sub-agent type. 'researcher' (web search/fetch, page reading — read-only, no DOM interaction), 'page_operator' (browser tab interaction, DOM manipulation, page automation), 'general' (all tools, default). Choose the most specific type for better results.",
4745
},
48-
to: {
49-
type: "string",
50-
description:
51-
"agentId of a previously completed sub-agent. Sends a follow-up message while preserving the sub-agent's full conversation context.",
52-
},
5346
tab_id: {
5447
type: "number",
5548
description:
@@ -71,10 +64,9 @@ export function createSubAgentTool(params: {
7164
const prompt = requireString(args, "prompt");
7265
const description = (args.description as string) || "Sub-agent task";
7366
const type = args.type as string | undefined;
74-
const to = args.to as string | undefined;
7567
const tabId = args.tab_id as number | undefined;
7668

77-
const result = await params.runSubAgent({ prompt, description, type, to, tabId });
69+
const result = await params.runSubAgent({ prompt, description, type, tabId });
7870

7971
// 返回结构化结果,附带子代理执行详情用于持久化
8072
const content = `[agentId: ${result.agentId}]\n\n${result.result}`;

src/app/service/agent/service_worker/chat_service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ export class ChatService {
522522
// Sub-agent
523523
const subAgentTool = createSubAgentTool({
524524
runSubAgent: (options: SubAgentRunOptions) => {
525-
const agentId = options.to || uuidv4();
525+
const agentId = uuidv4();
526526
const typeConfig = resolveSubAgentType(options.type);
527527
// 组合父信号和类型配置的超时信号
528528
const subSignal = AbortSignal.any([abortController.signal, AbortSignal.timeout(typeConfig.timeoutMs)]);

0 commit comments

Comments
 (0)