Skip to main content
Glama
collapseindex

CI-1T Prediction Stability Engine

compare_windows

Detect drift or degradation by comparing baseline and recent episode arrays. Returns trend, delta metrics, and severity factors for model health tracking.

Instructions

Compare two windows of episodes to detect drift or degradation — no API call, no auth, no credits. Takes baseline and recent episode arrays from evaluate or fleet_session_round responses. Response: { comparison: { baseline: stats, recent: stats }, delta: { ci_mean, ema_mean, al_mean, ghost_delta, warn_delta, fault_delta }, trend: 'improving'|'stable'|'degrading', degraded: bool, severity_factors: [...] }. Use after multiple evaluate calls to track model health over time.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
baselineYesBaseline episode array (e.g. last hour, known-good run)
recentYesRecent episode array to compare against baseline

Implementation Reference

  • src/index.ts:948-1042 (registration)
    Registration of the compare_windows tool via server.tool(...) call. Lines 948-1042 contain the full registration including name, description, schema definition, and handler.
    server.tool(
      "compare_windows",
      "Compare two windows of episodes to detect drift or degradation — no API call, no auth, no credits. Takes baseline and recent episode arrays from evaluate or fleet_session_round responses. Response: { comparison: { baseline: stats, recent: stats }, delta: { ci_mean, ema_mean, al_mean, ghost_delta, warn_delta, fault_delta }, trend: 'improving'|'stable'|'degrading', degraded: bool, severity_factors: [...] }. Use after multiple evaluate calls to track model health over time.",
      {
        baseline: z.array(z.record(z.string(), z.unknown())).min(1).describe("Baseline episode array (e.g. last hour, known-good run)"),
        recent: z.array(z.record(z.string(), z.unknown())).min(1).describe("Recent episode array to compare against baseline"),
      },
      async ({ baseline, recent }) => {
        const Q = 65535;
    
        function windowStats(eps: Array<Record<string, unknown>>) {
          const cis = eps.map(e => ((e.ci_out as number) || 0) / Q);
          const emas = eps.map(e => ((e.ci_ema_out as number) || 0) / Q);
          const als = eps.map(e => (e.al_out as number) || 0);
          const mean = (arr: number[]) => arr.reduce((a, b) => a + b, 0) / arr.length;
          const max = (arr: number[]) => Math.max(...arr);
          const min = (arr: number[]) => Math.min(...arr);
          const ghosts = eps.filter(e => e.ghost_confirmed).length;
          const warns = eps.filter(e => e.warn).length;
          const faults = eps.filter(e => e.fault).length;
    
          return {
            episodes: eps.length,
            ci_mean: mean(cis),
            ci_max: max(cis),
            ci_min: min(cis),
            ema_mean: mean(emas),
            al_mean: mean(als),
            al_max: max(als),
            ghosts,
            warns,
            faults,
          };
        }
    
        function classify(ci: number): string {
          if (ci <= 0.15) return "Stable";
          if (ci <= 0.45) return "Drift";
          if (ci <= 0.70) return "Flip";
          return "Collapse";
        }
    
        const base = windowStats(baseline as Array<Record<string, unknown>>);
        const curr = windowStats(recent as Array<Record<string, unknown>>);
    
        const ciDelta = curr.ci_mean - base.ci_mean;
        const emaDelta = curr.ema_mean - base.ema_mean;
        const alDelta = curr.al_mean - base.al_mean;
    
        // Trend direction
        let trend: "improving" | "stable" | "degrading";
        if (ciDelta < -0.03) trend = "improving";
        else if (ciDelta > 0.03) trend = "degrading";
        else trend = "stable";
    
        // Severity assessment
        const severityFactors: string[] = [];
        if (ciDelta > 0.15) severityFactors.push(`CI jumped significantly (+${(ciDelta * 100).toFixed(1)}%)`);
        if (curr.ghosts > base.ghosts) severityFactors.push(`Ghost count increased (${base.ghosts} → ${curr.ghosts})`);
        if (curr.faults > base.faults) severityFactors.push(`Fault count increased (${base.faults} → ${curr.faults})`);
        if (curr.al_max > base.al_max) severityFactors.push(`Max authority level rose (AL${base.al_max} → AL${curr.al_max})`);
        if (classify(curr.ci_mean) !== classify(base.ci_mean)) {
          severityFactors.push(`Classification changed: ${classify(base.ci_mean)} → ${classify(curr.ci_mean)}`);
        }
    
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify(
                {
                  comparison: {
                    baseline: { ...base, ci_mean_pct: +(base.ci_mean * 100).toFixed(2), classification: classify(base.ci_mean) },
                    recent: { ...curr, ci_mean_pct: +(curr.ci_mean * 100).toFixed(2), classification: classify(curr.ci_mean) },
                  },
                  delta: {
                    ci_mean: +(ciDelta * 100).toFixed(2),
                    ema_mean: +(emaDelta * 100).toFixed(2),
                    al_mean: +alDelta.toFixed(2),
                    ghost_delta: curr.ghosts - base.ghosts,
                    warn_delta: curr.warns - base.warns,
                    fault_delta: curr.faults - base.faults,
                  },
                  trend,
                  degraded: trend === "degrading",
                  severity_factors: severityFactors.length ? severityFactors : ["No significant changes detected"],
                },
                null,
                2
              ),
            },
          ],
        };
      }
    );
  • The async handler function for compare_windows. It takes baseline and recent episode arrays, computes per-window statistics (ci_mean, ema_mean, al_mean, ghosts, warns, faults), calculates deltas, determines trend direction (improving/stable/degrading), and assesses severity factors.
      async ({ baseline, recent }) => {
        const Q = 65535;
    
        function windowStats(eps: Array<Record<string, unknown>>) {
          const cis = eps.map(e => ((e.ci_out as number) || 0) / Q);
          const emas = eps.map(e => ((e.ci_ema_out as number) || 0) / Q);
          const als = eps.map(e => (e.al_out as number) || 0);
          const mean = (arr: number[]) => arr.reduce((a, b) => a + b, 0) / arr.length;
          const max = (arr: number[]) => Math.max(...arr);
          const min = (arr: number[]) => Math.min(...arr);
          const ghosts = eps.filter(e => e.ghost_confirmed).length;
          const warns = eps.filter(e => e.warn).length;
          const faults = eps.filter(e => e.fault).length;
    
          return {
            episodes: eps.length,
            ci_mean: mean(cis),
            ci_max: max(cis),
            ci_min: min(cis),
            ema_mean: mean(emas),
            al_mean: mean(als),
            al_max: max(als),
            ghosts,
            warns,
            faults,
          };
        }
    
        function classify(ci: number): string {
          if (ci <= 0.15) return "Stable";
          if (ci <= 0.45) return "Drift";
          if (ci <= 0.70) return "Flip";
          return "Collapse";
        }
    
        const base = windowStats(baseline as Array<Record<string, unknown>>);
        const curr = windowStats(recent as Array<Record<string, unknown>>);
    
        const ciDelta = curr.ci_mean - base.ci_mean;
        const emaDelta = curr.ema_mean - base.ema_mean;
        const alDelta = curr.al_mean - base.al_mean;
    
        // Trend direction
        let trend: "improving" | "stable" | "degrading";
        if (ciDelta < -0.03) trend = "improving";
        else if (ciDelta > 0.03) trend = "degrading";
        else trend = "stable";
    
        // Severity assessment
        const severityFactors: string[] = [];
        if (ciDelta > 0.15) severityFactors.push(`CI jumped significantly (+${(ciDelta * 100).toFixed(1)}%)`);
        if (curr.ghosts > base.ghosts) severityFactors.push(`Ghost count increased (${base.ghosts} → ${curr.ghosts})`);
        if (curr.faults > base.faults) severityFactors.push(`Fault count increased (${base.faults} → ${curr.faults})`);
        if (curr.al_max > base.al_max) severityFactors.push(`Max authority level rose (AL${base.al_max} → AL${curr.al_max})`);
        if (classify(curr.ci_mean) !== classify(base.ci_mean)) {
          severityFactors.push(`Classification changed: ${classify(base.ci_mean)} → ${classify(curr.ci_mean)}`);
        }
    
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify(
                {
                  comparison: {
                    baseline: { ...base, ci_mean_pct: +(base.ci_mean * 100).toFixed(2), classification: classify(base.ci_mean) },
                    recent: { ...curr, ci_mean_pct: +(curr.ci_mean * 100).toFixed(2), classification: classify(curr.ci_mean) },
                  },
                  delta: {
                    ci_mean: +(ciDelta * 100).toFixed(2),
                    ema_mean: +(emaDelta * 100).toFixed(2),
                    al_mean: +alDelta.toFixed(2),
                    ghost_delta: curr.ghosts - base.ghosts,
                    warn_delta: curr.warns - base.warns,
                    fault_delta: curr.faults - base.faults,
                  },
                  trend,
                  degraded: trend === "degrading",
                  severity_factors: severityFactors.length ? severityFactors : ["No significant changes detected"],
                },
                null,
                2
              ),
            },
          ],
        };
      }
    );
  • Input schema for compare_windows: baseline (array of episode objects) and recent (array of episode objects), both required with min 1 item.
    {
      baseline: z.array(z.record(z.string(), z.unknown())).min(1).describe("Baseline episode array (e.g. last hour, known-good run)"),
      recent: z.array(z.record(z.string(), z.unknown())).min(1).describe("Recent episode array to compare against baseline"),
    },
Behavior4/5

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

With no annotations provided, the description carries full burden. It discloses that no API call, auth, or credits are required—key behavioral traits. It also details the response format. However, it omits potential constraints like data size limits or performance characteristics.

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 concise with no wasted words. It front-loads the core purpose, then provides key restrictions, data source, and a structured response example. Every sentence serves a clear function.

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

Completeness5/5

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

Given the absence of an output schema, the description compensates with a detailed response structure. It explains when to use the tool, what inputs are expected, and what outputs to anticipate. For a comparison tool, this is thorough and sufficient.

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 coverage is 100%, so the parameter descriptions add some context (e.g., baseline episodes from a known-good run, recent episode array). The broader description clarifies that these arrays come from evaluate responses. This adds marginal value beyond the schema but does not provide detailed formatting or constraints.

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

Purpose5/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: comparing two windows of episodes to detect drift or degradation. It uses a specific verb ('Compare'), specifies the resource ('windows of episodes'), and highlights that it requires no API call, no auth, no credits. This distinguishes it from sibling tools like 'evaluate' or 'fleet_evaluate'.

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

Usage Guidelines4/5

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

The description explicitly recommends using this tool after multiple evaluate calls to track model health over time, and notes that inputs come from evaluate or fleet_session_round responses. While it provides clear context for use, it does not explicitly state when not to use it or mention alternatives.

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/collapseindex/ci-1t-mcp'

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