Class DomainToolTracker
-
- All Implemented Interfaces:
public final class DomainToolTrackerTracks domain instances and provides tools from them.
When a single instance of a registered domain class is retrieved, this tracker binds @LlmTool methods from that instance.
Supports two modes:
Registered sources mode: Only binds instances of explicitly registered types
Auto-discovery mode: Binds any object with @LlmTool methods, replacing previous bindings
In both modes, "last wins" - when a new matching artifact arrives, it replaces any previously bound instance.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classDomainToolTracker.Companion
-
Field Summary
Fields Modifier and Type Field Description public final static DomainToolTracker.CompanionCompanion
-
Constructor Summary
Constructors Constructor Description DomainToolTracker(List<DomainToolSource<?>> sources, Boolean autoDiscovery, AgentProcess agentProcess)
-
Method Summary
Modifier and Type Method Description final List<Tool>tryBindArtifact(Object artifact)Check if the given artifact is a single instance of a registered domain class (or any class with @LlmTool methods in auto-discovery mode). final List<Tool>drainPendingTools()Drain and return all pending tools discovered via auto-discovery. final <T extends Any> TgetBoundInstance(Class<T> type)Get the currently bound instance for a domain class, if any. final BooleanhasBoundInstance(Class<?> type)Check if an instance is bound for the given type. -
-
Constructor Detail
-
DomainToolTracker
DomainToolTracker(List<DomainToolSource<?>> sources, Boolean autoDiscovery, AgentProcess agentProcess)
- Parameters:
sources- List of registered domain tool sources (empty for auto-discovery mode)autoDiscovery- When true, discovers tools from any object with @LlmTool methodsagentProcess- Optional agent process for predicate evaluation
-
-
Method Detail
-
tryBindArtifact
final List<Tool> tryBindArtifact(Object artifact)
Check if the given artifact is a single instance of a registered domain class (or any class with @LlmTool methods in auto-discovery mode). If so, bind it and return any tools extracted from it.
In "last wins" semantics: if an instance of this type is already bound, it is replaced with the new artifact.
- Returns:
Tools extracted from the instance, or empty list if not applicable
-
drainPendingTools
final List<Tool> drainPendingTools()
Drain and return all pending tools discovered via auto-discovery. After calling this method, the pending buffer is cleared. Used by com.embabel.agent.spi.loop.ToolChainingInjectionStrategy to inject tools mid-loop.
-
getBoundInstance
final <T extends Any> T getBoundInstance(Class<T> type)
Get the currently bound instance for a domain class, if any.
-
hasBoundInstance
final Boolean hasBoundInstance(Class<?> type)
Check if an instance is bound for the given type.
-
-
-
-