Annotation Interface ChatModelSupplier
Marks a method as a supplier of the chat model to be used by an agent.
The method must be static on the agent type and return a
ChatModel.
When the method has no parameters, or only parameters provided by a SupplierParameterResolver, 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. Its parameters provided by a
SupplierParameterResolver are then resolved each time the method is invoked too.
Example (fixed model):
public interface SupervisorBanker {
@SupervisorAgent(responseStrategy = SupervisorResponseStrategy.SUMMARY,
subAgents = { WithdrawAgent.class, 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();
}
}
Like every helper method, it can be an instance method of a helper object of the agent instead of a static method
of the agent type: see the "Helper objects" section of the agentic tutorial and
AgenticServices.AgentConfigurator.