Skip to content

Commit a22f6a4

Browse files
authored
feat(mcp): add planning and reevaluation (#6541)
Signed-off-by: Ettore Di Giacinto <[email protected]>
1 parent e5bf2a9 commit a22f6a4

File tree

5 files changed

+43
-8
lines changed

5 files changed

+43
-8
lines changed

core/config/model_config.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,13 @@ type MCPConfig struct {
8585
}
8686

8787
type AgentConfig struct {
88-
MaxAttempts int `yaml:"max_attempts" json:"max_attempts"`
89-
MaxIterations int `yaml:"max_iterations" json:"max_iterations"`
90-
EnableReasoning bool `yaml:"enable_reasoning" json:"enable_reasoning"`
91-
EnableReEvaluation bool `yaml:"enable_re_evaluation" json:"enable_re_evaluation"`
88+
MaxAttempts int `yaml:"max_attempts" json:"max_attempts"`
89+
MaxIterations int `yaml:"max_iterations" json:"max_iterations"`
90+
EnableReasoning bool `yaml:"enable_reasoning" json:"enable_reasoning"`
91+
EnableReEvaluation bool `yaml:"enable_re_evaluation" json:"enable_re_evaluation"`
92+
EnablePlanning bool `yaml:"enable_planning" json:"enable_planning"`
93+
EnableMCPPrompts bool `yaml:"enable_mcp_prompts" json:"enable_mcp_prompts"`
94+
EnablePlanReEvaluator bool `yaml:"enable_plan_re_evaluator" json:"enable_plan_re_evaluator"`
9295
}
9396

9497
func (c *MCPConfig) MCPConfigFromYAML() (MCPGenericConfig[MCPRemoteServers], MCPGenericConfig[MCPSTDIOServers]) {

core/http/endpoints/openai/mcp.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,18 @@ func MCPCompletionEndpoint(cl *config.ModelConfigLoader, ml *model.ModelLoader,
9393
cogitoOpts = append(cogitoOpts, cogito.EnableToolReasoner)
9494
}
9595

96+
if config.Agent.EnablePlanning {
97+
cogitoOpts = append(cogitoOpts, cogito.EnableAutoPlan)
98+
}
99+
100+
if config.Agent.EnableMCPPrompts {
101+
cogitoOpts = append(cogitoOpts, cogito.EnableMCPPrompts)
102+
}
103+
104+
if config.Agent.EnablePlanReEvaluator {
105+
cogitoOpts = append(cogitoOpts, cogito.EnableAutoPlanReEvaluator)
106+
}
107+
96108
if config.Agent.EnableReEvaluation {
97109
cogitoOpts = append(cogitoOpts, cogito.EnableToolReEvaluator)
98110
}

docs/content/docs/features/mcp.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ The Model Context Protocol is a standard for connecting AI models to external to
2828
- **🔒 Secure Authentication**: Support for bearer token authentication
2929
- **🎯 OpenAI Compatible**: Uses the familiar `/mcp/v1/chat/completions` endpoint
3030
- **🧠 Advanced Reasoning**: Configurable reasoning and re-evaluation capabilities
31+
- **📋 Auto-Planning**: Break down complex tasks into manageable steps
32+
- **🎯 MCP Prompts**: Specialized prompts for better MCP server interaction
33+
- **🔄 Plan Re-evaluation**: Dynamic plan adjustment based on results
3134
- **⚙️ Flexible Agent Control**: Customizable execution limits and retry behavior
3235

3336
## Configuration
@@ -82,6 +85,9 @@ agent:
8285
max_iterations: 3 # Maximum number of reasoning iterations
8386
enable_reasoning: true # Enable tool reasoning capabilities
8487
enable_re_evaluation: false # Enable tool re-evaluation
88+
enable_planning: false # Enable auto-planning capabilities
89+
enable_mcp_prompts: false # Enable MCP prompts
90+
enable_plan_re_evaluator: false # Enable plan re-evaluation
8591
```
8692
8793
### Configuration Options
@@ -106,6 +112,9 @@ Configure agent behavior and tool execution:
106112
- **`max_iterations`**: Maximum number of reasoning iterations (default: 3)
107113
- **`enable_reasoning`**: Enable tool reasoning capabilities (default: false)
108114
- **`enable_re_evaluation`**: Enable tool re-evaluation (default: false)
115+
- **`enable_planning`**: Enable auto-planning capabilities (default: false)
116+
- **`enable_mcp_prompts`**: Enable MCP prompts (default: false)
117+
- **`enable_plan_re_evaluator`**: Enable plan re-evaluation (default: false)
109118

110119
## Usage
111120

@@ -171,6 +180,9 @@ agent:
171180
max_iterations: 5
172181
enable_reasoning: true
173182
enable_re_evaluation: true
183+
enable_planning: true
184+
enable_mcp_prompts: true
185+
enable_plan_re_evaluator: true
174186
```
175187

176188
## Agent Configuration Details
@@ -185,10 +197,16 @@ The `agent` section controls how the AI model interacts with MCP tools:
185197
- **`enable_reasoning`**: When enabled, the agent uses advanced reasoning to better understand tool results and plan next steps.
186198
- **`enable_re_evaluation`**: When enabled, the agent can re-evaluate previous tool results and decisions, allowing for self-correction and improved accuracy.
187199

200+
### Planning Capabilities
201+
- **`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.
202+
- **`enable_mcp_prompts`**: When enabled, the agent uses specialized prompts exposed by the MCP servers to interact with the exposed tools.
203+
- **`enable_plan_re_evaluator`**: When enabled, the agent can re-evaluate and adjust its execution plan based on intermediate results.
204+
188205
### Recommended Settings
189-
- **Simple tasks**: `max_attempts: 2`, `max_iterations: 2`, `enable_reasoning: false`
190-
- **Complex tasks**: `max_attempts: 5`, `max_iterations: 5`, `enable_reasoning: true`, `enable_re_evaluation: true`
191-
- **Development/Debugging**: `max_attempts: 1`, `max_iterations: 1`, `enable_reasoning: true`, `enable_re_evaluation: true`
206+
- **Simple tasks**: `max_attempts: 2`, `max_iterations: 2`, `enable_reasoning: false`, `enable_planning: false`
207+
- **Complex tasks**: `max_attempts: 5`, `max_iterations: 5`, `enable_reasoning: true`, `enable_re_evaluation: true`, `enable_planning: true`, `enable_mcp_prompts: true`
208+
- **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`
209+
- **Development/Debugging**: `max_attempts: 1`, `max_iterations: 1`, `enable_reasoning: true`, `enable_re_evaluation: true`, `enable_planning: true`
192210

193211
## How It Works
194212

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ require (
3333
github.com/mholt/archiver/v3 v3.5.1
3434
github.com/microcosm-cc/bluemonday v1.0.27
3535
github.com/modelcontextprotocol/go-sdk v1.0.0
36-
github.com/mudler/cogito v0.2.0
36+
github.com/mudler/cogito v0.3.0
3737
github.com/mudler/edgevpn v0.31.0
3838
github.com/mudler/go-processmanager v0.0.0-20240820160718-8b802d3ecf82
3939
github.com/nikolalohinski/gonja/v2 v2.4.1

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,8 @@ github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
515515
github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
516516
github.com/mudler/cogito v0.2.0 h1:UzowMlP6kiDLnuwQikac9yUOhI6Qe2tW1jZP5gHQvaY=
517517
github.com/mudler/cogito v0.2.0/go.mod h1:abMwl+CUjCp87IufA2quZdZt0bbLaHHN79o17HbUKxU=
518+
github.com/mudler/cogito v0.3.0 h1:NbVAO3bLkK5oGSY0xq87jlz8C9OIsLW55s+8Hfzeu9s=
519+
github.com/mudler/cogito v0.3.0/go.mod h1:abMwl+CUjCp87IufA2quZdZt0bbLaHHN79o17HbUKxU=
518520
github.com/mudler/edgevpn v0.31.0 h1:CXwxQ2ZygzE7iKGl1J+vq9pL5PvsW2uc3qI/zgpNpp4=
519521
github.com/mudler/edgevpn v0.31.0/go.mod h1:DKgh9Wu/NM3UbZoPyheMXFvpu1dSLkXrqAOy3oKJN3I=
520522
github.com/mudler/go-piper v0.0.0-20241023091659-2494246fd9fc h1:RxwneJl1VgvikiX28EkpdAyL4yQVnJMrbquKospjHyA=

0 commit comments

Comments
 (0)