# How to set Runtime Context when using astream\_events

**URL:** <https://forum.langchain.com/t/how-to-set-runtime-context-when-using-astream-events/945>\
**Category:** LangGraph\
**Tags:** python-help\
**Created:** [August 5, 2025, 9:12am UTC](https://forum.langchain.com/t/how-to-set-runtime-context-when-using-astream-events/945 "2025-08-05T09:12:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fangzheng2025-wq](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/fangzheng2025-wq/32/476_2.png) [@fangzheng2025-wq](https://forum.langchain.com/u/fangzheng2025-wq)\
**Post date:** [August 5, 2025, 9:12am UTC](https://forum.langchain.com/t/how-to-set-runtime-context-when-using-astream-events/945/1 "2025-08-05T09:12:47Z")

</div>

After create a graph, I can set context when use invoke(), but for function astream\_events, there is not params for context, is there a workaround i can follow?

 ![image](https://canada1.discourse-cdn.com/flex007/uploads/langchain/original/1X/eba6742ce3de3b18f9cfa93d3ab391163b81720b.png)

---

<div class="post-metadata">

**Author:** ![niilooy](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/niilooy/32/2886_2.png) [@niilooy](https://forum.langchain.com/u/niilooy)\
**Post date:** [August 7, 2025, 10:18am UTC](https://forum.langchain.com/t/how-to-set-runtime-context-when-using-astream-events/945/2 "2025-08-07T10:18:01Z")

</div>

Hi! You can use astream(). From LangGraph v 0.6.0, context is a parameter that you can pass inside astream() method.

> **[Graphs](https://langchain-ai.github.io/langgraph/reference/graphs/?h=astream#langgraph.graph.state.CompiledStateGraph.astream)**
>
> Build reliable, stateful AI systems, without giving up control

---

<div class="post-metadata">

**Author:** ![Tik1993](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/tik1993/32/309_2.png) [@Tik1993](https://forum.langchain.com/u/Tik1993)\
**Post date:** [August 7, 2025, 11:54pm UTC](https://forum.langchain.com/t/how-to-set-runtime-context-when-using-astream-events/945/3 "2025-08-07T23:54:48Z")

</div>

You can simply put the context to first argument.

For example like this

```python
for chunk in graph_memory.stream({"messages":input_messages},config_1, stream_mode="updates"):
 chunk["conversation"]["messages"].pretty_print()

```
