Repository navigation
feat(conversation): let a daemon client rewind a session to a prompt - #1824
Conversation
A client that resends a prompt asks the session worker to drop that prompt and everything after it with the rewind_conversation frame, the way the chat TUI message history does. The conversation context owns the rule as RewindToPrompt, which keeps the conversation id. The daemon routes the frame only to the session it names, and a worker that is running a turn refuses it.
|
@infer /model ollama_cloud/glm-5.3 can you review this PR? is it ready for merge? use /ponytail:ponytail /ponytail:ponytail-review /domain-driven-design /clean-architecture /clean-code /go /go-concurrency /cobra-viper |
|
Model: Todos
Pull Request✅ Infer Result: SuccessCI is now fully green - all 13 checks pass, including the three platform builds, the full What this change does: A chat that runs on the daemon keeps its conversation on the session's worker, so a client had no way to go back to an earlier prompt. This PR adds a Verification - all green:
Design (DDD / clean architecture / clean code): the new concept lives in the domain. Findings Must fix: none. Should fix:
for ctl.awaitTurn() {
ctl.turning.Store(true)
runServeTurn(ctx, svc, ctl, notifications, turn, notes)
if len(ctl.deferred) == 0 {
ctl.turning.Store(false)
}
}
Nice to have:
Is it ready for merge? Yes. CI is fully green, the commit is correctly typed for release, the mock is regenerated, and the downstream docs tracking issue exists. Verdict: Ship. Take finding 1 with it if you want the protocol docs' promise to hold exactly - it is two lines - but it is not a blocker. Lean: nothing to cut. The diff already deletes its own duplication: Not checked: the consumer side in inference-gateway/desktop, which the PR body and the docs issue track. Risk if merged as-is: finding 1's race - a client that rewinds without waiting for the Model: Tokens: 2,769,414 in · 43,702 out · 2,813,116 total (29 requests) Tool calls: 53 total · 100% success rate TracesStatsTriggered by edenreich · Infer Action · OSS |
… together The worker refused a rewind by reading a flag and the message queue, then rewound in a second step. Two gaps were left open. A prompt deferred behind a direct task sat off the queue while the flag was down, and a message that arrived from outside stdin could start a turn between the check and the rewind. The serve loop now holds one lock for each turn, and a rewind takes the same lock without waiting. A turn that is running, queued or deferred refuses the rewind, and a turn that arrives during a rewind starts after it. The reply's messages are read under the lock, so they are what the rewind left. - The refusal reads "the session is running a turn or has one queued", since a queued turn has nothing to stop. - The protocol docs say a rewind does not close the interrupts the last run left open.
|
🎉 This PR is included in version 0.260.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
A chat that runs on the daemon keeps its conversation on the session's worker, so a client had no way to go back to an earlier prompt - the chat TUI's message history is off there for the same reason. This adds a
rewind_conversationpanel frame: the client names one of the user's prompts, and the worker drops that prompt and everything after it. The client then sends the prompt again as an ordinaryrun_agent_input. The desktop app uses it for a "Resend prompt" button.Changes
conversation/domaingainsPromptRefandErrPromptNotFound. A prompt is named by its text and by which of the times the user sent that text it is, counted from the newest, because the ids of a snapshot's messages do not outlive the snapshot.ConversationRepositorygainsRewindToPrompt. It finds and drops in one locked step and keeps the conversation's id, also when no entry is left, whichCleardoes not. The persistent repository saves afterwards.rewind_conversationwithconversation_rewound, carrying the messages that are left or the reason it refused. A worker that is running a turn, or has one queued, refuses.project_dirandidname. A session that is not open gets aRUN_ERROR, and no other worker of the project takes the frame.docs/browser-extension-protocol.md, a pointer fromdocs/conversation-versioning.md, and the routing rule ininternal/sessions/README.md.FakeConversationRepositorymock is regenerated for the new method.Not in this change
inference-gateway/desktopdepends on a release that contains this frame.inference-gateway/docsneeds a page update for the new frame.