Interface AgenticScopeJsonCodec


public interface AgenticScopeJsonCodec
A codec for serializing and deserializing DefaultAgenticScope objects to and from JSON.
  • Method Details

    • fromJson

      DefaultAgenticScope fromJson(String json)
      Deserializes a JSON string to a DefaultAgenticScope object.
      Parameters:
      json - the JSON string.
      Returns:
      the deserialized DefaultAgenticScope object.
    • toJson

      String toJson(DefaultAgenticScope agenticScope)
      Serializes a DefaultAgenticScope object to a JSON string.
      Parameters:
      agenticScope - the DefaultAgenticScope object.
      Returns:
      the serialized JSON string.
    • allowPackagePrefix

      default boolean allowPackagePrefix(String packagePrefix)
      Allows every class under the given package prefix to be deserialized as part of an AgenticScope's state.

      Deserializing arbitrary types by name is how polymorphic deserialization becomes a vulnerability, so a codec that supports it keeps an allowlist. A codec that does not support allowlisting should return false rather than silently accept everything.

      Returns:
      whether this codec applied the registration.
    • allowType

      default boolean allowType(Class<?> type)
      Allows a single class to be deserialized as part of an AgenticScope's state.
      Returns:
      whether this codec applied the registration.
      See Also:
    • withClassLoader

      default boolean withClassLoader(ClassLoader classLoader)
      Sets the ClassLoader used to resolve the types named in a serialized AgenticScope, for applications whose domain types are not visible to the class loader that loaded LangChain4j.
      Returns:
      whether this codec applied the class loader.