You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: Java cookbook recipes to compile with copilot-sdk-java 0.2.1-java.1
Fix compilation errors and documentation inaccuracies in Java cookbook
recipes against the actual SDK API:
- MultipleSessions: Replace non-existent destroy() with close()
- AccessibilityReport: Replace non-existent McpServerConfig class with
Map<String, Object> (the actual type accepted by setMcpServers)
- error-handling.md: Replace non-existent session.addTool(),
ToolDefinition.builder(), and ToolResultObject with actual SDK APIs
(ToolDefinition.create(), SessionConfig.setTools(),
CompletableFuture<Object> return type)
All 7 recipes now compile successfully with jbang build.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2. **Unwrap `ExecutionException`**: Call `getCause()` to inspect the real error — the outer `ExecutionException` is just a `CompletableFuture` wrapper.
180
195
3. **Restore interrupt flag**: When catching `InterruptedException`, call `Thread.currentThread().interrupt()` to preserve the interrupted status.
181
196
4. **Set timeouts**: Use `get(timeout, TimeUnit)` instead of bare `get()` for any call that could block indefinitely.
182
-
5. **Return tool errors, don't throw**: Use `ToolResultObject.error()` so the model can recover gracefully.
197
+
5. **Return tool errors, don't throw**: Return an error string from the `CompletableFuture` so the model can recover gracefully.
183
198
6. **Log errors**: Capture error details for debugging — consider a logging framework like SLF4J for production applications.
0 commit comments