从小壹制作会话隐藏目标完成工具
This commit is contained in:
parent
b75c7e3b53
commit
3c9fbac269
@ -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;
|
||||
|
||||
@ -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]}]):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user