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
Copy file name to clipboardExpand all lines: docs/protocol/v1/draft/prompt-turn.mdx
+25Lines changed: 25 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -185,6 +185,31 @@ If the model requested tool calls, these are also reported immediately:
185
185
}
186
186
```
187
187
188
+
#### Session Usage Updates
189
+
190
+
The Agent **MAY** also report current session context and cumulative cost state with a `usage_update`:
191
+
192
+
```json
193
+
{
194
+
"jsonrpc": "2.0",
195
+
"method": "session/update",
196
+
"params": {
197
+
"sessionId": "sess_abc123def456",
198
+
"update": {
199
+
"sessionUpdate": "usage_update",
200
+
"used": 53000,
201
+
"size": 200000,
202
+
"cost": {
203
+
"amount": 0.045,
204
+
"currency": "USD"
205
+
}
206
+
}
207
+
}
208
+
}
209
+
```
210
+
211
+
`used` and `size` are required and non-null token counts for the current session context. `cost` is optional and, if present, `amount` and `currency` are required. `currency` is an ISO 4217 currency code like `"USD"`.
212
+
188
213
### 4. Check for Completion
189
214
190
215
If there are no pending tool calls, the turn ends and the Agent **MUST** respond to the original `session/prompt` request with a `StopReason`:
Copy file name to clipboardExpand all lines: docs/protocol/v1/prompt-turn.mdx
+25Lines changed: 25 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -182,6 +182,31 @@ If the model requested tool calls, these are also reported immediately:
182
182
}
183
183
```
184
184
185
+
#### Session Usage Updates
186
+
187
+
The Agent **MAY** also report current session context and cumulative cost state with a `usage_update`:
188
+
189
+
```json
190
+
{
191
+
"jsonrpc": "2.0",
192
+
"method": "session/update",
193
+
"params": {
194
+
"sessionId": "sess_abc123def456",
195
+
"update": {
196
+
"sessionUpdate": "usage_update",
197
+
"used": 53000,
198
+
"size": 200000,
199
+
"cost": {
200
+
"amount": 0.045,
201
+
"currency": "USD"
202
+
}
203
+
}
204
+
}
205
+
}
206
+
```
207
+
208
+
`used` and `size` are required and non-null token counts for the current session context. `cost` is optional and, if present, `amount` and `currency` are required. `currency` is an ISO 4217 currency code like `"USD"`.
209
+
185
210
### 4. Check for Completion
186
211
187
212
If there are no pending tool calls, the turn ends and the Agent **MUST** respond to the original `session/prompt` request with a `StopReason`:
Copy file name to clipboardExpand all lines: docs/protocol/v2/draft/prompt-turn.mdx
+25Lines changed: 25 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -189,6 +189,31 @@ If the model requested tool calls, these are also reported immediately:
189
189
}
190
190
```
191
191
192
+
#### Session Usage Updates
193
+
194
+
The Agent **MAY** also report current session context and cumulative cost state with a `usage_update`:
195
+
196
+
```json
197
+
{
198
+
"jsonrpc": "2.0",
199
+
"method": "session/update",
200
+
"params": {
201
+
"sessionId": "sess_abc123def456",
202
+
"update": {
203
+
"sessionUpdate": "usage_update",
204
+
"used": 53000,
205
+
"size": 200000,
206
+
"cost": {
207
+
"amount": 0.045,
208
+
"currency": "USD"
209
+
}
210
+
}
211
+
}
212
+
}
213
+
```
214
+
215
+
`used` and `size` are required and non-null token counts for the current session context. `cost` is optional and, if present, `amount` and `currency` are required. `currency` is an ISO 4217 currency code like `"USD"`.
216
+
192
217
### 4. Check for Completion
193
218
194
219
If there are no pending tool calls, the turn ends and the Agent **MUST** respond to the original `session/prompt` request with a `StopReason`:
Copy file name to clipboardExpand all lines: docs/protocol/v2/prompt-turn.mdx
+25Lines changed: 25 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -186,6 +186,31 @@ If the model requested tool calls, these are also reported immediately:
186
186
}
187
187
```
188
188
189
+
#### Session Usage Updates
190
+
191
+
The Agent **MAY** also report current session context and cumulative cost state with a `usage_update`:
192
+
193
+
```json
194
+
{
195
+
"jsonrpc": "2.0",
196
+
"method": "session/update",
197
+
"params": {
198
+
"sessionId": "sess_abc123def456",
199
+
"update": {
200
+
"sessionUpdate": "usage_update",
201
+
"used": 53000,
202
+
"size": 200000,
203
+
"cost": {
204
+
"amount": 0.045,
205
+
"currency": "USD"
206
+
}
207
+
}
208
+
}
209
+
}
210
+
```
211
+
212
+
`used` and `size` are required and non-null token counts for the current session context. `cost` is optional and, if present, `amount` and `currency` are required. `currency` is an ISO 4217 currency code like `"USD"`.
213
+
189
214
### 4. Check for Completion
190
215
191
216
If there are no pending tool calls, the turn ends and the Agent **MUST** respond to the original `session/prompt` request with a `StopReason`:
0 commit comments