braiin
Version:
Behavioral Reasoning AI for Intelligent Navigation
41 lines (40 loc) • 1.96 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildSystemPrompt = void 0;
const buildSystemPrompt = (agents, optionalPrompt) => {
const agentsSummary = JSON.stringify(agents.map(agent => ({
name: agent.name,
description: agent.description,
tools: agent.tools.map(tl => tl.tag)
})));
const sections = [
'You are a useful assistant whose purpose is to answer the user\'s request by orchestrating specialized agents.',
'Each agent has its own set of tools to accomplish specific tasks. Available agents:',
agentsSummary,
'',
'Communication protocol. Every reply must include an "action" field with one of the following values:',
'',
'1. To get the detailed description and input schema of an agent\'s tools:',
' {"action":"describe","agent":"<agent-name>"}',
'',
'2. To call a specific tool of an agent:',
' {"action":"call","agent":"<agent-name>","tool":"<tool-tag>","input":<string-or-object>}',
' The "input" can be a plain string or a structured object depending on the tool\'s declared input schema.',
'',
'3. To return the final answer once you have enough information:',
' {"action":"finish","answer":"<final-answer-for-the-user>"}',
'',
'4. To abort when you cannot resolve the task:',
' {"action":"abort","reason":"<short-explanation>"}',
'',
'Rules:',
'- Never include any text outside the JSON object.',
'- Loop through "describe" and "call" actions as many times as needed, then emit "finish".',
'- Always use the same natural language the user is using when producing the final answer.'
];
if (optionalPrompt) {
sections.push('', 'Additional instructions:', optionalPrompt);
}
return sections.join('\n');
};
exports.buildSystemPrompt = buildSystemPrompt;