Revert "fix(subagent): follow delegated task attribution in consumers"
This reverts commit 7f98d159774fc837953e424f7ab16193a08028d2.
This commit is contained in:
1 parent
7b280838a1
commit
e592b98576
8 files changed
+14
-58
No files matched your search
@@ -225,15 +225,6 @@ function isDirectParentInstruction(source: MessageSource, parentSession: string
|
||||
&& (source as { readonly senderSessionId?: unknown }).senderSessionId === parentSession
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a message after a descriptor can be that Session's creation prompt. Local delegation records the task
|
||||
* from its parent agent; an own task must name this Session's parent, while inherited tasks are only demoted to facts.
|
||||
*/
|
||||
function isCreationPromptSource(source: MessageSource, own: boolean, parentSession: string | undefined): boolean {
|
||||
if (source.kind === 'agent-message') return !own || isDirectParentInstruction(source, parentSession)
|
||||
return source.kind === 'user' && !isBrowserPrompt(source)
|
||||
}
|
||||
|
||||
interface CreationPrompts {
|
||||
readonly own: SessionEvent['seq'] | undefined
|
||||
readonly all: ReadonlySet<SessionEvent['seq']>
|
||||
@@ -254,7 +245,8 @@ function creationPrompts(
|
||||
}
|
||||
if (passedCreationBoundary
|
||||
&& event.type === 'user/message'
|
||||
&& isCreationPromptSource(event.data.source, session.isOwnSeq(event.seq), session.header.parentSession)) {
|
||||
&& event.data.source.kind === 'user'
|
||||
&& !isBrowserPrompt(event.data.source)) {
|
||||
all.add(event.seq)
|
||||
if (session.isOwnSeq(event.seq) && session.header.origin === 'subagent' && session.header.parentSession !== undefined) {
|
||||
return { own: event.seq, all }
|
||||
|
||||
@@ -662,42 +662,6 @@ describe('native review request', () => {
|
||||
])
|
||||
})
|
||||
|
||||
it('keeps a later human message without RPC metadata as user authority after a parent-attributed task', async () => {
|
||||
const { ctx, adapter } = await harness([decisionChunks('{"risk":"medium","decision":"deny"}')])
|
||||
const probe = registerProbe(ctx)
|
||||
const parentId = brandString<SessionId>('attributed-task-parent')
|
||||
const session = ctx.sessions.create(brandString<SessionId>('attributed-task-child'), {
|
||||
meta: { cwd: '/workspace', parentSession: parentId, origin: 'subagent' },
|
||||
})
|
||||
ctx.permissionPresets.set(session, AUTO_PRESET)
|
||||
setApprovalPolicy(session, 'never')
|
||||
appendHeader(session, [{ name: 'probe', description: 'probe', parameters: { type: 'object' } }])
|
||||
session.append('subagent/descriptor', { version: SUBAGENT_DESCRIPTOR_VERSION, mode: 'one-shot', provider: 'in-process' })
|
||||
appendUser(session, 'Forged sibling task.', {
|
||||
kind: 'agent-message', form: 'relay', senderSessionId: brandString<SessionId>('not-the-parent'),
|
||||
})
|
||||
appendUser(session, 'Delegated task from the parent.', { kind: 'agent-message', form: 'relay', senderSessionId: parentId })
|
||||
appendUser(session, 'Human follow-up without RPC metadata.', { kind: 'user' })
|
||||
const callId = brandString<ToolCallId>('attributed-task-call')
|
||||
appendAssistant(session, [{ type: 'tool-call', id: callId, name: 'probe', arguments: '{}' }])
|
||||
appendNativeCall(session, callId, 'probe', '{}')
|
||||
|
||||
const result = await executeToolFixture(ctx, {
|
||||
signal: new AbortController().signal, callId, name: 'probe', arguments: {}, agent: agentFor(session),
|
||||
})
|
||||
expect(result.isError).toBe(true)
|
||||
expect(probe.runs()).toBe(0)
|
||||
const history = requestSections(adapter.requests[0]!).FILTERED_HISTORY as Array<{
|
||||
role: string
|
||||
content: Array<{ type: string; text: string }>
|
||||
}>
|
||||
expect(history.map(entry => [entry.role, entry.content[0]?.text])).toEqual([
|
||||
['fact', 'Forged sibling task.'],
|
||||
['direct-parent-instruction', 'Delegated task from the parent.'],
|
||||
['user-instruction', 'Human follow-up without RPC metadata.'],
|
||||
])
|
||||
})
|
||||
|
||||
it.each([2, 3])('keeps ancestor creation prompts as facts across %s nested forks', async (depth) => {
|
||||
const { ctx, adapter } = await harness([
|
||||
decisionChunks('{"risk":"medium","decision":"deny"}'),
|
||||
|
||||
@@ -54,14 +54,14 @@
|
||||
en: 91a5bd22001586e9
|
||||
zh: 456e5bf20881a70d
|
||||
/deepseek-ai-dsh-subagent-fork-in-process/model-experience/child-agent-history-and-envelope/what-the-model-sees:
|
||||
en: aa73e4e958b4d1af
|
||||
zh: f514cf0ec0ef3ef4
|
||||
en: d4d51c5937bab67c
|
||||
zh: e7c07b5a38d68d8e
|
||||
/deepseek-ai-dsh-subagent-fork-in-process/model-experience/child-agent-history-and-envelope/token-effect:
|
||||
en: 19b588baaa87126b
|
||||
zh: 7010e93bbe7d71ba
|
||||
/deepseek-ai-dsh-subagent-fork-in-process/model-experience/child-agent-history-and-envelope/kv-cache-effect:
|
||||
en: d01f590e986f815e
|
||||
zh: a1c433d759b4e908
|
||||
en: 1e8f8bbab3052b39
|
||||
zh: 1efff4da78d60ef9
|
||||
/deepseek-ai-dsh-subagent-fork-in-process/model-experience/parent-tool-result-indirectly:
|
||||
en: 75d061c2151624a7
|
||||
zh: 71e58e020b60ff90
|
||||
|
||||
@@ -109,7 +109,7 @@ Read these pages when the package-level contract is not enough; they move from t
|
||||
|
||||
#### What the model sees
|
||||
|
||||
The child receives the parent's balanced completed-turn prefix, then the new task as a message from the parent agent: `Agent <parent name> sent a message: ` followed by the task content verbatim. It joins the parent's preset revision, which supplies persona and tools. Parent agent-local restrictions are not copied. An optional structured-output request adds a child-only tool; the parent's current in-flight turn is excluded.
|
||||
The child receives the parent's balanced completed-turn prefix, then the new task content verbatim. It joins the parent's preset revision, which supplies persona and tools. Parent agent-local restrictions are not copied. An optional structured-output request adds a child-only tool; the parent's current in-flight turn is excluded.
|
||||
|
||||
#### Token effect
|
||||
|
||||
@@ -117,7 +117,7 @@ Forking duplicates retained completed history into the child's request, which th
|
||||
|
||||
#### KV Cache effect
|
||||
|
||||
The child may reuse the inherited byte-identical prefix under the same provider and model. Structured output, generated-SDK, route changes, or historical descriptor overrides on cold resume can invalidate reuse before inherited history; later child history is append-only. Continuable messaging adds no child-only system-prompt section or tool schema; the parent id and return guidance follow inherited history in the initial delegated task ([cache-preserving fork Agent Note](../../../.agents/notes/implemented/architecture/2026-08-10-fork-children-stay-one-shot.md)).
|
||||
The child may reuse the inherited byte-identical prefix under the same provider and model. Structured output, generated-SDK, route changes, or historical descriptor overrides on cold resume can invalidate reuse before inherited history; later child history is append-only. Continuable messaging adds no child-only system-prompt section or tool schema; the parent id and return guidance follow inherited history in the initial user task ([cache-preserving fork Agent Note](../../../.agents/notes/implemented/architecture/2026-08-10-fork-children-stay-one-shot.md)).
|
||||
|
||||
### Parent tool result, indirectly
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ kind: "package-reference"
|
||||
|
||||
#### 模型看到什么
|
||||
|
||||
子 agent 先接收由父级已配平的已完成轮次构成的前缀,再接收一条来自父 agent 的新任务消息:`Agent <parent name> sent a message: ` 后接逐字任务内容。它加入父级的 preset 代际,由 preset 提供 persona 和工具。父级 agent 局部限制不会被复制。可选的结构化输出请求会添加仅属于子 agent 的工具;父级当前进行中的轮次会被排除。
|
||||
子 agent 先接收由父级已配平的已完成轮次构成的前缀,再逐字接收新的任务内容。它加入父级的 preset 代际,由 preset 提供 persona 和工具。父级 agent 局部限制不会被复制。可选的结构化输出请求会添加仅属于子 agent 的工具;父级当前进行中的轮次会被排除。
|
||||
|
||||
#### Token 影响
|
||||
|
||||
@@ -117,7 +117,7 @@ fork 会把保留的已完成历史复制到子 agent 的请求中,子 agent
|
||||
|
||||
#### KV Cache 影响
|
||||
|
||||
在提供方与模型相同的前提下,子 agent 可以复用继承的逐字节相同前缀。结构化输出、生成 SDK、路由变化,或冷恢复时的历史 descriptor 覆盖,可能在继承历史之前使复用失效;后续子 agent 历史仅追加。可继续消息不会增加子级专属的系统提示词区段或工具 schema;父级 ID 与返回指导在初始委派任务中位于继承历史之后(见[保持 fork 缓存的 Agent Note](../../../.agents/notes/implemented/architecture/2026-08-10-fork-children-stay-one-shot.zh.md))。
|
||||
在提供方与模型相同的前提下,子 agent 可以复用继承的逐字节相同前缀。结构化输出、生成 SDK、路由变化,或冷恢复时的历史 descriptor 覆盖,可能在继承历史之前使复用失效;后续子 agent 历史仅追加。可继续消息不会增加子级专属的系统提示词区段或工具 schema;父级 ID 与返回指导在初始用户任务中位于继承历史之后(见[保持 fork 缓存的 Agent Note](../../../.agents/notes/implemented/architecture/2026-08-10-fork-children-stay-one-shot.zh.md))。
|
||||
|
||||
### 父级工具结果(间接)
|
||||
|
||||
|
||||
@@ -51,8 +51,8 @@
|
||||
en: 05e6180f1498fdf9
|
||||
zh: 2b05d2b97bfa67da
|
||||
/deepseek-ai-dsh-subagent-spawn-in-process/model-experience/child-agent-request/what-the-model-sees:
|
||||
en: 84a5e689a55f5bec
|
||||
zh: 89d6bcbe1a7fb6e7
|
||||
en: c9dfab9a4d363fed
|
||||
zh: 6cb3b0914ccb73e2
|
||||
/deepseek-ai-dsh-subagent-spawn-in-process/model-experience/child-agent-request/token-effect:
|
||||
en: eb373a4b35a4b548
|
||||
zh: 9537d0e466e8bcd9
|
||||
|
||||
@@ -106,7 +106,7 @@ Read these pages when the package-level contract is not enough; they move from t
|
||||
|
||||
#### What the model sees
|
||||
|
||||
The fresh child receives the task as its only user message in a new empty conversation, attributed to the parent agent: `Agent <parent name> sent a message: ` followed by the task content verbatim. It uses the parent provider, model, reasoning effort, output-token limit, and working directory by default. The inherited or selected preset supplies tools and prompt sections. No parent conversation message is included.
|
||||
The fresh child receives the task content verbatim as its only user message in a new empty conversation, with the parent provider, model, reasoning effort, output-token limit, and working directory by default. The inherited or selected preset supplies tools and prompt sections. No parent conversation message is included.
|
||||
|
||||
#### Token effect
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ kind: "package-reference"
|
||||
|
||||
#### 模型看到什么
|
||||
|
||||
全新子 agent 在新空对话中接收唯一一条用户消息,即来自父 agent 的任务:`Agent <parent name> sent a message: ` 后接逐字任务内容。默认使用父级提供方、模型、推理强度、输出 token 上限与工作目录。继承或选定的 preset 提供工具和提示词片段。不包含任何父级对话消息。
|
||||
全新子 agent 逐字接收任务内容,作为新空对话中的唯一用户消息,默认使用父级提供方、模型、推理强度、输出 token 上限与工作目录。继承或选定的 preset 提供工具和提示词片段。不包含任何父级对话消息。
|
||||
|
||||
#### Token 影响
|
||||
|
||||
|
||||
Reference in new issue
Block a user