Skip to content

Commit 832ef77

Browse files
committed
Fix more documentation issues from PR review
- error-handling.md: Fix input fields (errorContext, recoverable instead of errorType, stack, context) - error-handling.md: Fix output fields (suppressOutput, errorHandling, retryCount, userNotification) - error-handling.md: Update examples to use correct field names - user-prompt-submitted.md: Remove non-existent reject/rejectReason, add suppressOutput - compatibility.md: Fix token usage event (assistant.usage not assistant.turn_end) - compatibility.md: Fix usage fields (inputTokens/outputTokens not usage object) - session-lifecycle.md: Fix Log Session Summary example to track startTime
1 parent c8b52e7 commit 832ef77

4 files changed

Lines changed: 25 additions & 24 deletions

File tree

docs/compatibility.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,11 @@ const session = await client.createSession({
146146
Instead of `/usage`, subscribe to usage events:
147147

148148
```typescript
149-
session.on("assistant.turn_end", (event) => {
150-
console.log("Tokens used:", event.data.usage);
149+
session.on("assistant.usage", (event) => {
150+
console.log("Tokens used:", {
151+
input: event.data.inputTokens,
152+
output: event.data.outputTokens,
153+
});
151154
});
152155
```
153156

docs/hooks/error-handling.md

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,19 @@ public delegate Task<ErrorOccurredHookOutput?> ErrorOccurredHandler(
6363
| `timestamp` | number | Unix timestamp when the error occurred |
6464
| `cwd` | string | Current working directory |
6565
| `error` | string | Error message |
66-
| `errorType` | string | Type/category of error |
67-
| `stack` | string | Stack trace (if available) |
68-
| `context` | object | Additional error context |
66+
| `errorContext` | string | Where the error occurred: `"model_call"`, `"tool_execution"`, `"system"`, or `"user_input"` |
67+
| `recoverable` | boolean | Whether the error can potentially be recovered from |
6968

7069
## Output
7170

7271
Return `null` or `undefined` to use default error handling. Otherwise, return an object with:
7372

7473
| Field | Type | Description |
7574
|-------|------|-------------|
76-
| `additionalContext` | string | Context to add to help recover |
77-
| `suppressError` | boolean | If true, don't show error to user |
78-
| `modifiedMessage` | string | Custom error message to display |
75+
| `suppressOutput` | boolean | If true, don't show error output to user |
76+
| `errorHandling` | string | How to handle: `"retry"`, `"skip"`, or `"abort"` |
77+
| `retryCount` | number | Number of times to retry (if errorHandling is `"retry"`) |
78+
| `userNotification` | string | Custom message to show the user |
7979

8080
## Examples
8181

@@ -89,10 +89,8 @@ const session = await client.createSession({
8989
hooks: {
9090
onErrorOccurred: async (input, invocation) => {
9191
console.error(`[${invocation.sessionId}] Error: ${input.error}`);
92-
console.error(` Type: ${input.errorType}`);
93-
if (input.stack) {
94-
console.error(` Stack: ${input.stack}`);
95-
}
92+
console.error(` Context: ${input.errorContext}`);
93+
console.error(` Recoverable: ${input.recoverable}`);
9694
return null;
9795
},
9896
},
@@ -107,9 +105,8 @@ const session = await client.createSession({
107105
```python
108106
async def on_error_occurred(input_data, invocation):
109107
print(f"[{invocation['session_id']}] Error: {input_data['error']}")
110-
print(f" Type: {input_data['errorType']}")
111-
if input_data.get("stack"):
112-
print(f" Stack: {input_data['stack']}")
108+
print(f" Context: {input_data['error_context']}")
109+
print(f" Recoverable: {input_data['recoverable']}")
113110
return None
114111

115112
session = await client.create_session({
@@ -127,10 +124,8 @@ session, _ := client.CreateSession(ctx, copilot.SessionConfig{
127124
Hooks: &copilot.SessionHooks{
128125
OnErrorOccurred: func(input copilot.ErrorOccurredHookInput, inv copilot.HookInvocation) (*copilot.ErrorOccurredHookOutput, error) {
129126
fmt.Printf("[%s] Error: %s\n", inv.SessionID, input.Error)
130-
fmt.Printf(" Type: %s\n", input.ErrorType)
131-
if input.Stack != "" {
132-
fmt.Printf(" Stack: %s\n", input.Stack)
133-
}
127+
fmt.Printf(" Context: %s\n", input.ErrorContext)
128+
fmt.Printf(" Recoverable: %v\n", input.Recoverable)
134129
return nil, nil
135130
},
136131
},

docs/hooks/session-lifecycle.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,12 +384,16 @@ const session = await client.createSession({
384384
#### Log Session Summary
385385

386386
```typescript
387-
const sessionData: Record<string, { prompts: number; tools: number }> = {};
387+
const sessionData: Record<string, { prompts: number; tools: number; startTime: number }> = {};
388388

389389
const session = await client.createSession({
390390
hooks: {
391-
onSessionStart: async (_, invocation) => {
392-
sessionData[invocation.sessionId] = { prompts: 0, tools: 0 };
391+
onSessionStart: async (input, invocation) => {
392+
sessionData[invocation.sessionId] = {
393+
prompts: 0,
394+
tools: 0,
395+
startTime: input.timestamp
396+
};
393397
return null;
394398
},
395399
onUserPromptSubmitted: async (_, invocation) => {

docs/hooks/user-prompt-submitted.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ Return `null` or `undefined` to use the prompt unchanged. Otherwise, return an o
7272
|-------|------|-------------|
7373
| `modifiedPrompt` | string | Modified prompt to use instead of original |
7474
| `additionalContext` | string | Extra context added to the conversation |
75-
| `reject` | boolean | If true, reject the prompt entirely |
76-
| `rejectReason` | string | Explanation shown when prompt is rejected |
75+
| `suppressOutput` | boolean | If true, suppress the assistant's response output |
7776

7877
## Examples
7978

0 commit comments

Comments
 (0)