Class AnthropicCacheDiagnostics

java.lang.Object
dev.langchain4j.model.anthropic.AnthropicCacheDiagnostics

@Experimental public class AnthropicCacheDiagnostics extends Object
Result of Anthropic's (beta) cache diagnostics comparison for a single request, surfaced via AnthropicChatResponseMetadata.cacheDiagnostics().

Cache diagnostics compares the current request against the one identified by previousMessageId (set via AnthropicChatRequestParameters.Builder.previousMessageId(String)) and reports the first point where the two diverged, so that an unexpected prompt-cache miss (e.g. usage.cacheReadInputTokens dropping to zero) can be diagnosed instead of guessed at. Requires AnthropicChatRequestParameters.Builder.returnCacheDiagnostics(Boolean) to be enabled.

AnthropicChatResponseMetadata.cacheDiagnostics() itself is null when diagnostics were not requested, or when a comparison ran and found no divergence. When this object is present, cacheMissReasonType() is null while the comparison is still running (treat this as inconclusive and check the next turn), otherwise it is one of: "model_changed", "system_changed", "tools_changed", "messages_changed", "previous_message_not_found", or "unavailable".

See the cache diagnostics docs.

Since:
1.10.0
  • Method Details

    • cacheMissReasonType

      public String cacheMissReasonType()
      The cache-miss reason discriminator, or null while the comparison is still running.
    • cacheMissedInputTokens

      public Integer cacheMissedInputTokens()
      An estimate of how many input tokens fell after the divergence point. Only populated for the "*_changed" reason types; null otherwise.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • builder

      public static AnthropicCacheDiagnostics.Builder builder()