Class CorrectableLLMException

All Implemented Interfaces:
LLMReadable, LLMReadableException, Serializable
Direct Known Subclasses:
GuardrailException, InvalidInputException, JsonParseException, ResourceNotFoundException, ResponseValidationException

public abstract non-sealed class CorrectableLLMException extends LLMReadableCheckedException
Base class for exceptions where the LLM's input was wrong and it may fix its parameters and call the same tool again.

The key semantic: the tool works fine - the LLM just sent bad input. Correcting the input and retrying the same tool could succeed. The LLM may also choose to take a different approach if correction seems unlikely to help.

Examples:

  • Parameter out of valid range (e.g., maxResults=1000 when limit is 100)
  • Invalid date format (e.g., "2024-13-01" when "YYYY-MM-DD" required)
  • Missing required parameter
  • Well-formed ID that doesn't exist (LLM can try a different ID)
  • Guardrail violation (e.g., PII detected in input)

Concrete subclasses:

Since:
0.1 (2025-11-21)
Author:
Andrey Santrosyan
See Also:
  • Constructor Details

    • CorrectableLLMException

      protected CorrectableLLMException(String message)
      Constructs a correctable exception with the specified detail message.
      Parameters:
      message - the detail message (for logging and debugging)
    • CorrectableLLMException

      protected CorrectableLLMException(String message, Throwable cause)
      Constructs a correctable exception with the specified detail message and cause.
      Parameters:
      message - the detail message (for logging and debugging)
      cause - the cause (which is saved for later retrieval by Throwable.getCause())
  • Method Details

    • isCorrectable

      public final boolean isCorrectable()
      Description copied from class: LLMReadableCheckedException
      Indicates whether the LLM may retry the same tool with different input.

      true (correctable): The LLM's input was wrong. It may fix its parameters and call the same tool again, or take a different approach if correction seems unlikely to help. Examples: invalid query syntax, missing required field, malformed identifier, ID that doesn't exist.

      false (uncorrectable): The tool itself cannot work right now, regardless of what the LLM sends. No amount of parameter tweaking will help. The LLM should not retry this tool - instead it should try a different tool, take an alternative approach, or explain the limitation to the user. Examples: API down, auth failure, rate limit, system error.

      Specified by:
      isCorrectable in interface LLMReadableException
      Specified by:
      isCorrectable in class LLMReadableCheckedException
      Returns:
      true if the LLM should retry the same tool with corrected input, false if the LLM should abandon this tool and try something else
    • explainToLLM

      public String explainToLLM()
      Description copied from class: LLMReadableCheckedException
      Returns a fully formatted string to add to the LLM conversation context.

      This declaration restates the interface default: just the LLM message. The four branch classes, CorrectableLLMException, UncorrectableLLMException, CorrectableRuntimeLLMException and UncorrectableRuntimeLLMException, override it to append their correctability hint, and no concrete class overrides it again, so every exception tells the model whether to retry in the same words.

      Specified by:
      explainToLLM in interface LLMReadableException
      Overrides:
      explainToLLM in class LLMReadableCheckedException
      Returns:
      formatted string for conversation context