- AG-UI Tool์ Agent๊ฐ ํธ์ถํ ์ ์๊ณ Frontend๊ฐ ์ ์ยท์คํํ ์ ์๋ ํจ์ ์ธํฐํ์ด์ค
- LLM ์ถ๋ก ๊ฒฐ๊ณผ๋ฅผ ์ธ๋ถ ์ก์ ยทUI ์กฐ์ยท์ฌ์ฉ์ ํ์ธ์ผ๋ก ์ฐ๊ฒฐํ๋ ๋ค๋ฆฌ
- JSON Schema๋ก ๋ช ์ธ๋๊ณ , ํ๋กํ ์ฝ ์ด๋ฒคํธ๋ก ์คํธ๋ฆฌ๋ฐ๋๋ ํ์คํ๋ ํธ์ถ ๋จ์
ํด๋น ๊ฐ๋ ์ด ํ์ํ ์ด์
- LLM ์ถ๋ก ๋ง์ผ๋ก๋ ์ธ๋ถ ์์คํ ์กฐ์ยท์ฌ์ฉ์ ์ ๋ ฅ ์์ง ๋ถ๊ฐ
- Backend tool ์ค์ฌ ์ค๊ณ๋ UI ์ํยท์ฌ์ฉ์ ๊ถํ์ ๋ฐ์ํ๊ธฐ ์ด๋ ค์
- HITL(Human-in-the-Loop)์ ์์ฐ์ค๋ฝ๊ฒ ํํํ ์ผ๊ธ ๋ฉ์ปค๋์ฆ ํ์
- ๋ค์ํ ๋ฐฑ์๋(LangGraph/CrewAI/Mastraโฆ) ๊ฐ tool call ํฌ๋งท ํต์ผ ํ์
AS-IS
๊ธฐ์กด LLM tool calling์ ๋ฐฑ์๋๊ฐ tool์ ์ ์ยท์คํํด UI/์ฌ์ฉ์ ์ปจํ ์คํธ์ ๋ถ๋ฆฌ๋๋ค.
sequenceDiagram autonumber participant FE as Frontend participant BE as Backend(Agent) participant LLM participant Sys as External System BE->>LLM: tools ์ ์ (๋ฐฑ์๋ ์์ ) LLM->>BE: tool call BE->>Sys: tool ์คํ Sys-->>BE: result BE-->>FE: ์ต์ข ์๋ต๋ง ์ ๋ฌ
TO-BE
AG-UI๋ frontend tool๊ณผ backend tool์ ํผ์ฌ์ํฌ ์ ์๊ณ , ํธ์ถ ๊ณผ์ ์ด ํ์ค ์ด๋ฒคํธ๋ก ์คํธ๋ฆฌ๋ฐ๋๋ค. Frontend tool์ด ์ถ๊ฐ๋ ๊ฒ์ด์ง ๊ธฐ์กด backend tool์ด ์ฌ๋ผ์ง ๊ฒ์ด ์๋๋ค. ํ๋ก ํธ์๋๋ AbstractAgent์ runAgent({ tools }) ์ง์
์ ์ ํตํด ๋งค ์คํ๋ง๋ค tool ์
์ ์ฃผ์
ํ๋ค.
sequenceDiagram autonumber participant FE as Frontend participant BE as Backend(Agent) participant LLM participant Sys as External System FE->>BE: runAgent({ tools, messages, state }) Note over BE: tools = frontend tools + backend tools (ํผ์ฌ ๊ฐ๋ฅ) BE->>LLM: tools ์ฃผ์ LLM-->>BE: TOOL_CALL_* ์ด๋ฒคํธ ๋ฐ์ alt Frontend Tool์ธ ๊ฒฝ์ฐ BE-->>FE: TOOL_CALL_START / ARGS(delta) / END ์คํธ๋ฆฌ๋ฐ FE->>FE: tool ์คํ (UI ๋ค์ด์ผ๋ก๊ทธยทํ์ด์ง ์ด๋ ๋ฑ) FE->>BE: tool message (role: "tool") else Backend Tool์ธ ๊ฒฝ์ฐ BE->>Sys: tool ์คํ (DBยท์ธ๋ถ API ๋ฑ) Sys-->>BE: result BE-->>FE: TOOL_CALL_* ์ด๋ฒคํธ + ๊ฒฐ๊ณผ (๊ฐ์์ฑ ์ ๊ณต) end BE->>LLM: ๊ฒฐ๊ณผ ํฌํจํ์ฌ ์๋ต ์์ฑ
Tool ๊ตฌ์กฐ
name, description, parameters 3ํ๋ ๊ตฌ์ฑ. parameters๋ JSON Schema๋ฅผ ๊ทธ๋๋ก ์ฌ์ฉ.
interface Tool {
name: string
description: string // LLM์ด "์ธ์ ์ธ์ง" ํ๋จ
parameters: {
type: "object",
properties: { ... },
required: string[]
}
}์ด ๊ตฌ์กฐ๋ OpenAI function calling, Anthropic tool use, MCP๊ฐ ๋ชจ๋ ์ฐ๋ ๊ณต์ฉ ํ์์ด๋ค. AG-UI๋ ์ด๋ฅผ ๊ทธ๋๋ก ์ฐจ์ฉํด LLM ํธํ์ฑ๊ณผ ์ํธ์ด์ฉ์ฑ์ ํ๋ณดํ๋ค.
์ ๊ณ ํ์ค๊ณผ AG-UI ๊ณ ์ ํ์ฅ์ ๊ด๊ณ
AG-UI Tool์ ์๋ก์ด ํ์์ ๋ฐ๋ช ํ ๊ฒ์ด ์๋๋ผ, ์ ๊ณ ํ์ค์ ์ฐจ์ฉํ๋ฉด์ ๊ทธ ์์ ๋ ๊ฐ์ง ๊ณ ์ ํ์ฅ์ ์น์ ๊ตฌ์กฐ๋ค. ์ด ๊ตฌ๋ถ์ ์ก๊ณ ๊ฐ๋ฉด ์ดํ ๋ด์ฉ์ด ํ ์ค๋ก ๊ฟฐ์ด์ง๋ค.
์ฐจ์ฉํ ๋ถ๋ถ (์ ๊ณ ํ์ค)
- Tool ์ ์ ๋ชจ์ (
name/description/parameters) - JSON Schema ๊ธฐ๋ฐ ํ๋ผ๋ฏธํฐ ๋ช ์ธ
- Tool result ๋ฉ์์ง ํ์ ([[AG-UI Messages|
role: "tool"]])
AG-UI๊ฐ ๋ํ ๋ถ๋ถ (๊ณ ์ ํ์ฅ)
- ์์ ๊ถ ๋ชจ๋ธ ํ์ฅ โ Tool์ ์ ์ํ๊ณ ์คํํ๋ ๊ถํ์ด backend ๋ ์ ์์ frontend๋ ๊ฐ๋ฅํ๋๋ก ์ด๋
- ํธ์ถ ๊ณผ์ ์ ํ๋กํ ์ฝํ โ Tool call์ ํ์ค ์ด๋ฒคํธ(
TOOL_CALL_STARTโTOOL_CALL_ARGSร N โTOOL_CALL_END)๋ก ์ ๊ทํ
โFrontend toolโ์ด๋ผ๋ ์ ์ข ๋ฅ๊ฐ ์ถ๊ฐ๋ ๊ฒ์ด ์๋๋ผ, Tool์ ๋๊ฐ ์ ์ํ๊ณ ๋๊ฐ ์คํํ๋์ง์ ๊ถํ ์์ฒด๊ฐ ์ ์ฐํด์ง ๊ฒ์ผ๋ก ์ดํดํด์ผ ํ๋ค. ๊ทธ๋ฆฌ๊ณ ์ด ๋ ํ์ฅ์ด ๊ฒฐํฉ๋์ด ํ์ ํ HITL์ ์ผ๊ธํ๋ก ์ด์ด์ง๋ค.
ํ์ฅ โ : ์์ ๊ถ ๋ชจ๋ธ โ Frontend๊ฐ ์ ์ยท์คํํ ์ ์๋ค
Frontend-defined Tools
Tool ์ ์ ์์ ๊ถ์ด frontend์ ์๋ค. runAgent({ tools })๋ก ๋งค ์คํ๋ง๋ค ๋ค๋ฅธ tool ์
์ ์ฃผ์
ํ ์ ์์ด, ๊ฐ์ agent๋ผ๋ ํ๋ฉดยท์ฌ์ฉ์ ๊ถํยท์ฑ ์ํ์ ๋ฐ๋ผ ๋ค๋ฅธ ๋ฅ๋ ฅ์ ๊ฐ๋๋ค.
Frontend-executed Tools
์ ์๊ฐ frontend๋ก ์ด๋ํ๊ธฐ ๋๋ฌธ์, ์คํ ์์น๋ ์์ฐ์ค๋ฝ๊ฒ frontend๊ฐ ๊ฐ๋ฅํด์ง๋ค. ๋ค์ด์ผ๋ก๊ทธ ํ์ยทํ์ด์ง ์ด๋ยทlocalStorage ์ ๊ทผ ๊ฐ์ UI ์ก์ ์ด ๊ทธ ์์ฒด๋ก tool์ด ๋๋ฉฐ, โ์ฌ์ฉ์์๊ฒ ๋ฌป๊ธฐโ๊ฐ ๋ณ๋ ๋ฉ์ปค๋์ฆ ์์ด ์ผ๋ฐ tool ํธ์ถ๊ณผ ๋์ผํ๊ฒ ์ฒ๋ฆฌ๋๋ค.
Frontend/Backend Tool ํผ์ฌ
ํ agent๊ฐ ๋ ์ข ๋ฅ๋ฅผ ๋์์ ๋ณด์ ํ ์ ์๋ค. Agent๋ ๋ชจ๋ ๊ฐ์ ๋ฐฉ์์ผ๋ก ํธ์ถํ์ง๋ง, ์ฒ๋ฆฌ ์ฃผ์ฒด๋ tool์ด ์ ์๋ ์์น๊ฐ ๊ฒฐ์ ํ๋ค. ๋ณด์์ด ํ์ํ ์์ ์ backend, ์ฌ์ฉ์ ์ํธ์์ฉ์ด ํ์ํ ์์ ์ frontend๋ก ์์ฐ์ค๋ฝ๊ฒ ๊ฐ๋ฆฐ๋ค.
ํ์ฅ โก: Tool Call Lifecycle ํ์คํ
OpenAIยทAnthropic๋ tool call์ ์คํธ๋ฆฌ๋ฐํ์ง๋ง ๊ฐ์ ๋ค๋ฅธ SSE ํฌ๋งท์ ์ฌ์ฉํ๋ค. AG-UI๋ ์ด๋ฅผ ๋ฐฑ์๋ยทํ๋ ์์ํฌ ๋ฌด๊ดํ ํ์ค ์ด๋ฒคํธ 3๋จ๊ณ๋ก ์ ๊ทํํ๋ค.
sequenceDiagram autonumber participant Agent participant FE as Frontend Agent-->>FE: TOOL_CALL_START { toolCallId, toolCallName } Agent-->>FE: TOOL_CALL_ARGS { delta: '{"act' } Agent-->>FE: TOOL_CALL_ARGS { delta: 'ion":"Depl' } Agent-->>FE: TOOL_CALL_ARGS { delta: 'oy"}' } Agent-->>FE: TOOL_CALL_END { toolCallId } Note over FE: delta ๋์ โ ์์ ํ JSON ๋ณต์ FE->>FE: tool ์คํ FE->>Agent: tool message { role: "tool", toolCallId, content }
delta๋ ์ธ์ JSON์ partial ๋ฌธ์์ด์ด๋ฉฐ, frontend๊ฐ ๋์ ํด ์์ ํ ์ธ์๋ฅผ ๋ณต์ํ๋ค. toolCallId๋ก ํธ์ถ๊ณผ ๊ฒฐ๊ณผ๋ฅผ ๋งค์นญํ๋ฏ๋ก, ์ฌ๋ฌ tool์ด ๋ณ๋ ฌ๋ก ํธ์ถ๋์ด๋ ์๋ต ๋งคํ์ด ์ด๊ธ๋์ง ์๋๋ค.
Tool Result ๋ฉ์์ง
Tool ์คํ ๊ฒฐ๊ณผ๋ ๋ํ ํ์คํ ๋ฆฌ์ role: "tool" ๋ฉ์์ง๋ก ์ถ๊ฐ๋๋ค. ์ด ํ์์ OpenAI ์ปจ๋ฒค์
์ ๊ทธ๋๋ก ์ฐจ์ฉํ ํ์ค ๋ถ๋ถ์ด๋ค.
{
id: "result-789",
role: "tool",
content: "approved", // ๊ฒฐ๊ณผ๋ ํญ์ string
toolCallId: "tool-123" // ์๋ ํธ์ถ๊ณผ ๋งค์นญ
}์ด ๋ฉ์์ง๊ฐ ๋ค์ LLM ํธ์ถ ์ ์ปจํ ์คํธ์ ํฌํจ๋์ด, agent๊ฐ ๊ฒฐ๊ณผ๋ฅผ ์ฐธ์กฐํ๋ฉฐ ์๋ต์ ์ด์ด๊ฐ๋ค.
๋ ํ์ฅ์ ๊ฒฐ๊ณผ: HITL์ด ์ผ๊ธ ์๋ฏผ์ด ๋๋ค
์์ ๊ถ ๋ชจ๋ธ ํ์ฅ๊ณผ lifecycle ํ์คํ๊ฐ ๊ฒฐํฉ๋๋ฉด, HITL(Human-in-the-Loop)์ด ํ๋กํ ์ฝ์ ์ผ๊ธ ์๋ฏผ(first-class citizen) ์ผ๋ก ํํ๋๋ค.
์ผ๊ธ ์๋ฏผ์ด๋? ํ๋ก๊ทธ๋๋ฐ ์ธ์ด ์ด๋ก ์ฉ์ด๋ก, ์ด๋ค ์์๊ฐ ๋ค๋ฅธ ์์๋ค๊ณผ ๋๋ฑํ ๊ถ๋ฆฌยท์ทจ๊ธ์ ๋ฐ์ ๋ โ์ผ๊ธ(first-class)โ์ด๋ผ๊ณ ํ๋ค. ์๋ฅผ ๋ค์ด JavaScript์์ ํจ์๋ ๋ณ์์ ๋ด๊ณ ์ธ์๋ก ์ ๋ฌํ๊ณ ๋ฐํํ ์ ์์ด ์ผ๊ธ ์๋ฏผ์ด๋ค. AG-UI์์ โHITL์ด ์ผ๊ธ ์๋ฏผโ์ด๋ผ๋ ๋ง์, ์ฌ์ฉ์์๊ฒ ๋ฌป๋ ์์ ์ด ๋ณ๋์ ์ฐํ๋ ํ์ฅ ๋ฉ์ปค๋์ฆ ์์ด ์ผ๋ฐ tool ํธ์ถ๊ณผ ์์ ํ ๋์ผํ ๋ฐฉ์์ผ๋ก ์๋ํ๋ค๋ ๋ป์ด๋ค.
๋ค๋ฅธ ํ๋กํ ์ฝ์์๋ โ์ฌ์ฉ์์๊ฒ ๋ฌป๊ธฐโ๋ฅผ ์ํด ๋ณ๋ ์ค๊ณ๊ฐ ํ์ํ์ง๋ง, AG-UI์์๋ frontend tool ํ๋ ์ ์ํ๋ฉด ๋๋๋ค. ํ๋ฆ์ ๋จ์ํ๋ค:
1. Agent: ์ค์ ๊ฒฐ์ ์ง๋ฉด
2. Agent โ confirmAction tool ํธ์ถ (TOOL_CALL_* ์ด๋ฒคํธ๋ก ์คํธ๋ฆฌ๋ฐ)
3. Frontend: ๋ค์ด์ผ๋ก๊ทธ ํ์ (tool ์คํ)
4. User: ์น์ธ/๊ฑฐ๋ถ
5. Frontend โ Agent: tool result ์ ๋ฌ
6. Agent: ์ฌ์ฉ์ ์์ฌ ๋ฐ์ํ์ฌ ์๋ต ์ด์ด๊ฐ
ํ์ฉ ์ฌ๋ก:
- Approval workflows: AI ์ ์ โ ์ฌ๋ ์น์ธ
- Data verification: AI ์์ฑ ๋ฐ์ดํฐ ๊ฒ์ฆ
- Collaborative decision-making: AIยท์ฌ๋ ํ์ ์์ฌ๊ฒฐ์
- Supervised learning: ํผ๋๋ฐฑ ์์ง
๋ณต์กํ ๊ตฌ์กฐํ ๋ฐ์ดํฐ๋ฅผ ์ฌ๋์ด ํธ์งํ๋ ์๋๋ฆฌ์ค๋ผ๋ฉด, Tool๋ง์ผ๋ก๋ ๋ถ์กฑํ๊ณ AG-UI State Management์ ์๋ฐฉํฅ state ์ฑ๋๊ณผ ๊ฒฐํฉํด ์ฌ์ฉํ๋ค. Tool์ โ๊ฒฐ์ ํธ๋ฆฌ๊ฑฐโ, State๋ โ๊ณต๋ ํธ์ง ๋ฐ์ดํฐโ๋ฅผ ๋ด๋นํ๋ ๋ณด์ ๊ด๊ณ๋ค.
์ผ๋ฐ AI Tool Calling๊ณผ์ ์ฐจ์ด ์์ฝ
์ง๊ธ๊น์ง์ ๋ด์ฉ์ ํ ํ๋ก ์ ๋ฆฌํ๋ฉด ๋ค์๊ณผ ๊ฐ๋ค.
| ํญ๋ชฉ | ์ผ๋ฐ (OpenAI/Anthropic) | AG-UI |
|---|---|---|
| Tool ์ ์ ๋ชจ์ | JSON Schema | JSON Schema (๋์ผ) |
| Tool result ํ์ | role: "tool" ๋ฉ์์ง | role: "tool" ๋ฉ์์ง (๋์ผ) |
| Tool ์ ์ ์์น | Backend | Frontend ๋๋ Backend |
| Tool ์คํ ์์น | Backend | Frontend ๋๋ Backend |
| ์คํธ๋ฆฌ๋ฐ ํฌ๋งท | ๋ฒค๋๋ณ SSE | ํ์ค TOOL_CALL_ ์ด๋ฒคํธ* |
| ๋ฐฑ์๋ ํต์ผ์ฑ | ๋ฒค๋ ์ข ์ | ํ๋ ์์ํฌ ๋ฌด๊ด |
| HITL ํํ | ๋ณ๋ ์ค๊ณ ํ์ | ์ผ๊ธ ์๋ฏผ |
์์ชฝ ๋ ํ์ด โ์ฐจ์ฉํ ํ์คโ์ด๊ณ , ์๋์ชฝ์ด โAG-UI ๊ณ ์ ํ์ฅโ์ ํด๋นํ๋ค.
์์ฃผ ํท๊ฐ๋ฆฌ๋ ํฌ์ธํธ
- JSON Schema๋ AG-UI๊ฐ ๋ง๋ ๊ฒ ์๋๋ผ ์ฐจ์ฉํ ์ ๊ณ ํ์ค์ด๋ค
- Tool result
content๋ ํญ์ string โ ๊ฐ์ฒด๊ฐ ์๋๋ผ ์ง๋ ฌํ๋ ๋ฌธ์์ด๋ก ์ ๋ฌ parentMessageId๋ optional, tool call์ด ์ด๋ค assistant ๋ฉ์์ง์์ ์์๋๋์ง ์ฐธ์กฐ- โFrontend toolโ์ด๋ผ๋ ๋ณ๋ ์ข ๋ฅ๊ฐ ์๋ ๊ฒ ์๋๋ผ, Tool์ ์ ์ยท์คํ ๊ถํ ์์ฒด๊ฐ ์ ์ฐํด์ง ๊ฒ์ด๋ค
- FrontendยทBackend tool ๊ตฌ๋ถ์ ์ ์ ์์ ์ด ์๋ ์คํ ์์น ๊ธฐ์ค์ด๋ค
๊ด๋ จ ๊ฐ๋
- AG-UI Event โ
TOOL_CALL_*์ด๋ฒคํธ์ ์ ์ฒด ์นดํ๋ก๊ทธ์ lifecycle ํจํด - AG-UI Messages โ
role: "tool"๋ฉ์์ง์ tagged-union ๊ตฌ์กฐ์ ๋์ ๋ฐฉ์ - AG-UI State Management โ Tool๊ณผ ํจ๊ป HITL ์ํฌํ๋ก์ฐ๋ฅผ ๊ตฌ์ฑํ๋ ์๋ฐฉํฅ state ์ฑ๋
- AbstractAgent โ
runAgent({ tools, ... })์ง์ ์ ๊ณผ RunAgentInput ์๋ ์กฐ๋ฆฝ - delta โ
TOOL_CALL_ARGS.delta๋์ ๋ฐฉ์์ ์ผ๋ฐ ๊ฐ๋ - CopilotKit โ
useCopilotAction์ผ๋ก Frontend tool์ React ์ปดํฌ๋ํธ์ ํจ๊ป ์ ์ - MCP Server โ ๋์ผํ JSON Schema ๊ธฐ๋ฐ์ด์ง๋ง Agent โ ์ธ๋ถ ๋๊ตฌ ์์ญ์ ์ง์ค
- Human-in-the-Loop โ Frontend tool์ด ์์ฐ์ค๋ฝ๊ฒ ํํํ๋ ํ์ ํจํด