Skip to content

Runner.__init__ 'agent' param typed Optional[BaseAgent] but class field and runtime accept BaseNode (e.g. Workflow) roots #6270

Description

@JesusCaseroDiazCano

Summary

Runner's class-level field is typed to accept node roots:

# runners.py:153
agent: Optional[BaseAgent | 'BaseNode'] = None

but the __init__ parameter was not widened to match:

# runners.py:175
agent: Optional[BaseAgent] = None,

The runtime explicitly supports a BaseNode root (e.g. a Workflow):

# runners.py:1023-1024
if isinstance(self.agent, BaseNode) and not isinstance(self.agent, BaseAgent):
    ...

So passing a Workflow as the root works at runtime, but type checkers (pyright) reject Runner(agent=my_workflow) against the narrower __init__ signature.

Expected

The __init__ agent parameter annotation matches the class field, e.g. Optional[BaseAgent | BaseNode].

Version

google-adk==2.3.0

Note

I only verified the __init__ agent path. There may be similar narrowing on related entry points (node=, run_live), but I have not confirmed those.

Metadata

Metadata

Assignees

Labels

core[Component] This issue is related to the core interface and implementationrequest clarification[Status] The maintainer need clarification or more information from the authorstale[Status] Issues which have been marked inactive since there is no user response

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions