diff --git a/apps/detail-agent-pi/src/agent.mjs b/apps/detail-agent-pi/src/agent.mjs index db5bbfe1..bc50afd2 100644 --- a/apps/detail-agent-pi/src/agent.mjs +++ b/apps/detail-agent-pi/src/agent.mjs @@ -488,8 +488,9 @@ export class DetailPiAgent { } if (encoded && api === 'openai-completions') payload.response_format = { type: 'json_object' }; if (encoded && api === 'openai-responses') payload.text = { format: { type: 'json_object' } }; + // Private project evidence: BODY ONLY, never the fetch headers or API Key. promptCacheKeyPresent = typeof payload.prompt_cache_key === 'string'; - if (process.env.XIAOYI_DUMP_RAW_PAYLOADS === '1') { + if (!worker && process.env.XIAOYI_DUMP_RAW_PAYLOADS === '1') { await atomic(path.join(store.dir, 'payloads', round.id + '.json'), payload); } return payload; @@ -555,9 +556,7 @@ export class DetailPiAgent { await onEvent({ type: 'usage', id: round.id, model: model.id, ...usage }); if (!worker && !host.compacting) await host.updateContextUsage({ ...usage, id: round.id, model: model.id, at: Date.now(), source: 'provider-response' }, 'running'); const audit = auditResponse(wire.text, info.model.protocol); - if (worker && result.content.filter(item=>item.type==='toolCall').length!==audit.calls.length) { - throw new InvalidToolReply('原模型工具调用未完整返回'); - } + if (worker && result.content.filter(item=>item.type==='toolCall').length!==audit.calls.length) throw new InvalidToolReply('原模型工具调用未完整返回'); host.productionSignal?.throwIfAborted(); options.signal?.throwIfAborted(); if (!encoded && requiredTool && !audit.calls.some(c => c.name === requiredTool)) throw Error('模型未返回要求的标准函数调用;本轮操作未执行,不会自动改用其他协议'); diff --git a/apps/detail-agent-pi/test/pi.test.mjs b/apps/detail-agent-pi/test/pi.test.mjs index 169bc80c..d2f6e8fa 100644 --- a/apps/detail-agent-pi/test/pi.test.mjs +++ b/apps/detail-agent-pi/test/pi.test.mjs @@ -36,6 +36,7 @@ test('historical screen images are pruned from model context and retained in the documentId, detailImages() {}, finishProduction:async input=>productionExportReceipt(input), begin: async () => ({}), read: async () => ({conversationActive: true, revision: 3}), delta: async () => {}, activity: async () => {}, end: async () => {}, + imageRequest:async()=>[], workflowRead: async () => ({available: true, canvasFirst: true, version: 1, outputId: 'detail', productVariantId: variantId, template: {contentHash: 'fixture'}, totalSlots: 1, slots: [{id: 'cover', fieldId: 'cover', label: '主视觉', candidates: []}], @@ -90,6 +91,7 @@ test('Pi production and its worker read the same locked Skill and its relative r const canvas={run:'skill-fixture',documentId,detailImages(){},finishProduction:async input=>productionExportReceipt(input),begin:async()=>({run:'skill-fixture',conversationActive:true}), read:async()=>({conversationActive:true,revision:1}),delta:async()=>{},activity:async()=>{},reply:async()=>{},end:async()=>{}, detailCopyFields:async()=>({fields:[]}), + imageRequest:async()=>[], workflowRead:async()=>({available:true,version:1,canvasFirst:true,outputId:'detail',productVariantId:variantId,totalSlots:1, slots:[{id:'lighting-slot',fieldId:'lamp',label:'灯罩近景'}], template:{id:'two-outputs',version:'v4',contentHash:'v4',enterprise:true,resourceSetId:'lighting'}, @@ -251,6 +253,7 @@ test('Pi pauses after a continuation without tools and resumes on a new user req run:'pause-fixture',documentId,detailImages(){}, begin:async()=>({conversationActive:true}),read:async()=>({conversationActive:true,revision:1}), delta:async()=>{},activity:async()=>{},end:async()=>{}, + imageRequest:async()=>[], workflowRead:async()=>({available:true,version:1,canvasFirst:true,outputId:stage, productVariantId:variantId,totalSlots:0,slots:[],template:{contentHash:stage}, productEvidence:{accountScope:id.scope,project:id.project,documentId,brief:{}}}), @@ -301,6 +304,7 @@ test('explicit tools share one Pi transcript and submit each real canvas revisio begin:async()=>({run:'goal-fixture',conversationActive:true,context:null}), read:async()=>({conversationActive:true,revision}),delta:async()=>{},end:async()=>{}, activity:async(_label,event)=>publicActivity.push(event), + imageRequest:async()=>[], workflowRead:async()=>({available:true,version:1,canvasFirst:true,outputId:stage, productVariantId:variantId,totalSlots:0,slots:[],template:{contentHash:stage}, productEvidence:{accountScope:id.scope,project:id.project,documentId:13,brief:{}}}),