diff --git a/packages/client/ui-chat/README.i18n.yaml b/packages/client/ui-chat/README.i18n.yaml index b2435fa8ab..0d7ca3f8fa 100644 --- a/packages/client/ui-chat/README.i18n.yaml +++ b/packages/client/ui-chat/README.i18n.yaml @@ -33,8 +33,8 @@ en: 0ca3e8c4eab1ca78 zh: 1a1c71bab151eb7d /deepseek-ai-dsh-client-ui-chat/grouped-rendering: - en: bb4661cd2b435e2b - zh: bde68d03839f7da8 + en: a4f1557cdbae804e + zh: 159dac17d36d8b4d /deepseek-ai-dsh-client-ui-chat/scroll-ownership: en: 69b021c5a5d8b5a7 zh: 091ae7986c7a8a20 diff --git a/packages/client/ui-chat/README.md b/packages/client/ui-chat/README.md index b8e1441864..3dbfe41189 100644 --- a/packages/client/ui-chat/README.md +++ b/packages/client/ui-chat/README.md @@ -93,7 +93,7 @@ Chat registers its process Group Definition through `uiConversation.groups`. Rea `groupPart` selects reasoning or response in the Assistant renderer without copying Node payloads. A Tool node owns its preparing, dispatched, and result stages under one callId. Each part has a distinct DOM anchor for reading-position restoration; Turn navigation addresses the original Node key and lands on its first visible part. Group sources, member parents, and keys survive display-mode changes and newly loaded prefixes that extend an intact group. The source Node Store remains the only Node-data owner, and a replaced Builder rebinds keyed subscriptions without remounting seats. Mode changes retain size observers and reuse the Turn-state selector. -Live tool deltas share reasoning's frame-batched publication; durable calls and results publish immediately. Repeated deltas retain the Tool node when observed argument answers, the anchor, location, and visibility are unchanged. The Definition supplies the same lazy argument reader to tool rows and group detail, without tool-specific registration. +Live tool deltas share reasoning's frame-batched publication; durable calls and results publish immediately. Native and nested results retain event presentation metadata, so historical file and command labels use the operation’s location. Repeated deltas retain the Tool node when observed argument answers, the anchor, location, and visibility are unchanged. The Definition supplies the same lazy argument reader to tool rows and group detail, without tool-specific registration. The process group uses a stable `div` layout box, a scroll body, and an uncapped content box that reports growth inside the body. Business styles must adapt spacing within and across groups, including hidden or empty members and the answer-spacing exception. CSS variables do not belong in the Group Definition. diff --git a/packages/client/ui-chat/README.zh.md b/packages/client/ui-chat/README.zh.md index 607b3075a4..ec22c5f3c6 100644 --- a/packages/client/ui-chat/README.zh.md +++ b/packages/client/ui-chat/README.zh.md @@ -93,7 +93,7 @@ Chat 通过 `uiConversation.groups` 注册过程 Group Definition。React 通过 `groupPart` 在 Assistant 渲染器中选择推理或回复,不复制 Node 载荷。同一个 callId 的准备、派发与结果阶段由 Tool 节点自己拥有。每个部分有独立的 DOM 锚点用于恢复阅读位置;轮次导航使用原 Node key,落到它的第一个可见部分。展示模式切换以及为完整旧组补入更早成员时,保留组来源、成员父级及 key。原 Node Store 仍是唯一节点数据所有者,替换 Builder 时重新绑定按键订阅,不重挂载容器。模式变化保留尺寸观察器,并复用整轮状态选择器。 -实时工具 delta 与推理共用按帧合并的发布节奏;持久调用和结果立即发布。当已读取参数的答案、锚点、位置及可见性均未变化时,重复 delta 保持 Tool 节点不变。Definition 向工具行和分组详情提供同一个懒计算参数读器,无需按工具注册。 +实时工具 delta 与推理共用按帧合并的发布节奏;持久调用和结果立即发布。原生与嵌套结果保留事件中的展示元数据,使历史文件与命令标签使用执行时的位置。当已读取参数的答案、锚点、位置及可见性均未变化时,重复 delta 保持 Tool 节点不变。Definition 向工具行和分组详情提供同一个懒计算参数读器,无需按工具注册。 过程组使用稳定的 `div` 布局盒子、滚动正文及不限高的内容盒子,后者报告正文内部的内容增长。业务样式必须适配组内及组边界间距,处理隐藏或空成员以及回答前的间距特例。CSS 变量不属于 Group Definition。 diff --git a/packages/client/ui-chat/src/client/conversation-nodes/tool.ts b/packages/client/ui-chat/src/client/conversation-nodes/tool.ts index 6d4e5c28ea..0252539059 100644 --- a/packages/client/ui-chat/src/client/conversation-nodes/tool.ts +++ b/packages/client/ui-chat/src/client/conversation-nodes/tool.ts @@ -125,6 +125,7 @@ interface DispatchData { readonly isError?: boolean readonly error?: { name: string; code: string; reason?: string } readonly content?: ToolResultNode['content'] + readonly meta?: ToolResultNode['meta'] } function childCall(match: ConversationMatch, data: DispatchData): StartedToolCall { @@ -154,6 +155,7 @@ function childResult(match: ConversationMatch, data: DispatchData, previous?: To call: { name: data.name, argsRaw: jsonArguments(data.arguments) }, callTime: previous?.time ?? null, content: data.content ?? [], + meta: data.meta, isError: data.isError === true, ...data.error === undefined ? {} : { error: data.error }, subCalls: [], diff --git a/packages/client/ui-chat/tests/conversation-node-definitions.client.spec.ts b/packages/client/ui-chat/tests/conversation-node-definitions.client.spec.ts index 310228f678..3823a0dbd5 100644 --- a/packages/client/ui-chat/tests/conversation-node-definitions.client.spec.ts +++ b/packages/client/ui-chat/tests/conversation-node-definitions.client.spec.ts @@ -1420,6 +1420,7 @@ describe('built-in conversation node Definitions', () => { isError: true, error: { name: 'AutoReviewDeniedError', code: 'AUTO_REVIEW_DENIED', reason: 'blocked' }, content: [{ type: 'text', text: 'contents' }], + meta: { cwd: '/selected', path: '/selected/README.md' }, }), at(16, 'tool/result', { turn: 2, @@ -1432,6 +1433,7 @@ describe('built-in conversation node Definitions', () => { { kind: 'tool-result', callId: 'child', parentCallId: 'history-root', call: { name: 'read' }, error: { name: 'AutoReviewDeniedError', code: 'AUTO_REVIEW_DENIED', reason: 'blocked' }, + meta: { cwd: '/selected', path: '/selected/README.md' }, }, ]) @@ -1454,6 +1456,7 @@ describe('built-in conversation node Definitions', () => { { kind: 'tool-result', callId: 'child', parentCallId: 'history-root', call: { name: 'read' }, error: { name: 'AutoReviewDeniedError', code: 'AUTO_REVIEW_DENIED', reason: 'blocked' }, + meta: { cwd: '/selected', path: '/selected/README.md' }, }, ]) diff --git a/packages/client/ui-tool/README.i18n.yaml b/packages/client/ui-tool/README.i18n.yaml index 12709bf911..d0c929008d 100644 --- a/packages/client/ui-tool/README.i18n.yaml +++ b/packages/client/ui-tool/README.i18n.yaml @@ -45,8 +45,8 @@ en: ca75c51c89c2c9b0 zh: de54f3467ef3b9be /deepseek-ai-dsh-client-ui-tool/known-limitations-and-deferred-work: - en: 1c68b9039071ae71 - zh: bf7a146f81ebac5a + en: 49f7008105e804df + zh: e773f101126b01b4 /deepseek-ai-dsh-client-ui-tool/known-limitations-and-deferred-work/dev-note: en: e67f633dc6fe7773 zh: 3bb0c20c93f16f98 diff --git a/packages/client/ui-tool/README.md b/packages/client/ui-tool/README.md index eed9487998..bfbe63f150 100644 --- a/packages/client/ui-tool/README.md +++ b/packages/client/ui-tool/README.md @@ -133,7 +133,7 @@ None; this package neither assembles nor sends a provider request. These limits define the dispatch depth and the view ownership; they are current package constraints. - **The Host excludes `run_code` from PTC mode program bindings** — production events produce one dispatch level; the recursive Runtime/UI contract supports nesting. -- **Nested relative locations** — PTC dispatches do not persist presentation metadata. Relative nested file links and inferred command directories stay unavailable; absolute call paths remain usable. +- **Historical nested relative locations** — Older PTC dispatches without presentation metadata do not infer relative file targets or command directories; absolute call paths remain usable. - **First-party Tool views are colocated here** — they can move to their owning business packages independently through the keyed slot. - **Web tool links always open a new tab** — the collapsed `web_fetch` URL and the expanded web card links ignore the `ui-chat` link-opening setting because Tool views receive no external-link callback. - **Tool copy reuses the `ui-conversation` locale namespace** — tool titles, row chrome, and Cordis-free primitive labels use that dictionary; presenter models retain locale keys or data rather than rendered wording. diff --git a/packages/client/ui-tool/README.zh.md b/packages/client/ui-tool/README.zh.md index 4b45b3232b..aabbce7eda 100644 --- a/packages/client/ui-tool/README.zh.md +++ b/packages/client/ui-tool/README.zh.md @@ -133,7 +133,7 @@ terminal model 使用浏览器安全入口 `@deepseek-ai/dsh-spill-policy/notice 这些限制定义分派深度与视图归属;它们是当前包约束。 - **Host 不把 `run_code` 暴露为 PTC mode 程序 binding**:生产事件只产生一层分发;递归的运行时/UI 约定支持嵌套。 -- **嵌套相对位置**——PTC dispatch 不持久化展示元数据。相对的嵌套文件链接与推断的命令目录保持不可用;绝对调用路径仍可使用。 +- **历史嵌套相对位置**——缺少展示元数据的旧 PTC dispatch 不推断相对文件目标或命令目录;绝对调用路径仍可使用。 - **第一方工具视图集中在本包**:它们可以通过 keyed slot 独立迁移到各自所属的业务包。 - **Web 工具链接总是打开新标签页**:折叠的 `web_fetch` URL 与展开的 web 卡片链接不遵循 `ui-chat` 的链接打开方式设置,因为工具视图没有外部链接回调。 - **工具文案复用 `ui-conversation` locale namespace**:工具标题、行 chrome 与无 Cordis 的 primitive label 使用该字典;展示转换器模型保留 locale key 或数据,而不是已渲染文案。 diff --git a/packages/client/ui-tool/src/client/tool/models/image-card-model.ts b/packages/client/ui-tool/src/client/tool/models/image-card-model.ts index 2932c21075..085451b35b 100644 --- a/packages/client/ui-tool/src/client/tool/models/image-card-model.ts +++ b/packages/client/ui-tool/src/client/tool/models/image-card-model.ts @@ -195,9 +195,9 @@ function fullyRendered(content: readonly unknown[]): boolean { * * The card is result-side only: a call carries no content until `execute` * returns, so a running `read_image` has none and this returns null for it. - * Both root and nested calls settle as ToolResultNode; the nested one (a - * read_image dispatched from inside run_code) persists no presentationMeta, so - * its label falls back to the call's own `file_path` argument. + * Both root and nested calls settle as ToolResultNode. Historical nested + * records without presentation metadata fall back to the call's own + * `file_path` argument for the label. * @param block - running or settled Tool block. * @param sessionCwd - the session workspace root; a workspace-rooted absolute * path label displays relative to it. Absent leaves the path as authored. @@ -216,9 +216,8 @@ export function imageCardModel( if (call?.name !== 'read_image') return null const { file_path: filePath } = call.args if (typeof filePath !== 'string' || filePath.trim() === '') return null - // The label path: root calls persist it in presentationMeta; a nested call - // (dispatched from inside run_code) persists none, so its own file_path - // argument fills the label. A root call with missing or malformed meta + // Historical nested records without metadata use the authored file_path + // for the label. A root call with missing or malformed meta // declines — malformed tool data falls back to the generic card, which shows // the flattened content rather than an author-typed path. const metaPath = imageMeta(block.meta)?.path diff --git a/packages/client/ui-tool/tests/terminal-card.client.spec.tsx b/packages/client/ui-tool/tests/terminal-card.client.spec.tsx index 9516534b04..d06a4ddf68 100644 --- a/packages/client/ui-tool/tests/terminal-card.client.spec.tsx +++ b/packages/client/ui-tool/tests/terminal-card.client.spec.tsx @@ -159,6 +159,8 @@ describe('terminalCardModel', () => { const block = settled({ call: { name, argsRaw: shellArgs({ workdir: 'nested' }) }, meta: { cwd: '/b/nested' } }) expect(terminalCardModel(block, '/a')?.card.cwd).toBe('/b/nested') expect(terminalCardModel(block, '/c')?.card.cwd).toBe('/b/nested') + expect(terminalCardModel({ ...block, parentCallId: 'outer' }, '/a')?.card.cwd).toBe('/b/nested') + expect(terminalCardModel({ ...block, parentCallId: 'outer' }, '/c')?.card.cwd).toBe('/b/nested') expect(terminalCardModel(settled({ ...block, meta: { cwd: 'relative' } }), '/a')?.card.cwd).toBe('/a/nested') expect(terminalCardModel(settled({ ...block, meta: { cwd: 'C:\\b\\nested' } }), '/a')?.card.cwd).toBe('C:\\b\\nested') } diff --git a/packages/client/ui-tool/tests/tool-row.client.spec.tsx b/packages/client/ui-tool/tests/tool-row.client.spec.tsx index 05a1f12a87..3020472796 100644 --- a/packages/client/ui-tool/tests/tool-row.client.spec.tsx +++ b/packages/client/ui-tool/tests/tool-row.client.spec.tsx @@ -166,8 +166,8 @@ describe('tool-call-model', () => { expect(toolRowModel('read', running({ name: 'read', argsRaw: '{"path":"/Users/u/ws/a.md"}' }), '').summary).toBe('/Users/u/ws/a.md') }) - it.each(['read', 'write', 'edit', 'read_image'])('opens %s at its recorded target after later directory changes without relabeling it', (name) => { - const block = result({ call: { name, argsRaw: '{"file_path":"note.txt"}' }, meta: { path: '/workspace/b/note.txt' } }) + it.each(['read', 'write', 'edit', 'read_image'].flatMap(name => [false, true].map(nested => ({ name, nested }))))('opens $name nested=$nested at its recorded target after later directory changes without relabeling it', ({ name, nested }) => { + const block = result({ ...(nested ? { parentCallId: 'outer' } : {}), call: { name, argsRaw: '{"file_path":"note.txt"}' }, meta: { path: '/workspace/b/note.txt' } }) for (const cwd of ['/workspace/a', '/workspace/c']) { const model = toolRowModel(name, block, cwd) expect(model.filePath).toBe('/workspace/b/note.txt') diff --git a/packages/client/ui-trajectory/README.i18n.yaml b/packages/client/ui-trajectory/README.i18n.yaml index 3d968ec180..8401dea9db 100644 --- a/packages/client/ui-trajectory/README.i18n.yaml +++ b/packages/client/ui-trajectory/README.i18n.yaml @@ -24,8 +24,8 @@ en: 0331f90cbd904862 zh: bdc2d4ed1c3c1f5e /deepseek-ai-dsh-client-ui-trajectory/understand-the-implementation: - en: 02ef008ff74a38df - zh: fa54d85ab89ed103 + en: 74cc8fc87241da34 + zh: cd72ff9c0fdd2575 /deepseek-ai-dsh-client-ui-trajectory/understand-the-implementation/virtual-rows: en: c85e342bc7eee4e6 zh: 9feab66ef1755b94 diff --git a/packages/client/ui-trajectory/README.md b/packages/client/ui-trajectory/README.md index e960d2300c..38303dc7f1 100644 --- a/packages/client/ui-trajectory/README.md +++ b/packages/client/ui-trajectory/README.md @@ -53,7 +53,7 @@ A fixed Overview above the ledger projects real record start/duration timing fro The view is a pure projection: Trajectory-owned Definitions assemble business records from the shared Session window — including durable cancellation-finalized prefixes, chunk-only interruption fallbacks, and interrupted Tool records — so Trajectory neither reads nor changes the Chat conversation snapshot. Its steering classifier retains only next-step Inbox IDs through persistent splice state and shares each current claimed batch across later Contexts. -Native and nested PTC Tool results retain their raw structured error details. Failed records show the error code in the ledger and the error name and code in the inspector. +Native and nested PTC Tool results retain their raw structured error details and presentation metadata. Failed records show the error code in the ledger and the error name and code in the inspector. Tool records begin at durable tool/call events and retain complete argument text with a lazy `args` view, reused by paired results. Chat's transient preparing stage does not create Trajectory tool rows or alter historical tool timing. diff --git a/packages/client/ui-trajectory/README.zh.md b/packages/client/ui-trajectory/README.zh.md index 060daef60e..f1a270983b 100644 --- a/packages/client/ui-trajectory/README.zh.md +++ b/packages/client/ui-trajectory/README.zh.md @@ -53,7 +53,7 @@ Trajectory 标签页让你以按轮次组织的事件记录表和交互式时间 视图是纯投影:Trajectory 自有的定义从共享会话窗口组装业务记录——包括因取消而定稿并持久保留的前缀、仅有分片时采用的中断回退记录,以及被中断的工具记录——因此 Trajectory 既不读取也不改变 Chat 会话快照。其 steering(中途引导)分类器通过持续保留的拼接状态只保留下一步的 Inbox ID,并让后续上下文共享当前已认领的每个批次。 -原生与嵌套 PTC 工具结果保留原始结构化错误详情。失败记录在记录表中显示错误代码,在检查器中显示错误名称和代码。 +原生与嵌套 PTC 工具结果保留原始结构化错误详情和展示元数据。失败记录在记录表中显示错误代码,在检查器中显示错误名称和代码。 工具记录从持久 tool/call 事件开始,保留完整参数文本和由配对结果复用的懒计算 `args` 视图。Chat 的瞬态 preparing 阶段不创建 Trajectory 工具行,也不改变历史工具计时。 diff --git a/packages/client/ui-trajectory/src/client/trajectory-tool-definition.ts b/packages/client/ui-trajectory/src/client/trajectory-tool-definition.ts index f157648dae..aa0f4489b1 100644 --- a/packages/client/ui-trajectory/src/client/trajectory-tool-definition.ts +++ b/packages/client/ui-trajectory/src/client/trajectory-tool-definition.ts @@ -29,6 +29,7 @@ interface DispatchData { readonly isError?: boolean readonly error?: ToolResultNode['error'] readonly content?: ToolResultNode['content'] + readonly meta?: ToolResultNode['meta'] } function rootCall(match: ConversationMatch): StartedToolCall { @@ -112,6 +113,7 @@ function childResult( call: { name: data.name, argsRaw: JSON.stringify(data.arguments) }, callTime: previous === undefined || 'kind' in previous ? null : previous.time, content: data.content ?? [], + meta: data.meta, isError: data.isError === true, ...(data.error === undefined ? {} : { error: data.error }), subCalls: [], diff --git a/packages/client/ui-trajectory/tests/conversation-definitions.client.spec.ts b/packages/client/ui-trajectory/tests/conversation-definitions.client.spec.ts index fd994e9b07..00c708048b 100644 --- a/packages/client/ui-trajectory/tests/conversation-definitions.client.spec.ts +++ b/packages/client/ui-trajectory/tests/conversation-definitions.client.spec.ts @@ -466,6 +466,7 @@ describe('Trajectory conversation Definitions', () => { name: 'read', arguments: { path: 'README.md' }, content: [{ type: 'text', text: 'contents' }], + meta: { cwd: '/selected', path: '/selected/README.md' }, }), at(7, 'tool/ptc-dispatch-start', { rootCallId: 'root-a', parentCallId: 'root-b:code:1', subCallId: 'root-b:ptc:2', @@ -505,6 +506,7 @@ describe('Trajectory conversation Definitions', () => { meta: { presentation: 'raw' }, subCalls: [{ kind: 'tool-result', callId: 'root-b:code:1', parentCallId: 'root-a', call: { name: 'read' }, + meta: { cwd: '/selected', path: '/selected/README.md' }, subCalls: [{ kind: 'tool-result', callId: 'root-b:ptc:2', parentCallId: 'root-b:code:1', callTime: 1_700_000_000_007, content: [{ type: 'text', text: 'not executed' }], diff --git a/packages/core/tools/README.i18n.yaml b/packages/core/tools/README.i18n.yaml index 71ce8497ed..ebedad8a58 100644 --- a/packages/core/tools/README.i18n.yaml +++ b/packages/core/tools/README.i18n.yaml @@ -45,8 +45,8 @@ en: dc44a88997777988 zh: 56454aeace1c8b77 /deepseek-ai-dsh-tools/understand-the-implementation/ptc-mode: - en: 4e31ece434498744 - zh: a52701fa0b039dc4 + en: a3e4a50598b9f348 + zh: 4b8edcbfec99a6ad /deepseek-ai-dsh-tools/understand-the-implementation/extension-points: en: c2a14d6f22bc9428 zh: 89c1414fca465931 diff --git a/packages/core/tools/README.md b/packages/core/tools/README.md index 8e663fa8ef..6967ad4d85 100644 --- a/packages/core/tools/README.md +++ b/packages/core/tools/README.md @@ -127,7 +127,7 @@ Each typed invocation materializes and freezes parsed arguments, assigns an opaq ### PTC mode -Under `ptc` or `both`, the registry exposes the reserved `run_code` transport plus a deterministic SDK generated in the loaded runtime's language. Each SDK binding captures a frozen ToolSchema and passes it through the scheduler to its execution context. Before policy, a started call records only pairing ids, name, and normalized arguments; its settle event preserves the rendered result and optional structured error. Description and parameters remain transient and never enter Session events or SDK output. Calls are scheduled through a per-run pool that reuses the native concurrency contract. Under `ptc` alone, a model-direct call naming any other visible tool resolves to `UNKNOWN_TOOL` before policy — the announced surface and the callable surface stay the same. Intermediate binding values are execution-local; only the outer `run_code` result has a hard size cap. +Under `ptc` or `both`, the registry exposes the reserved `run_code` transport plus a deterministic SDK generated in the loaded runtime's language. Each SDK binding captures a frozen ToolSchema and passes it through the scheduler to its execution context. Before policy, a started call records only pairing ids, name, and normalized arguments; its settle event preserves the rendered result, optional presentation metadata, and structured error. Metadata is projected from that call’s canonical value and frozen; it changes neither the program value nor model content. Description and parameters remain transient and never enter Session events or SDK output. Calls are scheduled through a per-run pool that reuses the native concurrency contract. Under `ptc` alone, a model-direct call naming any other visible tool resolves to `UNKNOWN_TOOL` before policy — the announced surface and the callable surface stay the same. Intermediate binding values are execution-local; only the outer `run_code` result has a hard size cap. New sub-calls use `:ptc:` ids. Consumers treat these ids as opaque and correlate events by exact equality; restored historical ids retain their original bytes. The [PTC mode decision](../../../.agents/notes/implemented/feature/2026-06-15-ptc.md) owns durable naming and restoration rules. diff --git a/packages/core/tools/README.zh.md b/packages/core/tools/README.zh.md index 69837c7542..23766bb56f 100644 --- a/packages/core/tools/README.zh.md +++ b/packages/core/tools/README.zh.md @@ -127,7 +127,7 @@ ctx.tools.register(defineTool({ ### PTC mode -在 `ptc` 或 `both` 下,注册表公开保留的 `run_code` 传输以及按所加载运行时语言生成的确定性 SDK。每个 SDK 绑定捕获冻结的 ToolSchema,经由调度器传入该次执行上下文。已开始的调用在策略之前只记录配对 id、名称和规范化参数;其结算事件保留渲染结果与可选结构化错误。描述与参数 schema 仅临时存活,不进入 Session 事件或 SDK 输出。调用通过复用原生并发约定的每次运行独有池调度。在纯 `ptc` 下,模型直呼其他任何可见工具都会在策略之前解析为 `UNKNOWN_TOOL`——通告面与可调用面保持一致。中间绑定值只存在于执行局部;只有外层 `run_code` 结果有硬大小上限。 +在 `ptc` 或 `both` 下,注册表公开保留的 `run_code` 传输以及按所加载运行时语言生成的确定性 SDK。每个 SDK 绑定捕获冻结的 ToolSchema,经由调度器传入该次执行上下文。已开始的调用在策略之前只记录配对 id、名称和规范化参数;其结算事件保留渲染结果、可选展示元数据与结构化错误;元数据由该次调用的规范值投影并冻结,不改变程序读取的值或模型内容。描述与参数 schema 仅临时存活,不进入 Session 事件或 SDK 输出。调用通过复用原生并发约定的每次运行独有池调度。在纯 `ptc` 下,模型直呼其他任何可见工具都会在策略之前解析为 `UNKNOWN_TOOL`——通告面与可调用面保持一致。中间绑定值只存在于执行局部;只有外层 `run_code` 结果有硬大小上限。 新子调用使用 `:ptc:` 标识。消费方将这些标识视为不透明值,并通过精确相等关联事件;恢复的历史标识保留原始字节。[PTC mode 决策](../../../.agents/notes/implemented/feature/2026-06-15-ptc.zh.md) 负责持久化命名与恢复规则。 diff --git a/packages/core/tools/src/index.ts b/packages/core/tools/src/index.ts index 5615630bea..5ddb29fa04 100644 --- a/packages/core/tools/src/index.ts +++ b/packages/core/tools/src/index.ts @@ -216,7 +216,7 @@ export interface ToolOutputDefinition { readonly schema: JsonSchemaNode /** Pure projection from validated arguments and value to Native/model content. */ render(args: unknown, value: JsonValue): ContentBlock[] - /** Pure replayable presentation projection, computed only for top-level calls. */ + /** Pure replayable presentation projection for native and nested calls. */ presentationMeta?(args: unknown, value: JsonValue): JsonValue } @@ -1851,7 +1851,7 @@ export class ToolRuntime extends Service { } const content = snapshotProjection(tool.name, 'render', rendered) let meta: JsonValue | undefined - if (exec.parent === undefined && tool.output.presentationMeta !== undefined) { + if (tool.output.presentationMeta !== undefined) { let projected: JsonValue try { projected = tool.output.presentationMeta(exec.arguments, value) diff --git a/packages/core/tools/src/ptc.ts b/packages/core/tools/src/ptc.ts index a2e697ad54..9d3bea545b 100644 --- a/packages/core/tools/src/ptc.ts +++ b/packages/core/tools/src/ptc.ts @@ -599,6 +599,7 @@ export function createRunCodeTool(registry: ToolRuntime, options: RunCodeBridgeO isError: result.isError, ...result.error?.info === undefined ? {} : { error: result.error.info }, content: logged, + ...result.meta === undefined ? {} : { meta: result.meta }, }) })().finally(() => { logWork.delete(task) }) logWork.add(task) diff --git a/packages/core/tools/src/schema.ts b/packages/core/tools/src/schema.ts index 5aea4f4f7f..2cc6f0cb0b 100644 --- a/packages/core/tools/src/schema.ts +++ b/packages/core/tools/src/schema.ts @@ -493,7 +493,7 @@ export interface DefineToolOptions, value: InferValue>): ContentBlock[] - /** Pure replayable presentation metadata for direct top-level calls. */ + /** Pure replayable presentation metadata for native and nested calls. */ presentationMeta?(args: InferArgs, value: InferValue>): JsonValue } /** Requests deferred loading of the tool definition; see {@link @deepseek-ai/dsh-llm#ToolSchema.deferLoading}. */ diff --git a/packages/core/tools/src/types.ts b/packages/core/tools/src/types.ts index 48b2556278..dc41c299a0 100644 --- a/packages/core/tools/src/types.ts +++ b/packages/core/tools/src/types.ts @@ -6,6 +6,7 @@ import type { ToolCallId } from '@deepseek-ai/dsh-llm/brand' import type { ContentBlock } from '@deepseek-ai/dsh-llm/types' +import type { JsonValue } from '@deepseek-ai/dsh-util-values' /** Payload recorded when one nested PTC mode Tool dispatch starts. */ export interface PtcDispatchStartEventData { @@ -20,6 +21,8 @@ export interface PtcDispatchStartEventData { export interface PtcDispatchEventData extends PtcDispatchStartEventData { isError: boolean content: ContentBlock[] + /** Replayable tool-owned presentation metadata, separate from model content. */ + meta?: JsonValue /** Optional failure identity and raw user-facing detail, outside model-facing content. */ error?: { name: string; code: string; reason?: string } } @@ -45,8 +48,8 @@ declare module '@deepseek-ai/dsh-session/types' { * `tool/ptc-dispatch-start` with the same `subCallId`), the tool `name` * with the same JSON-normalized `arguments`, and the sub-call's complete * durable outcome in `tool/result`'s own vocabulary (`content` + `isError` - * + optional structured `error`), so UIs and SDKs render a sub-call through - * the exact path used for a native call. Every started sub-call settles + * + optional presentation `meta` and structured `error`), so UIs and SDKs + * render a sub-call through the exact path used for a native call. Every started sub-call settles * with exactly one of these (abort included: the aborted pipeline result * is an `isError` outcome). * Log-only: `deriveMessages()` ignores it, so sub-calls never re-enter diff --git a/packages/core/tools/tests/ptc.spec.ts b/packages/core/tools/tests/ptc.spec.ts index 7704b34708..3dbf19b686 100644 --- a/packages/core/tools/tests/ptc.spec.ts +++ b/packages/core/tools/tests/ptc.spec.ts @@ -132,6 +132,42 @@ async function runCode( }) } +it('logs detached frozen nested metadata without changing the binding value or log-content policy', async () => { + const { ctx, runtime } = await setup({ mode: 'ptc' }) + try { + const metadata = { cwd: '/selected', path: '/selected/note.txt' } + ctx.tools.register(defineTool({ + name: 'location', description: 'Read a fixture.', parameters: {}, + output: { + schema: { type: 'string' }, render: (_args, value) => [{ type: 'text', text: value }], + presentationMeta: () => metadata, + }, execute: async () => 'original contents', + })) + ctx.on('tools/ptc-dispatch-log', async () => [{ type: 'text', text: 'redacted durable preview' }]) + const session = Session.create(SessionId('ptc-location')) + const agent = { session } as Agent + runtime.behavior = async (request) => { + const value = await request.bindings[0]!.functions.location!({}) + expect(value).toBe('original contents') + metadata.cwd = '/later' + metadata.path = '/later/other.txt' + return { logs: [], value } + } + const result = await runCode(ctx, 'return await tools.location({})', { agent }) + expect(result.isError).toBe(false) + expect(result.content).toEqual([{ type: 'text', text: 'original contents' }]) + const event = session.snapshotEvents().find(event => event.type === 'tool/ptc-dispatch') + expect(event?.data.content).toEqual([{ type: 'text', text: 'redacted durable preview' }]) + expect(event?.data.meta).toEqual({ cwd: '/selected', path: '/selected/note.txt' }) + expect(Object.isFrozen(event?.data.meta)).toBe(true) + const restored = Session.create(session.id, session.snapshotEvents(), session.header) + expect(restored.snapshotEvents().find(event => event.type === 'tool/ptc-dispatch')?.data.meta) + .toEqual({ cwd: '/selected', path: '/selected/note.txt' }) + } finally { + await ctx.fiber.dispose() + } +}) + describe('mode-aware wire contribution', () => { it.each([ { mode: 'ptc', language: 'typescript' }, diff --git a/packages/core/tools/tests/tools.spec.ts b/packages/core/tools/tests/tools.spec.ts index dab5d43063..870c72fe4c 100644 --- a/packages/core/tools/tests/tools.spec.ts +++ b/packages/core/tools/tests/tools.spec.ts @@ -616,7 +616,7 @@ describe('ToolRuntime', () => { }) }) - it('suppresses presentation metadata only for nested composite dispatches', async () => { + it('projects presentation metadata for native and nested composite dispatches', async () => { const ctx = await setup() ctx.tools.register({ ...echoTool, @@ -632,7 +632,8 @@ describe('ToolRuntime', () => { parent: Symbol('outer') as ToolExecutionToken, }) expect(direct.meta).toEqual({ card: true }) - expect(nested.meta).toBeUndefined() + expect(nested.meta).toEqual({ card: true }) + expect(Object.isFrozen(nested.meta)).toBe(true) expect(nested.isError ? undefined : nested.value).toBe('') }) diff --git a/packages/fs/tool-fs/tests/integration.spec.ts b/packages/fs/tool-fs/tests/integration.spec.ts index 8a4dcf08ed..989e4cb160 100644 --- a/packages/fs/tool-fs/tests/integration.spec.ts +++ b/packages/fs/tool-fs/tests/integration.spec.ts @@ -13,6 +13,7 @@ import { join } from 'node:path' import { Context } from '@deepseek-ai/cordis' import { SessionId } from '@deepseek-ai/dsh-session' import AgentLoop from '@deepseek-ai/dsh-agent-loop' +import { PtcRuntime, type PtcRunRequest, type PtcRunResult, type PtcRunSpec } from '@deepseek-ai/dsh-ptc-runtime' import SandboxPolicyService from '@deepseek-ai/dsh-sandbox-policy' import { ToolCallId } from '@deepseek-ai/dsh-llm' import type { FsVersion } from '@deepseek-ai/dsh-fs' @@ -585,7 +586,31 @@ describe('current working directory', () => { }) expect(edit.isError).toBe(false) expect(edit.meta).toMatchObject({ path: join(current, 'created.txt'), diffs: [{ path: join(current, 'created.txt') }] }) + class ReadBindingRuntime extends PtcRuntime { + readonly language = 'typescript' + readonly isolation = 'fixture' + resolve(request: PtcRunRequest): PtcRunSpec { + return { ...request, cwd: current, timeoutMs: 120_000 } + } + async run(spec: PtcRunSpec): Promise { + const read = spec.bindings.find(binding => binding.global === 'tools')?.functions.read + if (read === undefined) throw new Error('missing read binding') + const value = await read({ file_path: 'note.txt' }) + expect(JSON.stringify(value)).toContain('current') + return { logs: [], value } + } + } + await ctx.plugin(ReadBindingRuntime) + agent.ctx.tools.presentAs('both') + const nested = await ctx.tools.execute({ + signal: testToolSignal, callId: ToolCallId('ptc-read-current'), name: 'run_code', + arguments: { code: 'return await tools.read({file_path: "note.txt"})', description: 'Read the current note' }, agent, + }) + expect(nested.isError).toBe(false) + const dispatch = session.snapshotEvents().find(event => event.type === 'tool/ptc-dispatch') + expect(dispatch?.data.meta).toMatchObject({ path: join(current, 'note.txt') }) await ctx.workingDirectory.set(agent, dir) + expect(dispatch?.data.meta).toMatchObject({ path: join(current, 'note.txt') }) expect(write.meta).toMatchObject({ path: join(current, 'created.txt') }) expect(await readFile(join(next, 'created.txt'), 'utf8')).toBe('edited') await expect(readFile(join(dir, 'created.txt'), 'utf8')).rejects.toMatchObject({ code: 'ENOENT' }) diff --git a/packages/sdk/client/tests/sdk-client.spec.ts b/packages/sdk/client/tests/sdk-client.spec.ts index 76e86d7bc2..7dbfa38398 100644 --- a/packages/sdk/client/tests/sdk-client.spec.ts +++ b/packages/sdk/client/tests/sdk-client.spec.ts @@ -188,6 +188,7 @@ describe('DeepSeekHarness', () => { arguments: { command: 'git push --force' }, isError: true, content: [{ type: 'text', text: 'Error: blocked by policy' }], + meta: { cwd: '/selected', path: '/selected/note.txt', view: { line: 3 } }, error: { name: 'AutoReviewDeniedError', code: 'AUTO_REVIEW_DENIED', @@ -222,6 +223,8 @@ describe('DeepSeekHarness', () => { const result = await new HarnessSession(harness, 'owned').run('go') expect(result.events).toEqual([receipt, nativeResult, ptcStart, ptcResult]) + expect(result.events.find(event => event.type === 'tool/ptc-dispatch')?.data.meta) + .toEqual({ cwd: '/selected', path: '/selected/note.txt', view: { line: 3 } }) for (const event of result.events.filter(event => event.type.startsWith('tool/ptc-dispatch'))) { expect(event.data).not.toHaveProperty('description') expect(event.data).not.toHaveProperty('parameters') diff --git a/packages/shell/tool-bash/package.json b/packages/shell/tool-bash/package.json index e5f4c83893..5f51b174c3 100644 --- a/packages/shell/tool-bash/package.json +++ b/packages/shell/tool-bash/package.json @@ -44,6 +44,7 @@ "@deepseek-ai/schemastery": "workspace:~" }, "devDependencies": { + "@deepseek-ai/dsh-ptc-runtime": "workspace:*", "@deepseek-ai/dsh-agent": "workspace:*", "@deepseek-ai/dsh-agent-loop": "workspace:*", "@deepseek-ai/dsh-agent-loop-testkit": "workspace:*", diff --git a/packages/shell/tool-bash/tests/integration.spec.ts b/packages/shell/tool-bash/tests/integration.spec.ts index 5c4888de4c..19ec04c68a 100644 --- a/packages/shell/tool-bash/tests/integration.spec.ts +++ b/packages/shell/tool-bash/tests/integration.spec.ts @@ -1,13 +1,14 @@ -import { createUserMessage } from '@deepseek-ai/dsh-llm' +import { createUserMessage, ToolCallId } from '@deepseek-ai/dsh-llm' import { afterEach, describe, expect, it, vi } from 'vitest' import { Context } from '@deepseek-ai/cordis' -import { mkdtempSync, rmSync, writeFileSync } from 'node:fs' +import { mkdirSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from 'node:fs' import { tmpdir } from 'node:os' import { join } from 'node:path' import { SessionId, type SessionEvent } from '@deepseek-ai/dsh-session' import JsonlSessionPersistence from '@deepseek-ai/dsh-session-persistence-jsonl' import type { Agent } from '@deepseek-ai/dsh-agent' import AgentLoop from '@deepseek-ai/dsh-agent-loop' +import { PtcRuntime, type PtcRunRequest, type PtcRunResult, type PtcRunSpec } from '@deepseek-ai/dsh-ptc-runtime' import { mountAgentLoopTestDependencies } from '@deepseek-ai/dsh-agent-loop-testkit' import LocalJobRegistry from '@deepseek-ai/dsh-jobs-local' import * as ToolJobs from '@deepseek-ai/dsh-tool-jobs' @@ -93,6 +94,47 @@ async function pollUntil(predicate: () => boolean, timeoutMs = 5_000): Promise { + it('logs the real nested shell launch directory after the Session changes directories again', async () => { + const root = realpathSync(mkdtempSync(join(tmpdir(), 'dsh-nested-bash-cwd-'))) + dirs.push(root) + const selected = join(root, 'selected') + mkdirSync(selected) + const ctx = await harness(new MockAdapter([])) + try { + const agent = await ctx.agentLoop.create(SessionId('nested-shell-current-directory'), {}, { cwd: root }) + await ctx.workingDirectory.set(agent, selected) + class BashBindingRuntime extends PtcRuntime { + readonly language = 'typescript' + readonly isolation = 'fixture' + resolve(request: PtcRunRequest): PtcRunSpec { + return { ...request, cwd: selected, timeoutMs: 120_000 } + } + async run(spec: PtcRunSpec): Promise { + const bash = spec.bindings.find(binding => binding.global === 'tools')?.functions.bash + if (bash === undefined) throw new Error('missing bash binding') + const value = await bash({ command: 'pwd', description: 'Print launch directory' }) + expect(value).toMatchObject({ cwd: selected, stdout: { text: `${selected}\n` } }) + return { logs: [], value } + } + } + await ctx.plugin(BashBindingRuntime) + agent.ctx.tools.presentAs('both') + const result = await ctx.tools.execute({ + callId: ToolCallId('nested-shell-root'), agent, signal: new AbortController().signal, name: 'run_code', + arguments: { code: 'return await tools.bash({ command: "pwd", description: "Print launch directory" })', description: 'Inspect current directory' }, + }) + expect(result.error).toBeUndefined() + expect(result.isError).toBe(false) + await ctx.workingDirectory.set(agent, root) + const dispatch = agent.session.snapshotEvents().find(event => event.type === 'tool/ptc-dispatch') + expect(dispatch?.data.meta).toMatchObject({ cwd: selected }) + expect(dispatch?.data.content).toEqual([{ type: 'text', text: `${selected}\n` }]) + expect(agent.session.header.cwd).toBe(root) + } finally { + await ctx.fiber.dispose() + } + }) + it('first-turn bash receives session identity in a scrubbed DSH_* namespace', async () => { const root = mkdtempSync(join(tmpdir(), 'dsh-bash-session-env-')) dirs.push(root) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9df4ec20da..41b714174f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12003,6 +12003,9 @@ importers: '@deepseek-ai/dsh-llm': specifier: workspace:* version: link:../../llm/llm + '@deepseek-ai/dsh-ptc-runtime': + specifier: workspace:* + version: link:../../ptc-runtime/ptc-runtime '@deepseek-ai/dsh-sandbox': specifier: workspace:* version: link:../../sandbox/sandbox diff --git a/python/sdk/tests/test_client.py b/python/sdk/tests/test_client.py index 66b9b2665c..a79f560fb4 100644 --- a/python/sdk/tests/test_client.py +++ b/python/sdk/tests/test_client.py @@ -105,6 +105,7 @@ for line in sys.stdin: "arguments": {"command": "git push --force"}, "isError": True, "content": [{"type": "text", "text": "Error: blocked by policy"}], + "meta": {"cwd": "/selected", "path": "/selected/note.txt", "view": {"line": 3}}, "error": { "name": "AutoReviewDeniedError", "code": "AUTO_REVIEW_DENIED", @@ -200,6 +201,7 @@ for line in sys.stdin: ] ptc_events = [event for event in result.events if event["type"].startswith("tool/ptc-dispatch")] assert [event["type"] for event in ptc_events] == ["tool/ptc-dispatch-start", "tool/ptc-dispatch"] + assert ptc_events[-1]["data"]["meta"] == {"cwd": "/selected", "path": "/selected/note.txt", "view": {"line": 3}} for event in ptc_events: assert not {"description", "parameters", "schema"}.intersection(event["data"]) dumped_env = json.loads(env_dump.read_text()) diff --git a/snapshots/session/ptc-turn/session.v4.jsonl b/snapshots/session/ptc-turn/session.v4.jsonl index 7ec8d97798..eb47c01220 100644 --- a/snapshots/session/ptc-turn/session.v4.jsonl +++ b/snapshots/session/ptc-turn/session.v4.jsonl @@ -15,9 +15,9 @@ {"type":"assistant/message","data":{"turn":1,"step":1,"message":{"role":"assistant","content":[{"type":"reasoning","text":"The user wants me to write a single run_code program that:\n1. Calls bash tool twice: `echo CODE_ONE` and `echo CODE_TWO`\n2. console.log exactly `captured output`\n3. Return the two outputs joined with a plus sign\n\nLet me write this."},{"type":"tool-call","id":"call_00_UiQPVqoELyzBZCY5pm1z7875","name":"run_code","arguments":"{\"code\": \"\\nconst out1 = await tools.bash({command: \\\"echo CODE_ONE\\\", description: \\\"Print CODE_ONE\\\"});\\nconst out2 = await tools.bash({command: \\\"echo CODE_TWO\\\", description: \\\"Print CODE_TWO\\\"});\\nconsole.log(\\\"captured output\\\");\\nconst text1 = out1.stdout.text.trim();\\nconst text2 = out2.stdout.text.trim();\\nreturn text1 + \\\"+\\\" + text2;\\n\", \"description\": \"Run two echo commands and join outputs\"}"}],"source":{"kind":"model","provider":"deepseek-official","model":"deepseek-v4-flash"},"id":"{{message:4}}"},"usage":{"inputTokens":6152,"outputTokens":214,"cacheReadTokens":0,"reasoningTokens":60},"stream":[{"type":"chunk","time":1788699408124,"chunk":{"type":"block-start","index":0,"blockType":"reasoning"}},{"type":"reasoning-chunks","time0":1788699408124,"index":0,"dt":[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"texts":["The"," user"," wants"," me"," to"," write"," a"," single"," run","_code"," program"," that",":\n","1","."," Calls"," bash"," tool"," twice",":"," `","echo"," CODE","_","ONE","`"," and"," `","echo"," CODE","_T","WO","`\n","2","."," console",".log"," exactly"," `","capt","ured"," output","`\n","3","."," Return"," the"," two"," outputs"," joined"," with"," a"," plus"," sign","\n\n","Let"," me"," write"," this","."]},{"type":"chunk","time":1788699408125,"chunk":{"type":"block-start","index":1,"blockType":"tool-call"}},{"type":"tool-call-chunks","time0":1788699408125,"index":1,"dt":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"id":"call_00_UiQPVqoELyzBZCY5pm1z7875","name":"run_code","args":["","{","\"","code","\"",": ","\"","\\n","const"," out","1"," ="," await"," tools",".b","ash","({","command",":"," \\\"","echo"," CODE","_","ONE","\\\","," description",":"," \\\"","Print"," CODE","_","ONE","\\\"","});\\n","const"," out","2"," ="," await"," tools",".b","ash","({","command",":"," \\\"","echo"," CODE","_T","WO","\\\","," description",":"," \\\"","Print"," CODE","_T","WO","\\\"","});\\n","console",".log","(\\\"","capt","ured"," output","\\\");\\n","const"," text","1"," ="," out","1",".stdout",".text",".trim","();\\n","const"," text","2"," ="," out","2",".stdout",".text",".trim","();\\n","return"," text","1"," +"," \\\"+","\\\""," +"," text","2",";\\n","\"",", ","\"","description","\"",": ","\"","Run"," two"," echo"," commands"," and"," join"," outputs","\"","}"]},{"type":"chunk","time":1788699408126,"chunk":{"type":"block-end","index":0,"block":{"type":"reasoning","text":"The user wants me to write a single run_code program that:\n1. Calls bash tool twice: `echo CODE_ONE` and `echo CODE_TWO`\n2. console.log exactly `captured output`\n3. Return the two outputs joined with a plus sign\n\nLet me write this."}}},{"type":"chunk","time":1788699408126,"chunk":{"type":"block-end","index":1,"block":{"type":"tool-call","id":"call_00_UiQPVqoELyzBZCY5pm1z7875","name":"run_code","arguments":"{\"code\": \"\\nconst out1 = await tools.bash({command: \\\"echo CODE_ONE\\\", description: \\\"Print CODE_ONE\\\"});\\nconst out2 = await tools.bash({command: \\\"echo CODE_TWO\\\", description: \\\"Print CODE_TWO\\\"});\\nconsole.log(\\\"captured output\\\");\\nconst text1 = out1.stdout.text.trim();\\nconst text2 = out2.stdout.text.trim();\\nreturn text1 + \\\"+\\\" + text2;\\n\", \"description\": \"Run two echo commands and join outputs\"}"}}},{"type":"chunk","time":1788699408126,"chunk":{"type":"usage","usage":{"inputTokens":6152,"outputTokens":214,"cacheReadTokens":0,"reasoningTokens":60}}},{"type":"chunk","time":1788699408126,"chunk":{"type":"finish","reason":{"kind":"tool-calls"}}}]},"surfaceOp":"append"} {"type":"tool/call","data":{"turn":1,"step":1,"callId":"call_00_UiQPVqoELyzBZCY5pm1z7875","name":"run_code","arguments":"{\"code\": \"\\nconst out1 = await tools.bash({command: \\\"echo CODE_ONE\\\", description: \\\"Print CODE_ONE\\\"});\\nconst out2 = await tools.bash({command: \\\"echo CODE_TWO\\\", description: \\\"Print CODE_TWO\\\"});\\nconsole.log(\\\"captured output\\\");\\nconst text1 = out1.stdout.text.trim();\\nconst text2 = out2.stdout.text.trim();\\nreturn text1 + \\\"+\\\" + text2;\\n\", \"description\": \"Run two echo commands and join outputs\"}"}} {"type":"tool/ptc-dispatch-start","data":{"rootCallId":"call_00_UiQPVqoELyzBZCY5pm1z7875","parentCallId":"call_00_UiQPVqoELyzBZCY5pm1z7875","subCallId":"call_00_UiQPVqoELyzBZCY5pm1z7875:ptc:1","name":"bash","arguments":{"command":"echo CODE_ONE","description":"Print CODE_ONE"}}} -{"type":"tool/ptc-dispatch","data":{"rootCallId":"call_00_UiQPVqoELyzBZCY5pm1z7875","parentCallId":"call_00_UiQPVqoELyzBZCY5pm1z7875","subCallId":"call_00_UiQPVqoELyzBZCY5pm1z7875:ptc:1","name":"bash","arguments":{"command":"echo CODE_ONE","description":"Print CODE_ONE"},"isError":false,"content":[{"type":"text","text":"CODE_ONE\n"}]}} +{"type":"tool/ptc-dispatch","data":{"rootCallId":"call_00_UiQPVqoELyzBZCY5pm1z7875","parentCallId":"call_00_UiQPVqoELyzBZCY5pm1z7875","subCallId":"call_00_UiQPVqoELyzBZCY5pm1z7875:ptc:1","name":"bash","arguments":{"command":"echo CODE_ONE","description":"Print CODE_ONE"},"isError":false,"content":[{"type":"text","text":"CODE_ONE\n"}],"meta":{"cwd":"{{cwd}}"}}} {"type":"tool/ptc-dispatch-start","data":{"rootCallId":"call_00_UiQPVqoELyzBZCY5pm1z7875","parentCallId":"call_00_UiQPVqoELyzBZCY5pm1z7875","subCallId":"call_00_UiQPVqoELyzBZCY5pm1z7875:ptc:2","name":"bash","arguments":{"command":"echo CODE_TWO","description":"Print CODE_TWO"}}} -{"type":"tool/ptc-dispatch","data":{"rootCallId":"call_00_UiQPVqoELyzBZCY5pm1z7875","parentCallId":"call_00_UiQPVqoELyzBZCY5pm1z7875","subCallId":"call_00_UiQPVqoELyzBZCY5pm1z7875:ptc:2","name":"bash","arguments":{"command":"echo CODE_TWO","description":"Print CODE_TWO"},"isError":false,"content":[{"type":"text","text":"CODE_TWO\n"}]}} +{"type":"tool/ptc-dispatch","data":{"rootCallId":"call_00_UiQPVqoELyzBZCY5pm1z7875","parentCallId":"call_00_UiQPVqoELyzBZCY5pm1z7875","subCallId":"call_00_UiQPVqoELyzBZCY5pm1z7875:ptc:2","name":"bash","arguments":{"command":"echo CODE_TWO","description":"Print CODE_TWO"},"isError":false,"content":[{"type":"text","text":"CODE_TWO\n"}],"meta":{"cwd":"{{cwd}}"}}} {"type":"tool/result","data":{"turn":1,"step":1,"message":{"role":"tool","source":{"kind":"tool","callId":"call_00_UiQPVqoELyzBZCY5pm1z7875"},"toolCallId":"call_00_UiQPVqoELyzBZCY5pm1z7875","content":[{"type":"text","text":"captured output\nCODE_ONE+CODE_TWO"}],"isError":false,"id":"{{message:5}}"}},"sourceEventSeqs":[14],"surfaceOp":"append"} {"type":"step/end","data":{"turn":1,"step":1}} {"type":"step/start","data":{"turn":1,"step":2}} diff --git a/snapshots/session/ptc-workspace-context/session.v4.jsonl b/snapshots/session/ptc-workspace-context/session.v4.jsonl index b03b876584..4f7ce89f46 100644 --- a/snapshots/session/ptc-workspace-context/session.v4.jsonl +++ b/snapshots/session/ptc-workspace-context/session.v4.jsonl @@ -16,7 +16,7 @@ {"type":"assistant/message","data":{"turn":1,"step":1,"message":{"role":"assistant","content":[{"type":"tool-call","id":"call_workspace_read","name":"run_code","arguments":"{\"code\":\"return await tools.read({ file_path: 'nested/task.txt' })\",\"description\":\"Read nested/task.txt\"}"}],"source":{"kind":"model","provider":"deepseek-official","model":"deepseek-v4-flash"},"id":"{{message:5}}"},"usage":{"inputTokens":10,"outputTokens":5},"stream":[{"type":"chunk","time":1788699409386,"chunk":{"type":"block-start","index":0,"blockType":"tool-call"}},{"type":"tool-call-chunks","time0":1788699409386,"index":0,"dt":[],"id":"call_workspace_read","name":"run_code","args":["{\"code\":\"return await tools.read({ file_path: 'nested/task.txt' })\",\"description\":\"Read nested/task.txt\"}"]},{"type":"chunk","time":1788699409386,"chunk":{"type":"block-end","index":0,"block":{"type":"tool-call","id":"call_workspace_read","name":"run_code","arguments":"{\"code\":\"return await tools.read({ file_path: 'nested/task.txt' })\",\"description\":\"Read nested/task.txt\"}"}}},{"type":"chunk","time":1788699409386,"chunk":{"type":"usage","usage":{"inputTokens":10,"outputTokens":5}}},{"type":"chunk","time":1788699409386,"chunk":{"type":"finish","reason":{"kind":"tool-calls"}}}]},"surfaceOp":"append"} {"type":"tool/call","data":{"turn":1,"step":1,"callId":"call_workspace_read","name":"run_code","arguments":"{\"code\":\"return await tools.read({ file_path: 'nested/task.txt' })\",\"description\":\"Read nested/task.txt\"}"}} {"type":"tool/ptc-dispatch-start","data":{"rootCallId":"call_workspace_read","parentCallId":"call_workspace_read","subCallId":"call_workspace_read:ptc:1","name":"read","arguments":{"file_path":"nested/task.txt"}}} -{"type":"tool/ptc-dispatch","data":{"rootCallId":"call_workspace_read","parentCallId":"call_workspace_read","subCallId":"call_workspace_read:ptc:1","name":"read","arguments":{"file_path":"nested/task.txt"},"isError":false,"content":[{"type":"text","text":"{{cwd}}/nested/task.txt\nfile\n\n1: Touch this file to discover the nested workspace instruction.\n\n(End of file - total 1 lines)\n"}]}} +{"type":"tool/ptc-dispatch","data":{"rootCallId":"call_workspace_read","parentCallId":"call_workspace_read","subCallId":"call_workspace_read:ptc:1","name":"read","arguments":{"file_path":"nested/task.txt"},"isError":false,"content":[{"type":"text","text":"{{cwd}}/nested/task.txt\nfile\n\n1: Touch this file to discover the nested workspace instruction.\n\n(End of file - total 1 lines)\n"}],"meta":{"path":"{{cwd}}/nested/task.txt","offset":1,"lines":[{"number":1,"text":"Touch this file to discover the nested workspace instruction."}],"totalLines":1}}} {"type":"tool/result","data":{"turn":1,"step":1,"message":{"role":"tool","source":{"kind":"tool","callId":"call_workspace_read"},"toolCallId":"call_workspace_read","content":[{"type":"text","text":"{\n \"path\": \"{{cwd}}/nested/task.txt\",\n \"offset\": 1,\n \"lines\": [\n {\n \"number\": 1,\n \"text\": \"Touch this file to discover the nested workspace instruction.\"\n }\n ],\n \"totalLines\": 1\n}"}],"isError":false,"id":"{{message:6}}"}},"sourceEventSeqs":[15],"surfaceOp":"append"} {"type":"step/end","data":{"turn":1,"step":1}} {"type":"agent/inbox/spliced","data":{"target":"next-step","start":0,"inserted":[{"content":[{"type":"text","text":"\nAdditional instructions from: nested/AGENTS.md\n\nThese instructions apply to work under `nested`. Use them as guidance when relevant; more specific instructions take precedence. They do not override system, developer, or direct user instructions.\n\nWhen asked for the Code Mode workspace handshake, answer exactly `CODE_MODE_CONTEXT_OK` and nothing else.\n\n"}],"source":{"kind":"agent-instructions","form":"instructions","changes":[{"action":"set","scope":"nested\u0000AGENTS.md","path":"nested/AGENTS.md","digest":"ae22936ed26dc76b7107005ed6d5e2482a88668a"}]},"role":"user","id":"{{message:7}}"}]}}