# Function detectTrend

- detectTrend(
  outcomes: readonly {
  id: string;
  cli: "claude" | "gemini" | "codex" | "opencode";
  category:
  | "planning"
  | "code_generation"
  | "code_review"
  | "research"
  | "architecture"
  | "security_review"
  | "documentation"
  | "testing"
  | "devops"
  | "exploration";
  model: string;
  success: boolean;
  durationMs: number;
  timestamp: string;
  qualitySignals?: string[];
  failureCategory?: | "unknown"
  | "timeout"
  | "parse"
  | "connection"
  | "execution"
  | "rate_limit"
  | "validation"
  | "authentication"
  | "generic"
  | "crash"
  | "adapter_unavailable";
  errorMessage?: string;
  source: "delegate"
  | "consensus"
  | "manual";
  wasRetried?: boolean;
  triageAction?: string;
  routingStage?: string;
  retryCount?: number;
  vendor?: string;
  family?: string;
  voterRole?: string;
  baselineId?: string;
  }[],
  windowSize?: number,
  ): Trend

  Detects performance trend by comparing recent vs historical success rates.

  Splits outcomes into two windows of `windowSize` (default 25). If fewer than 2 * windowSize outcomes, uses half-split.

  #### Parameters

  - outcomes: readonly {
    id: string;
    cli: "claude" | "gemini" | "codex" | "opencode";
    category:
    | "planning"
    | "code_generation"
    | "code_review"
    | "research"
    | "architecture"
    | "security_review"
    | "documentation"
    | "testing"
    | "devops"
    | "exploration";
    model: string;
    success: boolean;
    durationMs: number;
    timestamp: string;
    qualitySignals?: string[];
    failureCategory?: | "unknown"
    | "timeout"
    | "parse"
    | "connection"
    | "execution"
    | "rate_limit"
    | "validation"
    | "authentication"
    | "generic"
    | "crash"
    | "adapter_unavailable";
    errorMessage?: string;
    source: "delegate"
    | "consensus"
    | "manual";
    wasRetried?: boolean;
    triageAction?: string;
    routingStage?: string;
    retryCount?: number;
    vendor?: string;
    family?: string;
    voterRole?: string;
    baselineId?: string;
    }[]
  - windowSize: number = DEFAULT_WINDOW_SIZE

  #### Returns Trend

  - Defined in packages/nexus-agents/src/orchestration/outcomes/adaptive-thresholds.ts:108