Annotation Interface ChatModelSupplier


@Retention(RUNTIME) @Target(METHOD) public @interface ChatModelSupplier
Marks a method as a supplier of the chat model to be used by an agent. The method must be static and return a ChatModel.

When the method has no parameters, it is invoked once at build time to provide a fixed model. When the method has parameters annotated with @V, they are resolved from the current AgenticScope at each invocation, enabling dynamic model selection based on runtime state.

Example (fixed model):


     public interface SupervisorBanker {

        @SupervisorAgent(responseStrategy = SupervisorResponseStrategy.SUMMARY, subAgents = {
                @SubAgent(type = WithdrawAgent.class),
                @SubAgent(type = CreditAgent.class)
        })
        String invoke(@V("request") String request);

        @ChatModelSupplier
        static ChatModel chatModel() {
            return plannerModel();
        }
    }

Example (dynamic model selection):


     public interface MyEditor {

        @Agent("Edit the story based on critique")
        String edit(@V("story") String story, @V("critique") CritiqueResult critique);

        @ChatModelSupplier
        static ChatModel chatModel(@V("critique") CritiqueResult critique) {
            return critique != null && critique.score() > 8.0 ? enhancedModel() : baseModel();
        }
    }