You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inspired by #57, the CugaSupervisorGraph should gain a proper planning and task decomposition layer analogous to what TaskDecompositionNode + PlanControllerNode provide for the main AgentState graph.
Today the supervisor uses create_update_todos as its only lightweight planning primitive (see create_prepare_agents_and_prompt_node in cuga_supervisor_graph.py). This is enough for simple linear tasks but falls short when:
The user's request spans multiple agents and requires sequential or parallel sub-task execution with dependencies.
Operators want the supervisor to produce a visible, structured plan before execution starts (currently plan_approval only interrupts for a yes/no approval of the agent list, not a structured plan).
There is no mechanism to surface intermediate progress as chat messages — sub-agent results are opaque until the supervisor emits its final_answer.
Complex multi-agent tasks have no complexity-based trigger to decide when structured decomposition is warranted versus simple create_update_todos.
How it could work
1. Supervisor-aware PlanningMode
Introduce a PlanningMode enum (mirroring #57's proposal) with a AGENTS variant consumed by the supervisor:
A new node (or a parameterised variant of TaskDecompositionNode) that:
Receives the user intent and the set of available agents (from CugaSupervisorState.available_agents).
Produces a structured SupervisorTaskPlan: an ordered list of sub-tasks, each scoped to a named agent, with dependency links.
Respects the existing policy layer — routing, sequencing, and approval policies already resolved in prepare_agents_and_prompt must be reflected in the plan.
3. SupervisorPlanControllerNode
A new controller node (parallel to PlanControllerNode) wired into the supervisor graph that:
Drives execution through the structured plan rather than leaving the LLM free to generate arbitrary delegation code.
Tracks each sub-task's status (pending → in_progress → completed / failed) in CugaSupervisorState.
Decides whether to delegate to the next agent, retry a failed sub-task, or conclude the plan.
Falls back to the current conversational loop for single-agent or conversational tasks.
4. Planning trigger logic
Add a heuristic (configurable via settings) to decide when structured planning is needed:
Condition
Mode chosen
>1 agent and task has explicit sequencing cues
Structured decomposition
Single agent, single step
create_update_todos
settings.supervisor.force_planning = true
Always structured
5. Chat message synchronisation
When structured planning is active, inject tagged AIMessage entries into supervisor_chat_messages at key moments:
After decomposition: formatted plan with all sub-task statuses.
Sub-task start: update or append a status message naming the active agent.
Sub-task completion: brief result summary before moving to the next sub-task.
Plan complete: final summary before final_answer is emitted.
6. YAML / SDK surface
Expose a planning_mode field in the supervisor: stanza and a matching parameter on create_cuga_supervisor_graph():
The existing create_update_todos tool should remain as the default / low-complexity path; structured planning is an opt-in enhancement.
CugaSupervisorState already has available_agents, supervisor_allowed_agents, supervisor_sequence_order, and supervisor_dispatched_agents — these can seed the plan without re-running policy checks.
What you want and why
Inspired by #57, the
CugaSupervisorGraphshould gain a proper planning and task decomposition layer analogous to whatTaskDecompositionNode+PlanControllerNodeprovide for the mainAgentStategraph.Today the supervisor uses
create_update_todosas its only lightweight planning primitive (seecreate_prepare_agents_and_prompt_nodeincuga_supervisor_graph.py). This is enough for simple linear tasks but falls short when:plan_approvalonly interrupts for a yes/no approval of the agent list, not a structured plan).final_answer.create_update_todos.How it could work
1. Supervisor-aware
PlanningModeIntroduce a
PlanningModeenum (mirroring #57's proposal) with aAGENTSvariant consumed by the supervisor:2.
SupervisorTaskDecompositionNodeA new node (or a parameterised variant of
TaskDecompositionNode) that:CugaSupervisorState.available_agents).SupervisorTaskPlan: an ordered list of sub-tasks, each scoped to a named agent, with dependency links.prepare_agents_and_promptmust be reflected in the plan.3.
SupervisorPlanControllerNodeA new controller node (parallel to
PlanControllerNode) wired into the supervisor graph that:pending→in_progress→completed/failed) inCugaSupervisorState.4. Planning trigger logic
Add a heuristic (configurable via
settings) to decide when structured planning is needed:create_update_todossettings.supervisor.force_planning = true5. Chat message synchronisation
When structured planning is active, inject tagged
AIMessageentries intosupervisor_chat_messagesat key moments:final_answeris emitted.6. YAML / SDK surface
Expose a
planning_modefield in thesupervisor:stanza and a matching parameter oncreate_cuga_supervisor_graph():Links or extra context
src/cuga/backend/cuga_graph/nodes/cuga_supervisor/cuga_supervisor_graph.py—create_cuga_supervisor_graph,prepare_agents_and_prompt,call_modelsrc/cuga/backend/cuga_graph/nodes/cuga_supervisor/cuga_supervisor_state.py— state fields to extendsrc/cuga/backend/cuga_graph/nodes/task_decomposition_planning/plan_controller.py— reference implementation ofPlanControllerNodesrc/cuga/backend/cuga_graph/nodes/task_decomposition_planning/task_decomposition.py— referenceTaskDecompositionNodesrc/cuga/supervisor_utils/supervisor_config.py— YAML config loading (needsplanning_modefield)create_update_todostool should remain as the default / low-complexity path; structured planning is an opt-in enhancement.CugaSupervisorStatealready hasavailable_agents,supervisor_allowed_agents,supervisor_sequence_order, andsupervisor_dispatched_agents— these can seed the plan without re-running policy checks.