fix(coding-agent): expose rpc context usage closes #2550

This commit is contained in:
Mario Zechner
2026-03-24 03:08:51 +01:00
parent 9a0be024a6
commit 835296b1d7
4 changed files with 160 additions and 2 deletions

View File

@@ -494,7 +494,7 @@ Response:
#### get_session_stats
Get token usage and cost statistics.
Get token usage, cost statistics, and current context window usage.
```json
{"type": "get_session_stats"}
@@ -521,11 +521,20 @@ Response:
"cacheWrite": 5000,
"total": 105000
},
"cost": 0.45
"cost": 0.45,
"contextUsage": {
"tokens": 60000,
"contextWindow": 200000,
"percent": 30
}
}
}
```
`tokens` contains assistant usage totals for the current session state. `contextUsage` contains the actual current context-window estimate used for compaction and footer display.
`contextUsage` is omitted when no model or context window is available. `contextUsage.tokens` and `contextUsage.percent` are `null` immediately after compaction until a fresh post-compaction assistant response provides valid usage data.
#### export_html
Export session to an HTML file.