`sdk-py integration` fails on `main` (`test_extensions`: `unexpected step sequence: []`). It started with `langgraph-api` 0.20.0.dev2 in the `latest-py3.12` image, not #9728. That version wraps `get_stream_writer()` data as `custom` events with `{"payload": ...}` and no `name`, so `custom:progress` matches nothing. ## Changes - The test graph relays root-level `progress` writes onto a named `StreamChannel("progress")`, which the server delivers as `custom:progress`. - The extensions test and script read each event's `payload`. ## Reviewer notes - The last real pass was Nov 15 (image on 0.20.0.dev1). Runs since then either skipped the job (path filter) or failed. - The Python SDK's `thread.extensions[name]` yields the `{name, payload}` envelope; JS yields `payload`. That parity gap is separate. ## Test Plan - [x] Integration suite against `langgraph dev` with `langgraph-api` 0.20.0.dev4 and local langgraph: 55 passed (2 failed before) [no screenshot] 🤖 Generated with [Claude Code](https://claude.com/claude-code)
49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
"""`thread.extensions[name]` channel against the integration API."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from .conftest import ASSISTANT_ID
|
|
|
|
pytestmark = pytest.mark.integration
|
|
|
|
_EXPECTED_PRE_INTERRUPT_STEPS = [
|
|
"stream_message",
|
|
"stream_message",
|
|
"call_tool",
|
|
"call_tool",
|
|
"ask_human",
|
|
]
|
|
|
|
|
|
async def test_extensions_async(async_threads) -> None:
|
|
threads, _ = async_threads
|
|
async with threads.stream(assistant_id=ASSISTANT_ID) as thread:
|
|
await thread.run.start(input={"messages": [], "value": "init", "items": []})
|
|
|
|
events: list[dict] = []
|
|
async for event in thread.extensions["progress"]:
|
|
events.append(event)
|
|
|
|
# Iterator exits at the `ask_human` interrupt via `_signal_paused`,
|
|
# so we capture exactly the pre-interrupt progress sequence.
|
|
steps = [e["payload"]["step"] for e in events]
|
|
assert steps == _EXPECTED_PRE_INTERRUPT_STEPS, (
|
|
f"unexpected step sequence: {steps}"
|
|
)
|
|
|
|
|
|
def test_extensions_sync(sync_threads) -> None:
|
|
threads, _ = sync_threads
|
|
with threads.stream(assistant_id=ASSISTANT_ID) as thread:
|
|
thread.run.start(input={"messages": [], "value": "init", "items": []})
|
|
|
|
events: list[dict] = []
|
|
for event in thread.extensions["progress"]:
|
|
events.append(event)
|
|
|
|
steps = [e["payload"]["step"] for e in events]
|
|
assert steps == _EXPECTED_PRE_INTERRUPT_STEPS, (
|
|
f"unexpected step sequence: {steps}"
|
|
)
|