Using custom context class in workflows #17

Closed
opened 2026-02-16 02:16:06 -05:00 by yindo · 2 comments
Owner

Originally created by @stdweird on GitHub (Oct 8, 2025).

Is there (an easy) way to pass a custom Context class to setup a workflow?

I want to add some custom code (mainly to interact with the store; but also a progress method to emit ProgressEvents) to make things a bit easier to read and write workflow code.

I haven't mdae up my mind yet how i will do this, but i need to find a way to test and play with some vague ideas i have.

Same/similar question wrt using custom InMemoryStateStore to move some customisations to the store itself (like a __getitem__, not sure it's a good idea though, esp since there never can be an async setitem).

Originally created by @stdweird on GitHub (Oct 8, 2025). Is there (an easy) way to pass a custom `Context` class to setup a workflow? I want to add some custom code (mainly to interact with the store; but also a `progress` method to emit `ProgressEvent`s) to make things a bit easier to read and write workflow code. I haven't mdae up my mind yet how i will do this, but i need to find a way to test and play with some vague ideas i have. Same/similar question wrt using custom `InMemoryStateStore` to move some customisations to the store itself (like a `__getitem__`, not sure it's a good idea though, esp since there never can be an async setitem).
yindo closed this issue 2026-02-16 02:16:06 -05:00
Author
Owner

@logan-markewich commented on GitHub (Oct 8, 2025):

@stdweird if you have a custom context class, you should be able to pass it into the run() method

An example with the existing context class

ctx = Context(workflow)
resp = await workflow.run(...., ctx=ctx)
@logan-markewich commented on GitHub (Oct 8, 2025): @stdweird if you have a custom context class, you should be able to pass it into the run() method An example with the existing context class ``` ctx = Context(workflow) resp = await workflow.run(...., ctx=ctx) ```
Author
Owner

@stdweird commented on GitHub (Oct 8, 2025):

Ah like that. Thanks a lot!

@stdweird commented on GitHub (Oct 8, 2025): Ah like that. Thanks a lot!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: run-llama/workflows-py#17