Skip to content

Commit f6d05dc

Browse files
committed
docs(streaming): refresh native-vs-fallback wording (vercel/chat#463)
Ports the runtime-code portion of vercel/chat#463 (commit 0cc3d06) — docstring cleanups around streaming. Upstream's #463 rewrote the StreamingPlanOptions.updateIntervalMs comment from "fallback mode (post + edit on adapters without native streaming)" to "Used by post+edit streaming paths" because the interval is consulted regardless of whether the adapter exposes its own ``stream`` method (Slack/Teams adapters internally rate-limit edits using the same value). Same logic applies to ThreadImpl._handle_stream's docstring and inline comment. The other 0cc3d06 runtime fix — StreamEvent type 'step-finish' → 'finish-step' — was already correct on the Python side (from_full_stream.py:79, thread.py:1273/1298), so nothing to do there. Added load-bearing pins: - TestStreamingPlanOptionsDocs::test_update_interval_ms_docstring_matches_upstream - TestStreamingPlanOptionsDocs::test_thread_handle_stream_docstring_matches_upstream Both fail if a future doc drift restores the stale wording. Refs vercel/chat#463, tracking #98. https://claude.ai/code/session_01FyMxQn2BEAzmwKS1GZczKj
1 parent 9888fc0 commit f6d05dc

4 files changed

Lines changed: 40 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Documentation alignment
66

77
- **DM routing precedence docstrings** (vercel/chat#491, commit `67c1794`). The Python runtime already routed direct messages to `on_direct_message` handlers before subscribed-message, mention, and pattern handlers (`Chat._handle_incoming_message`, `chat.py:2154`), but `on_direct_message` and `Thread.subscribe` lacked docstrings clarifying that contract. Refreshed both to match upstream's #491 docstring rewrite, plus a new `tests/integration/test_dm_flow.py::TestDMRoutingDocs` group and a `test_dm_handler_runs_before_pattern_handler` regression test that pin the documented precedence (DM > pattern) the previous suite did not explicitly cover. No runtime behavior change.
8+
- **Streaming docstring refresh** (vercel/chat#463, commit `0cc3d06`). Replaces stale "fallback mode (post + edit on adapters without native streaming)" wording on `StreamingPlanOptions.update_interval_ms` with "Used by post+edit streaming paths", matching upstream's #463 clarification (the interval is consulted regardless of whether the adapter exposes its own `stream` method — Slack/Teams may still rate-limit edits internally). Also reworks the `ThreadImpl._handle_stream` docstring + the in-function "Use native streaming if adapter supports it" comment so they no longer imply a binary native-vs-fallback split. The unrelated `step-finish``finish-step` upstream type fix was already correct in the Python port (`from_full_stream.py`, `thread.py`). No runtime behavior change.
89

910
> Version bump from `0.4.29a2` to `0.4.29a3` will be cut by a coordinating PR once the parallel 4.29 ports land; this entry intentionally leaves `pyproject.toml` unchanged.
1011

src/chat_sdk/plan.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,8 +543,7 @@ class StreamingPlanOptions:
543543
Useful for adding feedback buttons after a streamed response.
544544
update_interval_ms:
545545
Minimum interval between updates in ms (default: 500).
546-
Used for fallback mode (post + edit on adapters without native
547-
streaming).
546+
Used by post + edit streaming paths.
548547
"""
549548

550549
group_tasks: Literal["plan", "timeline"] | None = None

src/chat_sdk/thread.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,8 @@ async def _handle_stream(
648648
) -> SentMessage:
649649
"""Handle streaming from an AsyncIterable.
650650
651-
Uses adapter's native streaming if available, otherwise falls back to post+edit.
651+
Uses the adapter's stream implementation if available, otherwise
652+
falls back to post+edit.
652653
653654
``extra_options`` carries caller-supplied fields (e.g. from a
654655
:class:`StreamingPlan`: ``task_display_mode``, ``stop_blocks``,
@@ -682,7 +683,7 @@ async def _handle_stream(
682683
if extra_options.update_interval_ms is not None:
683684
options.update_interval_ms = extra_options.update_interval_ms
684685

685-
# Use native streaming if adapter supports it
686+
# Use adapter-provided streaming if available.
686687
if hasattr(self.adapter, "stream") and self.adapter.stream: # type: ignore[union-attr]
687688
accumulated = ""
688689

tests/test_plan.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
Plan,
2525
PostableObjectContext,
2626
StartPlanOptions,
27+
StreamingPlanOptions,
2728
UpdateTaskInput,
2829
is_postable_object,
2930
post_postable_object,
@@ -576,3 +577,37 @@ async def test_edit_failure_propagates_and_plan_continues(self) -> None:
576577
assert task is not None
577578
assert task.title == "Step 3"
578579
assert len(plan.tasks) == 3
580+
581+
582+
class TestStreamingPlanOptionsDocs:
583+
"""Pin the StreamingPlanOptions docstring to upstream's #463 refresh.
584+
585+
vercel/chat#463 (commit `0cc3d06`) dropped the stale "fallback mode (post
586+
+ edit on adapters without native streaming)" wording in favor of "Used
587+
by post+edit streaming paths" — the same string is used regardless of
588+
whether the adapter has a ``stream`` method (the adapter's stream method
589+
may also internally rate-limit using this value). Without this lock,
590+
Python could drift back to the old wording on the next sync.
591+
"""
592+
593+
def test_update_interval_ms_docstring_matches_upstream(self) -> None:
594+
doc = StreamingPlanOptions.__doc__ or ""
595+
# New (post-#463) wording
596+
assert "post + edit streaming paths" in doc or "post+edit streaming paths" in doc
597+
# Old wording must be gone
598+
assert "fallback mode" not in doc
599+
assert "without native streaming" not in doc
600+
601+
def test_thread_handle_stream_docstring_matches_upstream(self) -> None:
602+
"""ThreadImpl._handle_stream docstring uses the post-#463 wording.
603+
604+
Upstream rewrote the comment from "uses adapter's native streaming
605+
if available" to "uses the adapter's stream implementation if
606+
available" so the docs no longer imply a binary native/fallback
607+
split (some adapters' ``stream`` method does its own post+edit).
608+
"""
609+
doc = ThreadImpl._handle_stream.__doc__ or ""
610+
# New (post-#463) wording
611+
assert "stream implementation" in doc
612+
# Old wording must be gone
613+
assert "native streaming" not in doc

0 commit comments

Comments
 (0)