Package com.tnsai.context
Interface ContextManagerHandle
public interface ContextManagerHandle
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceFactory for creating ContextManagerHandle instances. -
Method Summary
Modifier and TypeMethodDescriptionintcleanupOldSnapshots(Instant olderThan) intcleanupOldTraces(Instant olderThan) voidvoidcreateSnapshot(SnapshotTrigger trigger) Creates a snapshot with just the trigger (for minimal snapshots).createSnapshot(SnapshotTrigger trigger, List<Belief> beliefs, List<Desire> desires, List<Intention> intentions) Creates a context snapshot capturing the current agent state.createTrace(DecisionTrace.Builder builder) Creates a decision trace manually.voiddefault StringStarts a conversation if none is active and returns the current ID.<T> TexecuteWithTrace(String description, Supplier<T> operation) Simplified traced execution without BDI suppliers.<T> TexecuteWithTrace(String description, Supplier<T> operation, Supplier<List<Belief>> beliefs, Supplier<List<Desire>> desires, Supplier<List<Intention>> intentions) Executes an operation with full decision tracing.explainDecision(String traceId) findDecisionsByAction(String action) findPrecedents(DecisionTrace referenceTrace, double threshold) findSnapshot(String snapshotId) intgetRecentDecisions(int limit) getRecentSnapshots(int limit) intgetVariable(String key) <T> Optional<T> getVariable(String key, Class<T> type) static ContextManagerHandlenoOp()Returns a no-op implementation that silently ignores all operations.voidremoveVariable(String key) voidsetVariable(String key, Object value) voidstartConversation(String conversationId) summarizeRecentDecisions(int limit) voidtrackEntity(Entity entity) voiduntrackEntity(String entityId)
-
Method Details
-
noOp
Returns a no-op implementation that silently ignores all operations. Used as a null-object when context graph is not enabled.- Returns:
- a no-op ContextManagerHandle (singleton)
-
createSnapshot
ContextSnapshot createSnapshot(SnapshotTrigger trigger, List<Belief> beliefs, List<Desire> desires, List<Intention> intentions) Creates a context snapshot capturing the current agent state.- Parameters:
trigger- the reason for the snapshotbeliefs- current beliefsdesires- current desiresintentions- current intentions- Returns:
- the created snapshot
-
createSnapshot
Creates a snapshot with just the trigger (for minimal snapshots).- Parameters:
trigger- the reason for the snapshot- Returns:
- the created snapshot
-
executeWithTrace
<T> T executeWithTrace(String description, Supplier<T> operation, Supplier<List<Belief>> beliefs, Supplier<List<Desire>> desires, Supplier<List<Intention>> intentions) Executes an operation with full decision tracing.- Type Parameters:
T- return type- Parameters:
description- operation descriptionoperation- the operation to executebeliefs- supplier for current beliefsdesires- supplier for current desiresintentions- supplier for current intentions- Returns:
- the operation result
-
executeWithTrace
Simplified traced execution without BDI suppliers.- Type Parameters:
T- return type- Parameters:
description- operation descriptionoperation- the operation to execute- Returns:
- the operation result
-
createTrace
Creates a decision trace manually.- Parameters:
builder- preconfigured trace builder- Returns:
- saved decision trace
-
findTrace
-
getRecentDecisions
-
getAllDecisions
List<DecisionTrace> getAllDecisions() -
findDecisionsByAction
-
findSuccessfulDecisions
List<DecisionTrace> findSuccessfulDecisions() -
findFailedDecisions
List<DecisionTrace> findFailedDecisions() -
findDecisionsInCurrentConversation
List<DecisionTrace> findDecisionsInCurrentConversation() -
findPrecedents
-
explainDecision
-
summarizeRecentDecisions
-
findSnapshot
-
getRecentSnapshots
-
trackEntity
-
untrackEntity
-
getTrackedEntities
Collection<Entity> getTrackedEntities() -
clearTrackedEntities
void clearTrackedEntities() -
setVariable
-
getVariable
-
getVariable
-
removeVariable
-
clearVariables
void clearVariables() -
startConversation
String startConversation() -
startConversation
-
endConversation
void endConversation() -
getCurrentConversationId
-
ensureConversation
Starts a conversation if none is active and returns the current ID.The default is check-then-act. Implementations that own a lifecycle lock must override this so concurrent callers share one conversation (TAN-3955).
-
getTraceStatistics
DecisionTraceStore.DecisionTraceStatistics getTraceStatistics() -
getSnapshotStatistics
SnapshotStore.SnapshotStoreStatistics getSnapshotStatistics() -
getDecisionCount
int getDecisionCount() -
getSnapshotCount
int getSnapshotCount() -
cleanupOldTraces
-
cleanupOldSnapshots
-
getAgentId
String getAgentId()
-