Skip to main content
Glama
sloth-wq

Prompt Auto-Optimizer MCP

by sloth-wq

gepa_record_trajectory

Records execution steps and results for prompt evaluation to enable performance analysis and iterative optimization.

Instructions

Record execution trajectory for prompt evaluation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptIdYesUnique identifier for the prompt candidate
taskIdYesIdentifier for the specific task instance
executionStepsYesSequence of execution steps
resultYesFinal execution result and performance score
metadataNoAdditional execution metadata (optional)

Implementation Reference

  • The primary handler function for the 'gepa_record_trajectory' tool. It validates input parameters, constructs an ExecutionTrajectory object, saves it to the TrajectoryStore, conditionally adds a candidate to the ParetoFrontier if successful, and returns a formatted text response with details.
      private async recordTrajectory(params: RecordTrajectoryParams): Promise<{
        content: { type: string; text: string; }[];
      }> {
        const { promptId, taskId, executionSteps, result, metadata } = params;
    
        // Validate required parameters
        if (!promptId || !taskId || !executionSteps || !result) {
          throw new Error('promptId, taskId, executionSteps, and result are required');
        }
    
        // Create trajectory object
        const trajectory: ExecutionTrajectory = {
          id: `trajectory_${Date.now()}_${Math.random().toString(36).substring(7)}`,
          promptId,
          taskId,
          timestamp: new Date(),
          steps: executionSteps,
          finalResult: result,
          llmCalls: [],
          toolCalls: [],
          totalTokens: metadata?.tokenUsage || 0,
          executionTime: metadata?.executionTime || 0,
        };
    
        try {
          // Save trajectory to store
          const saveResult = await this.trajectoryStore.save(trajectory);
    
          // Update Pareto frontier if this is a successful execution
          if (result.success && result.score > 0) {
            const candidate: GEPAPromptCandidate = {
              id: promptId,
              content: '', // Will be retrieved if needed
              generation: 0,
              taskPerformance: new Map([[taskId, result.score]]),
              averageScore: result.score,
              rolloutCount: 1,
              createdAt: new Date(),
              lastEvaluated: new Date(),
              mutationType: 'initial',
            };
    
            this.paretoFrontier.addCandidate(candidate);
          }
    
          return {
            content: [
              {
                type: 'text',
                text: `# Trajectory Recorded Successfully
    
    ## Trajectory Details
    - **Trajectory ID**: ${trajectory.id}
    - **Prompt ID**: ${promptId}
    - **Task ID**: ${taskId}
    - **Execution Steps**: ${executionSteps.length}
    - **Success**: ${result.success ? '✅' : '❌'}
    - **Performance Score**: ${result.score.toFixed(3)}
    
    ## Execution Summary
    - **Total Steps**: ${executionSteps.length}
    - **Successful Steps**: ${executionSteps.filter(step => !step.error).length}
    - **Failed Steps**: ${executionSteps.filter(step => step.error).length}
    - **Execution Time**: ${metadata?.executionTime || 'N/A'}ms
    - **Token Usage**: ${metadata?.tokenUsage || 'N/A'}
    
    ## Storage
    - **File**: ${saveResult.filePath || 'N/A'}
    - **Success**: ${saveResult.success ? 'Yes' : 'No'}
    - **ID**: ${saveResult.id || 'N/A'}
    
    ${result.success && result.score > 0 ? '✨ Candidate added to Pareto frontier for optimization.' : ''}`,
              },
            ],
          };
        } catch (error) {
          throw new Error(`Failed to record trajectory: ${error instanceof Error ? error.message : 'Unknown error'}`);
        }
      }
  • The JSON input schema definition for the gepa_record_trajectory tool, including all properties, descriptions, and required fields, used for tool listing and validation.
    {
      name: 'gepa_record_trajectory',
      description: 'Record execution trajectory for prompt evaluation',
      inputSchema: {
        type: 'object',
        properties: {
          promptId: {
            type: 'string',
            description: 'Unique identifier for the prompt candidate'
          },
          taskId: {
            type: 'string',
            description: 'Identifier for the specific task instance'
          },
          executionSteps: {
            type: 'array',
            items: {
              type: 'object',
              properties: {
                action: { type: 'string' },
                input: { type: 'object' },
                output: { type: 'object' },
                timestamp: { type: 'string' },
                success: { type: 'boolean' }
              },
              required: ['action', 'timestamp', 'success']
            },
            description: 'Sequence of execution steps'
          },
          result: {
            type: 'object',
            properties: {
              success: { type: 'boolean' },
              score: { type: 'number' },
              output: { type: 'object' }
            },
            required: ['success', 'score'],
            description: 'Final execution result and performance score'
          },
          metadata: {
            type: 'object',
            properties: {
              llmModel: { type: 'string' },
              executionTime: { type: 'number' },
              tokenUsage: { type: 'number' }
            },
            description: 'Additional execution metadata (optional)'
          }
        },
        required: ['promptId', 'taskId', 'executionSteps', 'result']
      }
    },
  • The switch case registration that maps incoming tool calls named 'gepa_record_trajectory' to the recordTrajectory handler method.
    case 'gepa_record_trajectory':
      return await this.recordTrajectory(args as unknown as RecordTrajectoryParams);
  • Type-safe constant defining the tool name 'gepa_record_trajectory' as RECORD_TRAJECTORY in the TOOL_NAMES object.
    RECORD_TRAJECTORY: 'gepa_record_trajectory',
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but reveals little. 'Record' implies a write operation, but it doesn't disclose if this is idempotent, requires specific permissions, has rate limits, or what happens on failure. The description lacks behavioral context like whether it overwrites existing trajectories or appends to them.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's front-loaded with the core purpose and appropriately sized for the tool's complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 5 parameters (including nested objects), no annotations, and no output schema, the description is inadequate. It doesn't explain the return value, error conditions, or how the recorded data is used. Given the complexity and lack of structured fields, more context is needed for an agent to use this effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all 5 parameters. The description adds no parameter-specific semantics beyond implying that parameters relate to 'execution trajectory' and 'prompt evaluation'. This meets the baseline of 3 when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Record execution trajectory for prompt evaluation' clearly states the verb ('Record') and resource ('execution trajectory'), and specifies the context ('for prompt evaluation'). It distinguishes from siblings like gepa_evaluate_prompt (which likely evaluates rather than records) and gepa_reflect (which might analyze rather than record). However, it doesn't explicitly differentiate from all siblings (e.g., gepa_create_backup might also involve recording).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., after gepa_evaluate_prompt), exclusions, or relationships to siblings like gepa_reflect or gepa_select_optimal. The agent must infer usage from the name and context alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/sloth-wq/prompt-auto-optimizer-mcp'

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