Fix stale evaluation and formatting in agent prompts

This commit is contained in:
larchanka
2026-04-10 16:50:57 +02:00
parent 6517c45992
commit 0255123229
4 changed files with 7 additions and 11 deletions

View File

@@ -45,10 +45,6 @@ You have access to the following core tools:
- schedule_reminder(time: string, message: string, isAction: boolean)
</available_tools>
<response_format>
{{response_format}}
</response_format>
MISSION: COMPLETE THE TASK. USE TOOLS. LOAD SKILLS IF NEEDED.
`;

View File

@@ -10,8 +10,6 @@ Your name is \`🧬 ManBot\`. You are a Professional Data Analyst and Assistant.
Your goal is to synthesize raw tool outputs into a clear response optimized for Telegram.
</role>
<current_date_iso>${new Date().toISOString()}</current_date_iso>
<instructions>
## ANALYSIS GUIDELINES:
- Synthesize: Combine multiple sources. Identify patterns or contradictions.
@@ -29,8 +27,9 @@ MISSION: COMPLETE THE TASK. REPLY WITH TELEGRAM HTML FORMAT.`;
* Builds the analyzer prompt.
*/
export function buildAnalyzerUserPrompt(goal: string, context: string): string {
const timeCtx = `<current_date_iso>${new Date().toISOString()}</current_date_iso>\n\n`;
if (!context || !context.trim()) {
return `Respond to the user goal directly:\n\n${goal}`;
return `${timeCtx}Respond to the user goal directly:\n\n${goal}`;
}
return `User Goal: ${goal}\n\nData Context:\n${context}\n\nTask: Synthesize the data to answer the goal. Use Telegram HTML formatting (no markdown, no tables).`;
return `${timeCtx}User Goal: ${goal}\n\n<data_context>\n${context}\n</data_context>\n\nTask: Synthesize the data to answer the goal. Use Telegram HTML formatting (no markdown, no tables).`;
}

View File

@@ -52,9 +52,9 @@ Return ONLY a raw JSON object. No markdown wrappers.
* Builds the critic prompt with injection protection.
*/
export function buildCriticPrompt(goal: string, draftOutput: string): string {
// Basic sanitization to prevent tag-breaking injection
const safeGoal = goal.replace(/<\/?[^>]+(>|$)/g, "");
const safeDraft = draftOutput.replace(/<\/?[^>]+(>|$)/g, "");
// Wrap in CDATA to prevent XML structure breakage while preserving original tags
const safeGoal = `<![CDATA[\n${goal.replace(/\]\]>/g, ']]]]><![CDATA[>')}\n]]>`;
const safeDraft = `<![CDATA[\n${draftOutput.replace(/\]\]>/g, ']]]]><![CDATA[>')}\n]]>`;
return `<audit_request>
<user_goal>

View File

@@ -50,6 +50,7 @@ export function buildSummarizerPrompt(chatHistory: string): string {
return `<metadata>
<task>Extract and update user profile and knowledge graph from the log below.</task>
<timestamp>${new Date().toISOString()}</timestamp>
</metadata>
<conversation_log>