Skip to content

SequentialAgent deprecated but replacement (Workflow) cannot fill its role as sub_agent #5872

Closed

Description

@deepakbatham572

🔴 Required Information

Describe the Bug:
SequentialAgent carries a deprecation warning saying "Please use Workflow instead."
However, Workflow is not a BaseAgent subclass and cannot be used in Agent.sub_agents,
which requires list[BaseAgent]. This leaves no ADK-native migration path for the
sub_agent composition pattern.

Steps to Reproduce:

  1. Install google-adk==2.1.0
  2. Try to replace a SequentialAgent sub_agent with a Workflow:
from google.adk.workflow import Workflow
from google.adk.agents import Agent

pipeline = Workflow(name="pipeline", edges=[...])

root = Agent(
    name="orchestrator",
    sub_agents=[pipeline],   # TypeError: Workflow is not BaseAgent
)
  1. Observe Workflow is rejected because it is not a BaseAgent.

Expected Behavior:
Either Workflow implements BaseAgent so it can be passed as a sub_agent, or the
deprecation notice documents an explicit migration path for this composition pattern.

Observed Behavior:

from google.adk.workflow import Workflow
from google.adk.agents.base_agent import BaseAgent
issubclass(Workflow, BaseAgent)  # False

from google.adk.agents import SequentialAgent
issubclass(SequentialAgent, BaseAgent)  # True  ← deprecated

Workflow → BaseNode only.
SequentialAgent → BaseAgent → BaseNode (deprecated, will be removed).
After removal, there is no BaseAgent-compatible sequential composition class.

Environment Details:

ADK Library Version: google-adk==2.1.0
Desktop OS: macOS
Python Version: 3.12
Model Information:

Are you using LiteLLM: Yes
Which model is being used: gpt-5.1 (via LiteLLM)

🟡 Optional Information

Regression:
N/A — SequentialAgent worked in prior versions. The deprecation was introduced in 2.x.

Logs:
N/A

Additional Context:
The workbench pattern (root Agent → SequentialAgent sub_agent → [gen_agent, review_agent])
is a common production pattern. Without a BaseAgent-compatible replacement, users must
either keep the deprecated class or abandon the sub_agent composition pattern entirely
and move all routing into a top-level Workflow, which has its own limitations

