Annotation Interface UserMessageProviderSupplier


@Retention(RUNTIME) @Target(METHOD) public @interface UserMessageProviderSupplier
Marks a method as a user message provider for an agent. The annotated method must be static on the agent type, accept an Object parameter (the memoryId), and return a String (the user message). Besides the memoryId, it can declare parameters resolved through a SupplierParameterResolver.

This provides a declarative alternative to programmatically calling AgentBuilder.userMessageProvider(java.util.function.Function), and is useful when the user message needs to be dynamically computed at runtime.

Example:


    public interface DynamicAgent {

        @Agent("An agent with a dynamic user message")
        String chat(@V("request") String request);

        @UserMessageProviderSupplier
        static String userMessageProvider(Object memoryId) {
            return "Process the request for session " + memoryId;
        }
    }

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.