Skip to main content
Glama

llm_evaluate_coherence

Assess LLM response consistency by running the same prompt multiple times to evaluate model coherence and reliability.

Instructions

Evalúa la coherencia del modelo ejecutando el mismo prompt múltiples veces

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
baseURLNoURL del servidor OpenAI-compatible (ej: http://localhost:1234/v1, http://localhost:11434/v1)
apiKeyNoAPI Key (requerida para OpenAI/Azure, opcional para servidores locales)
promptYesPrompt para evaluar
modelNoID del modelo
runsNoNúmero de ejecuciones (default: 3)
temperatureNoTemperatura (default: 0.7)

Implementation Reference

  • Main tool handler function that evaluates model coherence by calling LLMClient.evaluateCoherence and formatting the results into a markdown report.
    async llm_evaluate_coherence(args: z.infer<typeof CoherenceSchema>) {
      const client = getClient(args);
      const result = await client.evaluateCoherence(args.prompt, {
        model: args.model,
        runs: args.runs,
        temperature: args.temperature,
      });
    
      let output = `# 🎯 Evaluación de Coherencia\n\n`;
      output += `**Prompt:** ${args.prompt}\n\n`;
      output += `**Métricas:**\n`;
      output += `- Consistencia: ${(result.consistency * 100).toFixed(1)}%\n`;
      output += `- Longitud promedio: ${result.avgLength.toFixed(0)} caracteres\n\n`;
      output += `**Respuestas:**\n\n`;
    
      result.responses.forEach((r, i) => {
        output += `---\n**Respuesta ${i + 1}:**\n${r}\n\n`;
      });
    
      return { content: [{ type: "text" as const, text: output }] };
    },
  • Zod schema for input validation of the llm_evaluate_coherence tool parameters.
    export const CoherenceSchema = ConnectionConfigSchema.extend({
      prompt: z.string().describe("Prompt para evaluar coherencia"),
      model: z.string().optional().describe("ID del modelo a usar"),
      runs: z.number().optional().default(3).describe("Número de ejecuciones"),
      temperature: z.number().optional().default(0.7).describe("Temperatura"),
    });
  • src/tools.ts:137-151 (registration)
    Tool registration entry in the tools array, including name, description, and input schema for MCP list tools.
    {
      name: "llm_evaluate_coherence",
      description: "Evalúa la coherencia del modelo ejecutando el mismo prompt múltiples veces",
      inputSchema: {
        type: "object" as const,
        properties: {
          ...connectionProperties,
          prompt: { type: "string", description: "Prompt para evaluar" },
          model: { type: "string", description: "ID del modelo" },
          runs: { type: "number", description: "Número de ejecuciones (default: 3)" },
          temperature: { type: "number", description: "Temperatura (default: 0.7)" },
        },
        required: ["prompt"],
      },
    },
  • src/index.ts:67-68 (registration)
    Dispatch case in the main CallToolRequest handler that routes to the tool handler.
    case "llm_evaluate_coherence":
      return await toolHandlers.llm_evaluate_coherence(args as any);
  • Core helper method in LLMClient that runs the prompt multiple times, computes response consistency based on length variance, and returns metrics.
    async evaluateCoherence(
      prompt: string,
      options: {
        model?: string;
        runs?: number;
        temperature?: number;
      } = {}
    ): Promise<{
      responses: string[];
      consistency: number;
      avgLength: number;
    }> {
      const runs = options.runs || 3;
      const responses: string[] = [];
    
      for (let i = 0; i < runs; i++) {
        const result = await this.chat(prompt, {
          model: options.model,
          temperature: options.temperature ?? 0.7,
        });
        responses.push(result.response);
      }
    
      // Calcular similitud básica entre respuestas
      const avgLength = responses.reduce((sum, r) => sum + r.length, 0) / responses.length;
      
      // Calcular consistencia basada en longitud similar
      const lengthVariance = responses.reduce((sum, r) => {
        return sum + Math.pow(r.length - avgLength, 2);
      }, 0) / responses.length;
      
      const consistency = Math.max(0, 1 - (Math.sqrt(lengthVariance) / avgLength));
    
      return {
        responses,
        consistency,
        avgLength,
      };
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the core behavior (running the same prompt multiple times to evaluate coherence) but lacks details on what 'coherence' means, how results are measured or returned, whether this is a read-only operation, rate limits, or authentication requirements. The description is too vague for a tool with 6 parameters and no output schema.

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 in Spanish that directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, with every word earning its place. No structural issues or redundancy.

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?

Given the complexity (6 parameters, no annotations, no output schema), the description is incomplete. It doesn't explain what 'coherence' entails, how results are returned, or the tool's behavioral traits. For an evaluation tool with multiple parameters and no structured output, more context is needed to guide effective use.

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 already documents all 6 parameters thoroughly. The description doesn't add any meaningful parameter semantics beyond what's in the schema—it doesn't explain how parameters like 'runs' or 'temperature' specifically affect coherence evaluation. Baseline 3 is appropriate when the 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 clearly states the tool's purpose: 'Evalúa la coherencia del modelo ejecutando el mismo prompt múltiples veces' (Evaluates model coherence by running the same prompt multiple times). It specifies the verb (evaluates) and resource (model coherence), but doesn't explicitly differentiate from sibling tools like llm_benchmark or llm_quality_report, which might have overlapping evaluation functions.

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 sibling tools like llm_benchmark or llm_quality_report, nor does it specify contexts where coherence evaluation is preferred over other types of model testing or comparison. Usage is implied but not articulated.

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/ramgeart/llm-mcp-bridge'

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