Skip to content

feat(conversation): let a daemon client rewind a session to a prompt - #1824

Merged
edenreich merged 3 commits into
mainfrom
feat/rewind-conversation-frame
Nov 12, 2026
Merged

edenreich merged 3 commits into
mainfrom
feat/rewind-conversation-frame

Conversation

@edenreich

Copy link
Copy Markdown
Contributor

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_conversation panel 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 ordinary run_agent_input. The desktop app uses it for a "Resend prompt" button.

Changes

  • conversation/domain gains PromptRef and ErrPromptNotFound. 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.
  • ConversationRepository gains RewindToPrompt. It finds and drops in one locked step and keeps the conversation's id, also when no entry is left, which Clear does not. The persistent repository saves afterwards.
  • The headless panel answers rewind_conversation with conversation_rewound, carrying the messages that are left or the reason it refused. A worker that is running a turn, or has one queued, refuses.
  • The daemon routes the frame only to the session its project_dir and id name. A session that is not open gets a RUN_ERROR, and no other worker of the project takes the frame.
  • Docs: the frame in docs/browser-extension-protocol.md, a pointer from docs/conversation-versioning.md, and the routing rule in internal/sessions/README.md.
  • The FakeConversationRepository mock is regenerated for the new method.

Not in this change

  • The chat TUI's message history keeps its own index-based drop logic.
  • Other clients following the same session are not told about a rewind.
  • Affected repos: inference-gateway/desktop depends on a release that contains this frame. inference-gateway/docs needs a page update for the new frame.

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.
@edenreich

Copy link
Copy Markdown
Contributor Author

@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

@inference-gateway-maintainer

inference-gateway-maintainer Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Model: ollama_cloud/glm-5.3 · Action: v0.59.7 · CLI: v0.254.0 · Gateway: v0.63.5 · View Job

Todos

  • Read the full PR diff
  • Read changed files and their surrounding context (domain, repository, panel, registry, docs)
  • Trace callers and invariants (locks, routing, mock regeneration, style rules)
  • Run tests and lint on the changed packages
  • Write the review report and merge verdict

Pull Request

#1824

✅ Infer Result: Success

CI is now fully green - all 13 checks pass, including the three platform builds, the full test job, and e2e. I have everything needed for the verdict.

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 rewind_conversation panel frame: the client names one of the user's prompts by text and by occurrence counted from the newest, and the worker drops that prompt and everything after it in one locked step, then answers with the messages that are left or with why it refused. The daemon routes the frame only to the open session it names, and a busy worker refuses.

Verification - all green:

  • Local on the head branch: go test over the changed packages plus the regenerated mock, go test -race over the three touched packages, golangci-lint run, and markdownlint on the three changed docs - all clean.
  • CI on the PR: all 13 checks pass, including the three platform builds (ubuntu, windows, macos), the full test job, and e2e.
  • The counterfeiter mock is regenerated properly (it compiles and the suite passes), and the commit is a typed conventional feat(conversation):, so semantic-release will cut the release the desktop app waits on. Never merge with a reworded or retyped commit.
  • The downstream tracking the PR body calls for already exists: [DOCS] Document resending a prompt and the rewind_conversation frame docs#1202.

Design (DDD / clean architecture / clean code): the new concept lives in the domain. PromptRef is a value object, ErrPromptNotFound a domain sentinel, and RewindToPrompt a new method on the repository port in conversation/domain, which stays pure (it imports only errors). The text-matching rule sits in the adapter because it needs the formatting platform package, which is the right boundary. Each context keeps one job: conversation drops the entries, headless answers the frame, sessions only routes it. Names match the language of the docs (rewind, prompt, occurrence), functions are small and single-purpose, and the tests are table-driven with no hand-written fakes. One subtlety worth naming as a strength: matching prompt text with ExtractTextFromContent(content, nil) is exactly how snapshotMessages renders a MESSAGES_SNAPSHOT, so the text a client copies from its snapshot is guaranteed to match on the worker. I score the change 9/10 on each of the three frameworks. Nothing under cmd/ or config/ changes, so there is no Cobra or Viper surface to review - the frame needs no flag, env var or config key.

Findings

Must fix: none.

