Hi again! I have a custom node which writes an llm...
# koog-agentic-framework
c
Hi again! I have a custom node which writes an llmSession and tries to restore some data from a "withPersistence" block. The last part are optional data. This works well during productive. However when using the koog testing framwork I don't want to install the persistence feature because I don't need it. Can I check somehow inside the node if the persistence feature is available?
Error executing node (name: RestoreCreateRequirementsHistoryNode): Feature ai.koog.agents.core.agent.entity.AIAgentStorageKey@1e041cd2(name=agents-features-snapshot) is not found.
java.util.NoSuchElementException: Feature ai.koog.agents.core.agent.entity.AIAgentStorageKey@1e041cd2(name=agents-features-snapshot) is not found.
at ai.koog.agents.snapshot.feature.PersistenceKt.persistence(Persistence.kt:404)
at ai.koog.agents.snapshot.feature.PersistenceKt.withPersistence(Persistence.kt:375)
j
Hey Mark! > Can I check somehow inside the node if the persistence feature is available? Yes 🙂 You can use
feature(someAgentFeature)
function in your node - it returns nullable feature (depending if it was installed or not). In case of
Persistence
it would look like this
Copy code
// in your node
val persistence = feature(Persistence)
if(persistence == null) { 
   // ...
}
Take a look on how `withPersistence` block is implemented - it uses
featureOrThrow(Persistence)
- a throwable cousin of nullable
feature(Persistence)
❤️ 1