From 20db60b0705ab65b6ade67ff614d347e13dc9803 Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Mon, 22 Jun 2026 02:53:20 +0900 Subject: feat: stop generation mid-turn (POST /conversations/:id/stop) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add stopTurn to the orchestrator: aborts the in-flight turn's AbortController without changing conversation status. The turn seals normally (finishReason: 'aborted'), partial messages are persisted, and the conversation transitions active → idle via the normal settle path. Distinct from closeConversation which marks the conversation closed. - POST /conversations/:id/stop endpoint - dispatch stop CLI command - FE handoff: frontend-stop-generation-handoff.md --- packages/cli/src/http.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'packages/cli/src/http.ts') diff --git a/packages/cli/src/http.ts b/packages/cli/src/http.ts index 585c678..42fcfec 100644 --- a/packages/cli/src/http.ts +++ b/packages/cli/src/http.ts @@ -204,6 +204,26 @@ export async function compactConversation( return (await res.json()) as CompactResponse; } +interface StopTurnOpts { + readonly server: string; + readonly conversationId: string; +} + +export async function stopTurn( + deps: FetchDeps, + opts: StopTurnOpts, +): Promise<{ conversationId: string; abortedTurn: boolean }> { + const url = `${opts.server}/conversations/${encodeURIComponent(opts.conversationId)}/stop`; + const res = await deps.fetchImpl(url, { method: "POST" }); + + if (!res.ok) { + const body = await res.text(); + throw new Error(`POST /conversations/:id/stop failed with status ${res.status}: ${body}`); + } + + return (await res.json()) as { conversationId: string; abortedTurn: boolean }; +} + /** * The outcome of short-ID resolution: either the full conversation id to use, * or a human-readable error describing why resolution failed. -- cgit v1.2.3