Find answers from the community

Updated last month

Enabling Context Persistence Across Multiple Workflow Runs

Hey all, how do we enable Context to persist over multiple runs of the same workflow?
L
D
2 comments
Plain Text
handler = workflow.run(...)
result = await handler

handler = workflow.run(ctx=handler.ctx, ....)
result = await handler


You can also serialize the context (the pickling-serializer is opt in, in case you are storing non-json serializable objects in the context)

Plain Text
from llama_index.core.workflow.context_serializers import JsonSerializer, JsonPickleSerializer

# serialize
serialized_context = handler.ctx.to_dict(serializer=JsonSerializer())

# resume at a later point
ctx = Context.from_dict(serialized_context, serializer=JsonSerializer())
Add a reply
Sign up and join the conversation on Discord