Agent Sandbox Registry

python-sdk

Decision: Connect Streaming Frame Parser

无中文版

.agents/notes/implemented/feature/2026-09-02-transport-streaming.md

Decision: Connect Streaming Frame Parser

Status: implemented Implemented: 2026-09-02

Problem

envd API uses Connect protocol with Server-Streaming responses in NDJSON format. Need a parser that handles streaming frames efficiently.

Decision

ConnectStreamReader in transport/streaming.py: - Parse application/connect+json streaming responses - Yield typed frames via AsyncIterator - Backpressure via asyncio.Queue(maxsize) to prevent memory overflow - Handle incomplete frames at chunk boundaries - Support both data frames and end-of-stream frames with optional error/trailer

Frame format: newline-delimited JSON objects, each containing result or error field.

API Design

class ConnectStreamReader:
    def __init__(self, response: httpx.Response, *, maxsize: int = ...): ...
    def __aiter__(self) -> AsyncIterator[dict]: ...   # yields parsed {"result"|"error": ...} frames
# Handles NDJSON frames split across HTTP chunks; backpressure via asyncio.Queue(maxsize).

Implementation

Alternatives considered

Dependencies

Test Strategy

Acceptance criteria