Show a compaction happening, and what it recovered
The Compacting status had been declared, rendered in four places, and never once emitted: no driver produced it, and the app had no control to ask for a compaction in the first place. Pressing nothing for two minutes and then quietly having less context was the whole experience. The CLI turns out to announce all of it, which was worth measuring rather than guessing at. Driven through /compact against 2.1.237 it emits a `status: "compacting"` line at the start, a `status: null` carrying `compact_result` at the end -- `"failed"` with a sentence saying why, when it does -- and then a `compact_boundary` with the token counts. The same records appear in the CLI's own transcript file with camelCase keys, which is the obvious place to read the shape off and gets every field name wrong. So none of it is inferred here. The driver writes the line and says nothing; the translator reports what the CLI reports. A failed compaction surfaces the CLI's own sentence, which is specific enough to act on. The counts are the part worth keeping afterwards, so they land in the transcript rather than only in a status that vanishes: a session that went from 128,402 tokens to 9,617 has just been given its context back. They are optional throughout, because a compaction whose size nobody reported has to be able to say so -- a zero would read as "recovered nothing". Also here, all found on the way: - `rename_all` renames variants; fields need `rename_all_fields`. Every field in Event was a single word until `pre_tokens`, which went out as snake_case, was not found by the app, and rendered as the "no counts reported" case -- a state it is allowed to be in, so nothing looked wrong. There is now a test on the wire names. - The unparseable-line warning sliced bytes, not chars, on output that is full of em dashes. A panic there kills the task reading the session's stdout, and the session goes deaf with nothing on screen. The other three truncations in the tree already did this correctly. - Echo compacts too, with invented numbers and a real shape, so this screen can be looked at without spending two minutes of somebody's account to reach the state.
This commit is contained in:
1 parent
42131c75d6
commit
5396da76c7
8 files changed
+408
-38
No files matched your search
@@ -533,6 +533,17 @@ fun setSessionPermissionMode(settings: ServerSettings, sessionId: String, mode:
|
||||
) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asks the session to summarise its own history and carry on from the summary.
|
||||
*
|
||||
* Nothing comes back here: a compaction takes a minute or two, and what it is doing arrives on the
|
||||
* event stream like everything else -- a `compacting` status while it runs, then how much context
|
||||
* it recovered. A call that waited would be a second, worse account of the same thing.
|
||||
*/
|
||||
fun compactSession(settings: ServerSettings, sessionId: String) {
|
||||
requestFromServer(settings, "/sessions/$sessionId/compact", method = "POST") {}
|
||||
}
|
||||
|
||||
fun deleteSession(settings: ServerSettings, sessionId: String) {
|
||||
requestFromServer(settings, "/sessions/$sessionId", method = "DELETE") {}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user