# Function identifySessionsToRemove

- identifySessionsToRemove(
  sessions: [string, ObserverSessionMetrics][],
  maxSessions: number,
  ): string[]

  Identifies session IDs to remove based on max history limit. Returns oldest sessions first.

  #### Parameters

  - sessions: [string, ObserverSessionMetrics][]

    Array of [sessionId, metrics] entries

  - maxSessions: number

    Maximum sessions to keep

  #### Returns string[]

  Array of session IDs to remove

  - Defined in packages/nexus-agents/src/agents/observability/orchestration-observer-helpers.ts:253