Hello community!
I’m encountering an issue with the type inference on a child workflow’s return value. In my code (included below), the variable recollections
is inferred as any
instead of List[str]
—even though the child workflow RecallSkill.run
is annotated to return a List[str]
. As a consequence, on runtime, the following error is thrown: “TypeError: cannot pickle ‘coroutine’ object”.
In addition, if I change the argument of the child workflow call, the type is suddenly inferred correctly. Another strange behavior I notice is that, for this particular call to execute_child_workflow
, hovering over it shows all overload signatures, whereas for the same call in other parts of my project, only a single signature is displayed.
I’ve provided the minimal reproducible code snippets for both the parent and child workflows. I’d appreciate any guidance on:
- Why the type inference might be failing specifically in this scenario,
- How to correct it so that
recollections
is recognized asList[str]
, and - Why the
execute_child_workflow
method’s overload signatures might appear differently in this workflow vs. others in my project.
Thank you in advance for your help, and please let me know if there’s any additional information I can provide.
Relevant Code Snippets
# parent workflow snippet
# In this snippet, recollections is wrongly interpreted as "any"
recollections = await workflow.execute_child_workflow(
Recall.run,
Recall.EntryCriteria(
query="some question",
scope=Scope.BOTH,
state=load_state(),
config=config
),
id=f"recall-{uuid4()}",
task_queue="task-queue"
)
# child workflow snippet
@workflow.defn(sandboxed=False)
class Recall:
@dataclass
class EntryCriteria:
state: Dict[str, Any]
config: RunnableConfig
query: str = field(default_factory=str)
scope: Optional[Scope] = Scope.BOTH
@workflow.run
async def run(self, params: EntryCriteria) -> List[str]:
...
return some_list
Looking forward to hearing from you!
Best regards,
Daniel