Agentix.Provider.ReqLLM (Agentix v0.1.0)

Copy Markdown View Source

The default Agentix.Provider — a thin wrapper over ReqLLM.stream_text/3.

ReqLLM.stream_text/3 returns {:ok, %ReqLLM.StreamResponse{}} (not a bare stream). The struct carries a lazy stream of %ReqLLM.StreamChunk{}, a metadata_handle collected concurrently, and a cancel closure that actually closes the socket. This adapter maps that onto the normalized Agentix.Provider.Stream the agent consumes:

  • chunks — the lazy stream, wrapped so each chunk is accumulated as the agent forwards it as a live delta;
  • cancelStreamResponse's own closure, passed through unchanged (the agent invokes it on :cancel so the HTTP connection is freed);
  • finalize — awaits the metadata handle and rebuilds the finalized assistant %ReqLLM.Message{} + usage from the accumulated chunks, reusing ReqLLM's own ResponseBuilder so tool-call ids (assembled by ReqLLM, absent from individual StreamChunks) survive. Call it after chunks is consumed.

Streaming pools are HTTP/1-only by default (Finch ALPN bug with mixed-protocol large bodies).