LangChain4J-CDI best practices LangChain4J-CDI enables integration of AI services into enterprise Java applications using CDI. Best practices include avoiding direct CDI scope annotations on AI service interfaces and instead using the scope parameter in stereotype annotations like @RegisterAIService. For MicroProfile Fault Tolerance Retry, developers must disable LangChain4J's internal retry policy to prevent exponential retry complexity. LangChain4J-CDI is the pivotal component that enables developers to integrate their AI services into their enterprise Java applications with ease, thanks to CDI. Whether you're a seasoned developer or getting started with integrating AI in your existing Java application, here are the best practices that will ensure you get building your AI solutions with ease. Whether you're creating an AI Service or an AI agent, you would feel compelled to apply the CDI scopes in this manner: @RegisterAIService @ApplicationScoped //<-- Do not do this. It doesn't work, and there's no side effect. public interface ChatAiService { String chat String message ; }; This won't work as the interface is not CDI managed. For those who want to be too technical, the CD scopes cannot propagate down to its proxy. Instead, each of the LangChain4J-CDI stereotype annotations contains a scope parameter where you can assign your CDI scope. Example: @RegisterAIService scope = ApplicationScoped.class //Better approach, it works. public interface ChatAiService { String chat String message ; }; This applies to all of these annotations: //For AI Service @RegisterAIService, //For AI Agent @RegisterSimpleAgent, @RegisterSequenceAgent, @RegisterLoopAgent, @RegisterParallelAgent, @RegisterParallelMapperAgent, @RegisterConditionalAgent, @RegisterSupervisorAgent, @RegisterPlannerAgent, @RegisterA2AAgent, @RegisterMcpClientAgent, @RegisterHumanInTheLoopAgent 2. Using MicroProfile Fault Tolerance Retry If you want to apply a retry policy to your AI service or AI agent using MicroProfile @Retry annotation, you first have to disable LangChain4J's internal retry policy which is set to 3 retries by default . There are various ways to do this. Using MicroProfile config, set the maxRetries = 0 . For example: dev.langchain4j.cdi.plugin.