DomainToolTracker

class DomainToolTracker(sources: List<DomainToolSource<*>> = emptyList(), autoDiscovery: Boolean = false, agentProcess: AgentProcess? = null)

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.

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

Constructors

Link copied to clipboard
constructor(sources: List<DomainToolSource<*>> = emptyList(), autoDiscovery: Boolean = false, agentProcess: AgentProcess? = null)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard

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.

Link copied to clipboard
fun <T : Any> getBoundInstance(type: Class<T>): T?

Get the currently bound instance for a domain class, if any.

Link copied to clipboard

Check if an instance is bound for the given type.

Link copied to clipboard
fun tryBindArtifact(artifact: Any): List<Tool>

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.