export interface FailedMessageLike { id?: string; messageId?: string; timestamp?: number; provider?: string; model?: string; } export const failedMessageKey = (message: FailedMessageLike): string => { const identity = message.id ?? message.messageId ?? String(message.timestamp ?? "unknown"); return `${identity}:${message.provider ?? ""}/${message.model ?? ""}`; }; export const STEERING = (primary: string, fallback: string): string => `[fallback] Model was switched from ${primary} to ${fallback} after exhaustion of the subscription quota. Continue the interrupted task from the current state. Tool actions already completed above are done — do not repeat them.`; /** R5, steering half. A tier-2 entry means every tier-1 substitute is gone, so the model now holding the * conversation is an assistant with a narrower mandate, not a peer replacement. Reusing `STEERING` here * would tell it to "continue the interrupted task" exactly as a substitute is told to — the one thing * R5 forbids — so this text names the role and bounds the work: finish what is in flight, leave the * workspace consistent for a substitute that comes back, and start nothing new. Deliberately not * string-equal to `STEERING(primary, assistant)` for the same pair. */ export const TIER2_STEERING = (primary: string, assistant: string): string => `[fallback] Every substitute for ${primary} is exhausted, so ${assistant} is now active as the tier-2 assistant. Its mandate is narrower than the model it replaced: drive the in-flight mechanical task to completion and leave the workspace consistent for a returning substitute. Do not start new work, and do not repeat tool actions already completed above.`;