Class NeverEvictStrategy
- All Implemented Interfaces:
ToolIndexEvictionStrategy
ToolIndexEvictionStrategy that never evicts sessions automatically.
Tool indexes persist across requests for the lifetime of the
ToolSearchToolCallingAdvisor bean, or until explicitly released via
ToolSearchToolCallingAdvisor#evictSession(String).
Memory warning: this strategy accumulates one index entry per distinct session
ID and never frees them. In a service that handles many short-lived conversations (e.g.
HTTP sessions, anonymous users) the index map will grow without bound, eventually
exhausting heap (Lucene ByteBuffersDirectory instances) or remote vector-store
quota. For production deployments use LruEvictionStrategy to cap the number of
concurrently retained indexes, TtlEvictionStrategy to expire idle sessions, or
a CompositeEvictionStrategy combining both.
This strategy is appropriate only when the set of active sessions is small and stable
(e.g. a single-user tool or a bounded pool of long-running agents), or when the
application manages session lifecycle explicitly via
ToolSearchToolCallingAdvisor#evictSession(String).
- Since:
- 2.0.0
- Author:
- Christian Tzolov
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionCalled each time a session is accessed at the start of request processing.voidCalled after a session's tool index has been cleared — either because this strategy returned it fromToolIndexEvictionStrategy.onAccess(java.lang.String), or because of an explicit eviction request.
-
Field Details
-
INSTANCE
Shared singleton instance.
-
-
Method Details
-
onAccess
Description copied from interface:ToolIndexEvictionStrategyCalled each time a session is accessed at the start of request processing.Implementations should update their internal tracking state for
sessionIdand return the set of session IDs whose tool indexes must now be cleared. The returned set must never include the currently-accessedsessionId.- Specified by:
onAccessin interfaceToolIndexEvictionStrategy- Parameters:
sessionId- the session being accessed- Returns:
- session IDs to evict; never
null, may be empty
-
onRemoved
Description copied from interface:ToolIndexEvictionStrategyCalled after a session's tool index has been cleared — either because this strategy returned it fromToolIndexEvictionStrategy.onAccess(java.lang.String), or because of an explicit eviction request.Implementations should remove any internal tracking state for the evicted session.
- Specified by:
onRemovedin interfaceToolIndexEvictionStrategy- Parameters:
sessionId- the session that was evicted
-