From 9b8cf79c96668628926d32046cd650f0cfbd285b Mon Sep 17 00:00:00 2001 From: weichen Date: Thu, 1 Oct 2026 15:21:47 +0000 Subject: [PATCH] Add optional tools, model, and maxTurns to prompt modules Why: User overrides of a subagent profile need a place on the shared contract, and empty fields must stay omitted so older modules keep their meaning. Evidence: go test ./... passed, including the new prompt_module_subagent golden. Impact: Existing modules serialize the same. Frontend and UI contracts still need a copy of the type. Refs: feature/agent-harness-p3b Co-authored-by: Cursor --- conformance_test.go | 8 ++++++++ prompts.go | 4 ++++ testdata/golden/prompt_module_subagent.json | 14 ++++++++++++++ ts/types.ts | 2 ++ 4 files changed, 28 insertions(+) create mode 100644 testdata/golden/prompt_module_subagent.json diff --git a/conformance_test.go b/conformance_test.go index 5e65262..27c3cce 100644 --- a/conformance_test.go +++ b/conformance_test.go @@ -60,6 +60,14 @@ func sampleRun() Run { } } +func TestGoldenPromptModule(t *testing.T) { + golden(t, "prompt_module_subagent", PromptModule{ + ID: "agent.sub.explore", Layer: LayerAgent, Version: 1, + Title: "探索子代理", Body: "只读检索。", + Tools: []string{"knowledge_search", "web_search"}, Model: "lightweight", MaxTurns: 8, + }) +} + func TestGoldenDomain(t *testing.T) { golden(t, "message", sampleMessage()) golden(t, "run", sampleRun()) diff --git a/prompts.go b/prompts.go index 66fd5b1..ded5267 100644 --- a/prompts.go +++ b/prompts.go @@ -26,6 +26,10 @@ type PromptModule struct { BasedOnVersion int `json:"basedOnVersion,omitempty"` // 用户副本基于的内置版本 Drifted bool `json:"drifted,omitempty"` // 用户副本落后于当前内置版本(提示用,不阻断) Disabled bool `json:"disabled,omitempty"` // 用户停用 + // 子代理 profile。只对 agent.sub.* 有意义;空字段表示沿用内置。 + Tools []string `json:"tools,omitempty"` + Model string `json:"model,omitempty"` // lightweight | chat + MaxTurns int `json:"maxTurns,omitempty"` } // PromptTrigger 触发条件;模块命中 = 任一 trigger 命中(再过 RequiresAttachments)。 diff --git a/testdata/golden/prompt_module_subagent.json b/testdata/golden/prompt_module_subagent.json new file mode 100644 index 0000000..438a61e --- /dev/null +++ b/testdata/golden/prompt_module_subagent.json @@ -0,0 +1,14 @@ +{ + "id": "agent.sub.explore", + "layer": "agent", + "version": 1, + "title": "探索子代理", + "description": "", + "body": "只读检索。", + "tools": [ + "knowledge_search", + "web_search" + ], + "model": "lightweight", + "maxTurns": 8 +} diff --git a/ts/types.ts b/ts/types.ts index 85f3dfd..50c83d7 100644 --- a/ts/types.ts +++ b/ts/types.ts @@ -209,6 +209,8 @@ export interface PromptModule { body: string; outputContract?: string; source?: 'builtin' | 'plugin' | 'user'; owner?: string; basedOnVersion?: number; drifted?: boolean; disabled?: boolean; + /** 子代理 profile。只对 agent.sub.* 有意义;空字段表示沿用内置。 */ + tools?: string[]; model?: string; maxTurns?: number; } export interface PromptBlock { moduleId: string; version: number; layer: string; body: string; }