Class PersistedDecisionAnswers
java.lang.Object
dev.langchain4j.agentic.scope.PersistedDecisionAnswers
The persistable form of the answers that decision agents write to the
AgenticScope: Choice and
Scale are generic in their enum type, which the JSON serialization of the scope would lose, and none of
the three types has a constructor a JSON library can call. The AgenticScopeJsonCodec converts them to
these records before writing the scope and back after reading it.
The records keep one constant of the enum in a field declared as Enum, so that the codec writes its type
next to it and resolves that type when reading, with its own class loader and allowlist, which always admits
enums. The probabilities are kept by constant name.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordstatic final recordstatic final record -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectfromPersisted(Object value) The answer restored from its persistable form, or the value itself when it is not one.static booleanisCompositeAnswer(Object value) Whether the given value is an object with fields of the answer types, inherited ones included, like the record a decision agent returns to answer several questions in one call.static ObjecttoPersisted(Object value) The persistable form of the given value, or the value itself when it is not an answer of a decision agent.
-
Method Details
-
isCompositeAnswer
Whether the given value is an object with fields of the answer types, inherited ones included, like the record a decision agent returns to answer several questions in one call. Its fields cannot be converted in place, so such a value is not persisted, like aDecisionResult: the records of a recoverable system should havebooleanand enum fields instead. The check runs on every agent output and on every state entry read by an untyped agent or persisted, so its result is computed once per class. -
toPersisted
-
fromPersisted
-