Class AlwaysEvictStrategy
- All Implemented Interfaces:
ToolIndexEvictionStrategy
ToolIndexEvictionStrategy that clears a session's tool index before every
request, ensuring tools are always re-indexed on each conversation turn.
Use this strategy when the tool set may change between turns (e.g. dynamically
generated tool descriptions) and you want to guarantee freshness at the cost of
re-indexing on every request. For stable tool sets, NeverEvictStrategy is more
efficient.
Contract note: onAccess(java.lang.String) intentionally returns the currently-accessed
session ID, which diverges from the general recommendation in
ToolIndexEvictionStrategy.onAccess(java.lang.String). This is safe because the advisor's
doEvict + fingerprint-recheck sequence is idempotent: evicting the current
session removes its cached fingerprint, so the subsequent fingerprint comparison always
sees null and triggers a full re-index. When combined with other strategies in
a CompositeEvictionStrategy, the always-evict behaviour is preserved (the more
aggressive strategy wins).
- Since:
- 2.0.0
- Author:
- Christian Tzolov
- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionReturns a set containingsessionId, causing the advisor to clear the session's index and remove its cached fingerprint before the fingerprint-comparison step.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
Returns a set containingsessionId, causing the advisor to clear the session's index and remove its cached fingerprint before the fingerprint-comparison step. The comparison then always sees a missing fingerprint and re-indexes the full tool set.- Specified by:
onAccessin interfaceToolIndexEvictionStrategy- Parameters:
sessionId- the session being accessed- Returns:
- a singleton set containing
sessionId
-
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
-