[LLM] Agent Development Kit (ADK)
Agent Development Kit(์ดํ ADK)๋ ๊ตฌ๊ธ์์ ๋ฐํํ ์์ด์ ํธ ๊ฐ๋ฐ์ฉ ํ๋ ์์ํฌ๋ค.
์ฑํ
์ผ๋ก ๋ํ๋๋ LLM ์์ด์ ํธ ๊ฐ๋ฐ์ฉ์ผ๋ก ๋ง๋ค์ด์ก๋ค.
ํ์ฌ๋ Python๊ณผ Java ์ ๋๋ง ์ง์๋๋ค. ๋ฉ์ธ์ ๋น์ฐํ Python์ด๋ค.
๊ตฌ๊ธ์์ ์ ๊ณตํ๋ Gemini๋ vertex API๋ฅผ ์ฃผ๋ก ์ด๋ค๋ ๊ฐ์ ํ์ ์น์ ํ๊ฒ ๊พธ๋ฉฐ๋์ ๋ชจ์์๋ค. ๋ฌผ๋ก Gemini์ ์ข ์๋ ๊ตฌ์กฐ๋ ์๋๋ผ์ Claude๋ GPT ๊ฐ์ LLM ๋ชจ๋ธ๋ค๊ณผ๋ ํตํฉ์ด ๊ฐ๋ฅํ๊ธด ํ๋ค.
์ฌ๊ธฐ์๋ ๊ฐ๋ต์ ์ธ ์ฌ์ฉ ๊ตฌ์กฐ์ ๊ธฐ๋ณธ์ ์ธ ์์ ์ ๋๋ง์ ๋ค๋ค๋ณธ๋ค.
๊ตฌ์กฐ
๊ธฐ๋ณธ์ ์ธ ๊ตฌ์กฐ๋ ๋ฐฉ๋ฒ๋ก ์์ฒด๋ ๋น๊ต์ ๊ฐ๋จํ ํธ์ด๋ค.
๋ณ๋์ ์์ด์ ํธ ๋จ์๋ฅผ ํด๋์ค ๋จ์๋ก ์ ์ํ๊ณ , ๊ทธ๊ฑธ ํ์์ ๋ฐ๋ผ์ ์ฐ๊ฒฐํ๊ณ ์ํธ๊ฐ์ ํธ์ถํ ์ ์๊ฒ ์ฎ์ด์ฃผ๋ ๊ฒ์ด ๊ณจ์๋ค.

๊ทธ ์ธ์๋ ์ด๊ฒ์ ๊ฒ ์ง์ํ๊ธด ํ๋ค.
tool ๊ด๋ฆฌ ๊ธฐ๋ฅ๋ ์๊ณ , ๊ฐ๋ฐ/๋๋ฒ๊น
๋ณด์กฐ์ฉ ๋๊ตฌ๋ค์ ์ฝ๊ฐ ์ง์ํ๋ค.

์ค์น
์ค์น ์์ฒด๋ ๊ฐ๋จํ๋ค. ๋จ์ผ ์ข ์์ฑ์ผ๋ก ๋ฐ๋ก ์ฌ์ฉํ ์ ์๋ค.
uv add google-adk

ํฌ๊ธฐ๋ 340mb์ฏค ๋๋ค. ๋ก์น ์ ํ๋ ํด๋์ ์ข ๋น๋ํ ํธ์ด๋ค.


ํ๋ก์ ํธ ๊ธฐ๋ณธ ๊ตฌ์กฐ
๋จผ์ , LLM์ ์ฌ์ฉํ๊ธฐ ์ํ API Key๋ฅผ ์ค๋นํด์ผ ํ๋ค.
GCP API๋ฅผ ํตํด์ Gemini๋ฅผ ์ด๋ค๋ฉด, ์ด๋ ๊ฒ .env ํ์ผ์ ํตํด์ GOOGLE_API_KEY ํ๊ฒฝ๋ณ์๋ก ํค๋ฅผ ์ค์ ํ ์ ์๋ค.
์ด๊ฑด ํ๋ก์ ํธ ๋ฃจํธ ๊ฒฝ๋ก์ ์์ด๋ ๋๊ณ , ์์ด์ ํธ๋ณ ๋ณ๋ ๋๋ ํฐ๋ฆฌ์ ์์ด๋ ๋๋ค.
๊ทธ๋ฆฌ๊ณ ์ด๊ฒ ํ๋ก์ ํธ์ ๊ธฐ๋ณธ์ ์ธ ํํ๋ค.
์์ด์ ํธ๋ง๋ค ํด๋๋ฅผ ๋ง๋ค๊ณ , agent.py๋ผ๋ ๊ธฐ๋ณธ ์ง์
์ ํ์ผ์ ์ถ๊ฐํ๋ค.

