Skip to content

feat(http-client-python): generate structured JSONL/SSE streaming (Azure flavor) - #11593

Closed
Libba Lawrence (l0lawrence) wants to merge 1 commit into
microsoft:mainfrom
l0lawrence:l0lawrence-jsonl-sse-streaming-codegen
Closed

feat(http-client-python): generate structured JSONL/SSE streaming (Azure flavor)#11593
Libba Lawrence (l0lawrence) wants to merge 1 commit into
microsoft:mainfrom
l0lawrence:l0lawrence-jsonl-sse-streaming-codegen

Conversation

@l0lawrence

Copy link
Copy Markdown
Member

Summary

  • Generate Azure-flavor client methods that return Stream[T] / AsyncStream[T] for JSONL (application/jsonl) and SSE (text/event-stream) response streams.
  • Use TCGC streamMetadata / sseMetadata to deserialize JSONL items and dispatch named SSE events to their concrete generated models, including terminal-event handling.
  • Vendor the JSONL/SSE streaming runtime in generated packages while preserving unbranded raw-byte iterator behavior.
  • Preserve registered stream item-type references across request overloads.
stream = client.receive()  # Stream[Thing]
for thing in stream:
    ...

Coverage

  • Emitter structured-streaming tests
  • Pygen response and serializer coverage
  • Azure JSONL/SSE regeneration
  • Sync and async Spector smoke coverage for homogeneous and heterogeneous streams

Notes

This uses the TCGC prerelease containing sseMetadata. The external Azure mock API streaming test still asserts the previous raw-byte contract and is expected to remain failing until that test is aligned with the type-driven behavior.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e57edafe-9764-4b99-a1ae-0efd56e8729e
@pkg-pr-new

pkg-pr-new Bot commented Aug 7, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-python@11593

commit: 4a36e0a

@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:client:python Issue for the Python client emitter: @typespec/http-client-python label Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @typespec/http-client-python
Show changes

@typespec/http-client-python - feature ✏️

Generate structured streaming client methods for the Azure flavor: operations whose HTTP response is a JSONL (application/jsonl) or SSE (text/event-stream) stream now return Stream[T] / AsyncStream[T], yielding deserialized model instances instead of raw bytes.,> ,> ,> The Stream / AsyncStream runtime (plus the JSONL / SSE decoders) is vendored into the generated package at _utils/streaming_base.py (like _utils/model_base.py), so it depends only on the released azure.core.rest — not on an unreleased azure.core.streaming.,> ,> python,> # For an operation returning JsonlStream<Thing> (Azure flavor):,> stream = client.receive() # -> Stream[Thing],> for thing in stream: # deserialized model instances,> ...,>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:python Issue for the Python client emitter: @typespec/http-client-python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant