workflow-patterns
Choose and implement mcp-agent workflow patterns including routers, intent classifiers, parallel fan-out/fan-in, orchestrators, evaluators, swarms, and structured outputs.
- License 许可
- Apache-2.0
- 最近更新
- 2026-10-08
- Stars
- ★ 11
- Forks
- 3
01 前言 Front Matter
- name
- workflow-patterns
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Choose and implement mcp-agent workflow patterns including routers, intent classifiers, parallel fan-out/fan-in, orchestrators, evaluators, swarms, and structured outputs.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/api-reference.md14.1 KB
- 参考文档references/pattern-selection.md6.7 KB
- 参考文档references/troubleshooting.md9.2 KB
- 参考文档references/workflows.md13.2 KB
03 SKILL.md 正文
mcp-agent Workflow Patterns
Use this sub-skill when a task asks you to choose, compose, or implement an mcp-agent workflow pattern beyond basic Agent/AugmentedLLM setup. It covers routers, embedding routers, intent classifiers, parallel map-reduce/fan-out/fan-in, orchestrator/deep orchestrator flows, evaluator-optimizer loops, swarm handoffs, planner-style compositions, and structured outputs.
For basic MCPApp, Agent, server connections, and LLM setup, use the sibling ../core-sdk/SKILL.md. For Temporal or durable execution semantics, use ../durable-execution/SKILL.md. This sub-skill focuses on in-process pattern selection and code structure.
Fast Pattern Choice
- Use
LLMRouterorcreate_router_llm(...)when a request must be dispatched to the best agent, MCP server, or callable based on candidate descriptions and reasoning. - Use
EmbeddingRouterorcreate_router_embedding(...)when categories are stable and semantic-similarity scoring is preferable to another LLM call. - Use
LLMIntentClassifieror embedding intent classifiers when you need a fixed intent taxonomy, confidence, and optional extracted entities before routing. - Use
ParallelLLMorcreate_parallel_llm(...)when independent specialists can process the same input concurrently and a fan-in step can aggregate their outputs. - Use
Orchestratororcreate_orchestrator(...)when the system must plan sequential steps and delegate tasks to workers dynamically. - Use
DeepOrchestratororcreate_deep_orchestrator(...)for long-horizon research with budgets, memory, policy-driven replanning, and knowledge extraction. - Use
EvaluatorOptimizerLLMorcreate_evaluator_optimizer_llm(...)when a clear quality rubric can drive bounded refinement. - Use
SwarmAgentplusOpenAISwarm,AnthropicSwarm, orcreate_swarm(...)when a conversation should hand off between agents while preserving context variables.
Implementation Checklist
- Start inside
async with app.run() as running_app:and passcontext=running_app.contextto factory helpers so server registry, executor, secrets, tracing, and token tracking are shared. - Model specialists as
AgentSpec,Agent, existingAugmentedLLM, or deterministic callables depending on the helper. Keep agent names unique and instructions capability-specific. - Prefer factory helpers from
mcp_agent.workflows.factoryfor ordinary application code; drop to provider-specific classes only when you need direct constructor control. - For routers, use
LLMRouter, notRouterLLM. Preferroute_to_agent,route_to_server, orroute_to_functionwhen the destination type is known. - For embedding routers/classifiers, confirm the optional provider package and API key are configured before instantiating provider default models.
- For parallel workflows, make every fan-out worker independent; aggregate by source name and avoid assuming the first response is the winner.
- For evaluator loops, pass an explicit
QualityRatingthreshold and a smallmax_refinementscap. - For structured output, define Pydantic response models and call
generate_structured(..., response_model=YourModel, request_params=RequestParams(strict=True))where the provider supports strict mode. - Inspect token costs with
await workflow.get_token_node()after nested runs when budget matters. - Keep reusable code in your application, not in ad-hoc notebooks; use
scripts/pattern_skeletons.pyfrom this skill to print safe starting templates.
Reference Map
- Pattern selection guide:
references/pattern-selection.md - Current API and constructors:
references/api-reference.md - Reusable workflow skeletons:
references/workflows.md - Troubleshooting and validation:
references/troubleshooting.md - Import sanity checker:
scripts/check_workflow_imports.py - Skeleton printer:
scripts/pattern_skeletons.py
Safety Notes
- Provider examples may require optional extras and configured API keys. Import checks should not instantiate network clients unless you explicitly opt in.
- Parallel and orchestrator patterns multiply LLM calls. Estimate worst-case calls before enabling high
top_k, many fan-out agents, or high refinement counts. - Router and intent classifier confidence should gate irreversible actions. Escalate or ask a clarifying question when top candidates are close or low-confidence.
- Do not use workflow patterns to expose MCP servers or cloud/CLI operations; use the sibling skills for those areas.
04 同仓库更多 Skills
obsidian-clipper-template-creator
Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.
obsidian-clipper-template-creator
Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.
python-api
Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP/mAP semantics, and source-style import diagnostics.
file-evaluation
Folder-based PASCAL VOC AP/mAP evaluation from ground-truth and detection text files.
object-detection-metrics
Guides legacy Object-Detection-Metrics PASCAL VOC AP/mAP evaluation from detection text folders and direct Python API classes.
nx-workspace-patterns
Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.