langchain-ai/langgraph · error · RuntimeError

SyncToolCallHandle.deltas can only be iterated by a single…

Error message

SyncToolCallHandle.deltas can only be iterated by a single consumer.

What it means

Single-consumer guard on SyncToolCallHandle.deltas: deltas is backed by one queue.Queue that only one iterator may drain. A second access/concurrent iteration would split or interleave chunks, so it is refused.

Solutions

  1. Iterate handle.deltas only once per tool call
  2. Fan out deltas yourself (e.g. tee into your own buffers) if multiple consumers are needed
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at libs/sdk-py/langgraph_sdk/_sync/stream.py:501 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of langchain-ai/langgraph@38031739e5 (2026-08-26). Data as JSON: /api/errors/7fe3aa2bc8521b0b. Report an issue: GitHub.

Appendix: source

Thrown at libs/sdk-py/langgraph_sdk/_sync/stream.py:501

        self._result: _BlockingResult = _BlockingResult()
        self._deltas: queue.Queue[str | None] = queue.Queue(maxsize=max_queue_size)
        self._deltas_consumed: bool = False

    @property
    def output(self) -> Any:
        """Block until the tool call completes and return its output."""
        return self._result.result()

    @property
    def deltas(self) -> Iterator[str]:
        """Iterate over tool output deltas emitted before the terminal event.

        Raises:
            RuntimeError: if called more than once — the underlying queue is
                single-consumer and cannot be fanned out safely.
        """
        if self._deltas_consumed:
            raise RuntimeError(
                "SyncToolCallHandle.deltas can only be iterated by a single consumer."
            )
        self._deltas_consumed = True
        return self._delta_iter()

    def _delta_iter(self) -> Iterator[str]:
        while True:
            item = self._deltas.get()
            if item is None:
                return
            yield item

    def _push_delta(self, delta: str) -> None:
        if self.done:
            return
        self._deltas.put_nowait(delta)

    def _finish(self, output: Any) -> None:

View on GitHub (pinned to 38031739e5)