Skip to content

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
mainfrom
fix/event-streaming-docs
Open

docs(event-streaming): fix raw event payload, text-delta type, and async examples#4012
Nick Hollon (nick-hollon-lc) wants to merge 6 commits into
mainfrom
fix/event-streaming-docs

Conversation

@nick-hollon-lc
Copy link
Copy Markdown
Contributor

Summary

  • deepagents: fix raw protocol event iteration in the "Consume concurrently" section — event["params"]["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 (deepagents, langchain, langgraph): reframe the Python multiple-projections section to lead with the async path (astream_events + asyncio.gather) and relegate stream.interleave() to a sync-only fallback
  • async examples verified: astream_events() returns a coroutine and requires await; message.text in async projections is an AsyncProjection and also requires await — both confirmed by running the examples against the live API

Test plan

  • All three async examples (deepagents, langchain, langgraph) run successfully against live API
  • Raw event structure confirmed: data is a 2-tuple, data[0] is the event dict, delta type is "text-delta"
  • make lint_prose passes on all changed files

AI involvement

Changes were implemented and verified with Claude Code.

…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.
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for opening a docs PR, Nick Hollon (@nick-hollon-lc)! When it's ready for review, please add the relevant reviewers:

  • @npentrel or @lnhsingh (Deep Agents)
  • @npentrel or @lnhsingh (LangChain)
  • @npentrel or @lnhsingh (LangGraph)

@github-actions github-actions Bot added deepagents For docs changes to Deep Agents langchain For docs changes to LangChain langgraph For docs changes to LangGraph oss internal labels May 14, 2026
await asyncio.gather(consume_coordinator(), consume_subagents())
```

For synchronous code, use `stream.interleave(...)` instead:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs py / js fencing? (I see interLeave here for python)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interleave is python only purely because we have a sync path. checked the preview and things look correct given this

Comment thread src/oss/deepagents/event-streaming.mdx
Comment thread src/oss/deepagents/event-streaming.mdx Outdated
…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.
@github-actions
Copy link
Copy Markdown
Contributor

Mintlify preview branch generated: preview-fixeve-1778818735-27c37e8

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):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deepagents For docs changes to Deep Agents internal langchain For docs changes to LangChain langgraph For docs changes to LangGraph oss

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants