Skip to main content
Glama
collapseindex

CI-1T Prediction Stability Engine

alert_check

Check prediction episodes against configurable thresholds to detect stability issues, ghost detections, or faults. Get triggered alerts with severity levels for immediate action.

Instructions

Check episodes against configurable thresholds and return triggered alerts — no API call, no auth, no credits. Takes an episode array from evaluate or fleet responses. Response: { status: 'ok'|'warn'|'critical', total_alerts, critical, warnings, episodes_checked, thresholds, alerts: [{ episode, type, value, threshold, severity }] }. Alert types: ci_exceeded, ema_exceeded, authority_elevated, ghost_detected, fault.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
episodesYesEpisode array from an evaluate or fleet response
ci_thresholdNoAlert if any episode CI exceeds this (default: 0.45 = Drift boundary)
ema_thresholdNoAlert if any episode EMA exceeds this (default: 0.45)
al_thresholdNoAlert if any episode authority level >= this (default: 3 = Minimal)
ghost_alertNoAlert on ghost detections (default: true)
fault_alertNoAlert on faults (default: true)

Implementation Reference

  • The alert_check tool handler function. Takes episodes and thresholds, checks each episode against configured thresholds (ci_threshold, ema_threshold, al_threshold, ghost_alert, fault_alert), and returns triggered alerts with severity levels (ok/warn/critical).
      async ({ episodes, ci_threshold, ema_threshold, al_threshold, ghost_alert, fault_alert }) => {
        const Q = 65535;
        const ciThresh = ci_threshold ?? 0.45;
        const emaThresh = ema_threshold ?? 0.45;
        const alThresh = al_threshold ?? 3;
        const ghostOn = ghost_alert ?? true;
        const faultOn = fault_alert ?? true;
    
        interface Alert {
          episode: number;
          type: string;
          value: string;
          threshold: string;
          severity: "warn" | "critical";
        }
    
        const alerts: Alert[] = [];
    
        (episodes as Array<Record<string, unknown>>).forEach((ep, i) => {
          const ci = ((ep.ci_out as number) || 0) / Q;
          const ema = ((ep.ci_ema_out as number) || 0) / Q;
          const al = (ep.al_out as number) || 0;
    
          if (ci > ciThresh) {
            alerts.push({
              episode: i + 1,
              type: "ci_exceeded",
              value: `${(ci * 100).toFixed(1)}%`,
              threshold: `${(ciThresh * 100).toFixed(1)}%`,
              severity: ci > 0.70 ? "critical" : "warn",
            });
          }
    
          if (ema > emaThresh) {
            alerts.push({
              episode: i + 1,
              type: "ema_exceeded",
              value: `${(ema * 100).toFixed(1)}%`,
              threshold: `${(emaThresh * 100).toFixed(1)}%`,
              severity: ema > 0.70 ? "critical" : "warn",
            });
          }
    
          if (al >= alThresh) {
            alerts.push({
              episode: i + 1,
              type: "authority_elevated",
              value: `AL${al}`,
              threshold: `AL${alThresh}`,
              severity: al >= 4 ? "critical" : "warn",
            });
          }
    
          if (ghostOn && ep.ghost_confirmed) {
            alerts.push({
              episode: i + 1,
              type: "ghost_detected",
              value: `streak ${ep.ghost_suspect_streak || 0}`,
              threshold: "any",
              severity: "critical",
            });
          }
    
          if (faultOn && ep.fault) {
            alerts.push({
              episode: i + 1,
              type: "fault",
              value: `code ${ep.fault_code || 0}`,
              threshold: "any",
              severity: "critical",
            });
          }
        });
    
        const critCount = alerts.filter(a => a.severity === "critical").length;
        const warnCount = alerts.filter(a => a.severity === "warn").length;
    
        let status: "ok" | "warn" | "critical";
        if (critCount > 0) status = "critical";
        else if (warnCount > 0) status = "warn";
        else status = "ok";
    
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify(
                {
                  status,
                  total_alerts: alerts.length,
                  critical: critCount,
                  warnings: warnCount,
                  episodes_checked: episodes.length,
                  thresholds: {
                    ci: `${(ciThresh * 100).toFixed(0)}%`,
                    ema: `${(emaThresh * 100).toFixed(0)}%`,
                    al: `AL${alThresh}`,
                    ghost: ghostOn,
                    fault: faultOn,
                  },
                  alerts,
                },
                null,
                2
              ),
            },
          ],
        };
      }
    );
  • Zod input schema for alert_check: episodes array, optional ci_threshold (default 0.45), ema_threshold (default 0.45), al_threshold (default 3), ghost_alert (default true), fault_alert (default true).
    {
      episodes: z.array(z.record(z.string(), z.unknown())).min(1).describe("Episode array from an evaluate or fleet response"),
      ci_threshold: z.number().min(0).max(1).optional().describe("Alert if any episode CI exceeds this (default: 0.45 = Drift boundary)"),
      ema_threshold: z.number().min(0).max(1).optional().describe("Alert if any episode EMA exceeds this (default: 0.45)"),
      al_threshold: z.number().int().min(0).max(4).optional().describe("Alert if any episode authority level >= this (default: 3 = Minimal)"),
      ghost_alert: z.boolean().optional().describe("Alert on ghost detections (default: true)"),
      fault_alert: z.boolean().optional().describe("Alert on faults (default: true)"),
    },
  • src/index.ts:1044-1164 (registration)
    Registration of the alert_check tool via server.tool() with its description, input schema, and handler function.
    server.tool(
      "alert_check",
      "Check episodes against configurable thresholds and return triggered alerts — no API call, no auth, no credits. Takes an episode array from evaluate or fleet responses. Response: { status: 'ok'|'warn'|'critical', total_alerts, critical, warnings, episodes_checked, thresholds, alerts: [{ episode, type, value, threshold, severity }] }. Alert types: ci_exceeded, ema_exceeded, authority_elevated, ghost_detected, fault.",
      {
        episodes: z.array(z.record(z.string(), z.unknown())).min(1).describe("Episode array from an evaluate or fleet response"),
        ci_threshold: z.number().min(0).max(1).optional().describe("Alert if any episode CI exceeds this (default: 0.45 = Drift boundary)"),
        ema_threshold: z.number().min(0).max(1).optional().describe("Alert if any episode EMA exceeds this (default: 0.45)"),
        al_threshold: z.number().int().min(0).max(4).optional().describe("Alert if any episode authority level >= this (default: 3 = Minimal)"),
        ghost_alert: z.boolean().optional().describe("Alert on ghost detections (default: true)"),
        fault_alert: z.boolean().optional().describe("Alert on faults (default: true)"),
      },
      async ({ episodes, ci_threshold, ema_threshold, al_threshold, ghost_alert, fault_alert }) => {
        const Q = 65535;
        const ciThresh = ci_threshold ?? 0.45;
        const emaThresh = ema_threshold ?? 0.45;
        const alThresh = al_threshold ?? 3;
        const ghostOn = ghost_alert ?? true;
        const faultOn = fault_alert ?? true;
    
        interface Alert {
          episode: number;
          type: string;
          value: string;
          threshold: string;
          severity: "warn" | "critical";
        }
    
        const alerts: Alert[] = [];
    
        (episodes as Array<Record<string, unknown>>).forEach((ep, i) => {
          const ci = ((ep.ci_out as number) || 0) / Q;
          const ema = ((ep.ci_ema_out as number) || 0) / Q;
          const al = (ep.al_out as number) || 0;
    
          if (ci > ciThresh) {
            alerts.push({
              episode: i + 1,
              type: "ci_exceeded",
              value: `${(ci * 100).toFixed(1)}%`,
              threshold: `${(ciThresh * 100).toFixed(1)}%`,
              severity: ci > 0.70 ? "critical" : "warn",
            });
          }
    
          if (ema > emaThresh) {
            alerts.push({
              episode: i + 1,
              type: "ema_exceeded",
              value: `${(ema * 100).toFixed(1)}%`,
              threshold: `${(emaThresh * 100).toFixed(1)}%`,
              severity: ema > 0.70 ? "critical" : "warn",
            });
          }
    
          if (al >= alThresh) {
            alerts.push({
              episode: i + 1,
              type: "authority_elevated",
              value: `AL${al}`,
              threshold: `AL${alThresh}`,
              severity: al >= 4 ? "critical" : "warn",
            });
          }
    
          if (ghostOn && ep.ghost_confirmed) {
            alerts.push({
              episode: i + 1,
              type: "ghost_detected",
              value: `streak ${ep.ghost_suspect_streak || 0}`,
              threshold: "any",
              severity: "critical",
            });
          }
    
          if (faultOn && ep.fault) {
            alerts.push({
              episode: i + 1,
              type: "fault",
              value: `code ${ep.fault_code || 0}`,
              threshold: "any",
              severity: "critical",
            });
          }
        });
    
        const critCount = alerts.filter(a => a.severity === "critical").length;
        const warnCount = alerts.filter(a => a.severity === "warn").length;
    
        let status: "ok" | "warn" | "critical";
        if (critCount > 0) status = "critical";
        else if (warnCount > 0) status = "warn";
        else status = "ok";
    
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify(
                {
                  status,
                  total_alerts: alerts.length,
                  critical: critCount,
                  warnings: warnCount,
                  episodes_checked: episodes.length,
                  thresholds: {
                    ci: `${(ciThresh * 100).toFixed(0)}%`,
                    ema: `${(emaThresh * 100).toFixed(0)}%`,
                    al: `AL${alThresh}`,
                    ghost: ghostOn,
                    fault: faultOn,
                  },
                  alerts,
                },
                null,
                2
              ),
            },
          ],
        };
      }
    );
Behavior5/5

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

No annotations, but description fully covers behavior: no external calls, details response shape (status, alerts list, thresholds), lists alert types. Very transparent.

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?

Concise yet packed with useful info: purpose, input source, response structure, alert types. No fluff, well-structured.

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?

For a non-API-checking tool with 6 params and no output schema, description covers inputs, outputs, alert types, thresholds, and constraints. Fully complete.

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

Parameters4/5

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

100% schema coverage so baseline 3. Description adds default thresholds and context (e.g., '0.45 = Drift boundary') beyond property descriptions, and explains overall purpose that ties parameters to alert types.

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?

Description clearly states 'Check episodes against configurable thresholds and return triggered alerts' – specific verb and resource. It also distinguishes from siblings like evaluate/fleet by stating input source.

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?

Explicitly notes no API call/auth/credits, and input from evaluate or fleet. Suggests lightweight analysis, but no explicit when-not.

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