diff --git a/REPL.md b/REPL.md index d975335..613a9d7 100644 --- a/REPL.md +++ b/REPL.md @@ -214,6 +214,11 @@ with "Nothing to undo" once the session has no more messages to remove. > **Requires an active session.** `.undo` is only available when a session is open. Outside a session, conversation > history is not tracked in memory, so there is nothing to walk back. +> **Discarding an interrupted response:** If you pressed Ctrl+C during a streaming response (see +> [Mid-Stream Interruption](Sessions#mid-stream-interruption)), the partial response was saved to the session. +> Use `.undo` to remove it and restore your original prompt if you want to start fresh rather than continue from the +> partial output. + Note that `.undo` only modifies the in-memory session state. The append-only `messages.md` log is not affected. If you save the session after undoing (via `.save session` or automatic save-on-exit), the saved file will reflect the trimmed history. diff --git a/Sessions.md b/Sessions.md index 5dca223..1612d7d 100644 --- a/Sessions.md +++ b/Sessions.md @@ -140,3 +140,32 @@ at runtime using the `.set` command or configured in the session's YAML file: | `skill_instructions` | Global `skill_instructions` value | Custom text for the skill-discovery hint. `null` to reset to the built-in default. | For more information on the Todo System, see the [Todo System documentation](TODO-System). + +# Mid-Stream Interruption + +When streaming is enabled and a session is active, pressing **Ctrl+C** during a response interrupts the stream and +preserves any text the model had already generated. The partial response is saved to the session as the model's last +turn, and Coyote returns to the prompt so you can continue the conversation. + +This lets you redirect the LLM mid-flight without losing the context that led up to the interruption: + +1. The model begins generating a response. +2. You press **Ctrl+C**. The stream stops and Coyote prints `Response interrupted`. +3. The partial response is saved to the session history. +4. You type your next message at the normal prompt. The model sees the full conversation history, including the partial + response, and your new prompt. + +If you want to discard the partial response entirely rather than continuing from it, use [`.undo`](REPL#undo---undo-the-last-exchange) +to remove the last exchange from the session and restore your original prompt for editing or re-sending. + +> **Requires an active session.** Mid-stream interruption only preserves partial responses when a session is open. +> Without a session, Ctrl+C aborts the response as usual and nothing is saved to history. + +> **Ctrl+C before the first token.** If you press Ctrl+C while the spinner is still showing (before any response text has +> arrived), the request is aborted cleanly and nothing is saved. This is identical behavior to how `Ctrl+C` functions without a session. + +> **Ctrl+D is always a hard abort.** Pressing Ctrl+D during streaming discards the partial response regardless of session state and +> exits the REPL. + +> **REPL only.** When running Coyote as a one-shot CLI command (`coyote `), Ctrl+C aborts as usual. Mid-stream interruption +> is a REPL-only feature.