VOOZH about

URL: https://docs.langchain.com/oss/python/langchain/multi-agent/custom-workflow

⇱ Custom workflow - Docs by LangChain


Documentation Index

Fetch the complete documentation index at: /llms.txt

Use this file to discover all available pages before exploring further.

Skip to main content
In the custom workflow architecture, you define your own bespoke execution flow using LangGraph. You have complete control over the graph structure—including sequential steps, conditional branches, loops, and parallel execution.

Key characteristics

  • Complete control over graph structure
  • Mix deterministic logic with agentic behavior
  • Support for sequential steps, conditional branches, loops, and parallel execution
  • Embed other patterns as nodes in your workflow

When to use

Use custom workflows when standard patterns (subagents, skills, etc.) don’t fit your requirements, you need to mix deterministic logic with agentic behavior, or your use case requires complex routing or multi-stage processing. Each node in your workflow can be a simple function, an LLM call, or an entire agent with tools. You can also compose other architectures within a custom workflow—for example, embedding a multi-agent system as a single node. For a complete example of a custom workflow, see the tutorial below.

Tutorial: Build a multi-source knowledge base with routing

The router pattern is an example of a custom workflow. This tutorial walks through building a router that queries GitHub, Notion, and Slack in parallel, then synthesizes results.

Basic implementation

The core insight is that you can call a LangChain agent directly inside any LangGraph node, combining the flexibility of custom workflows with the convenience of prebuilt agents:
from langchain.agents import create_agent
from langgraph.graph import StateGraph, START, END

agent = create_agent(model="openai:gpt-5.5", tools=[...])

def agent_node(state: State) -> dict:
 """A LangGraph node that invokes a LangChain agent."""
 result = agent.invoke({
 "messages": [{"role": "user", "content": state["query"]}]
 })
 return {"answer": result["messages"][-1].content}

# Build a simple workflow
workflow = (
 StateGraph(State)
 .add_node("agent", agent_node)
 .add_edge(START, "agent")
 .add_edge("agent", END)
 .compile()
)

Example: RAG pipeline

A common use case is combining retrieval with an agent. This example builds a WNBA stats assistant that retrieves from a knowledge base and can fetch live news.
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

Was this page helpful?