Support passing runtime context in Send API

Currently, the Send API in LangGraph allows dynamically routing execution to other nodes or subgraphs by passing updated graph state (arg), but it does not support passing or updating the runtime context alongside the state. This limits the ability to modify or extend runtime context dynamically during graph execution.

Proposed enhancement:
Add support for an optional context parameter in the Send API that allows passing a new or updated runtime context dictionary when routing to the next node(s).
Example usage:

return Send(
    "next_node",
    arg=updated_state, # or: state: updated_state,
    context={"user_id": "new_user_123", "session_id": "abc123"}
)

Thanks for the request. Hmm, I think context is intended to be run scoped. If something is changing during a graph invocation, it belongs in state I’d say!

@sydney-runkle
Yes, on second thought, I totally agree, my initial deduction was wrong. The context should remain run-scoped. At first, I completely overlooked that in a multi-agent system (orchestrator workflow), we’re still operating on a single thread run. Mutating the context in favor of one subgraph (agent) would break the context for all other subgraphs (agents).
I initially thought we could isolate the contexts of the sub-agents, but that’s exactly what the state handles. Anyway, thanks for the clarification!

Hi @codeonym

@sydney-runkle is right.

Keep runtime context run‑scoped and immutable for the duration of a run. If something must change during execution, put it in state and pass it via Send/Command. This preserves consistency across concurrent subgraphs/agents within the same run.

  • Why not context in Send?
    • In LangGraph, context is designed to be run‑scoped (set at invoke/stream), while state is the mutable, per‑run data that evolves across nodes. Allowing Send to mutate context mid‑run would create cross‑agent inconsistencies in orchestrations where multiple nodes/subgraphs share the same run.
  • What to do instead
    • Put dynamic values (e.g., user_id, session_id, per‑agent knobs) into the graph state and forward them to the next node with Send.
    • Keep shared, run‑level resources/configuration (e.g., tools, clients, credentials, thread identifiers) in the context passed at the start of the run via invoke/stream config.

From the conceptual perspective, both of them are context:

References

Official docs - Context is run‑scoped; state is the mutable, per‑run memory:

1 Like