# Function collectStream

Adapters exports - Model adapters (Claude, OpenAI, Gemini, Ollama) Split from index.ts for file size compliance (Issue #285)

- collectStream<T>(
  stream: AsyncIterable<T>,
  options?: { signal?: AbortSignal; maxChunks?: number },
  ): Promise<Result<T[], StreamError>>

  Collects all chunks from a stream into an array.

  #### Type Parameters

  - T

  #### Parameters

  - stream: AsyncIterable<T>

    The stream to collect

  - options: { signal?: AbortSignal; maxChunks?: number } = {}

    Options including optional AbortSignal. `maxChunks` defaults to DEFAULT_COLLECT_STREAM_MAX_CHUNKS to prevent unbounded memory growth on forgotten limits. Pass `Infinity` explicitly for truly unbounded collection.

  #### Returns Promise<Result<T[], StreamError>>

  Result containing collected chunks or error

  - Defined in packages/nexus-agents/src/adapters/streaming.ts:44