Title: Agents API: replayable turn-ended event on the chat stream and chat watch · Issue #32587 · coder/coder · GitHub
Open Graph Title: Agents API: replayable turn-ended event on the chat stream and chat watch · Issue #32587 · coder/coder
X Title: Agents API: replayable turn-ended event on the chat stream and chat watch · Issue #32587 · coder/coder
Description: Problem API clients that drive Coder Agents chats (bots, orchestrators, integrations) need to know when a turn has ended, how it ended, and which message is the final answer. Today they have to infer it: Status changes are the only signa...
Open Graph Description: Problem API clients that drive Coder Agents chats (bots, orchestrators, integrations) need to know when a turn has ended, how it ended, and which message is the final answer. Today they have to inf...
X Description: Problem API clients that drive Coder Agents chats (bots, orchestrators, integrations) need to know when a turn has ended, how it ended, and which message is the final answer. Today they have to inf...
Opengraph URL: https://github.com/coder/coder/issues/32587
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Agents API: replayable turn-ended event on the chat stream and chat watch","articleBody":"### Problem\nAPI clients that drive Coder Agents chats (bots, orchestrators, integrations) need to know when a turn has ended, how it ended, and which message is the final answer. Today they have to infer it:\n\n\n- Status changes are the only signal. Clients watch status events on `/api/v2/chats/{chat}/stream` for running → waiting, then fetch history to find the final assistant message.\n- Status events aren't replayed with `after_id`, so a client that reconnects can miss the transition entirely.\n- A status change doesn't say how the turn ended: completed normally, interrupted, errored, or stopped for requires_action.\n- A turn can end without the chat ever going idle, when it immediately promotes a queued message. With steer messages (#30074), one user prompt can also span several model calls, so running → waiting doesn't map cleanly onto \"the turn I care about finished\".\n- Finding the final response means guessing which assistant message in the history closes the turn.\n- Watching many chats takes one stream connection per chat, because `/api/v2/chats/watch` has `status_change` but no turn-level event.\n\nI drive a small team of Agents chats (a coordinator, a reviewer, and several workers) from an external service, and this inference is the most fragile part of it. It needs reconnect handling, interruption filtering and history re-reads to avoid both missed and false completions.\n\n### Request\nEmit a turn-ended event when a chat turn finishes:\n\n**Fields:**\n- `chat_id`\n- a turn identifier, for example the ID of the user message that started it\n- `final_message_id`: the last assistant message of the turn, if any\n- outcome: `completed`, `interrupted`, `error` or `requires_action`\n- `started_at` and `ended_at`\n\n**Replayable** with `after_id` on `/api/v2/chats/{chat}/stream`, so a reconnecting client can't miss it.\n\nAlso available as a kind on `/api/v2/chats/watch`, so one connection covers all of a user's chats.\n\nLater, the same event could feed chat automations or outgoing webhooks, but the stream and watch events alone would cover most API clients.\n\n### Current state\nAt main (325fbc292a), `ChatStreamEventType` has `message_part`, `message`, `status, error`, `queue_update`, `retry`, `action_required`, `preview_reset` and `history_reset`. `ChatWatchEventKind` has `status_change`, `action_required` and others, but there is no turn-level event on either.","author":{"url":"https://github.com/RJ","@type":"Person","name":"RJ"},"datePublished":"2026-11-22T19:31:33Z","url":"https://github.com/coder/coder/issues/32587"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:af306187-70f4-3411-f108-32e8cfe78c73 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BAC6:713DD:1D742A:27D70C:6B04314D |
| html-safe-nonce | 5999d5ca0673fe722d5a369e8bacc6888430ea1c4cdddf82fe87932b6891b5a0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQUM2OjcxM0REOjFENzQyQToyN0Q3MEM6NkIwNDMxNEQiLCJ2aXNpdG9yX2lkIjoiMzk4MjU2NDE0ODg5NjE5Nzg5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | a47540b03fb285ae64058e63552593521b5c1c42985a32ee12e54d22e9ed8ab2 |
| hovercard-subject-tag | issue:6546758012 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/coder/coder/32587/issue_layout |
| twitter:image | https://opengraph.githubassets.com/71a80b76566ac9b1eaeae6612ac7a2364cc2044a6134d7a82794a2da63a9de17/coder/coder/issues/32587 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/71a80b76566ac9b1eaeae6612ac7a2364cc2044a6134d7a82794a2da63a9de17/coder/coder/issues/32587 |
| og:image:alt | Problem API clients that drive Coder Agents chats (bots, orchestrators, integrations) need to know when a turn has ended, how it ended, and which message is the final answer. Today they have to inf... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | RJ |
| hostname | github.com |
| expected-hostname | github.com |
| None | b7a1d2b9101496921b08579fbee988d014345aef2f5bd660d1f8c7332d81560e |
| turbo-cache-control | no-preview |
| go-import | github.com/coder/coder git https://github.com/coder/coder.git |
| octolytics-dimension-user_id | 95932066 |
| octolytics-dimension-user_login | coder |
| octolytics-dimension-repository_id | 440752086 |
| octolytics-dimension-repository_nwo | coder/coder |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 440752086 |
| octolytics-dimension-repository_network_root_nwo | coder/coder |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c3dd496c3da6ea6b77e69c09279d2b81604654f1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width