When to use config['configurable'] vs. context in graph nodes?

Hi all,

I see a previous post around this topic but I find the replies confusing.

I am building a simulation with multiple rounds where agents need to solve jobs each round. I am using LangGraph for the simulation loop.
In each round a list of different jobs are generated. I want to do this in the very first node of my graph (a start_round node). At the end of every round I will loop back to this node and generate new jobs.

For generating the jobs I want to pass an instance of my JobGenerator class such that the node can use the methods provided by this class.

Should I pass the instance of the class via the config or context argument and why? Is what I am trying to achieve even possible?

Another possibility would be to add the instance to the state, but fields in the state need to be serializable right?

Any guidance is appreciated - I am happy to provide more information if needed.

sounds like something that belongs in runtime context, bc you don’t want to serialize it
you can think of runtime context as injected read-only deps

1 Like

Okay great, thanks for the reply! :smile:

What is the use case for config then if I may ask?

config[“configurable”] is the old untyped version of runtime.context :slight_smile:

1 Like

You are a lifesaver. Thank you! :folded_hands:

1 Like

it also has other internal config information (like thread id, etc), but we’ll eventually move to properly typing those as well

1 Like