Should fix:

  1. A rewind can slip between two queued turns (internal/presentation/headless/serve.go:41-45, internal/presentation/headless/control.go:183-185)
  • What this is: busy() must refuse a rewind while a turn runs or one is queued, which is the promise docs/browser-extension-protocol.md makes.
  • Problem: it checks turning and the message queue, but not deferred - the messages nextTurn parks for after a direct !cmd task, which only the serve loop touches. In the gap between ctl.turning.Store(false) at one turn's end and ctl.turning.Store(true) at the next turn's start, deferred can hold the next batch while busy() reports idle. A rewind landing in that gap drops entries and the queued turn then appends on top, so the conversation keeps messages the client believes were dropped.
  • Concrete case: a client queues !cmd and a prompt together, then sends the rewind just as the direct task ends. The rewind is accepted and the queued prompt's turn still runs into the rewound conversation, where the docs say the worker must answer with an error instead.
  • Fix: keep the flag set while another turn is pending. Only the serve loop touches deferred, so this needs no new lock:
for ctl.awaitTurn() {
    ctl.turning.Store(true)
    runServeTurn(ctx, svc, ctl, notifications, turn, notes)
    if len(ctl.deferred) == 0 {
        ctl.turning.Store(false)
    }
}
  • If we skip it: the gap is two statements wide and the outcome is benign - the repo mutex serializes the drop against the turn's appends and autoSaveMutex serializes the saves, so nothing corrupts. A client that waits for conversation_rewound before resending, which is the documented flow, never hits it.

Nice to have:

  1. "stop it before rewinding" is the wrong advice for a queued turn (internal/presentation/headless/panel_rewind.go:18)
  • What this is: the error text a client sees when busy() refuses the rewind.
  • Problem: busy() also refuses when a turn is merely queued, and there is nothing to stop then.
  • Fix: word it after the docs, for example "the session is running a turn or has one queued".
  • If we skip it: a user sees slightly wrong advice in a case that usually resolves within milliseconds.
  1. What a rewind does to a suspended run's open interrupts is undocumented (internal/presentation/headless/panel_rewind.go:47-51)
  • What this is: a run that ended on an approval, question or plan leaves interrupts open, but no turn is running, so busy() is false and the rewind proceeds. That is the right call - rewinding to rephrase instead of answering a question is a plausible flow, and the resent prompt (a plain run_agent_input without resume entries) is forwarded by the daemon's resume policy, so the flow works end to end.
  • Problem: the dropped run's interrupts stay open until the next run's terminal line replaces them. A client that attaches in between gets the stale suspended RUN_FINISHED replayed against a conversation whose messages were dropped, so it may render an approval box for a run that no longer exists.
  • Fix: one docs line in the rewind section, for example "a rewind does not close the interrupts the last run left open". Refusing there instead would block the rephrase flow, so documenting is the better call.
  • If we skip it: a newly attaching client may see a stale decision box. Nothing breaks.

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: autoSaveShortened absorbs the save block DeleteMessagesAfterIndex carried, and the runsOnlyOnItsSession map replaces the three-way string comparison.

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 conversation_rewound answer can end up with a conversation that still holds a queued turn's messages.

Model: ollama_cloud/glm-5.3 · Action: v0.59.7 · CLI: v0.254.0 · Gateway: v0.63.5 · Exit Code: 0 · Duration: 12m 10s

Tokens: 2,769,414 in · 43,702 out · 2,813,116 total (29 requests)

Tool calls: 53 total · 100% success rate

Traces
Session: 1794522289-9a202888

