Skip to content

feat: add streaming HTTP client target - #16515

Draft
andrewheard wants to merge 1 commit into
ah/gemini-for-foundation-modelsfrom
ah/ai-http-streaming-client
Draft

feat: add streaming HTTP client target#16515
andrewheard wants to merge 1 commit into
ah/gemini-for-foundation-modelsfrom
ah/ai-http-streaming-client

Conversation

@andrewheard

Copy link
Copy Markdown
Contributor

Add a lightweight HTTP client backed by URLSession that supports asynchronous byte and text line streaming.

  • Introduce HTTPStreamingClient with bytes(for:) streaming API.
  • Provide HTTPAsyncBytes and HTTPAsyncLineSequence mirroring standard URLSession.AsyncBytes ergonomics.
  • Implement incremental UTF-8 line decoding supporting CRLF, LF, CR, and split multi-byte unicode characters across chunk boundaries.
  • Adopt Swift 6 strict concurrency with compiler-checked Sendable types and actor-coordinated task delegate management.
  • Add comprehensive unit test suite in HTTPStreamingClientTests.

@gemini-code-assist

Copy link
Copy Markdown
Contributor
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

@andrewheard
andrewheard force-pushed the ah/ai-http-streaming-client branch 5 times, most recently from 6871de1 to c615f41 Compare August 18, 2026 19:30
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

This pull request introduces a new streaming HTTP client to the repository, designed to handle asynchronous data streams efficiently. By leveraging URLSession and modern Swift concurrency, the implementation provides a clean API for consuming byte streams and line-delimited text. The changes also include necessary infrastructure for robust testing, ensuring reliability in network communication and data parsing.

Highlights

  • HTTPStreamingClient Implementation: Introduced a new lightweight HTTP client using URLSession that supports asynchronous byte and text line streaming, featuring Swift 6 strict concurrency compliance.
  • Incremental Line Decoding: Implemented a robust UTF-8 line decoder that handles various line delimiters (CRLF, LF, CR) and correctly manages multi-byte characters split across network chunks.
  • Testing Infrastructure: Added a comprehensive test suite, including a custom MockHTTPURLProtocol for integration testing and unit tests for the line decoder logic.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Activity
  • Pull request created by andrewheard.
  • Automated bot comment provided instructions for Gemini Code Assist.
  • Author requested a summary via /gemini summary.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new HTTPStreamingClient package for streaming bytes and lines of text using URLSession, complete with integration and unit tests. The review feedback identifies a platform compatibility issue where AsyncThrowingStream.makeStream() is used despite targeting older OS versions (iOS 15 and macOS 12). Additionally, the reviewer points out that the underlying network tasks are not cancelled if the consuming task is cancelled during stream iteration, recommending that the task be passed down to the iterators to support cooperative cancellation. Finally, a performance optimization is suggested for HTTPLineDecoder to avoid inefficient byte-by-byte iteration on large streaming payloads.

Comment thread Sources/HTTPStreamingClient/HTTPStreamingClient.swift
Comment thread Sources/HTTPStreamingClient/HTTPStreamingClient.swift
Comment thread Sources/HTTPStreamingClient/HTTPStreamingClient.swift
Comment thread Sources/HTTPStreamingClient/HTTPStreamingClient.swift
Comment thread Sources/HTTPStreamingClient/HTTPStreamingClient.swift
Comment thread Sources/HTTPStreamingClient/HTTPStreamingClient.swift
Comment thread Sources/HTTPStreamingClient/HTTPStreamingClient.swift
Comment thread Sources/HTTPStreamingClient/HTTPStreamingClient.swift
Comment thread Sources/HTTPStreamingClient/HTTPStreamingClient.swift
Comment thread Sources/HTTPStreamingClient/HTTPStreamingClient.swift
Add a lightweight HTTP client backed by URLSession that supports
asynchronous byte and text line streaming.

Key additions:
- Introduce `HTTPStreamingClient` with `bytes(for:)` streaming API.
- Provide `HTTPAsyncBytes` and `HTTPAsyncLineSequence` mirroring
  standard `URLSession.AsyncBytes` ergonomics.
- Implement incremental UTF-8 line decoding supporting CRLF, LF, CR,
  and split multi-byte unicode characters across chunk boundaries.
- Adopt Swift 6 strict concurrency with compiler-checked `Sendable`
  types and synchronous lock-based delegate task management.
- Provide package-visible `MockHTTPURLProtocol` test transport adapter.
- Add comprehensive unit test suite in `HTTPStreamingClientTests`.
@andrewheard
andrewheard force-pushed the ah/ai-http-streaming-client branch from c615f41 to a13a909 Compare August 18, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant