Member Junction
    Preparing search index...

    Interface MJUserRoutineEntity_IRoutineWakeConfiguration

    Configuration for autonomous wake conditions and durable entity change watching on MJ: User Routines (UserRoutine.WakeConfiguration).

    Evaluated by WakeGateEvaluator inside UserRoutineDispatcherDriver before invoking the routine's target (Agent, Action, or Prompt) so routines only spend LLM tokens when meaningful state changes or scheduled wake deadlines occur.

    interface MJUserRoutineEntity_IRoutineWakeConfiguration {
        resumeState?: Record<string, unknown>;
        wakeGate?: {
            forceWakeAfterMinutes?: number;
            skipIfUnchanged?: boolean;
            tier1Expression?: string;
            tier2Decision?: {
                additionalInstructions?: string;
                options?: { description: string; key: string }[];
                question: string;
                type?: "Likelihood" | "Choice";
                wakeIfAtLeast?: number;
                wakeOnChoices?: string[];
            };
            tier3WakePromptId?: string;
        };
        wakeReason?: string;
        watchedEntities?: {
            alias?: string;
            entityName: string;
            extraFilter?: string;
            includeRecordChanges?: boolean;
        }[];
        workstreamKey?: string;
    }
    Index

    Properties

    resumeState?: Record<string, unknown>

    Arbitrary JSON state saved by the agent when going to sleep and restored into the conversation/payload when the routine wakes.

    wakeGate?: {
        forceWakeAfterMinutes?: number;
        skipIfUnchanged?: boolean;
        tier1Expression?: string;
        tier2Decision?: {
            additionalInstructions?: string;
            options?: { description: string; key: string }[];
            question: string;
            type?: "Likelihood" | "Choice";
            wakeIfAtLeast?: number;
            wakeOnChoices?: string[];
        };
        tier3WakePromptId?: string;
    }

    3-Tier Wake Condition Gate evaluated in order of increasing cost:

    • Tier 0: Durable watermark / hash comparison (0 tokens)
    • Tier 1: Deterministic SafeExpressionEvaluator boolean expression (0 tokens)
    • Tier 2: Fast classifier / decision model via AIDecisionRunner (~100 tokens)
    • Tier 3: Full metadata MJ: AI Prompts evaluation via AIPromptRunner

    Type Declaration

    • OptionalforceWakeAfterMinutes?: number

      Optional maximum minutes of silence before forcing a wake even if watched entities are unchanged (e.g. 480 for an 8-hour heartbeat).

    • OptionalskipIfUnchanged?: boolean

      When true, skips target execution if watched entities and signals have not changed since LastCheckedAt AND any forceWakeAfterMinutes deadline has not elapsed.

    • Optionaltier1Expression?: string

      Tier 1: Deterministic boolean expression evaluated by SafeExpressionEvaluator against { deltas, totalChangedCount, elapsedMinutes, isScheduledWakeTimeReached, payload }. When it evaluates to false, the wake is skipped with zero LLM cost.

    • Optionaltier2Decision?: {
          additionalInstructions?: string;
          options?: { description: string; key: string }[];
          question: string;
          type?: "Likelihood" | "Choice";
          wakeIfAtLeast?: number;
          wakeOnChoices?: string[];
      }

      Tier 2: Fast Decision Model question evaluated via AIDecisionRunner (Default Decision / Jev / Kev) when Tier 1 passes (or when Tier 1 is omitted).

      • OptionaladditionalInstructions?: string

        Optional extra context instructions for the decision classifier.

      • Optionaloptions?: { description: string; key: string }[]

        Choice options when type === 'Choice'.

      • question: string

        Question posed to the decision model along with the delta summary.

      • Optionaltype?: "Likelihood" | "Choice"

        Decision type ('Likelihood' 0-100 or 'Choice'). Defaults to 'Likelihood'.

      • OptionalwakeIfAtLeast?: number

        Minimum likelihood score (0-100) required to wake the agent when type === 'Likelihood'.

      • OptionalwakeOnChoices?: string[]

        Option keys that trigger a wake when type === 'Choice'.

    • Optionaltier3WakePromptId?: string

      Tier 3: Optional MJ: AI Prompts ID executed via AIPromptRunner as the final gate when deeper synthesis is required before waking the full agent.

    wakeReason?: string

    Human-readable reason the agent scheduled this wake (injected into the wake prompt).

    watchedEntities?: {
        alias?: string;
        entityName: string;
        extraFilter?: string;
        includeRecordChanges?: boolean;
    }[]

    Entities watched for durable change detection since UserRoutine.LastCheckedAt. Checked via GetRunViewsDatabaseStatus (COUNT(*) + MAX(__mj_UpdatedAt)) and/or MJ: Record Changes under the routine owner's contextUser security scope.

    Type Declaration

    • Optionalalias?: string

      Optional alias used as the key inside deltas.<alias> for Tier 1 expressions.

    • entityName: string

      Exact MJ Entity Name (e.g. "MJ_BizApps_Tasks: Tasks", "MJ_BizApps_Issues: Issues").

    • OptionalextraFilter?: string

      Optional SQL ExtraFilter (validated via SQLExpressionValidator) scoping watched rows.

    • OptionalincludeRecordChanges?: boolean

      When true, also inspects MJ: Record Changes for field-level diffs since LastCheckedAt.

    workstreamKey?: string

    Logical workstream or monitor key used by self-scheduling agents (e.g. "q4-okr-rollup", "chief-of-staff-main") to upsert a specific AgentWake routine row per workstream.