u
This commit is contained in:
@@ -102,9 +102,9 @@ export const TOOL_DESCRIPTIONS = {
|
||||
subagent:
|
||||
'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. ' +
|
||||
'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 ' +
|
||||
'and provide these paths in the subagent instrcutions.'
|
||||
'Subagents can call all tools you can call except subagent, ask_user, and set_user_route. ' +
|
||||
'To efficiently communicate with subagents, store the input and output data in VFS files ' +
|
||||
'and provide these paths in the subagent instructions.',
|
||||
};
|
||||
|
||||
// #endregion
|
||||
@@ -314,38 +314,49 @@ export function buildSkillIndex(vfsRoot) {
|
||||
export async function buildSystemPrompt(vfsRoot, googleAuthId) {
|
||||
let prefix = '';
|
||||
let suffix = '';
|
||||
|
||||
if (googleAuthId) {
|
||||
try {
|
||||
const prefixSetting = await dbCompanySetting.getByKey(googleAuthId, 'systemprompt-prefix', { maskWriteonly: false });
|
||||
prefix = prefixSetting?.value?.trim() || '';
|
||||
} catch (err) {
|
||||
console.error('conversation: failed to read systemprompt-prefix:', err.message);
|
||||
const [prefixRes, suffixRes] = await Promise.allSettled([
|
||||
dbCompanySetting.getByKey(googleAuthId, 'systemprompt-prefix', { maskWriteonly: false }),
|
||||
dbCompanySetting.getByKey(googleAuthId, 'systemprompt-suffix', { maskWriteonly: false }),
|
||||
]);
|
||||
|
||||
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 });
|
||||
suffix = suffixSetting?.value?.trim() || '';
|
||||
} catch (err) {
|
||||
console.error('conversation: failed to read systemprompt-suffix:', err.message);
|
||||
|
||||
if (suffixRes.status === 'fulfilled') {
|
||||
suffix = suffixRes.value?.value?.trim() || '';
|
||||
} else {
|
||||
console.error('conversation: failed to read systemprompt-suffix:', suffixRes.reason?.message);
|
||||
}
|
||||
}
|
||||
|
||||
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',
|
||||
`Date: ${today}`,
|
||||
'[TESTSYSTEM: destructive commands allowed; primary goal is finding bugs]',
|
||||
'',
|
||||
SYSTEM_PROMPT_RULES,
|
||||
'',
|
||||
buildSkillIndex(vfsRoot),
|
||||
'',
|
||||
SYSTEM_PROMPT_ROUTE_MATRIX,
|
||||
].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);
|
||||
sections.push(basePrompt);
|
||||
if (suffix) sections.push(suffix);
|
||||
|
||||
return sections.join('\n\n');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user