Skip to main content

Custom Agent Prompt

DelReact allows you to customize the behavior of individual agents by providing custom prompts. This powerful feature enables you to create specialized agent behaviors for specific domains, industries, or use cases.

Overview

The custom agent prompt system allows you to override the default prompts used by DelReact's core agents:

  • TaskBreakdownAgent - Breaks down objectives into actionable tasks
  • TaskReplanningAgent - Replans and adjusts tasks based on progress
  • ActionAgent - Executes individual tasks
  • SummarizerAgent - Creates final summaries and conclusions
  • EnhancePromptAgent - Enhances and refines user prompts

Basic Configuration

To use custom prompts, provide a prompts object when creating your ReactAgentBuilder:

import { ReactAgentBuilder, TaskBreakdownParams, ActionAgentParams } from "delreact-agent";

const builder = new ReactAgentBuilder({
geminiKey: process.env.GEMINI_KEY,
openaiKey: process.env.OPENAI_KEY,
prompts: {
taskBreakdown: (params: TaskBreakdownParams) => {
return `Custom task breakdown prompt for: ${params.objective}`;
},
actionAgent: (params: ActionAgentParams) => {
return `Custom action execution for: ${params.currentTask}`;
}
}
});

Available Agent

1. TaskBreakdown Agent

Customizes how objectives are broken down into tasks.

taskBreakdown: (params: TaskBreakdownParams) => {
return `You are a specialized task planner for ${domain}.

Break down this objective into ${params.maxTasks} or fewer practical steps:
"${params.objective}"

Consider these constraints:
- Focus on ${industry}-specific requirements
- Always end with "[summarize]" task
- Return semicolon-separated list only

Additional context: ${params.sessionContext}`;
}

Parameters (TaskBreakdownParams):

ParameterTypeDescription
objectivestringThe user's main goal that needs to be broken down
maxTasksnumberMaximum number of tasks to generate (typically 5-8)
ragGuidancestringRAG system guidance if enabled
sessionContextstringPrevious conversation context and memory
documentContextstringContext from processed documents (images, PDFs, etc.)
stateAgentStateCurrent agent state with tasks, results, and execution history
configRecordRuntime configuration including provider settings

2. Action Agent

Customizes how individual tasks are executed.

actionAgent: (params: ActionAgentParams) => {
return `You are a ${role} expert.

Execute this specific task: "${params.currentTask}"

For objective: "${params.objective}"

Guidelines:
- Provide ${style} responses
- Consider ${industry} best practices
- Be concise and actionable

Context: ${params.sessionContext}`;
}

Parameters (ActionAgentParams):

ParameterTypeDescription
objectivestringThe overall goal the task contributes to
currentTaskstringThe specific task being executed right now
sessionContextstringAccumulated conversation and memory context
documentContextstringRelevant information from processed files
stateAgentStateCurrent workflow state with previous results
configRecordConfiguration settings and runtime parameters

3. Task Replanning Agent

Customizes how tasks are adjusted during execution.

taskReplanning: (params: TaskReplanningParams) => {
return `As a ${role} specialist, review and adjust the task plan.

Objective: "${params.objective}"
Completed: ${params.actionedTasks.join(", ")}
Current plan: ${params.currentTasks.join(", ")}
Recent results: ${params.actionResults.join(", ")}

Create an improved task sequence considering ${domain} requirements.
Return only semicolon-separated tasks that still need completion.`;
}

Parameters (TaskReplanningParams):

ParameterTypeDescription
objectivestringThe main goal being pursued
actionedTasksstring[]Array of completed tasks
currentTasksstring[]Array of remaining tasks in current plan
actionResultsstring[]Results from completed tasks
ragGuidancestringRAG system guidance for replanning
sessionContextstringSession memory and conversation context
documentContextstringDocument-derived context
stateAgentStateCurrent agent state
configRecordConfiguration settings

4. Summarize Agent

Customizes final summary generation.

summarizerAgent: (params: SummarizerAgentParams) => {
return `You are a ${role} report writer.

Summarize these results for: "${params.objective}"

Results: ${params.actionResults.join("\n")}

Format Requirements:
${params.formatInstruction}

Style: ${reportStyle}
Focus: ${keyAspects}`;
}

Parameters (SummarizerAgentParams):

ParameterTypeDescription
objectivestringThe original goal that was pursued
actionResultsstring[]All results from completed tasks
formatInstructionstringSpecific formatting requirements from user
sessionContextstringSession conversation context
documentContextstringContext from processed documents
stateAgentStateCurrent agent state
configRecordConfiguration settings

