[Feature Request] Improve how state is shared between workflows #7

Open
opened 2026-02-16 02:16:03 -05:00 by yindo · 0 comments
Owner

Originally created by @logan-markewich on GitHub (Jul 29, 2025).

Today, each workflow is completely decoupled from another. And furthermore, the Context ensures each .run() is also isolated.

If you run a workflow inside another workflow, you end up with

  • two context objects
  • two states
  • two event streams

I think it'd be useful to explore a UX where we actually share information from an outer workflow to an inner workflow.

For example, here's a scenario

@step
async def run_some_step(self, ctx: Context[SomeState], ev: SomeEvent) -> OtherEvent:
  some_val = await ctx.store.get("some_val")
  inner_workflow = InnerWorkflow()
  
  handler = inner_workflow.run(some_val=some_val)
  async for inner_ev in handler.stream_events():
    ctx.write_event_to_stream(inner_ev)

  result = await handler
  await ctx.store.set("some_other_value", result)
  return OtherEvent()

Notice that

  1. Need to propagate events through outer context
  2. Need to pass any state from the outer state to the inner workflow
  3. Need to propagate any state changes from inner workflow to outer state

This gets infinitely more complicated (or even impossible?) if the inner workflow involves human-in-the-loop.

However, its also an option that maybe we don't share state, but if we don't, we should be principled and outline proper development practices.

Originally created by @logan-markewich on GitHub (Jul 29, 2025). Today, each workflow is completely decoupled from another. And furthermore, the `Context` ensures each `.run()` is also isolated. If you run a workflow inside another workflow, you end up with - two context objects - two states - two event streams I think it'd be useful to explore a UX where we actually share information from an outer workflow to an inner workflow. For example, here's a scenario ``` @step async def run_some_step(self, ctx: Context[SomeState], ev: SomeEvent) -> OtherEvent: some_val = await ctx.store.get("some_val") inner_workflow = InnerWorkflow() handler = inner_workflow.run(some_val=some_val) async for inner_ev in handler.stream_events(): ctx.write_event_to_stream(inner_ev) result = await handler await ctx.store.set("some_other_value", result) return OtherEvent() ``` Notice that 1. Need to propagate events through outer context 2. Need to pass any state from the outer state to the inner workflow 3. Need to propagate any state changes from inner workflow to outer state This gets infinitely more complicated (or even impossible?) if the inner workflow involves human-in-the-loop. However, its also an option that maybe we don't share state, but if we don't, we should be principled and outline proper development practices.
yindo added the enhancement label 2026-02-16 02:16:03 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: run-llama/workflows-py#7