Interface LlmStreamCallback

All Known Implementing Classes:
PhaseAwareStreamCallback
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface LlmStreamCallback
Callback interface for receiving streaming chat responses from LLM.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    onChunk(String chunk, boolean done)
    Called for each chunk of the streaming response.
    default void
    Called when an error occurs during streaming.
    default void
    onRetry(String operation, int attempt, int maxAttempts, long sleepMs, Throwable cause)
    Called when the LLM HTTP call is being retried.
    default void
    onWaiting(String reason, long elapsedMs, long timeoutMs)
    Called when the request is waiting for a concurrency permit.
    default void
    onWarning(String code, String detail)
    Called when an internal silent fallback occurs (e.g., reasoning model token exhaustion).
  • Method Details

    • onChunk

      void onChunk(String chunk, boolean done)
      Called for each chunk of the streaming response.
      Parameters:
      chunk - the text chunk from the LLM response
      done - true if this is the final chunk
    • onError

      default void onError(Throwable error)
      Called when an error occurs during streaming.
      Parameters:
      error - the error that occurred
    • onRetry

      default void onRetry(String operation, int attempt, int maxAttempts, long sleepMs, Throwable cause)
      Called when the LLM HTTP call is being retried.
      Parameters:
      operation - log label for the operation (e.g., "chat", "streamChat")
      attempt - 1-based current attempt index that just failed
      maxAttempts - total attempts including the first
      sleepMs - milliseconds the client will sleep before the next attempt
      cause - the cause of the retry (RetryableHttpException or IOException)
    • onWaiting

      default void onWaiting(String reason, long elapsedMs, long timeoutMs)
      Called when the request is waiting for a concurrency permit.
      Parameters:
      reason - short reason code, currently always "concurrency_limit"
      elapsedMs - milliseconds already spent waiting (0 on the first call)
      timeoutMs - maximum milliseconds the client will wait before giving up
    • onWarning

      default void onWarning(String code, String detail)
      Called when an internal silent fallback occurs (e.g., reasoning model token exhaustion).
      Parameters:
      code - short machine-readable warning code (e.g., "reasoning_token_exhausted")
      detail - human-readable detail (free-form)