๊ฐ agent.py์๋ ๋ค์๊ณผ ๊ฐ์ด ์์ด์ ํธ ์ ์๊ฐ ๋ค์ด๊ฐ๋ฉด ๋๋ค.
from google.adk.agents import Agent
root_agent = Agent(
name="hello_agent",
model="gemini-2.0-flash",
description=("Agent to say hello."),
instruction=(
"You are an agent who handles greetings and basic daily conversations."
),
tools=[],
)
description์ ๋๋ต์ ์ธ agent์ ์ญํ ์ ๋ช
์ํ๊ณ , instruction์ ์ธ๋ถ์ ์ธ ์ง์์ฌํญ๋ค์ ์ ์ํ๋ ๋ถ๋ถ์ด๋ค.
tools๋ ์ธ๋ถ ์์ค๋ ๋ญ ๊ทธ๋ฐ๊ฑธ ์ถ๊ฐํ๋๊ฑด๋ฐ, ๊ทธ๊ฑด ์ถํ์ ๋ค์ ์ ๋ฆฌํด๋ณด๊ฒ ๋ค.
๊ธฐ๋ณธ ์ฌ์ฉ๋ฒ: adk CLI
adk CLI๋ฅผ ํตํด์ ์ ์ดํ๋ ๊ฒ์ ๊ถ์ฅํ๋ค.

adk web์ ์ฌ์ฉํ๋ฉด, ํ์ฌ ๋๋ ํฐ๋ฆฌ ๊ธฐ์ค์ผ๋ก ์์ด์ ํธ ๊ตฌ์ฑ์ ์ฝ์ด์ ๋๋ฒ๊ทธ์ฉ ํ์ด์ง๋ฅผ ์์ฑํด์ค๋ค.

๊ทธ๋ฌ๋ฉด ์ด๋ฐ ์ ๊พธ๋ฉฐ์ง ํ์ด์ง๊ฐ ๋จ๊ณ

์์ด์ ํธ๋ฅผ ๊ณจ๋ผ์ ์คํํ ์ ์์ผ๋ฉฐ

์ฆ์ ๋๋ ค๋ณด๋ฉด์ ํ ์คํธํ ์ ์๋ค.

api_server ๋ช ๋ น์ ์ฌ์ฉํ๋ฉด ์ ๊ธฐ์ ๊ทธ๋ฅ API ์๋ฒ๋ง ์คํ๋๊ฒ ํ ์ ์๋ค.

์ข ๋ญ๊ฐ ๋ง๊ธด ํ๋ค.
ํ๋กฌํํธ ์ค์ - instruction
LLM์ ํ๋ ๋ฐฉ์์ ์ ์ดํ๋ ค๋ฉด, instruction ํ๋๋ฅผ ํตํด์ ํ๋กฌํํธ๋ฅผ ์ค์ ํ๋ฉด ๋๋ค.

