llm-retry-event.ts 847 B

123456789101112131415161718192021222324252627
  1. import type { LLMMetricErrorKind } from './llm-error-classifier.js';
  2. export const SESSION_LLM_RETRY_EVENT_TYPE = 'session.llm_retry' as const;
  3. export type SessionLLMRetryScope = 'agent' | 'compaction' | 'title';
  4. export type SessionLLMRetryStatus = 'waiting' | 'recovered' | 'exhausted' | 'cancelled';
  5. /** Retry trigger reasons plus the bounded final-attempt reason on terminal events. */
  6. export type SessionLLMRetryReason = LLMMetricErrorKind;
  7. export interface SessionLLMRetryEventPayload {
  8. schemaVersion: 1;
  9. sessionId: string;
  10. turnId: string;
  11. callId: string;
  12. scope: SessionLLMRetryScope;
  13. status: SessionLLMRetryStatus;
  14. retryAttempt: number;
  15. maxRetries: number;
  16. requestAttempt: number;
  17. delayMs?: number;
  18. nextRetryAtMs?: number;
  19. error?: {
  20. reason: SessionLLMRetryReason;
  21. code?: number;
  22. message: string;
  23. };
  24. }