predict_next_action
Anticipate the next likely action by analyzing context and previous actions. Ideal for enhancing decision-making and streamlining workflows in autonomous systems.
Instructions
Predict the next likely action based on context
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| context | No | ||
| previousActions | No |
Implementation Reference
- mcp-self-learning-server.js:1273-1301 (handler)Core handler for 'predict_next_action' tool. Matches input previousActions against learned tool sequences in patterns, predicts next action from matching patterns, sorts by confidence, returns top 5 predictions.async handlePredictNextAction(args) { const { context, previousActions = [] } = args; const predictions = []; // Find matching patterns for (const [key, pattern] of this.learningEngine.patterns) { const sequence = pattern.features?.toolSequence || []; // Check if previous actions match pattern prefix if (this.sequenceMatches(previousActions, sequence)) { if (sequence.length > previousActions.length) { predictions.push({ action: sequence[previousActions.length], confidence: pattern.confidence, pattern: key }); } } } // Sort by confidence predictions.sort((a, b) => b.confidence - a.confidence); return { success: true, predictions: predictions.slice(0, 5), context: context }; }
- mcp-self-learning-server.js:1028-1041 (registration)Registration of the 'predict_next_action' tool in the ListTools response, defining its name, description, and input schema.{ name: 'predict_next_action', description: 'Predict the next likely action based on context', inputSchema: { type: 'object', properties: { context: { type: 'object' }, previousActions: { type: 'array', items: { type: 'string' } } } } },
- mcp-self-learning-server.js:1094-1096 (registration)Dispatch case in the main CallToolRequestHandler switch statement that routes to the predict_next_action handler.case 'predict_next_action': result = await this.handlePredictNextAction(args); break;
- Helper method used by handlePredictNextAction to determine if provided previousActions match the prefix of a learned tool sequence.sequenceMatches(actions, sequence) { if (actions.length > sequence.length) return false; for (let i = 0; i < actions.length; i++) { if (actions[i] !== sequence[i]) return false; } return true; }