Class AgenticServiceInterceptor

java.lang.Object
io.micronaut.langchain4j.agentic.AgenticServiceInterceptor
All Implemented Interfaces:
io.micronaut.aop.Interceptor<Object,Object>, io.micronaut.aop.MethodInterceptor<Object,Object>, io.micronaut.core.order.Ordered

@InterceptorBean(AgenticService.class) public final class AgenticServiceInterceptor extends Object implements io.micronaut.aop.MethodInterceptor<Object,Object>
Interceptor that builds and caches a LangChain4j declarative agentic service instance from an interface annotated with AgenticService. Agents are created via AgenticServiceFactory.buildAgenticService(BeanContext, AgenticServiceInfo) which delegates to LangChain4j's declarative API (AgenticServices.createAgenticSystem).
  • Field Details

  • Constructor Details

    • AgenticServiceInterceptor

      public AgenticServiceInterceptor(io.micronaut.context.BeanContext beanContext, AgentRegistry agentRegistry, AgenticServiceFactory agenticServiceFactory)
  • Method Details

    • intercept

      @Nullable public @Nullable Object intercept(io.micronaut.aop.MethodInvocationContext<Object,Object> context)
      Specified by:
      intercept in interface io.micronaut.aop.MethodInterceptor<Object,Object>
    • resolveAgentInterface

      public static Class<?> resolveAgentInterface(Class<?> beanType)
      For Micronaut introduction proxies (e.g. GreeterAgent$Intercepted), return the original agent interface annotated with AgenticService, otherwise return the given type.
      Parameters:
      beanType - The bean type that may be an intercepted class
      Returns:
      The agent interface annotated with AgenticService or the provided type if already an interface