Skip to main content
Glama

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
NameRequiredDescriptionDefault
contextNo
previousActionsNo

Implementation Reference

  • 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 }; }
  • 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' } } } } },
  • 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; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/saralegui-solutions/mcp-self-learning-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server