.promptHandler((req, context) -> {
String sessionId = context.getSessionId();
// 1. Thought — show thinking process (convenience method)
context.sendThought("Let me analyze this request...");
// 2. Plan — show steps and progress (full API)
context.sendUpdate(sessionId,
new Plan("plan", List.of(
new PlanEntry("Analyze the prompt",
PlanEntryPriority.HIGH, PlanEntryStatus.IN_PROGRESS),
new PlanEntry("Generate response",
PlanEntryPriority.HIGH, PlanEntryStatus.PENDING),
new PlanEntry("Format output",
PlanEntryPriority.MEDIUM, PlanEntryStatus.PENDING)
)));
// 3. Tool Call — show tool execution starting
context.sendUpdate(sessionId,
new ToolCall("tool_call",
"tool-1", "Analyzing prompt", ToolKind.THINK,
ToolCallStatus.IN_PROGRESS,
List.of(), null, null, null, null));
// 4. Tool Call Update — show progress
context.sendUpdate(sessionId,
new ToolCallUpdateNotification("tool_call_update",
"tool-1", "Analyzing prompt", ToolKind.THINK,
ToolCallStatus.COMPLETED,
List.of(), null, null, null, null));
// 5. Available Commands — advertise slash commands
context.sendUpdate(sessionId,
new AvailableCommandsUpdate("available_commands_update", List.of(
new AvailableCommand("help", "Show help",
new AvailableCommandInput("topic")),
new AvailableCommand("clear", "Clear context", null)
)));
// 6. Mode Update — report current mode
context.sendUpdate(sessionId,
new CurrentModeUpdate("current_mode_update", "default"));
// 7. Message chunks — the actual response (convenience method)
context.sendMessage("Here is my response ");
context.sendMessage("streamed in ");
context.sendMessage("multiple chunks.");
return PromptResponse.endTurn();
})