Skip to content

Commit 46d5e24

Browse files
committed
Update .lastmerge to ea90f076091371810c66d05590f65e2863f79bdf
1 parent f5ffa05 commit 46d5e24

File tree

3 files changed

+85
-19
lines changed

3 files changed

+85
-19
lines changed

.lastmerge

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
062b61c8aa63b9b5d45fa1d7b01723e6660ffa83
1+
ea90f076091371810c66d05590f65e2863f79bdf

src/main/java/com/github/copilot/sdk/EventErrorPolicy.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@
2929
* <b>Example:</b>
3030
*
3131
* <pre>{@code
32-
* // Default: propagate errors (stop dispatch on first error, log the error)
33-
* session.setEventErrorPolicy(EventErrorPolicy.PROPAGATE_AND_LOG_ERRORS);
34-
*
35-
* // Opt-in to suppress errors (continue dispatching, log each error)
32+
* // Default: suppress errors (continue dispatching after errors, log each
33+
* // error)
3634
* session.setEventErrorPolicy(EventErrorPolicy.SUPPRESS_AND_LOG_ERRORS);
35+
*
36+
* // Opt-in to propagate errors (stop dispatch on first error, log the error)
37+
* session.setEventErrorPolicy(EventErrorPolicy.PROPAGATE_AND_LOG_ERRORS);
3738
* }</pre>
3839
*
3940
* @see CopilotSession#setEventErrorPolicy(EventErrorPolicy)
@@ -44,7 +45,7 @@ public enum EventErrorPolicy {
4445

4546
/**
4647
* Suppress errors: log the error and continue dispatching to remaining
47-
* listeners.
48+
* listeners (default).
4849
* <p>
4950
* When a handler throws an exception, the error is logged at
5051
* {@link java.util.logging.Level#WARNING} and remaining handlers still execute.
@@ -54,8 +55,7 @@ public enum EventErrorPolicy {
5455
SUPPRESS_AND_LOG_ERRORS,
5556

5657
/**
57-
* Propagate errors: log the error and stop dispatch on first listener error
58-
* (default).
58+
* Propagate errors: log the error and stop dispatch on first listener error.
5959
* <p>
6060
* When a handler throws an exception, the error is logged at
6161
* {@link java.util.logging.Level#WARNING} and no further handlers are invoked.

src/site/markdown/advanced.md

Lines changed: 77 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,36 @@ var session = client.createSession(
110110
).get();
111111
```
112112

113+
### Skipping Permission Prompts for Safe Tools
114+
115+
For tools that are inherently safe (e.g., read-only lookups), you can skip the CLI permission
116+
prompt by using `ToolDefinition.createWithSkipPermission()`. The CLI will invoke the tool
117+
directly without presenting a permission request.
118+
119+
```java
120+
var safeLookupTool = ToolDefinition.createWithSkipPermission(
121+
"safe_lookup",
122+
"Look up a value by ID — read-only, no side effects",
123+
Map.of(
124+
"type", "object",
125+
"properties", Map.of(
126+
"id", Map.of("type", "string", "description", "Lookup ID")
127+
),
128+
"required", List.of("id")
129+
),
130+
invocation -> {
131+
String id = (String) invocation.getArguments().get("id");
132+
return CompletableFuture.completedFuture("Value for " + id);
133+
}
134+
);
135+
136+
var session = client.createSession(
137+
new SessionConfig()
138+
.setTools(List.of(safeLookupTool))
139+
.setOnPermissionRequest(PermissionHandler.APPROVE_ALL)
140+
).get();
141+
```
142+
113143
---
114144

115145
## Switching Models Mid-Session
@@ -126,6 +156,9 @@ var session = client.createSession(
126156
// Switch to a different model mid-conversation
127157
session.setModel("gpt-4.1").get();
128158

159+
// Switch model and set reasoning effort at the same time
160+
session.setModel("claude-sonnet-4.6", "high").get();
161+
129162
// Next message will use the new model
130163
session.sendAndWait(new MessageOptions().setPrompt("Continue with the new model")).get();
131164
```
@@ -624,6 +657,10 @@ The `PermissionRequestResultKind` class provides well-known constants for common
624657
| `PermissionRequestResultKind.DENIED_BY_RULES` | `"denied-by-rules"` | Denied by policy rules |
625658
| `PermissionRequestResultKind.DENIED_COULD_NOT_REQUEST_FROM_USER` | `"denied-no-approval-rule-and-could-not-request-from-user"` | No rule and user could not be prompted |
626659
| `PermissionRequestResultKind.DENIED_INTERACTIVELY_BY_USER` | `"denied-interactively-by-user"` | User denied interactively |
660+
| `PermissionRequestResultKind.NO_RESULT` | `"no-result"` | Leave the request unanswered (pass to another handler) |
661+
662+
Use `NO_RESULT` in extension scenarios where your handler is not responsible for a particular
663+
permission request and wants to let another handler (or the CLI default) handle it instead.
627664

628665
You can also pass a raw string to `setKind(String)` for custom or extension values. Use
629666
[`PermissionHandler.APPROVE_ALL`](apidocs/com/github/copilot/sdk/json/PermissionHandler.html) to approve all
@@ -890,22 +927,22 @@ session.setEventErrorHandler(null);
890927

891928
### Event Error Policy
892929

893-
By default, the SDK propagates errors and stops dispatch on the first handler
894-
error (`EventErrorPolicy.PROPAGATE_AND_LOG_ERRORS`). You can opt in to
895-
**suppress** errors so that all handlers execute despite errors:
930+
By default, the SDK **suppresses** handler errors and continues dispatching to all remaining
931+
handlers (`EventErrorPolicy.SUPPRESS_AND_LOG_ERRORS`). Errors are always logged at `WARNING`
932+
level. You can opt in to the strict **propagate** policy to stop dispatch on the first error:
896933

897934
```java
898-
session.setEventErrorPolicy(EventErrorPolicy.SUPPRESS_AND_LOG_ERRORS);
935+
session.setEventErrorPolicy(EventErrorPolicy.PROPAGATE_AND_LOG_ERRORS);
899936
```
900937

901938
The `EventErrorHandler` (if set) is always invoked regardless of the policy —
902939
the policy only controls whether remaining handlers execute after the error
903-
handler returns. Errors are always logged at `WARNING` level.
940+
handler returns.
904941

905942
| Policy | Behavior |
906943
|---|---|
907-
| `PROPAGATE_AND_LOG_ERRORS` (default) | Log the error; dispatch halts after the first error |
908-
| `SUPPRESS_AND_LOG_ERRORS` | Log the error; all remaining handlers execute |
944+
| `SUPPRESS_AND_LOG_ERRORS` (default) | Log the error; all remaining handlers execute |
945+
| `PROPAGATE_AND_LOG_ERRORS` | Log the error; dispatch halts after the first error |
909946

910947
You can combine both for full control:
911948

@@ -919,17 +956,46 @@ session.setEventErrorHandler((event, ex) ->
919956
Or switch policies dynamically:
920957

921958
```java
922-
// Start strict (propagate errors, stop dispatch)
923-
session.setEventErrorPolicy(EventErrorPolicy.PROPAGATE_AND_LOG_ERRORS);
924-
925-
// Later, switch to lenient mode (suppress errors, continue)
959+
// Lenient (suppress errors, continue) — the default
926960
session.setEventErrorPolicy(EventErrorPolicy.SUPPRESS_AND_LOG_ERRORS);
961+
962+
// Strict: stop dispatch on first error
963+
session.setEventErrorPolicy(EventErrorPolicy.PROPAGATE_AND_LOG_ERRORS);
927964
```
928965

929966
See [EventErrorPolicy](apidocs/com/github/copilot/sdk/EventErrorPolicy.html) and [EventErrorHandler](apidocs/com/github/copilot/sdk/EventErrorHandler.html) Javadoc for details.
930967

931968
---
932969

970+
## OpenTelemetry Support
971+
972+
Enable distributed tracing for the Copilot CLI server by setting a `TelemetryConfig` on
973+
`CopilotClientOptions`. When configured, the CLI is started with OpenTelemetry instrumentation
974+
enabled, producing traces for each request.
975+
976+
```java
977+
var client = new CopilotClient(
978+
new CopilotClientOptions()
979+
.setTelemetry(new TelemetryConfig()
980+
.setOtlpEndpoint("http://localhost:4318")
981+
.setExporterType("otlp-http"))
982+
);
983+
```
984+
985+
### TelemetryConfig Options
986+
987+
| Option | Environment Variable | Description |
988+
|--------|----------------------|-------------|
989+
| `setOtlpEndpoint(String)` | `OTEL_EXPORTER_OTLP_ENDPOINT` | OTLP exporter endpoint URL |
990+
| `setFilePath(String)` | `COPILOT_OTEL_FILE_EXPORTER_PATH` | File path for the file exporter |
991+
| `setExporterType(String)` | `COPILOT_OTEL_EXPORTER_TYPE` | Exporter type: `"otlp-http"` or `"file"` |
992+
| `setSourceName(String)` | `COPILOT_OTEL_SOURCE_NAME` | Source name for telemetry spans |
993+
| `setCaptureContent(Boolean)` | `OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT` | Whether to capture message content |
994+
995+
See [TelemetryConfig](apidocs/com/github/copilot/sdk/json/TelemetryConfig.html) Javadoc for details.
996+
997+
---
998+
933999
## Next Steps
9341000

9351001
- 📖 **[Documentation](documentation.html)** - Core concepts, events, streaming, models, tool filtering, reasoning effort

0 commit comments

Comments
 (0)