Skip to main content

Separate Model Configuration Feature

Overview

This feature allows ReactAgentBuilder to use different models for different types of agents:

  • Reasoning Agents: TaskBreakdownAgent, TaskReplanningAgent, EnhancePromptAgent
  • Execution Agents: ActionAgent, CompletionAgent

This enables cost optimization and performance tuning by using appropriate models for different tasks.

Configuration Options

Basic Separate Model Configuration

const agent = builder.init({
// Fast reasoning for planning tasks
reasonProvider: "gemini",
reasonModel: "gemini-2.0-flash",

// High-quality execution for action and completion tasks
provider: "openai", // Provider for execution agents
model: "gpt-4o-mini" // Model for execution agents
}).build();

Backward Compatible (Unchanged)

const agent = builder.init({
provider: "gemini", // or selectedProvider (legacy)
model: "gemini-2.0-flash" // All agents use this model
}).build();

Same Provider, Different Models

const agent = builder.init({
reasonProvider: "openai",
reasonModel: "gpt-4o-mini", // Fast reasoning
provider: "openai",
model: "gpt-4o" // High-quality execution
}).build();

Parameters

ParameterDescriptionAgent TypeDefault
reasonProviderProvider for reasoning agentsTaskBreakdown, TaskReplanning, EnhancePromptFalls back to provider
reasonModelModel for reasoning agentsTaskBreakdown, TaskReplanning, EnhancePromptFalls back to model or smart default
providerProvider for execution agentsAction, CompletionFirst available provider
modelModel for execution agentsAction, CompletionFalls back to reasonModel or smart default

Legacy parameter selectedProvider is still supported for backward compatibility.

Agent Classification

Reasoning Agents (use reasonProvider/reasonModel)

  • TaskBreakdownAgent: Breaks down objectives into actionable tasks
  • TaskReplanningAgent: Evaluates progress and replans if needed
  • EnhancePromptAgent: Enhances user prompts for clarity (when enabled)

Execution Agents (use provider/model)

  • ActionAgent: Executes individual tasks using tools and generates outputs
  • CompletionAgent: Synthesizes results and provides final conclusion

Note: provider and model specifically configure the execution agents that handle action execution and final result generation.

Validation and Warnings

The system provides helpful warnings for common misconfigurations:

// Warning: reasonModel specified but reasonProvider is missing
{
reasonModel: "gpt-4o-mini", // ⚠️ Warning triggered
provider: "openai",
model: "gpt-4o-mini"
}

// Warning: reasonProvider specified but reasonModel is missing
{
reasonProvider: "openai", // ⚠️ Warning triggered
provider: "gemini",
model: "gemini-2.0-flash"
}

// Warning: No API key for provider
{
reasonProvider: "openai", // ⚠️ Warning if openaiKey missing
reasonModel: "gpt-4o-mini",
provider: "gemini",
model: "gemini-2.0-flash"
}

Use Cases

1. Cost Optimization

Use faster, cheaper models for planning and more capable models for execution:

const agent = builder.init({
reasonProvider: "gemini", // Fast and cost-effective
reasonModel: "gemini-2.0-flash",
provider: "openai", // Higher quality
model: "gpt-4o-mini"
}).build();

2. Provider Specialization

Leverage different providers' strengths:

const agent = builder.init({
reasonProvider: "gemini", // Google's strength in reasoning
reasonModel: "gemini-2.0-flash",
provider: "anthropic", // Anthropic's strength in execution
model: "claude-3-sonnet"
}).build();

3. Development vs Production

Different models for different environments:

// Development: Fast models for quick iteration
const devAgent = builder.init({
reasonProvider: "gemini",
reasonModel: "gemini-2.0-flash",
provider: "openai",
model: "gpt-4o-mini"
}).build();

// Production: High-quality models for best results
const prodAgent = builder.init({
reasonProvider: "openai",
reasonModel: "gpt-4o",
provider: "openai",
model: "gpt-4o"
}).build();

Default Behavior

When configuration is incomplete, the system uses intelligent defaults:

  1. If only provider/model specified → All agents use execution config (backward compatible)
  2. If only reasonProvider/reasonModel specified → Execution agents use default
  3. If no models specified → All agents use gpt-4.1-mini
  4. If no providers specified → All agents use first available provider

Benefits

  • Cost Efficiency: Optimize costs by using appropriate models for different tasks
  • Performance Tuning: Fine-tune performance based on agent responsibilities
  • Provider Flexibility: Mix and match providers based on their strengths
  • Zero Breaking Changes: Existing configurations continue to work unchanged
  • Smart Validation: Prevents common misconfigurations with helpful warnings
  • Intelligent Defaults: Sensible fallbacks when configuration is incomplete

Migration Guide

Existing Code (No Changes Required)

// This continues to work exactly as before
const agent = builder.init({
selectedProvider: "gemini",
model: "gemini-2.0-flash"
}).build();

Enhanced with Separate Models

// Add reasoning configuration for optimization
const agent = builder.init({
reasonProvider: "gemini", // New: Fast reasoning
reasonModel: "gemini-2.0-flash", // New: Fast reasoning
provider: "openai", // Existing: Execution
model: "gpt-4o-mini" // Existing: Execution
}).build();

The feature is fully backward compatible - no existing code needs to change.