StreamResult (provider/stream_epilogue.hpp)

agentty · include/agentty/provider/stream_epilogue.hpp · cpp · MIT
ai

pragma once ── Provider stream epilogue: the shared "how a streamed turn ends" layer ──── Every streaming transport (Anthropic, OpenAI-compat, Ollama, ChatGPT/Codex) faces the SAME two problems once its SSE/NDJSON body has been fed to the HTTP client: 1. Emit EXACTLY ONE terminal

// Source: https://github.com/agentty-org/agentty | License: MIT | Copyright 2026 Ayush Bhat
// Provided via justclaw.it.com; keep this notice with the code.
#pragma once

// ── Provider stream epilogue: the shared "how a streamed turn ends" layer ────
//
// Every streaming transport (Anthropic, OpenAI-compat, Ollama, ChatGPT/Codex)
// faces the SAME two problems once its SSE/NDJSON body has been fed to the
// HTTP client:
//
//   1. Emit EXACTLY ONE terminal event. A turn finishes with a single
//      StreamFinished (success) or StreamError (failure) — never zero, never
//      two. The body itself usually fires it (a `response.completed` /
//      `message_stop` / `[DONE]` frame), so the post-loop code must NOT emit a
//      second one. Forgetting this guard is exactly the bug the Chat

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key