Repository navigation
Conversation
Add an experimental workflow helper that plans a task, selects one specialist at a time, replans when progress stalls, and can pause for a person to accept the plan. The loop is an original ADK workflow on top of ctx.run_node, structured output, and RequestInput. It is inspired by the publicly described Magentic-One pattern (google#8167). Co-authored-by: Ferran Pons Serra <ferponse@users.noreply.github.com>
cursor
Bot
force-pushed
the
cursor/magentic-orchestration-5616
branch
from
November 16, 2026 09:10
95eb7fc to
48a580f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
This pull request is on the fork. It does not close the upstream issue by itself. The branch is based on current
google/adk-pythonmainso it can be proposed upstream later.Problem:
ADK can already route work with a
Workflow,ctx.run_node, sub-agent transfer, andAgentTool. It does not ship the open-ended team loop from issue google#8167: a coordinator that writes a plan, checks progress in a structured way, picks the next specialist, notices a stall, replans within a limit, optionally pauses for a person to accept the plan, and then writes one answer. Applications otherwise rebuild that bookkeeping themselves.Solution:
adaptive_team(...)ingoogle.adk.labs.adaptive_teamreturns a normalWorkflow. One driver node, withrerun_on_resume=True, runs the loop in Python and calls the coordinator and the specialists throughctx.run_node.The shape is a labs helper rather than a new agent runtime or a class named after Magentic. ADK 2.x already treats imperative
ctx.run_nodeloops as the orchestration surface (Workflowgraphs, dynamic nodes,RequestInput,output_schema). A helper that returns aWorkflowreuses resumability, event streaming, and session state instead of adding a second executor. Labs keeps the API experimental (FeatureName.ADAPTIVE_TEAM, on by default, one warning) so the ledger fields can still change.This is an original implementation inspired by the publicly described Magentic-One pattern (a coordinator, a task plan, a per-round progress check, stall handling, an optional human plan review, and a final answer). Prompts, schemas, class names, and control flow were written for ADK. No Microsoft source was copied.
Behavior:
TaskPlan, then aRoundAssessmenteach round, then the final answer.ctx.run_node.stall_limitstalled rounds in a row replace the plan, up toreplan_limit. After that the coordinator writes a best-effort answer.max_roundsbounds specialist turns.review_plan=Truepauses with the existingRequestInput/PlanDecisionpath before a plan is executed, and again after a replacement. A rejection spends one replacement.TeamSnapshotin session state (team_state_key). It is scoped to the invocation, so a review resume continues and a new user message starts over. Run ids are stable, so a resume replays finished model calls.custom_metadata["adaptive_team"]["kind"]toplan,replan,progress, oranswer. Specialist events keep the specialist as the author. The workflow output is the answer text.Testing Plan
Unit Tests:
pytest tests/unittests/labs/adaptive_team/test_adaptive_team.py tests/unittests/features -qtests/unittests/features: 43 passedThe tests use ADK's
MockModel/InMemoryRunner.mypyonsrc/google/adk/labs/adaptive_teamreported no errors.pylinton the new package rated 10.00/10.Manual End-to-End (E2E) Tests:
No hosted model was called. Importing
contributing/samples/workflows/adaptive_team/agent.pybuilds aWorkflownamedenergy_brief. The loop itself is covered by the mock-model tests above, including pause and resume.Try:
Compare the energy use of electric and gas heating for a small apartment, and name the bigger uncertainty.Checklist
Additional context
Open questions for maintainers:
google.adk.labsthe right home until the ledger schema settles, or should this be a publicWorkflowbuilder undergoogle.adk.workflow?replan_limitwith stall replans, as it does here, or have its own budget?stalledflag and a mechanical check for a repeated assignment or an unknown name. Is that the policy you want, or should the model be the only judge?adaptive_team, not Magentic. Happy to rename if a different word fits the rest of the API.BaseAgent. Should that be narrowed toLlmAgent?