Overview
we sometimes want LLM systems that can pick their own control flow to solve more complex problems! This is one definition of anย [agent](https://blog.langchain.dev/what-is-an-agent/):ย _an agent is a system that uses an LLM to decide the control flow of an application.
๋ค์ํ ์ข
๋ฅ์ AI agent ์กด์ฌ

Router
- Single step decision, 1๋จ๊ณ ์์ฌ ๊ฒฐ์
- Single decision์ ์ค์ , ์๋์ ์ผ๋ก ์์ ๋ ๋ฎ์
Structured Output
์๋ต ๊ตฌ์กฐํ
- Output parsers: Client์๊ฒ ๋ฏธ๋ฆฌ ์ ์๋ ๊ตฌ์กฐํ๋ ์๋ต ์ ๋ฌ e.g. JSON ์๋ต ์ ๋ฌ
- Tool calling: ์ ์๋ Tools์ ์ฌ์ฉํ๊ธฐ ์ํด ๊ตฌ์กฐํ๋ ์๋ต์ ์ ๋ฌ e.g. ๋ค์ด๋ฒ ์ผํ ๊ฒ์ Tool์๊ฒ JSON ํํ๋ก ์์ฒญ
Tool-calling agent
- Multi step decision, ๋ค๋จ๊ณ ์์ฌ ๊ฒฐ์
- ์ ์ ํ Tool์ ํ์ฉ ReAct ๊ฐ ๋ฒ์ฉ์ ์ธ Agent์ด๊ณ ์๋ ํน์ง์ ๊ฐ์
Tool calling

Memory
์ผ๋ฐ์
- Short-term memory
- Long-term memory
LangGraph
- State: User-defined memory
- Checkpointer: ๋งค๋จ๊ณ ๋ง๋ค ์ํ๋ฅผ ์ ์ฅํ๋ ๋งค์ปค๋์ฆ
- Store: user-specific or application-level data ์ ์ฅ ๋งค์ปค๋์ฆ Manage memory on LangGraph
Planning
Tool-calling agent๋ ๋ฐ๋ณต์ ์ผ๋ก while-loop ํธ์ถ.
Custom agent architectures
Router์ Tool-calling agent๊ฐ ์๋ ์ปค์คํ ํ agent
Human-in-the-loop
์ธ๊ฐ ๊ฐ์ agent Human-in-the-loop
- Approving specific actions
- Providing feedback
Parallelization
for efficient multi-agent systems and complex tasks. LangGraph์์ Send API๋ก ์ง์
Subgraphs
for managing complex agent architectures, particularly in multi-agent systems.
- ๋ ๋ฆฝ๋ ์ํ ๊ด๋ฆฌ
- ์์ด์ ํธ ๊ฐ ๊ณ์ธต์ ์กฐ์งํ ๋ถ๋ชจ ๊ทธ๋ํ์ ์ค๋ฒ๋ฉํํ key๋ฅผ ํตํด ์ํต Use subgraphs
Reflection
ํด๋น ๋งค์ปค๋์ฆ์ agent์ ์ ๋ขฐ์ฑ์ ํฅ์ ์ํจ๋ค.
- ํ ์คํฌ ํ๊ฐ
- ํผ๋๋ฐฑ ๋ฐ ์กฐ์ธ
- ํ์ต https://youtu.be/MvNdgmM7uyc?feature=shared
https://langchain-ai.github.io/langgraph/tutorials/workflows/
Workflows & agents
- ์ผ๋ฐ์ ์ธ agentic systems ํจํด
- workflows์ agent๋ฅผ ๊ตฌ๋ถํ๋ ๊ฒ์ด ์ ์ฉ
Workflows are systems where LLMs and tools are orchestrated through predefined code paths. Agents, on the other hand, are systems where LLMs dynamically direct their own processes and tool usage, maintaining control over how they accomplish tasks.

The Augmented LLM
LLM์ ์ธ์๋ฅผ ์ถ๊ฐํ๋ ๋จ์ํ ๋ฐฉ๋ฒ
from pydantic import BaseModel, Field
## structured outputs
class SearchQuery(BaseModel):
search_query: str = Field(None, description="Query that is optimized web search.")
justification: str = Field(
None, description="Why this query is relevant to the user's request."
)
# Augment the LLM with schema for structured output
structured_llm = llm.with_structured_output(SearchQuery)
# Invoke the augmented LLM
output = structured_llm.invoke("How does Calcium CT score relate to high cholesterol?")
## tool calling
def multiply(a: int, b: int) -> int:
return a * b
# Augment the LLM with tools
llm_with_tools = llm.bind_tools([multiply])
# Invoke the LLM with input that triggers the tool call
msg = llm_with_tools.invoke("What is 2 times 3?")
# Get the tool call
msg.tool_callsPrompt chaining
์ด์ ์ ๊ฒฐ๊ณผ๋ฅผ ๋ค์ ์
๋ ฅ์ผ๋ก ์ฐ๊ฒฐํ๋ ๋ฐฉ๋ฒ์ผ๋ก ํ๋จ๋จ. LangChain์ ์ฌ์ฉํ๋ ๊ฒ์ด ์ํ์ค์ ๋ฐ๋ผ ์ฒ๋ฆฌ๋๋ ๊ฒ์ผ๋ก ์ดํด

Parallelization
๋ณ๋ ฌ๋ก ํ ์คํฌ ์งํ ํ ์ง๊ณํด์ ๊ฒฐ๊ณผ ๋ฐํ

Routing
์
๋ ฅ์ ๋ถ๋ฆฌํ๊ณ ํ์ ์์
์ผ๋ก ์๋ด

Orchestrator-Worker
subtasks๊ฐ ํ์ํ ์์ธกํ ์ ์๋ ๋ณต์กํ ํ
์คํฌ
c.f. Parallelization โ ์ ์ฐ์ฑ, subtasks๋ ๋ฏธ๋ฆฌ ์ ์๋๋ ๊ฒ์ด ์๋ orchestrator๊ฐ ์ค์ค๋ก ๊ฒฐ์

Evaluator-optimizer
๋ช
ํํ ํ๊ฐ ๊ธฐ์ค, ์ธก์ ๊ฐ๋ฅํ ๊ฐ์ด ์์ ๋ ํจ๊ณผ์ ,
e.g. ์๊ฐ๊ฐ ์ธ๋ จ๋ ๋ฌธ์๋ฅผ ์์ฑ์ ์ ๋ฐ๋ณต์ ์ผ๋ก ๊ธ์ ์์ ํ๋ ๊ณผ์ ๊ณผ ๋น์ท

Agent
ํ์ํ ๋จ๊ณ ์๋ฅผ ์์ธกํ๊ธฐ ์ด๋ ต๊ฑฐ๋ ๋ถ๊ฐ๋ฅ, ๋จ๊ณ๋ฅผ ์ ํ ์ ์๋ ๊ฐ๋ฐฉํ ๋ฌธ์ ์ ์ ํฉ
LangChain์์๋ ๋ฏธ๋ฆฌ ์ ์๋ Agent ์กด์ฌ e.g. https://langchain-ai.github.io/langgraph/reference/agents/#langgraph.prebuilt.chat_agent_executor.create_react_agent
