Create a nested chat workflow where a multi-step pipeline is encapsulated inside a single agent. Use when you want to package a sequence of agent interactions (research, draft, edit) into one agent that runs the pipeline automatically when triggered.
How this skill is triggered — by the user, by Claude, or both
Slash command
/ag2-workflow-patterns:nested-chatThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
You are creating an AG2 nested chat workflow. This encapsulates a multi-step pipeline inside a single agent using `register_nested_chats`.
You are creating an AG2 nested chat workflow. This encapsulates a multi-step pipeline inside a single agent using register_nested_chats.
Ask the user for:
summary_method)Create the nested chat following this pattern:
import asyncio
from autogen import ConversableAgent, LLMConfig
llm_config = LLMConfig({"api_type": "anthropic", "model": "claude-sonnet-4-6"})
user = ConversableAgent(
name="user",
human_input_mode="NEVER",
)
# The outer agent that encapsulates the pipeline
coordinator = ConversableAgent(
name="coordinator",
system_message="Present the final result.",
llm_config=llm_config,
)
# Pipeline stage agents
step_1 = ConversableAgent(
name="step_1",
system_message="Do the first step.",
llm_config=llm_config,
)
step_2 = ConversableAgent(
name="step_2",
system_message="Do the second step.",
llm_config=llm_config,
)
step_3 = ConversableAgent(
name="step_3",
system_message="Do the third step.",
llm_config=llm_config,
)
# Register the nested pipeline -- fires when coordinator receives from user
coordinator.register_nested_chats(
chat_queue=[
{
"recipient": step_1,
"message": lambda recipient, messages, sender, config: messages[-1]["content"],
"max_turns": 1,
"summary_method": "last_msg",
},
{
"recipient": step_2,
"message": "Continue with the second step.",
"max_turns": 1,
"summary_method": "last_msg",
},
{
"recipient": step_3,
"message": "Complete the third step.",
"max_turns": 1,
"summary_method": "last_msg",
},
],
trigger=user, # fires when message comes from user
)
async def main():
response = await user.a_run(
coordinator,
message="Your task here",
max_turns=1,
)
await response.process()
print(await response.summary)
if __name__ == "__main__":
asyncio.run(main())
register_nested_chats to define the pipeline on the outer agentchat_queue MUST have a message field -- without it, subsequent stages won't firemessage to forward the original user request: lambda recipient, messages, sender, config: messages[-1]["content"]message strings -- the previous stage's output is automatically appended as contextchat_queue runs sequentially -- output of one feeds into the nextmax_turns=1 per stage for clean handoffssummary_method="last_msg" passes the last message as input to the next stagetrigger parameter controls which sender activates the nested pipelinea_run (async) with .process() then .summary -- NOT initiate_chatLLMConfig({...}) -- NOT a raw dict like {"model": "..."}See examples/article_pipeline.py for a research-draft-edit pipeline.
npx claudepluginhub ag2ai/ag2-claude-plugins --plugin ag2-workflow-patternsDesigns and executes custom multi-agent pipelines using Claude Code subagents. Spawns researcher, builder, strategist, reviewer, evaluator, etc. with parallel and background execution.
Guides proactive use of /orchestrate for complex multi-agent workflows with sequential/parallel execution, conditionals, retries, visualization, checkpoints, and automation.
Guides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.