Class AgenticScopeSerializer
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidallowDeserializationPackagePrefix(String packagePrefix) Registers an additional type prefix (typically a package name) to be allowed during deserialization ofAgenticScopestate.static voidallowDeserializationType(Class<?> type) Registers a single class to be allowed during deserialization ofAgenticScopestate.static DefaultAgenticScopeDeserializes a JSON string into a AgenticScope object.static StringtoJson(DefaultAgenticScope agenticScope) Serializes a AgenticScope into a JSON string.
-
Method Details
-
toJson
Serializes a AgenticScope into a JSON string.- Parameters:
agenticScope- AgenticScope to be serialized.- Returns:
- A JSON string with the contents of the AgenticScope.
- See Also:
-
fromJson
Deserializes a JSON string into a AgenticScope object.- Parameters:
json- JSON string to be deserialized.- Returns:
- A AgenticScope object constructed from the JSON.
- See Also:
-
allowDeserializationPackagePrefix
Registers an additional type prefix (typically a package name) to be allowed during deserialization ofAgenticScopestate.By default, the deserializer allows standard JDK types (
java.util.*,java.math.*, primitive wrappers). If your agents store domain objects in the agentic scope state, you must register their package prefix before deserialization occurs:AgenticScopeSerializer.allowDeserializationPackagePrefix("com.acme.");Registrations are process-wide and permanent: they apply to every subsequent deserialization in the JVM and cannot be removed. In tests this means a prefix registered by one test stays allowed for all later tests.
Registration is not retroactive: a type must be registered before the
fromJson(String)call that encounters it, otherwise that call fails withUnserializableAgenticScopeException. It takes effect immediately for all subsequent deserializations.- Parameters:
packagePrefix- the package prefix to allow (e.g."com.acme.")- Throws:
IllegalArgumentException- if the prefix is null or empty- See Also:
-
allowDeserializationType
Registers a single class to be allowed during deserialization ofAgenticScopestate.AgenticScopeSerializer.allowDeserializationType(Order.class);Registrations are process-wide and permanent: they apply to every subsequent deserialization in the JVM and cannot be removed. Register the type before the
fromJson(String)call that encounters it, otherwise that call fails withUnserializableAgenticScopeException.- Parameters:
type- the class to allow- See Also:
-