5. EnhancePrompt Agent

Customizes prompt enhancement behavior.

enhancePrompt: (params: EnhancePromptParams) => {
return `You are a ${domain} prompt enhancement specialist.

Enhance this prompt for better ${industry} outcomes:
"${params.objective}"

Use the required format with initial enhancement, critique, and final enhancement.
Focus on ${domain}-specific terminology and best practices.`;
}

Parameters (EnhancePromptParams):

ParameterTypeDescription
objectivestringThe original user prompt that needs enhancement
sessionContextstringPrevious conversation context for enhancement
documentContextstringContext from uploaded documents
stateAgentStateCurrent agent state
configRecordConfiguration settings

Real-World Examples

Example 1: Career Advisor Agent

const careerAdvisor = new ReactAgentBuilder({
geminiKey: process.env.GEMINI_KEY,
prompts: {
taskBreakdown: (params: TaskBreakdownParams) => {
return `You are a career advisor specializing in the Indonesian job market.

Break down this career objective into practical, actionable steps:
"${params.objective}"

Consider:
- Indonesian job market trends
- Local industry requirements
- Professional development paths
- Maximum ${params.maxTasks} tasks
- End with "[summarize]"

Return semicolon-separated list only.`;
},

actionAgent: (params: ActionAgentParams) => {
return `You are a career counselor with expertise in Indonesian employment.

Complete this career-related task: "${params.currentTask}"
For objective: "${params.objective}"

Provide practical, Indonesia-specific advice that considers:
- Local job market conditions
- Cultural workplace norms
- Available resources and platforms
- Professional development opportunities`;
},

summarizerAgent: (params: SummarizerAgentParams) => {
return `You are a professional career advisor creating a comprehensive career plan.

Summarize this career guidance for: "${params.objective}"

Results: ${params.actionResults.join("\n")}

Format as a structured career action plan with:
- Immediate next steps (1-2 weeks)
- Short-term goals (1-3 months)
- Medium-term objectives (6-12 months)
- Key resources and contacts
- Success metrics

${params.formatInstruction}`;
}
}
});

Example 2: Technical Documentation Agent

const techDocAgent = new ReactAgentBuilder({
geminiKey: process.env.GEMINI_KEY,
prompts: {
taskBreakdown: (params: TaskBreakdownParams) => {
return `You are a technical documentation specialist.

Break down this documentation objective: "${params.objective}"

Structure should include:
- Requirements analysis
- Architecture overview
- Implementation details
- Testing procedures
- Deployment guide

Maximum ${params.maxTasks} tasks, end with "[summarize]"
Return semicolon-separated list only.`;
},

actionAgent: (params: ActionAgentParams) => {
return `You are a technical writer creating developer documentation.

Complete: "${params.currentTask}"
For: "${params.objective}"

Guidelines:
- Use clear, concise technical language
- Include code examples where relevant
- Consider different skill levels
- Follow documentation best practices
- Be accurate and up-to-date`;
}
}
});

Example 3: Business Analysis Agent

const businessAnalyst = new ReactAgentBuilder({
geminiKey: process.env.GEMINI_KEY,
prompts: {
taskBreakdown: (params: TaskBreakdownParams) => {
return `You are a senior business analyst specializing in market research.

Break down this business analysis objective: "${params.objective}"

Structure your analysis to include:
- Market landscape assessment
- Competitive analysis
- Financial projections
- Risk assessment
- Strategic recommendations

Maximum ${params.maxTasks} tasks, conclude with "[summarize]"
Return semicolon-separated list only.`;
},

actionAgent: (params: ActionAgentParams) => {
return `You are a business analyst with expertise in ${industry} markets.

Execute: "${params.currentTask}"
Objective: "${params.objective}"

Approach:
- Use data-driven insights
- Apply business frameworks (SWOT, Porter's 5 Forces, etc.)
- Consider market dynamics
- Provide actionable recommendations
- Support with relevant metrics`;
},

summarizerAgent: (params: SummarizerAgentParams) => {
return `You are creating an executive business analysis report.

Objective: "${params.objective}"
Analysis Results: ${params.actionResults.join("\n")}

Structure as professional business report:
- Executive Summary
- Key Findings
- Market Opportunities
- Risk Factors
- Strategic Recommendations
- Next Steps

${params.formatInstruction}`;
}
}
});