Stop background tasks separately from chat turns

Keep Esc and /stop scoped to the foreground turn while exposing an explicit stop-tasks operation for supported chat backends. Add the protocol, server routing, app command, and coverage for task stopping and unsupported harnesses.
This commit is contained in:
2026-11-13 16:47:41 +00:00
parent c3c2c1bbc9
commit 2a182d7f17
19 changed files with 331 additions and 2 deletions
+10
View File
@@ -28,6 +28,9 @@ const (
ChatPrompt = "chat_prompt"
ChatMessages = "chat_messages"
ChatInterrupt = "chat_interrupt"
// ChatStopTasks stops background tasks without interrupting the current turn.
// Older clients ignore this additive command.
ChatStopTasks = "chat_stop_tasks"
ChatReply = "chat_reply"
// ChatClose finishes an operator session and records it as closed on the
// server: any in-flight turn is interrupted through the existing interrupt,
@@ -149,6 +152,13 @@ const (
ChatPermission = "chat_permission"
)
// ChatStopTasksResult reports the result of an explicit background-task stop.
type ChatStopTasksResult struct {
SessionID string `json:"session_id"`
Stopped int `json:"stopped"`
Message string `json:"message,omitempty"`
}
const (
ChatAutomationSupported = "supported"
ChatAutomationUnavailable = "unavailable"
+3 -2
View File
@@ -262,8 +262,9 @@ type Message struct {
// body names the session like ChatQuery. A chat_prompt response sets
// ChatQueued when the prompt had to wait for an in-flight turn and was
// accepted into the session's queue instead of being sent immediately.
ChatSubscribe *ChatQuery `json:"chat_subscribe,omitempty"`
ChatQueued bool `json:"chat_queued,omitempty"`
ChatSubscribe *ChatQuery `json:"chat_subscribe,omitempty"`
ChatQueued bool `json:"chat_queued,omitempty"`
ChatStopTasks *ChatStopTasksResult `json:"chat_stop_tasks,omitempty"`
// ChatSteered means the prompt was handed to the turn already running; its
// reply is that turn's continuing output.
ChatSteered bool `json:"chat_steered,omitempty"`