interface ContextModule {
    beforeBuild?: (() => void);
    functions?: common.apis.cortex.Function[];
    id: string;
    name: string;
    output_instructions?: string;
    output_structure?: any;
    position: number;
    state?: string;
    system_msg?: string;
}

Properties

beforeBuild?: (() => void)

Optional hook called by build_messages() before collecting state. The module can mutate itself (update state, system_msg, functions, etc.).

Current uses:

  • Timing module: refreshes timestamps, session duration, turn count

Future use cases:

  • Context pruning: trim system_msg or drop functions based on token budget
  • Dynamic function registry: reload/sync function list from DB or cache
  • Auth refresh: check token validity and update auth status in system_msg
  • Workspace summary: scan workspace and build compact state summary
  • Conversation summarization: compress long conversations into state
functions?: common.apis.cortex.Function[]
id: string
name: string
output_instructions?: string
output_structure?: any
position: number
state?: string
system_msg?: string