mirror of
https://github.com/mudler/LocalAI.git
synced 2025-12-20 08:50:38 -06:00
feat(mcp): add planning and reevaluation (#6541)
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
committed by
GitHub
parent
e5bf2a9a11
commit
a22f6a499d
@@ -85,10 +85,13 @@ type MCPConfig struct {
|
||||
}
|
||||
|
||||
type AgentConfig struct {
|
||||
MaxAttempts int `yaml:"max_attempts" json:"max_attempts"`
|
||||
MaxIterations int `yaml:"max_iterations" json:"max_iterations"`
|
||||
EnableReasoning bool `yaml:"enable_reasoning" json:"enable_reasoning"`
|
||||
EnableReEvaluation bool `yaml:"enable_re_evaluation" json:"enable_re_evaluation"`
|
||||
MaxAttempts int `yaml:"max_attempts" json:"max_attempts"`
|
||||
MaxIterations int `yaml:"max_iterations" json:"max_iterations"`
|
||||
EnableReasoning bool `yaml:"enable_reasoning" json:"enable_reasoning"`
|
||||
EnableReEvaluation bool `yaml:"enable_re_evaluation" json:"enable_re_evaluation"`
|
||||
EnablePlanning bool `yaml:"enable_planning" json:"enable_planning"`
|
||||
EnableMCPPrompts bool `yaml:"enable_mcp_prompts" json:"enable_mcp_prompts"`
|
||||
EnablePlanReEvaluator bool `yaml:"enable_plan_re_evaluator" json:"enable_plan_re_evaluator"`
|
||||
}
|
||||
|
||||
func (c *MCPConfig) MCPConfigFromYAML() (MCPGenericConfig[MCPRemoteServers], MCPGenericConfig[MCPSTDIOServers]) {
|
||||
|
||||
@@ -93,6 +93,18 @@ func MCPCompletionEndpoint(cl *config.ModelConfigLoader, ml *model.ModelLoader,
|
||||
cogitoOpts = append(cogitoOpts, cogito.EnableToolReasoner)
|
||||
}
|
||||
|
||||
if config.Agent.EnablePlanning {
|
||||
cogitoOpts = append(cogitoOpts, cogito.EnableAutoPlan)
|
||||
}
|
||||
|
||||
if config.Agent.EnableMCPPrompts {
|
||||
cogitoOpts = append(cogitoOpts, cogito.EnableMCPPrompts)
|
||||
}
|
||||
|
||||
if config.Agent.EnablePlanReEvaluator {
|
||||
cogitoOpts = append(cogitoOpts, cogito.EnableAutoPlanReEvaluator)
|
||||
}
|
||||
|
||||
if config.Agent.EnableReEvaluation {
|
||||
cogitoOpts = append(cogitoOpts, cogito.EnableToolReEvaluator)
|
||||
}
|
||||
|
||||
@@ -28,6 +28,9 @@ The Model Context Protocol is a standard for connecting AI models to external to
|
||||
- **🔒 Secure Authentication**: Support for bearer token authentication
|
||||
- **🎯 OpenAI Compatible**: Uses the familiar `/mcp/v1/chat/completions` endpoint
|
||||
- **🧠 Advanced Reasoning**: Configurable reasoning and re-evaluation capabilities
|
||||
- **📋 Auto-Planning**: Break down complex tasks into manageable steps
|
||||
- **🎯 MCP Prompts**: Specialized prompts for better MCP server interaction
|
||||
- **🔄 Plan Re-evaluation**: Dynamic plan adjustment based on results
|
||||
- **⚙️ Flexible Agent Control**: Customizable execution limits and retry behavior
|
||||
|
||||
## Configuration
|
||||
@@ -82,6 +85,9 @@ agent:
|
||||
max_iterations: 3 # Maximum number of reasoning iterations
|
||||
enable_reasoning: true # Enable tool reasoning capabilities
|
||||
enable_re_evaluation: false # Enable tool re-evaluation
|
||||
enable_planning: false # Enable auto-planning capabilities
|
||||
enable_mcp_prompts: false # Enable MCP prompts
|
||||
enable_plan_re_evaluator: false # Enable plan re-evaluation
|
||||
```
|
||||
|
||||
### Configuration Options
|
||||
@@ -106,6 +112,9 @@ Configure agent behavior and tool execution:
|
||||
- **`max_iterations`**: Maximum number of reasoning iterations (default: 3)
|
||||
- **`enable_reasoning`**: Enable tool reasoning capabilities (default: false)
|
||||
- **`enable_re_evaluation`**: Enable tool re-evaluation (default: false)
|
||||
- **`enable_planning`**: Enable auto-planning capabilities (default: false)
|
||||
- **`enable_mcp_prompts`**: Enable MCP prompts (default: false)
|
||||
- **`enable_plan_re_evaluator`**: Enable plan re-evaluation (default: false)
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -171,6 +180,9 @@ agent:
|
||||
max_iterations: 5
|
||||
enable_reasoning: true
|
||||
enable_re_evaluation: true
|
||||
enable_planning: true
|
||||
enable_mcp_prompts: true
|
||||
enable_plan_re_evaluator: true
|
||||
```
|
||||
|
||||
## Agent Configuration Details
|
||||
@@ -185,10 +197,16 @@ The `agent` section controls how the AI model interacts with MCP tools:
|
||||
- **`enable_reasoning`**: When enabled, the agent uses advanced reasoning to better understand tool results and plan next steps.
|
||||
- **`enable_re_evaluation`**: When enabled, the agent can re-evaluate previous tool results and decisions, allowing for self-correction and improved accuracy.
|
||||
|
||||
### Planning Capabilities
|
||||
- **`enable_planning`**: When enabled, the agent uses auto-planning to break down complex tasks into manageable steps and execute them systematically. The agent will automatically detect when planning is needed.
|
||||
- **`enable_mcp_prompts`**: When enabled, the agent uses specialized prompts exposed by the MCP servers to interact with the exposed tools.
|
||||
- **`enable_plan_re_evaluator`**: When enabled, the agent can re-evaluate and adjust its execution plan based on intermediate results.
|
||||
|
||||
### Recommended Settings
|
||||
- **Simple tasks**: `max_attempts: 2`, `max_iterations: 2`, `enable_reasoning: false`
|
||||
- **Complex tasks**: `max_attempts: 5`, `max_iterations: 5`, `enable_reasoning: true`, `enable_re_evaluation: true`
|
||||
- **Development/Debugging**: `max_attempts: 1`, `max_iterations: 1`, `enable_reasoning: true`, `enable_re_evaluation: true`
|
||||
- **Simple tasks**: `max_attempts: 2`, `max_iterations: 2`, `enable_reasoning: false`, `enable_planning: false`
|
||||
- **Complex tasks**: `max_attempts: 5`, `max_iterations: 5`, `enable_reasoning: true`, `enable_re_evaluation: true`, `enable_planning: true`, `enable_mcp_prompts: true`
|
||||
- **Advanced planning**: `max_attempts: 5`, `max_iterations: 5`, `enable_reasoning: true`, `enable_re_evaluation: true`, `enable_planning: true`, `enable_mcp_prompts: true`, `enable_plan_re_evaluator: true`
|
||||
- **Development/Debugging**: `max_attempts: 1`, `max_iterations: 1`, `enable_reasoning: true`, `enable_re_evaluation: true`, `enable_planning: true`
|
||||
|
||||
## How It Works
|
||||
|
||||
|
||||
2
go.mod
2
go.mod
@@ -33,7 +33,7 @@ require (
|
||||
github.com/mholt/archiver/v3 v3.5.1
|
||||
github.com/microcosm-cc/bluemonday v1.0.27
|
||||
github.com/modelcontextprotocol/go-sdk v1.0.0
|
||||
github.com/mudler/cogito v0.2.0
|
||||
github.com/mudler/cogito v0.3.0
|
||||
github.com/mudler/edgevpn v0.31.0
|
||||
github.com/mudler/go-processmanager v0.0.0-20240820160718-8b802d3ecf82
|
||||
github.com/nikolalohinski/gonja/v2 v2.4.1
|
||||
|
||||
2
go.sum
2
go.sum
@@ -515,6 +515,8 @@ github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
|
||||
github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
|
||||
github.com/mudler/cogito v0.2.0 h1:UzowMlP6kiDLnuwQikac9yUOhI6Qe2tW1jZP5gHQvaY=
|
||||
github.com/mudler/cogito v0.2.0/go.mod h1:abMwl+CUjCp87IufA2quZdZt0bbLaHHN79o17HbUKxU=
|
||||
github.com/mudler/cogito v0.3.0 h1:NbVAO3bLkK5oGSY0xq87jlz8C9OIsLW55s+8Hfzeu9s=
|
||||
github.com/mudler/cogito v0.3.0/go.mod h1:abMwl+CUjCp87IufA2quZdZt0bbLaHHN79o17HbUKxU=
|
||||
github.com/mudler/edgevpn v0.31.0 h1:CXwxQ2ZygzE7iKGl1J+vq9pL5PvsW2uc3qI/zgpNpp4=
|
||||
github.com/mudler/edgevpn v0.31.0/go.mod h1:DKgh9Wu/NM3UbZoPyheMXFvpu1dSLkXrqAOy3oKJN3I=
|
||||
github.com/mudler/go-piper v0.0.0-20241023091659-2494246fd9fc h1:RxwneJl1VgvikiX28EkpdAyL4yQVnJMrbquKospjHyA=
|
||||
|
||||
Reference in New Issue
Block a user