Agent Workflow vs Agent-like Workflow
Let’s distinguish `Agent Workflow` vs `Agent-like Workflow` before diving into LangGraph.
When designing an LLM-based application, how to structure the agent-based processing flow is a critical decision. As I’ve been studying frameworks like LangGraph, I wanted to define my approach through two distinct patterns: Agent Workflow and Agent-like Workflow.
In this post, I’ll summarize the concepts, differences, and selection criteria between these two approaches.
Agent Workflow
An Agent Workflow leverages the built-in agent systems provided by LangGraph, such as the create_react_agent() functions.
Key Features
- Built-in reasoning loops (e.g., ReAct)
- Automatic management of tool usage, decision-making, and iterative reasoning
- Provides explicit APIs (
create_react_agent
)AgentExecutor
is used when building agents with LangChain. For reference, see the LangChain-Agent section.
- LLM-driven conversational flow and tool invocation
Example Usage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from ai.tools.get_time import get_current_datetime_tool
from ai.tools.repl import python_repl_tool
from ai.tools.search_web import googlenews_search_tool, tavily_search_tool
from ai.tools.retriever import pdf_retriever_tool
my_tools = [python_repl_tool, tavily_search_tool, googlenews_search_tool,
get_current_datetime_tool, pdf_retriever_tool]
llm = ChatOpenAI(
model=openai_api_model,
openai_api_base=openai_api_base,
openai_api_key=openai_api_key
)
agent = create_react_agent(
model=llm,
tools=my_tools,
state_modifier="You are a helpful assistant"
)
def run_agent(state: GraphState) -> GraphState:
response = agent.invoke({"messages": state["messages"]})
return {"messages": response["messages"]}
workflow = StateGraph(GraphState)
workflow.add_node("MyAgent", run_agent)
workflow.set_entry_point("MyAgent")
workflow.add_edge("MyAgent", END)
Agent-like Workflow
An Agent-like Workflow manually implements agent-like logic by explicitly composing workflow nodes using frameworks like LangGraph. Developers configure individual nodes (e.g., LLM nodes, tool nodes, conditional edges) to replicate agent behaviors. I expect to primarily adopt this approach when building with LangGraph going forward.
Key Features
- No reliance on LangGraph’s official agent APIs
- Explicit tool invocation and conditional logic defined by the developer
- Highly customizable workflow design
- Ideal for complex logic or hybrid human-agent collaboration
Example Usage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from ai.tools.get_time import get_current_datetime_tool
from ai.tools.repl import python_repl_tool
from ai.tools.search_web import googlenews_search_tool, tavily_search_tool
from ai.tools.retriever import pdf_retriever_tool
my_tools = [python_repl_tool, tavily_search_tool, googlenews_search_tool,
get_current_datetime_tool, pdf_retriever_tool]
llm_with_tools = ChatOpenAI(
model=openai_api_model, # OpenRouter 모델 이름
openai_api_base=openai_api_base,
openai_api_key=openai_api_key,
max_tokens=1000
).bind_tools(tools=my_tools)
tool_node = ToolNode(tools=my_tools)
def run_llm_with_tools(state: GraphState) -> GraphState:
response = llm_with_tools.invoke(state["messages"])
return {"messages": [response]}
workflow = StateGraph(GraphState)
workflow.add_node("MyLLM", run_llm_with_tools)
workflow.add_node("tools", tool_node)
workflow.set_entry_point("MyLLM")
workflow.add_conditional_edges("MyLLM", tools_condition)
workflow.add_edge("tools", "MyLLM")
Choosing the Right Workflow
Scenario | Recommended Workflow |
Simple QA agents using predefined tools | Agent Workflow |
Complex interactions involving conditional logic and human input | Agent-like Workflow |
Workflows needing explicit control over reasoning steps | Agent-like Workflow |
Developing LangGraph-based LLM apps | Agent-like Workflow |
Conclusion
Using LangGraph’s Agent Workflow is beneficial for rapid development and simpler use cases. However, as your application grows in complexity, LangGraph’s Agent-like Workflow provides superior flexibility and control.
Stay tuned for future posts detailing step-by-step implementations and practical examples of building Agent-like Workflows with LangGraph.