u
This commit is contained in:
@@ -102,9 +102,9 @@ export const TOOL_DESCRIPTIONS = {
|
|||||||
subagent:
|
subagent:
|
||||||
'Delegate a task to an isolated subagent. Pre-loads requested SKILL files into its ' +
|
'Delegate a task to an isolated subagent. Pre-loads requested SKILL files into its ' +
|
||||||
'system prompt and returns a compact summary of tool executions alongside the final output. ' +
|
'system prompt and returns a compact summary of tool executions alongside the final output. ' +
|
||||||
'Subagents can call all tools you can call except subagent, ask_user and set_user_route.' +
|
'Subagents can call all tools you can call except subagent, ask_user, and set_user_route. ' +
|
||||||
'To efficently communicate with sugagents store the input and output data in vfs files ' +
|
'To efficiently communicate with subagents, store the input and output data in VFS files ' +
|
||||||
'and provide these paths in the subagent instrcutions.'
|
'and provide these paths in the subagent instructions.',
|
||||||
};
|
};
|
||||||
|
|
||||||
// #endregion
|
// #endregion
|
||||||
@@ -314,38 +314,49 @@ export function buildSkillIndex(vfsRoot) {
|
|||||||
export async function buildSystemPrompt(vfsRoot, googleAuthId) {
|
export async function buildSystemPrompt(vfsRoot, googleAuthId) {
|
||||||
let prefix = '';
|
let prefix = '';
|
||||||
let suffix = '';
|
let suffix = '';
|
||||||
|
|
||||||
if (googleAuthId) {
|
if (googleAuthId) {
|
||||||
try {
|
const [prefixRes, suffixRes] = await Promise.allSettled([
|
||||||
const prefixSetting = await dbCompanySetting.getByKey(googleAuthId, 'systemprompt-prefix', { maskWriteonly: false });
|
dbCompanySetting.getByKey(googleAuthId, 'systemprompt-prefix', { maskWriteonly: false }),
|
||||||
prefix = prefixSetting?.value?.trim() || '';
|
dbCompanySetting.getByKey(googleAuthId, 'systemprompt-suffix', { maskWriteonly: false }),
|
||||||
} catch (err) {
|
]);
|
||||||
console.error('conversation: failed to read systemprompt-prefix:', err.message);
|
|
||||||
|
if (prefixRes.status === 'fulfilled') {
|
||||||
|
prefix = prefixRes.value?.value?.trim() || '';
|
||||||
|
} else {
|
||||||
|
console.error('conversation: failed to read systemprompt-prefix:', prefixRes.reason?.message);
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
const suffixSetting = await dbCompanySetting.getByKey(googleAuthId, 'systemprompt-suffix', { maskWriteonly: false });
|
if (suffixRes.status === 'fulfilled') {
|
||||||
suffix = suffixSetting?.value?.trim() || '';
|
suffix = suffixRes.value?.value?.trim() || '';
|
||||||
} catch (err) {
|
} else {
|
||||||
console.error('conversation: failed to read systemprompt-suffix:', err.message);
|
console.error('conversation: failed to read systemprompt-suffix:', suffixRes.reason?.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const today = new Date().toISOString().split('T')[0];
|
const today = new Date().toISOString().split('T')[0];
|
||||||
const basePrompt = [
|
|
||||||
|
// 1. STATIC CORE FIRST (100% cacheable across all users, days, and VFS changes)
|
||||||
|
const staticCore = [
|
||||||
'QuixPOS Article Management System API Assistant',
|
'QuixPOS Article Management System API Assistant',
|
||||||
`Date: ${today}`,
|
|
||||||
'[TESTSYSTEM: destructive commands allowed; primary goal is finding bugs]',
|
'[TESTSYSTEM: destructive commands allowed; primary goal is finding bugs]',
|
||||||
'',
|
'',
|
||||||
SYSTEM_PROMPT_RULES,
|
SYSTEM_PROMPT_RULES,
|
||||||
'',
|
'',
|
||||||
buildSkillIndex(vfsRoot),
|
|
||||||
'',
|
|
||||||
SYSTEM_PROMPT_ROUTE_MATRIX,
|
SYSTEM_PROMPT_ROUTE_MATRIX,
|
||||||
].join('\n');
|
].join('\n');
|
||||||
|
|
||||||
const sections = [];
|
// 2. DYNAMIC / PER-TENANT STATE LAST (ordered from least-volatile to most-volatile)
|
||||||
|
const dynamicContext = [
|
||||||
|
`Date: ${today}`,
|
||||||
|
'',
|
||||||
|
buildSkillIndex(vfsRoot),
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
|
const sections = [staticCore, dynamicContext];
|
||||||
if (prefix) sections.push(prefix);
|
if (prefix) sections.push(prefix);
|
||||||
sections.push(basePrompt);
|
|
||||||
if (suffix) sections.push(suffix);
|
if (suffix) sections.push(suffix);
|
||||||
|
|
||||||
return sections.join('\n\n');
|
return sections.join('\n\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user