session (headless, success)                                                                        12m3s
├── chat ollama_cloud/glm-5.3                                                                      10.9s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       5.9s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     5.9s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                        5.9s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 5.9s
├── execute_tool Skill call_lmec8j18                                                               192µs
├── execute_tool Skill call_k3zjywug                                                                76µs
├── execute_tool Skill call_q8tqe36z                                                                76µs
├── execute_tool Skill call_7pm3nbtz                                                                56µs
├── execute_tool Skill call_qam93cu1                                                                41µs
├── execute_tool Skill call_04xx95ab                                                                48µs
├── execute_tool Skill call_f8klj7u7                                                                36µs
├── execute_tool Skill call_vyq0m4ix                                                                63µs
├── chat ollama_cloud/glm-5.3                                                                       3.3s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       3.3s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     3.3s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                        3.3s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 3.3s
├── execute_tool TodoWrite call_7ey6206k                                                            52µs
├── chat ollama_cloud/glm-5.3                                                                       1.5s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.5s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.5s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                        1.5s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.5s
├── execute_tool Bash call_sblfkaj3                                                                  8ms
├── execute_tool Bash call_msszpdgu                                                                  4ms
├── chat ollama_cloud/glm-5.3                                                                       1.3s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.3s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.3s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                        1.3s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.3s
├── execute_tool Bash call_54m43nm3                                                                  9ms
├── chat ollama_cloud/glm-5.3                                                                      21.1s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      21.1s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    21.1s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                       21.1s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                21.1s
├── execute_tool TodoWrite call_pb1f2ry6                                                            66µs
├── execute_tool Read call_s10oqgdp                                                                549µs
├── execute_tool Read call_rliv6731                                                                567µs
├── chat ollama_cloud/glm-5.3                                                                       2.1s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       2.1s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     2.1s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                        2.1s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 2.1s
├── execute_tool Read call_inmi1bqc                                                                608µs
├── execute_tool Read call_0bjydpon                                                                647µs
├── chat ollama_cloud/glm-5.3                                                                      19.1s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      19.1s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    19.1s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                       19.1s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                19.1s
├── execute_tool Grep call_0j8iqc9b                                                                574ms
├── execute_tool Read call_bnutfh46                                                                623µs
├── chat ollama_cloud/glm-5.3                                                                      25.0s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      25.0s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    25.0s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                       25.0s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                25.0s
├── execute_tool Read call_tag7kb1n                                                                604µs
├── chat ollama_cloud/glm-5.3                                                                       2.5s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       2.5s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     2.5s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                        2.5s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 2.5s
├── execute_tool Grep call_dyumibq7                                                                 26ms
├── chat ollama_cloud/glm-5.3                                                                       2.6s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       2.6s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     2.6s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                        2.6s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 2.6s
├── execute_tool Read call_3eqqysta                                                                601µs
├── execute_tool Read call_hs7ixp78                                                                678µs
├── execute_tool Read call_29nwaak4                                                                638µs
├── chat ollama_cloud/glm-5.3                                                                       5.8s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       5.8s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     5.8s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                        5.8s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 5.8s
├── execute_tool Grep call_58nqstg6                                                                589ms
├── execute_tool Read call_aul43zat                                                                705µs
├── chat ollama_cloud/glm-5.3                                                                       2.2s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       2.1s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     2.1s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                        2.1s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 2.1s
├── execute_tool Grep call_lz53j9gk                                                                  2ms
├── execute_tool Read call_za52xonu                                                                693µs
├── chat ollama_cloud/glm-5.3                                                                       3.0s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       3.0s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     3.0s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                        3.0s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 3.0s
├── execute_tool Grep call_j01exat1                                                                  3ms
├── execute_tool Read call_9jv8etil                                                                753µs
├── chat ollama_cloud/glm-5.3                                                                       4.7s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       4.7s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     4.7s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                        4.7s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 4.7s
├── execute_tool Grep call_iz355f52                                                                  2ms
├── execute_tool Read call_2l3yazxy                                                                582µs
├── chat ollama_cloud/glm-5.3                                                                       2.9s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       2.9s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     2.9s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                        2.9s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 2.9s
├── execute_tool Read call_hqib5e4a                                                                564µs
├── execute_tool Read call_zt99s00i                                                                497µs
├── chat ollama_cloud/glm-5.3                                                                       8.6s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       8.6s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     8.6s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                        8.6s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 8.6s
├── execute_tool Read call_v3yi65gw                                                                608µs
├── execute_tool Read call_zfot211i                                                                588µs
├── chat ollama_cloud/glm-5.3                                                                      17.4s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      17.4s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    17.3s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                       17.3s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                17.3s
├── execute_tool Grep call_hin65vwk                                                                  1ms
├── chat ollama_cloud/glm-5.3                                                                       2.5s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       2.5s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     2.5s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                        2.5s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 2.5s
├── execute_tool Grep call_g7z0vf2d                                                                  2ms
├── execute_tool Read call_k5ovn78b                                                                722µs
├── chat ollama_cloud/glm-5.3                                                                      23.2s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      23.2s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    23.2s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                       23.2s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                23.2s
├── execute_tool TodoWrite call_2d1rr6d0                                                            65µs
├── execute_tool Bash call_e4je892m                                                                  3ms
├── chat ollama_cloud/glm-5.3                                                                       3.9s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       3.8s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     3.8s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                        3.8s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 3.8s
├── execute_tool Bash call_kfkn30gy                                                                 1.0s
├── chat ollama_cloud/glm-5.3                                                                       2.3s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       2.2s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     2.2s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                        2.2s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 2.2s
├── execute_tool Wait call_iy7wwjiy                                                                1m30s
├── chat ollama_cloud/glm-5.3                                                                       4.2s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       4.2s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     4.2s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                        4.2s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 4.2s
├── execute_tool Bash call_y7z0qfqb                                                                  4ms
├── execute_tool Bash call_yti023b1                                                                  3ms
├── execute_tool Bash call_i4a089ny                                                                 1.4s
├── chat ollama_cloud/glm-5.3                                                                       2.4s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       2.3s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     2.2s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                        2.2s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 2.2s
├── execute_tool Wait call_xro164he                                                                2m10s
├── chat ollama_cloud/glm-5.3                                                                      42.8s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      42.8s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    42.8s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                       42.8s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                42.8s
├── execute_tool TodoWrite call_pd8r9c8w                                                            67µs
├── chat ollama_cloud/glm-5.3                                                                      19.1s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      19.0s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    19.0s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                       19.0s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                19.0s
├── execute_tool Bash call_ukd41bmm                                                                 1.1s [error: tool_error]
├── chat ollama_cloud/glm-5.3                                                                       6.7s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       6.7s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     6.7s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                        6.7s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 6.7s
├── execute_tool Wait call_q6n0xwux                                                                51.1s [error: tool_error]
├── chat ollama_cloud/glm-5.3                                                                       2.8s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       2.8s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     2.8s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                        2.8s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 2.8s
├── execute_tool Wait call_4k1tcvj1                                                                2m55s
├── chat ollama_cloud/glm-5.3                                                                       4.7s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       4.7s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     4.7s
│           ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                        4.7s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 4.7s
├── execute_tool TodoWrite call_uazk02ck                                                            64µs
╰── chat ollama_cloud/glm-5.3                                                                      19.4s
    ╰── POST /v1/chat/completions [inference-gateway, server]                                      19.4s
        ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    19.3s
            ╰── POST /proxy/{provider}/{path...} [inference-gateway, server]                       19.3s
                ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                19.3s
