agentSdkLooksLikeResumeError function

bool agentSdkLooksLikeResumeError(
  1. String message
)

True when message looks like a Claude-Code rejection of a stale / unknown session id, so the provider evicts the stored id and retries once with a fresh session.

Deliberately conservative: it requires the word session and a failure cue, so a generic error that merely mentions sessions does not trigger a (wasteful) fresh retry.

Implementation

bool agentSdkLooksLikeResumeError(String message) {
  final lower = message.toLowerCase();
  if (!lower.contains('session')) return false;
  const cues = <String>[
    'not found',
    // Claude Code: "No conversation found with session ID: <id>".
    'no conversation found',
    'invalid',
    'no such',
    'unknown',
    'expired',
    'does not exist',
  ];
  for (final cue in cues) {
    if (lower.contains(cue)) return true;
  }
  return false;
}