Activity

  1. added
    workflow[Component] This issue is related to ADKworkflow
    on May 27, 2026
  2. added theissue type on May 27, 2026
  3. ruben-cid commented on May 28, 2026

    @ruben-cid

    HI

    There was this discussions for a similar topic / constraint if you are interested in the findings.

    #5581

  4. deepakbatham572 commented on May 28, 2026

    @deepakbatham572
    Author

    HI @GWeale could you please help here ?

  5. surajksharma07 commented on May 29, 2026

    @surajksharma07
    Collaborator

    @deepakbatham572 A workaround worth trying: subclass BaseAgent, hold the Workflow as a field, and in _run_async_impl bridge via wf_ctx = Context(invocation_context=ctx, node=self.workflow), then delegate to self.workflow.run(ctx=wf_ctx, node_input=None).

    Could you validate this covers your pipeline pattern and test it thoroughly on your side before we look at wiring it in natively?

  6. deepakbatham572 commented on Jun 4, 2026

    @deepakbatham572
    Author

    Hi @surajksharma07 ,
    Thanks — Two notes:

    1. The bridge must re-yield, not return — Workflow.run() and BaseAgent._run_async_impl are both event generators:

    class WorkflowAgent(BaseAgent):
    workflow: Workflow
    async def _run_async_impl(self, ctx): # InvocationContext
    wf_ctx = Context(invocation_context=ctx, node=self.workflow)
    async for event in self.workflow.run(ctx=wf_ctx, node_input=...):
    yield event

    1. node_input=None only works if the entry node doesn't branch on the input; otherwise the parent's message must be threaded through. Also, the hand-built Context (no parent_ctx) bypasses the parent's scheduler/state wiring — that's the part needing careful testing.

    should Workflow expose a BaseAgent-compatible adapter natively so callers don't have to get this bridging right by hand?

  7. surajksharma07 commented on Jun 4, 2026

    @surajksharma07
    Collaborator

    @deepakbatham572 You're right on all three points.

    On re-yield: Yes, async for event in self.workflow.run(...): yield event is required — both sides are async generators. fix_5872.py already implements this correctly; the initial comment was imprecise in not making the generator delegation explicit.

    On node_input: Pass ctx.user_content (the InvocationContext field that holds the original user message) instead of None. Internally, _seed_start_triggers() distributes node_input as trigger.input to all of START's direct successors, so None silently gives entry nodes no message to branch on.
    The corrected bridge:

    async def _run_async_impl(self, ctx: InvocationContext):
        wf_ctx = Context(invocation_context=ctx, node=self.workflow)
        async for event in self.workflow.run(ctx=wf_ctx, node_input=ctx.user_content):
            yield event
    

    One caveat on resume turns (HITL): node_input becomes the latest user message rather than the original task brief — ADK itself flags this in _validate_no_task_mode_graph_nodes() in _workflow.py and blocks task-mode LlmAgents as static graph nodes for exactly this reason.
    For single-turn, stateless functional nodes (pure transform/fetch), passing ctx.user_content is safe.

    On Context without parent_ctx: What IS correctly threaded is everything flowing through the shared invocation_context — session, session_service, artifact_service, memory_service, user_content. Persistent session state writes from workflow nodes do propagate.

    What is NOT wired: node_path starts from root rather than nested under the parent agent's path, so temp:* state written by workflow nodes operates in a separate namespace from the parent agent and won't be readable by it.
    The more serious risk is HITL resumability — if a workflow node raises RequestInput, the suspended node's state lives in the workflow's own Context; on the next user turn the parent runner re-enters _run_async_impl and constructs a fresh Context, losing the scheduler's knowledge of which node was suspended. Multi-turn HITL inside the bridged workflow will silently restart rather than resume.

    On the native adapter question: Yes, a first-class WorkflowAgent that handles node_input threading, proper parent_ctx construction, and HITL re-entry is the right answer — this is exactly the gap tracked in #5581.
    We'll flag it to the team.
    Until then, the workaround is reliable for single-turn, non-HITL pipelines with stateless nodes — avoid it for multi-turn workflows or any node that writes temp: scoped state the parent agent needs to read back.

  8. deepakbatham572 commented on Jun 9, 2026

    @deepakbatham572
    Author

    Hi @surajksharma07 / @GWeale / @klateefa ,
    is there any ETA when we are getting the fix ?

  9. deepakbatham572 commented on Jun 10, 2026

    @deepakbatham572
    Author

    Hi @surajksharma07

    any update ?

  10. surajksharma07 commented on Jun 12, 2026

    @surajksharma07
    Collaborator

    @deepakbatham572 Honest status: no PR is linked to this or #5581 yet, and I re-checked v2.2.0 (released this week) — Workflow is still BaseNode-only, so nothing has landed for this.

    Per the discussion in #5581, the team's current direction is the "node as a tool" pattern rather than making Workflow a BaseAgent, and the native WorkflowAgent adapter is still under internal discussion — I've flagged it again, but I can't commit to an ETA from my side.

    Until then the bridge above remains the reliable path for single-turn, non-HITL pipelines.
    I'll post here the moment a PR goes up!

  11. deepakbatham572 commented on Jul 2, 2026

    @deepakbatham572
    Author

    Hi @GWeale , @surajksharma07, is there any update on this ?

  12. surajksharma07 commented on Jul 13, 2026

    @surajksharma07
    Collaborator

    @deepakbatham572 Good update — v2.4.0 shipped two real changes here.

    The deprecation messages now say plainly that Workflow can't be used as an LlmAgent sub-agent yet (commit 53a8ab1), which matches your exact ask. More importantly, there's now a first-class "Workflow as Tool" feature (commit 1263ed6) — pass your Workflow straight into Agent(tools=[pipeline]) and ADK auto-wraps it as a callable NodeTool. It just needs pipeline.description set, or it raises a ValueError.

    It's still not a sub_agent — the LLM decides when to invoke it rather than it running as a deterministic pipeline step, and Workflow is still BaseNode-only under the hood — but it's the officially supported path the team was pointing at back in #5581.

    Could you try that in place of the WorkflowAgent bridge and confirm whether it covers your workbench pattern?

  13. surajksharma07 commented on Jul 31, 2026

    @surajksharma07
    Collaborator

    Rechecked against the latest release (2.6.0) — Workflow is still BaseNode-only, so it can't be a sub_agent yet, that part's genuinely unresolved.

    That said, both things called out here did ship in 2.4.0 and are still there: the deprecation message no longer implies Workflow is a drop-in replacement, and "Workflow as Tool" is now the officially supported path.
    Since there's been no reply on whether that covers your workbench pattern, closing this for now — please reopen if it doesn't hold up, and #5581 is where the native sub_agent ask is being tracked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

request clarification[Status] The maintainer need clarification or more information from the authorv2Affects only 2.0 versionworkflow[Component] This issue is related to ADKworkflow

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions