From 3c9fbac269bb33bb6fd0ca41a21fbf06969e9c19 Mon Sep 17 00:00:00 2001 From: WuYongJie <549727955@qq.com> Date: Sun, 29 Nov 2026 12:01:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=8E=E5=B0=8F=E5=A3=B9=E5=88=B6=E4=BD=9C?= =?UTF-8?q?=E4=BC=9A=E8=AF=9D=E9=9A=90=E8=97=8F=E7=9B=AE=E6=A0=87=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/photocraft-extension.mjs | 18 +++++++++++++++++- apps/detail-agent-pi/test/pi.test.mjs | 13 ++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/apps/detail-agent-pi/src/photocraft-extension.mjs b/apps/detail-agent-pi/src/photocraft-extension.mjs index 49c35f97..af85082e 100644 --- a/apps/detail-agent-pi/src/photocraft-extension.mjs +++ b/apps/detail-agent-pi/src/photocraft-extension.mjs @@ -50,7 +50,23 @@ export async function createPhotoCraftExtensions(host, existing = [], { noPromptTemplates: !includeProjectResources, systemPromptOverride: () => systemPrompt, appendSystemPrompt: [], - extensionsOverride: result => ({...result, extensions:[...existing, ...result.extensions]}), + extensionsOverride: result => { + if (includeGoal && host.productionGoal) { + for (const extension of result.extensions) { + const update = extension.tools.get('update_goal'); + if (!update) continue; + // pi-goal activates both goal tools when a goal starts or resumes. + // Keep host calls available while projecting this tool out of model requests. + const {promptSnippet, promptGuidelines, ...definition} = update.definition; + update.definition = { + ...definition, + description: '记录宿主已核验的交付结果。', + prepareLoadout: () => ({hiddenDeclarations:['update_goal']}), + }; + } + } + return {...result, extensions:[...existing, ...result.extensions]}; + }, skillsOverride: local => { const enterprise = host.productionSkills?.resource; if (!enterprise) return local; diff --git a/apps/detail-agent-pi/test/pi.test.mjs b/apps/detail-agent-pi/test/pi.test.mjs index 885e792b..585d1437 100644 --- a/apps/detail-agent-pi/test/pi.test.mjs +++ b/apps/detail-agent-pi/test/pi.test.mjs @@ -5,7 +5,7 @@ import fs from 'node:fs/promises'; import os from 'node:os'; import path from 'node:path'; import { randomUUID } from 'node:crypto'; -import { createAssistantMessageEventStream, getCurrentSystemPrompt } from '@earendil-works/pi-ai/compat'; +import { createAssistantMessageEventStream, getCurrentSystemPrompt, getCurrentTools } from '@earendil-works/pi-ai/compat'; import { ProjectStore } from '../src/store.mjs'; import { evaluate, ToolLab } from '../src/tool-lab.mjs'; import { openAgent } from './fake-canvas.mjs'; @@ -426,11 +426,22 @@ test('a production goal completes only on the verified delivery receipt', {timeo }; const steps=[ ['open_production_output',{outputId:'detail',variantId}],['finish_production',{revision}], + ['tool_search',{query:'update_goal'}], ['update_goal',{status:'complete'}], ['open_production_output',{outputId:'sku_images',variantId}],['finish_production',{revision}], ['finish_production',{scope:'all'}], ]; const transport={info:info(id.scope),stream(_model,context){ + const tools=getCurrentTools(context.messages); + assert.ok(tools.some(tool=>tool.name==='finish_production')); + assert.ok(!tools.some(tool=>tool.name==='update_goal')); + assert.doesNotMatch(tools.find(tool=>tool.name==='codemode').description,/update_goal/u); + assert.doesNotMatch(getCurrentSystemPrompt(context.messages),/update_goal/u); + const search=context.messages.findLast(message=>message.role==='toolResult'&&message.toolName==='tool_search'); + if(search) { + assert.equal(search.isError,false); + assert.doesNotMatch(search.content.map(part=>part.text).join(''),/update_goal/u); + } premature??=context.messages.findLast(message=>message.role==='toolResult'&&message.toolName==='update_goal'); const call=steps.shift(); return call?stream([{type:'toolCall',name:call[0],id:'tool-'+(++serial),arguments:call[1]}]):