Class ToolIntrospector

java.lang.Object
dyntabs.ai.assistant.ToolIntrospector

public final class ToolIntrospector extends Object
Uses reflection to discover tool methods on POJOs (and EJB proxies) and build ToolSpecification instances for them.

Exposure policy (since 3.0.0): two entry points with different safety postures.

  • introspect(Object...)opt-in (default, safe): only methods annotated with EasyTool are turned into tools. Unannotated methods stay invisible to the model. This is what withTools(...) uses.
  • introspectAllPublic(Object...)escape hatch (unsafe): every eligible public method becomes a tool, annotated or not. This is what withAllPublicMethodsAsTools(...) uses and should be reserved for prototypes.
  • Method Details

    • introspect

      public static List<ToolMethod> introspect(Object... toolObjects)
      Discovers opt-in tool methods — those annotated with EasyTool — on the given objects and creates a ToolMethod entry for each. Unannotated methods are ignored, so they can never be invoked by the model.

      If the object is a Jakarta EJB proxy (CDI/Weld-injected @Stateless, @Stateful, or @Singleton bean), the methods are read from the actual bean class (the proxy's superclass) while the proxy instance is kept as the invocation target. This ensures method calls still go through the container pipeline (transactions, security, interceptors).

      Parameters:
      toolObjects - the service objects to scan (POJOs or injected EJB proxies)
      Returns:
      one ToolMethod per @EasyTool-annotated method
    • introspectAllPublic

      public static List<ToolMethod> introspectAllPublic(Object... toolObjects)
      Discovers every eligible public method (annotated or not) on the given objects.

      Unsafe by design. This is the escape hatch behind withAllPublicMethodsAsTools(...) and exposes the whole public surface of the beans to the model. Prefer introspect(Object...) plus EasyTool everywhere but throwaway prototypes.

      Parameters:
      toolObjects - the service objects to scan (POJOs or injected EJB proxies)
      Returns:
      one ToolMethod per eligible public method
    • resolveTargetClass

      public static Class<?> resolveTargetClass(Object obj)
      Resolves the actual bean class behind a CDI/EJB proxy.

      CDI containers (Weld, OpenWebBeans, etc.) create proxy subclasses when injecting EJB beans. The proxy class itself has no business methods declared — they live on the superclass (the real bean class). This method detects whether the object is such a proxy by checking if the superclass carries a Jakarta EJB annotation (@Stateless, @Stateful, or @Singleton). If so, the superclass is returned for method discovery; otherwise the object's own class is returned.

      Parameters:
      obj - the tool object (possibly a proxy)
      Returns:
      the class to use for method discovery