@octavus/docs 3.4.0 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/content/02-server-sdk/02-sessions.md +61 -0
- package/dist/{chunk-5L4PRXYU.js → chunk-VGQQ3XM5.js} +11 -11
- package/dist/chunk-VGQQ3XM5.js.map +1 -0
- package/dist/content.js +1 -1
- package/dist/docs.json +5 -5
- package/dist/index.js +1 -1
- package/dist/search-index.json +1 -1
- package/dist/search.js +1 -1
- package/dist/search.js.map +1 -1
- package/dist/sections.json +5 -5
- package/package.json +1 -1
- package/dist/chunk-5L4PRXYU.js.map +0 -1
|
@@ -75,6 +75,67 @@ console.log({
|
|
|
75
75
|
|
|
76
76
|
> **Note**: Use `getMessages()` for client-facing code. The `get()` method returns internal message format that includes hidden content not intended for end users.
|
|
77
77
|
|
|
78
|
+
## Getting Execution Logs
|
|
79
|
+
|
|
80
|
+
`getLogs()` returns the chronological execution trace for a session - triggers, messages, tool calls, LLM responses, errors, and other events emitted while the agent ran. Useful for debugging, observability, and building custom timeline views.
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
const result = await client.agentSessions.getLogs(sessionId);
|
|
84
|
+
|
|
85
|
+
if (result.status === 'expired') {
|
|
86
|
+
console.log('Session expired:', result.sessionId);
|
|
87
|
+
} else {
|
|
88
|
+
for (const entry of result.entries) {
|
|
89
|
+
console.log(entry.type, entry.timestamp);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Each entry is a typed variant of `ExecutionLogEntry` (a discriminated union) so consumers can narrow on `entry.type`:
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
const result = await client.agentSessions.getLogs(sessionId);
|
|
98
|
+
|
|
99
|
+
if (result.status !== 'expired') {
|
|
100
|
+
const toolCalls = result.entries.filter((e) => e.type === 'tool-call');
|
|
101
|
+
for (const call of toolCalls) {
|
|
102
|
+
// call.toolName, call.toolArguments are typed without optional chaining
|
|
103
|
+
console.log(call.toolName, call.toolArguments);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Excluding Model Request Payloads
|
|
109
|
+
|
|
110
|
+
Model-request entries include the full provider request body and can be large. Pass `excludeModelRequests: true` to skip them:
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
const result = await client.agentSessions.getLogs(sessionId, {
|
|
114
|
+
excludeModelRequests: true,
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Truncation
|
|
119
|
+
|
|
120
|
+
Responses are capped at 1000 entries (most recent). When the log exceeds that cap, the response includes `total` and `truncated` so consumers can detect this:
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
const result = await client.agentSessions.getLogs(sessionId);
|
|
124
|
+
|
|
125
|
+
if (result.status !== 'expired' && result.truncated) {
|
|
126
|
+
console.warn(`Showing latest 1000 of ${result.total} entries`);
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Response Types
|
|
131
|
+
|
|
132
|
+
| Status | Type | Description |
|
|
133
|
+
| --------- | --------------------- | -------------------------------------------------------------------------------------------- |
|
|
134
|
+
| `active` | `ExecutionLogsResult` | `{ sessionId, entries, total?, truncated? }`. `total` and `truncated` are present when known |
|
|
135
|
+
| `expired` | `ExpiredSessionState` | `{ sessionId, agentId, status: 'expired', createdAt }` |
|
|
136
|
+
|
|
137
|
+
> **Forward-compatible types**: `ExecutionLogEntry` may gain new variants over time. Include a `default` case when switching on `entry.type` so unknown variants are handled gracefully.
|
|
138
|
+
|
|
78
139
|
## Attaching to Sessions
|
|
79
140
|
|
|
80
141
|
To trigger actions on a session, you need to attach to it first:
|