Class DomainToolTracker

  • All Implemented Interfaces:

    
    public final class DomainToolTracker
    
                        

    Tracks 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.

    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • 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> T getBoundInstance(Class<T> type) Get the currently bound instance for a domain class, if any.
      final Boolean hasBoundInstance(Class<?> type) Check if an instance is bound for the given type.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 methods
        agentProcess - 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.