Package com.github.copilot.sdk.json
Interface AutoModeSwitchHandler
- 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 auto-mode-switch requests from the agent.
Register an auto-mode-switch handler via
SessionConfig.setOnAutoModeSwitch(AutoModeSwitchHandler) or
ResumeSessionConfig.setOnAutoModeSwitch(AutoModeSwitchHandler). When
provided, the server routes autoModeSwitch.request callbacks to this
handler.
Example Usage
AutoModeSwitchHandler handler = (request, invocation) -> {
System.out.println("Rate limited: " + request.getErrorCode());
return CompletableFuture.completedFuture(AutoModeSwitchResponse.YES);
};
var session = client.createSession(new SessionConfig().setOnAutoModeSwitch(handler)).get();
- Since:
- 1.0.8
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionhandle(AutoModeSwitchRequest request, AutoModeSwitchInvocation invocation) Handles an auto-mode-switch request from the agent.
-
Method Details
-
handle
CompletableFuture<AutoModeSwitchResponse> handle(AutoModeSwitchRequest request, AutoModeSwitchInvocation invocation) Handles an auto-mode-switch request from the agent.- Parameters:
request- the auto-mode-switch request containing the error code and retry-after secondsinvocation- context information about the invocation- Returns:
- a future that resolves with the user's decision
-