๋์ ๋ฐฉ์ ์์ฒด๋ ๋จ์ํ๋ค.
๋ง์ฝ ํ๋กฌํํธ๋ฅผ ๋์ ์ผ๋ก ๊ด๋ฆฌํ๊ณ ์ถ๋ค๋ฉด, before_model_callback ๋ฑ์ ํตํด์ state๋ฅผ ์กฐ์ํ๊ณ , state variable ๊ธฐ๋ฐ์ผ๋ก ํ๋กฌํํธ ํ
์คํธ๊ฐ ๋ณ๊ฒฝ๋๊ฒ๋ ๋ง๋ค ์ ์๋ค.
์ฌ๊ธฐ์๋ ์์ธํ ๊ฒ๊น์ง๋ ๋ค๋ฃจ์ง ์๊ณ ๋์ด๊ฐ๋ค.
Tools
tools๋ ADK์์ ์ธ๋ถ ์์ค์ ์ ๊ทผํ๊ธฐ ์ํ ์๋จ์ด๋ค.
๋ฐ์ดํฐ๋ฒ ์ด์ค์ ์ ๊ทผํ๋ค๊ฑฐ๋, ๋ ์จ๋ ์๊ฐ ์ ๋ณด๋ฅผ ๊ฐ์ ธ์จ๋ค๊ฑฐ๋ ํ๋, LLM ์์ฒด์ ์ผ๋ก ํ๋ํ ์ ์๋ ์์ค๋ฅผ ์ฐ๊ฒฐํ๊ธฐ ์ํ ์๋จ์ด๋ค.
์๋ฅผ ๋ค์ด, ์๊ฐ ์ ๋ณด๋ฅผ LLM์ ์ฃผ๊ณ ์ถ๋ค๋ฉด ์ด๋ฐ ์์ผ๋ก tool์ ์ ์ํ ์ ์๋ค.
ํจ์ ๋ด ๊ตฌํ์ด ์ด๋ป๊ฒ ๋๋์ง๋ ๊ทธ๋ค์ง ์ค์ํ์ง ์๋ค.
ํจ์ ๋ด ์ฝ๋ฉํธ๋ฅผ ํตํด์ ํด๋น tool ํจ์์ ๋์๊ณผ, ์
๋ ฅ/์ถ๋ ฅ๊ฐ์ ์ ์ ์ํ๋ ๊ฒ์ด ์ค์ํ๋ค.
๊ทธ๋ฆฌ๊ณ ์ ๊ฑธ tools์ ๋๊ฒจ์ฃผ๋ฉด ๋์ด๋ค.
๊ทธ๋ฌ๋ฉด Agent๊ฐ ์ ์ฝ๋ฉํธ์ ๊ธฐ๋ฐํด์, ํ์ํ๋ค๊ณ ํ๋จ๋๋ tool์ ์์จ์ ์ผ๋ก ํธ์ถํ๋ ๊ฒ์ด๋ค.
๊ทธ๋ฌ๊ณ ๋์ ์คํํด๋ณด๋ฉด
์ด๋ฐ ์์ผ๋ก ํธ์ถํด์ LLM์ด ๋ด๋ถ์ ์ผ๋ก ๋ฐ์๋ค๊ฐ ์ฐ๊ฒ ๋๋ค.
๋ฉํฐ ์์ด์ ํธ ๊ตฌ์ฑ
์ด๋ฐ ์์ด์ ํธ ํ๋ ์์ํฌ๋ฅผ ์ฐ๋ ์ฃผ์ํ ์ด์ ์ค ํ๋๊ฐ, ์ฌ๋ฌ๊ฐ์ ์์ด์ ํธ๋ก ๊ตฌ์ฑ๋ ๋ฉํฐ ์์ด์ ํธ ์์คํ ์ ๊ตฌ์ฑํ๊ณ ๊ด๋ฆฌํ๊ธฐ ์ํ ๊ฒ์ด๋ค.

from google.adk.agents import Agent
dev_agent = Agent(
name="dev_agent",
model="gemini-2.0-flash",
description=("Agent informing about programming"),
instruction="""
1. You are an agent who handles programming-related queries.
2. You must always answer about programming.
""",
tools=[],
)
food_agent = Agent(
name="food_agent",
model="gemini-2.0-flash",
description=("Agent informing about food"),
instruction="""
1. You are an agent who handles food-related queries.
2. You must always answer about food.
""",
tools=[],
)
root_agent = Agent(
name="root_agent",
model="gemini-2.0-flash",
description=("Root agent"),
instruction="""
1. You are the root agent.
2. You must always answer about programming or food.
""",
tools=[],
sub_agents=[dev_agent, food_agent],
)
์ด๋ฐ ์์ผ๋ก, ์ด๋ค ์์ด์ ํธ๊ฐ ๋ค๋ฅธ ์์ด์ ํธ๋ฅผ ํธ์ถํ๊ฒ ํ๋ ค๋ฉด sub_agents๋ก ๋ค๋ฅธ ์์ด์ ํธ ์ ์๋ฅผ ๊ตฌ๊ฒจ๋ฃ์ผ๋ฉด ๋๋ค.
์ด ๊ฒฝ์ฐ์๋ "๊ฐ๋ฐ"๊ณผ "์์"์ ๋ํ ์์ด์ ํธ๋ฅผ ๋ณ๋๋ก ์ ์ํ๊ณ , root ์์ด์ ํธ๊ฐ ์ํฉ์ ๋ฐ๋ผ์ ํ์ํ ๊ฒฝ์ฐ ํธ์ถํ ์ ์๊ฒ ํ๋ค.
๊ทธ๋ฌ๋ฉด ์ด๋ฐ ์์ผ๋ก root => food์ ์์๋ก ์์ด์ ํธ๋ฅผ ํธ์ถํด์ ๊ฒฐ๊ณผ๋ฅผ ๋์ถํ ๊ฒ์ด๋ค.
์์ ์คํ ๋ก๊ทธ๋ ์ด๋ฒคํธ๋ก ํ์ธ ๊ฐ๋ฅํ๋ค.
์ฐธ์กฐ
https://developers.googleblog.com/en/agent-development-kit-easy-to-build-multi-agent-applications/
https://google.github.io/adk-docs/agents/llm-agents/
https://dev.to/masahide/smarter-adk-prompts-inject-state-and-artifact-data-dynamically-placeholders-2dcm