Repository navigation
Conversation
…old through that summary, and the message after it is told again Deleting or editing a message that a conversation's saved summary covers drops the summary first, so its words are not sent with later requests and the summary's message count cannot shift past the next message. The next turn tells the remaining messages whole and summarises again when they fill up, as after a rewind. A summary written one message at a time also checks that the messages it read are unchanged before it is saved. A deletion or edit whose save fails reports the failure, and the summary is restored only when its file still has it.
…that, also when the summary could not be written When a message the saved summary covers is deleted or edited while a turn is summarising older messages, the summary is dropped and that summary job stops. The turn was then still sent the transcript built before the job, with the dropped summary and the old words in it. It is now built again after every summary attempt, as it already was after a successful one, on both the turn's own path and a new session's story.
Owner
|
Thanks, Roman, this is a careful fix, and the tests made it easy to review. It's landed with your two commits as you wrote them, plus a small follow-up of mine: the turn's transcript now uses your |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #499.
A saved summary covers the first
throughsettled messages of a lane. Deleting one of them left the summary in place, so its words were told with every later request. A tombstone is not counted, so the count then reached one message further: the first message after the summary was told neither through the summary nor whole, and later folds started after it. Editing a covered message left its old words in the summary the same way.What changes:
DELETEandPATCH /api/threads/:lane/messages/:id(server/index.ts): when the message is one the summary counted, the summary is dropped before the message changes, and the app is told. Covered means one of the firstthroughmessages by the rule the fold and the transcript count with, decided before the change; the fold's filter is now that predicate,summaryCounts. APATCHdrops it only when the words change. A message after the count, a row the count skips (a notice, a tombstone, a message never sent or still queued), an edit to the same words and a refused change leave the summary as it was. The next turn is told the conversation without it and summarises again when it fills up, as afterbloks summary --clear. Nothing is asked of the engine at the change itself.durable: true. A message that cannot be saved now stays as it was in memory as well, and the request fails with 500. Before, the request failed too, but the change stayed in memory, where later requests used it, until a restart brought the old message back.Store.dropTaskContext(server/store.ts) drops the summary and savesbots.json. When that save fails, the message is not changed, and the summary is back in memory only whenbots.jsonstill holds it: after a busy renamewriteFileAtomicwrites in place, and that write can fail with the file already changed. When the summary was dropped but the message then could not be saved, the summary stays dropped, the request fails, and the app is told only that the summary is gone.microFoldsaves only when the messages its step read are still there, in their places, with the words it read. It checked only that the lane's summary was the same one, which cannot show a change to the message being read, or any change when there was no summary before.startClaimedTurn, on its own path and for a new session's story) builds what it is told again after every summary attempt, not only after a successful one. A summary dropped while that summary ran used to leave the turn with what was built before it, the old summary and words included.Not changed: what an engine keeps in a session of its own, what was already sent, quotes and replies, memory and files; copies taken before the change, in a branch or in words that linked the conversation with @; the tombstone itself; and the refusal to take back words whose delivery is unresolved. A lane whose summary was dropped sends longer requests until it is summarised again, and a long one summarises before its next turn. Rebuilding can add latency and provider cost. If summarisation fails, the existing fallback sends only the newest bounded part of the conversation.
Tests: test/summary-message-changes.test.ts runs real HTTP turns against a synthetic OpenAI-compatible engine: a covered message deleted or edited (the summary goes, the app is told, and the next request has neither the old words nor a gap; the deletion asks nothing of the engine); messages after the count and rows the count skips, deleted or edited; edits to the same words and refused changes; a person's message counted after one-at-a-time summarising took over; one-at-a-time steps with and without a summary before them, unchanged and with the message they read deleted meanwhile, and one with a covered message edited meanwhile; a turn that summarises first while a covered message is deleted; and both write failures, through a restart. test/task-context-drop.test.ts drives the store's drop through a write that saves, one that fails, and a busy rename followed by an in-place write that saves, is refused, or fails with the file cut short. test/summary-passes.test.ts adds a covered message deleted and edited while a summary request is out, and checks what the turn that waited for it is told.
Hosted CI on the proposed source, on this fork: run 42526538014 passed typecheck, tests and build. Of 6,491 tests, 6,487 passed and four were skipped: two macOS Touch ID helper tests on Linux, and two that run only on a real Chrome (
BLOKS_REAL_CHROME=1). The server exercises use synthetic model responses.