MCPcopy Create free account
hub / github.com/anus-dev/ANUS / buildChatSystemPrompt

Method buildChatSystemPrompt

packages/core/src/core/subagent.ts:654–681  ·  view source on GitHub ↗

* Builds the system prompt for the chat based on the provided configurations. * It templates the base system prompt and appends instructions for emitting * variables if an `OutputConfig` is provided. * @param {ContextState} context - The context for templating. * @returns {string} The co

(context: ContextState)

Source from the content-addressed store, hash-verified

652 * @returns {string} The complete system prompt.
653 */
654 private buildChatSystemPrompt(context: ContextState): string {
655 if (!this.promptConfig.systemPrompt) {
656 // This should ideally be caught in createChatObject, but serves as a safeguard.
657 return '';
658 }
659
660 let finalPrompt = templateString(this.promptConfig.systemPrompt, context);
661
662 // Add instructions for emitting variables if needed.
663 if (this.outputConfig && this.outputConfig.outputs) {
664 let outputInstructions =
665 '\n\nAfter you have achieved all other goals, you MUST emit the required output variables. For each expected output, make one final call to the `self.emitvalue` tool.';
666
667 for (const [key, value] of Object.entries(this.outputConfig.outputs)) {
668 outputInstructions += `\n* Use 'self.emitvalue' to emit the '${key}' key, with a value described as: '${value}'`;
669 }
670 finalPrompt += outputInstructions;
671 }
672
673 // Add general non-interactive instructions.
674 finalPrompt += `
675
676Important Rules:
677 * You are running in a non-interactive mode. You CANNOT ask the user for input or clarification. You must proceed with the information you have.
678 * Once you believe all goals have been met and all required outputs have been emitted, stop calling tools.`;
679
680 return finalPrompt;
681 }
682}

Callers 1

createChatObjectMethod · 0.95

Calls 1

templateStringFunction · 0.85

Tested by

no test coverage detected