Package com.github.copilot.sdk.json
Interface UserInputHandler
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Handler for user input requests from the agent.
Implement this interface to handle user input requests when the agent uses the ask_user tool.
Example Usage
UserInputHandler handler = (request, invocation) -> {
System.out.println("Agent asks: " + request.getQuestion());
String answer = readUserInput(); // your input method
return CompletableFuture.completedFuture(new UserInputResponse().setAnswer(answer).setWasFreeform(true));
};
var session = client.createSession(new SessionConfig().setOnUserInputRequest(handler)).get();
- Since:
- 1.0.6
-
Method Summary
Modifier and TypeMethodDescriptionhandle(UserInputRequest request, UserInputInvocation invocation) Handles a user input request from the agent.
-
Method Details
-
handle
CompletableFuture<UserInputResponse> handle(UserInputRequest request, UserInputInvocation invocation) Handles a user input request from the agent.- Parameters:
request- the user input request containing the question and optional choicesinvocation- context information about the invocation- Returns:
- a future that resolves with the user's response
-