Stats
Tool Calls

╭───────────┬───────┬───────┬──────────╮
│ Tool      │ Calls │ Fail% │ Avg      │
├───────────┼───────┼───────┼──────────┤
│ Read      │ 18    │ 0%    │ 622µs    │
│ Bash      │ 9     │ 11%   │ 403ms    │
│ Skill     │ 8     │ 0%    │ 70µs     │
│ Grep      │ 8     │ 0%    │ 151ms    │
│ TodoWrite │ 5     │ 0%    │ 56µs     │
│ Wait      │ 4     │ 25%   │ 111364ms │
╰───────────┴───────┴───────┴──────────╯

Token Usage

╭──────────────────────┬─────────┬─────────┬────────────┬─────────┬──────╮
│ Model                │ Prompt  │ Cached  │ Completion │ Total   │ Cost │
├──────────────────────┼─────────┼─────────┼────────────┼─────────┼──────┤
│ ollama_cloud/glm-5.3 │ 2769414 │ 2503744 │ 43702      │ 2813116 │ -    │
╰──────────────────────┴─────────┴─────────┴────────────┴─────────┴──────╯

Sessions

╭───────────┬──────────┬──────────╮
│ Execution │ Mode     │ Sessions │
├───────────┼──────────┼──────────┤
│ headless  │ headless │ 1        │
╰───────────┴──────────┴──────────╯

Triggered 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.
@edenreich
edenreich merged commit 26de9c1 into main Nov 12, 2026
13 checks passed
@edenreich
edenreich deleted the feat/rewind-conversation-frame branch November 12, 2026 23:16
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.260.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Nov 12, 2026
@edenreich edenreich moved this from Todo to Done in 2026 Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant