docs(event-streaming): fix raw event payload, text-delta type, and async examples#4012
Open
Nick Hollon (nick-hollon-lc) wants to merge 6 commits into
Open
docs(event-streaming): fix raw event payload, text-delta type, and async examples#4012Nick Hollon (nick-hollon-lc) wants to merge 6 commits into
Nick Hollon (nick-hollon-lc) wants to merge 6 commits into
Conversation
…ync for concurrent consumption Fix two issues in the Consume concurrently / Stream multiple projections sections across deepagents, langchain, and langgraph event-streaming pages: - deepagents: correct raw protocol event example — data is a (event_dict, metadata) tuple so the payload is at data[0], and the delta type is "text-delta" not "text" - all three pages: lead the Python multiple-projections section with the async astream_events + asyncio.gather pattern; relegate stream.interleave() to a secondary mention for synchronous code only
…message.text astream_events() returns a coroutine and must be awaited to get the AsyncGraphRunStream object. message.text in async projections is an AsyncProjection and also requires await. Both verified by running examples against the live API.
Contributor
|
Thanks for opening a docs PR, Nick Hollon (@nick-hollon-lc)! When it's ready for review, please add the relevant reviewers:
|
| await asyncio.gather(consume_coordinator(), consume_subagents()) | ||
| ``` | ||
|
|
||
| For synchronous code, use `stream.interleave(...)` instead: |
Contributor
There was a problem hiding this comment.
needs py / js fencing? (I see interLeave here for python)
Contributor
Author
There was a problem hiding this comment.
interleave is python only purely because we have a sync path. checked the preview and things look correct given this
…ent loop data[0] can be a ToolMessage object (not a dict) when subagent tool results flow through the messages channel. Add isinstance(payload, dict) guard before calling .get() to avoid AttributeError. Also remove end="" from print so each text-delta prints on its own line with the source prefix rather than concatenating all tokens with repeated prefixes.
data is a (payload, metadata) tuple in langgraph 1.2.0, not a plain dict. Use data[0] and guard with isinstance to skip non-dict payloads (e.g. ToolMessage) that appear when tool results flow through the messages channel.
Contributor
|
Mintlify preview branch generated: Site preview: https://langchain-5e9cc07a-preview-fixeve-1778818735-27c37e8.mintlify.app Preview links may take a few minutes to start working while the deployment finishes. Changed documentation pages (preview deep links): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
event["params"]["data"]is a(event_dict, metadata)tuple so the payload is atdata[0], and the delta type is"text-delta"not"text"astream_events+asyncio.gather) and relegatestream.interleave()to a sync-only fallbackastream_events()returns a coroutine and requiresawait;message.textin async projections is anAsyncProjectionand also requiresawait— both confirmed by running the examples against the live APITest plan
datais a 2-tuple,data[0]is the event dict, delta type is"text-delta"make lint_prosepasses on all changed filesAI involvement
Changes were implemented and verified with Claude Code.