Merge pull request #15 from FabAgentGroup/feat/conductor
Browse filesfeat: Plan-and-Execute Conductor ํจํด - latency -54%, ๋น์ฉ -58%, ํ์ง ๋๋ฑ
- README.md +32 -7
- agents/cause.py +90 -12
- agents/impact.py +102 -4
- agents/orchestrator.py +127 -80
- agents/planner.py +184 -0
- agents/response.py +107 -4
- experiments/README.md +27 -1
- experiments/conductor_vs_autonomous/__init__.py +0 -0
- experiments/conductor_vs_autonomous/benchmark.py +346 -0
- experiments/conductor_vs_autonomous/charts/calls_comparison.png +0 -0
- experiments/conductor_vs_autonomous/charts/cost_comparison.png +0 -0
- experiments/conductor_vs_autonomous/charts/latency_comparison.png +0 -0
- experiments/conductor_vs_autonomous/results.md +94 -0
README.md
CHANGED
|
@@ -23,8 +23,9 @@ auditableํ reasoning trace๋ฅผ ์ ๊ณตํฉ๋๋ค.
|
|
| 23 |
## ํต์ฌ ํน์ง
|
| 24 |
|
| 25 |
- **4-Tier multi-agent system** - ํ์ง(ML) ยท ์์ธ(agentic RAG) ยท ์ํฅ(tool-using) ยท ๋์(tool-using)
|
| 26 |
-
- **
|
| 27 |
-
- **
|
|
|
|
| 28 |
- **์กฐ๊ฑด๋ถ ๋ผ์ฐํ
** - LangGraph์์ severity gate + cause confidence retry + supervisor ๋ถ๊ธฐ (3๋จ๊ณ)
|
| 29 |
- **CRAG self-correction** - retrieval grader๊ฐ ๊ฒ์ ํ์ง ํ๊ฐ, ์๊ณ์น ๋ฏธ๋ฌ ์ ์ฟผ๋ฆฌ ์๋ ์ฌ์์ฑ
|
| 30 |
- **LangSmith observability** - ๋ชจ๋ LLMยทtoolยทagent ํธ์ถ ์๋ ํธ๋ ์ด์ค (production-grade)
|
|
@@ -122,6 +123,7 @@ PHM 2016 CMP๋ ์ค์ CMP ๊ณต์ ์ผ์ ๋ฐ์ดํฐ๋ก step-specific ์ถ๋ก ์ด
|
|
| 122 |
| **D8** | CRAG (Self-correction) ON vs OFF | CRAG **ํ์ฑ ์ ์ง** (๊ด์ธก ๊ฐ์น) | ํ์ง ๋ณํ -0.1%p (๋๊ธ), refinement ๋ฐ๋๋ฅ 20%, relevance_score ๋
ธ์ถ, ๋น์ฉ +31% |
|
| 123 |
| **D9** | ํ๊ตญ์ด reranker (Dongjin-kr/ko-reranker) vs ์์ด(BAAI) vs hybrid (12 docs) | ๋ ๋ค hybrid์ ๋ฏธ๋ฌ | hybrid 0.734 / BAAI 0.714 / ko 0.703 |
|
| 124 |
| **D10** | **D9 ํ์**: ์ฝํผ์ค 12โ34 ํ์ฅ ํ reranker ์ฌํ๊ฐ | **๊ฐ์ค ๊ฒ์ฆ - ํจ๊ณผ ์์ ๋ฐ์ ** | hybrid **0.592** / BAAI **0.709 (+0.117)** / ko **0.675 (+0.083)** |
|
|
|
|
| 125 |
|
| 126 |
### D6 ํต์ฌ ๊ทธ๋ํ
|
| 127 |
|
|
@@ -230,6 +232,20 @@ PHM 2016 CMP๋ ์ค์ CMP ๊ณต์ ์ผ์ ๋ฐ์ดํฐ๋ก step-specific ์ถ๋ก ์ด
|
|
| 230 |
- **๊ฒฐ์ **: ์ฝํผ์ค 30+ ํ๊ฒฝ์์๋ `RAG_BACKEND=hybrid_rerank` ๊ถ์ฅ. ๋ฐ๋ชจ์ฉ 12๊ฐ์์ hybrid ์ ์ง
|
| 231 |
- **์๋ฆฌ์ฆ ์์**: D6 โ D9 โ D10์ด portfolio narrative๋ก ์์ฑ. "ํต๋
โ ์ ๋ ๋ฐ๋ฐ โ ๊ฐ์ค โ ์ ๋ ๊ฒ์ฆ"์ ์ฌ์ดํด์ด ์ ๋ ํ๊ฐ์ ๊ฐ์น ์์ฒด๋ฅผ ์ฆ๋ช
|
| 232 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
### 8. Supervisor agent - LLM-driven ๋์ workflow routing
|
| 234 |
|
| 235 |
- **์์**: ๊ธฐ์กด conditional edge๋ threshold ๊ธฐ๋ฐ(`score < 0.3` โ skip, `max pct < 40` โ retry). "์ง์ง agent๋ผ๋ฉด LLM์ด ๋งฅ๋ฝ์ ๋ณด๊ณ ๊ฒฐ์ ํด์ผ ํ๋ค"
|
|
@@ -270,6 +286,13 @@ RAG_BACKEND=faiss streamlit run app.py # ์ต์
: ์๋ฏธ ์์ฃผ
|
|
| 270 |
RAG_BACKEND=keyword streamlit run app.py # ์ต์
: ์์กด์ฑ ์ต์
|
| 271 |
```
|
| 272 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 273 |
### CRAG (Self-correction) ํ ๊ธ
|
| 274 |
|
| 275 |
```bash
|
|
@@ -314,10 +337,11 @@ fabagent/
|
|
| 314 |
โโโ agents/
|
| 315 |
โ โโโ orchestrator.py # LangGraph StateGraph + ์กฐ๊ฑด๋ถ ๋ผ์ฐํ
|
| 316 |
โ โโโ detection.py # Tier 1 IsolationForest (SECOM/PHM ๋์คํจ์น)
|
| 317 |
-
โ โโโ
|
| 318 |
-
โ โโโ
|
| 319 |
-
โ โโโ
|
| 320 |
-
โ โโโ
|
|
|
|
| 321 |
โ โโโ llm.py # OpenAI ํด๋ผ์ด์ธํธ + LangSmith wrap_openai ํตํฉ
|
| 322 |
โ โโโ tools/ # 7๊ฐ agent ๋๊ตฌ
|
| 323 |
โ โ โโโ knowledge.py # search_knowledge (RAG ๊ฒ์)
|
|
@@ -345,7 +369,8 @@ fabagent/
|
|
| 345 |
โ โโโ rag_paradigm/ # D6: 5๋จ๊ณ paradigm ablation
|
| 346 |
โ โโโ agentic_vs_workflow/ # D7: workflow vs agentic ๋น๊ต
|
| 347 |
โ โโโ crag_eval/ # D8: CRAG self-correction ํจ๊ณผ ํ๊ฐ
|
| 348 |
-
โ
|
|
|
|
| 349 |
โโโ docs/orchestrator_graph.mmd # LangGraph ์๋ ์ถ์ถ mermaid
|
| 350 |
โโโ styles/main.css # ๋์์ธ ์์คํ
|
| 351 |
โโโ tests/
|
|
|
|
| 23 |
## ํต์ฌ ํน์ง
|
| 24 |
|
| 25 |
- **4-Tier multi-agent system** - ํ์ง(ML) ยท ์์ธ(agentic RAG) ยท ์ํฅ(tool-using) ยท ๋์(tool-using)
|
| 26 |
+
- **Plan-and-Execute ํจํด** (๊ธฐ๋ณธ) - Central Planner Agent๊ฐ ์ ์ฒด ์ํฌํ๋ก์ฐ plan์ 1ํ ์ฐ์ถ, Tier executor๊ฐ plan๋๋ก ์คํ โ ํต์ ์ค๋ฒํค๋ ์ต์ํ (LLM ํธ์ถ -60%, latency -54%)
|
| 27 |
+
- **Tool-using agent** (์ต์
) - 7๊ฐ ๋๋ฉ์ธ ๋๊ตฌ๋ฅผ LLM์ด ์์จ ์ ํยท๋ฐ๋ณต ํธ์ถ (`AGENT_MODE=autonomous`)
|
| 28 |
+
- **Supervisor agent** (autonomous ๋ชจ๋) - LLM์ด Tier 2 ๊ฒฐ๊ณผ๋ฅผ ๋ณด๊ณ ํ์ workflow path(proceed_full / fast_track / escalate) ๋์ ๊ฒฐ์
|
| 29 |
- **์กฐ๊ฑด๋ถ ๋ผ์ฐํ
** - LangGraph์์ severity gate + cause confidence retry + supervisor ๋ถ๊ธฐ (3๋จ๊ณ)
|
| 30 |
- **CRAG self-correction** - retrieval grader๊ฐ ๊ฒ์ ํ์ง ํ๊ฐ, ์๊ณ์น ๋ฏธ๋ฌ ์ ์ฟผ๋ฆฌ ์๋ ์ฌ์์ฑ
|
| 31 |
- **LangSmith observability** - ๋ชจ๋ LLMยทtoolยทagent ํธ์ถ ์๋ ํธ๋ ์ด์ค (production-grade)
|
|
|
|
| 123 |
| **D8** | CRAG (Self-correction) ON vs OFF | CRAG **ํ์ฑ ์ ์ง** (๊ด์ธก ๊ฐ์น) | ํ์ง ๋ณํ -0.1%p (๋๊ธ), refinement ๋ฐ๋๋ฅ 20%, relevance_score ๋
ธ์ถ, ๋น์ฉ +31% |
|
| 124 |
| **D9** | ํ๊ตญ์ด reranker (Dongjin-kr/ko-reranker) vs ์์ด(BAAI) vs hybrid (12 docs) | ๋ ๋ค hybrid์ ๋ฏธ๋ฌ | hybrid 0.734 / BAAI 0.714 / ko 0.703 |
|
| 125 |
| **D10** | **D9 ํ์**: ์ฝํผ์ค 12โ34 ํ์ฅ ํ reranker ์ฌํ๊ฐ | **๊ฐ์ค ๊ฒ์ฆ - ํจ๊ณผ ์์ ๋ฐ์ ** | hybrid **0.592** / BAAI **0.709 (+0.117)** / ko **0.675 (+0.083)** |
|
| 126 |
+
| **D11** | Conductor (Plan-and-Execute) vs Autonomous (tool-using loop) | **Conductor ์ฑํ** | LLM -60%, Latency **131โ60์ด (-54%)**, ๋น์ฉ -58%, **์ธ์ฉ ๋๋ฑ(6.0)** |
|
| 127 |
|
| 128 |
### D6 ํต์ฌ ๊ทธ๋ํ
|
| 129 |
|
|
|
|
| 232 |
- **๊ฒฐ์ **: ์ฝํผ์ค 30+ ํ๊ฒฝ์์๋ `RAG_BACKEND=hybrid_rerank` ๊ถ์ฅ. ๋ฐ๋ชจ์ฉ 12๊ฐ์์ hybrid ์ ์ง
|
| 233 |
- **์๋ฆฌ์ฆ ์์**: D6 โ D9 โ D10์ด portfolio narrative๋ก ์์ฑ. "ํต๋
โ ์ ๋ ๋ฐ๋ฐ โ ๊ฐ์ค โ ์ ๋ ๊ฒ์ฆ"์ ์ฌ์ดํด์ด ์ ๋ ํ๊ฐ์ ๊ฐ์น ์์ฒด๋ฅผ ์ฆ๋ช
|
| 234 |
|
| 235 |
+
### 11. Conductor ํจํด (Plan-and-Execute) ๋์
- "agentic โ conductor" ์ ํ
|
| 236 |
+
|
| 237 |
+
- **์ํฉ**: 4-tier agentic ์์คํ
(D7) ๋์
ํ ์๋๋น ์ฝ 3๋ถ(194์ด)ยทLLM 10~13ํ๋ก ๋ฐ๋ชจ UX ์ ํ. ์ฝํผ์ค ํ์ฅ(D10)์ผ๋ก ์ปจํ
์คํธ ๋ ๋ฌด๊ฑฐ์์ง
|
| 238 |
+
- **์ง๋จ**: Anthropic์ [Building Effective Agents](https://www.anthropic.com/engineering/building-effective-agents)๊ฐ ๋ช
์ํ๋ฏ "autonomous" ํจํด์ ์ ์์ฑ์ด ๊ฐ์ ์ด์ง๋ง ํต์ ์ค๋ฒํค๋(iteration ๋์ ยท์ฌ๊ท ํธ์ถ ์ํ) ํผ
|
| 239 |
+
- **์ ํ**: Plan-and-Execute ํจํด - Central Planner Agent๊ฐ ์๋+Tier 1์ ๋ณด๊ณ ์ ์ฒด ์ํฌํ๋ก์ฐ(Tier 2/3/4 ๊ฐ tool ํธ์ถ plan)๋ฅผ 1ํ ์ฐ์ถ, ๊ฐ Tier executor๋ plan๋๋ก tool ์ง์ ์คํ + LLM 1ํ synthesis
|
| 240 |
+
- **๊ตฌํ**: `agents/planner.py` ์ ๊ท + `cause/impact/response.py`์ conductor ๊ฒฝ๋ก ์ถ๊ฐ (autonomous๋ ์ต์
์ ์ง). ํ๊ฒฝ๋ณ์ `AGENT_MODE=conductor` (๊ธฐ๋ณธ) / `autonomous`๋ก ํ ๊ธ
|
| 241 |
+
- **D11 ์ ๋ ๊ฒฐ๊ณผ (3 ์๋, CRAG OFF ๋์ผ ์กฐ๊ฑด)**:
|
| 242 |
+
- LLM ํธ์ถ: 10.0 โ 4.0 (**-60%**, Planner 1 + Tierร3 synthesis)
|
| 243 |
+
- Latency: 131์ด โ **60์ด** (**-54%**)
|
| 244 |
+
- ๋น์ฉ: $33.23 โ $13.80 / 1000์๋ (**-58%**)
|
| 245 |
+
- ์ธ์ฉ ๊น์ด: 6.0 โ 6.0 (**๋๋ฑ**, ํ์ง ์์ค ์์)
|
| 246 |
+
- **ํต์ฌ narrative**: D7(workflow โ agentic์ผ๋ก ์์จ์ฑ ํ๋ณด) โ D11(agentic โ conductor๋ก ํจ์จ ํ๋ณต). ๋ ๋จ๊ณ ๋ชจ๋ ์ ๋ ๋ฐ์ดํฐ ๊ธฐ๋ฐ ์์ฌ๊ฒฐ์ . **autonomous์ ์์จ์ฑ vs conductor์ ํจ์จ์ฑ์ trade-off๋ก ๋ช
์ ์ฑํ**
|
| 247 |
+
- **์ฌ๊ท ์ํ ์์ฒ ์ฐจ๋จ**: ๊ธฐ์กด `MAX_TOOL_ITERATIONS=4` ์บก์ ์์กดํ๋ ๋ฌดํ๋ฃจํ ๋ฐฉ์ง๊ฐ plan ๊ณ ์ ์คํ์ผ๋ก ๋ณธ์ง์ ์ผ๋ก ํด๊ฒฐ
|
| 248 |
+
|
| 249 |
### 8. Supervisor agent - LLM-driven ๋์ workflow routing
|
| 250 |
|
| 251 |
- **์์**: ๊ธฐ์กด conditional edge๋ threshold ๊ธฐ๋ฐ(`score < 0.3` โ skip, `max pct < 40` โ retry). "์ง์ง agent๋ผ๋ฉด LLM์ด ๋งฅ๋ฝ์ ๋ณด๊ณ ๊ฒฐ์ ํด์ผ ํ๋ค"
|
|
|
|
| 286 |
RAG_BACKEND=keyword streamlit run app.py # ์ต์
: ์์กด์ฑ ์ต์
|
| 287 |
```
|
| 288 |
|
| 289 |
+
### Agent ๋ชจ๋ ํ ๊ธ (D11)
|
| 290 |
+
|
| 291 |
+
```bash
|
| 292 |
+
AGENT_MODE=conductor streamlit run app.py # ๊ธฐ๋ณธ - Plan-and-Execute (๋น ๋ฅด๊ณ ์ ๋ ด, ํต์ ์ต์)
|
| 293 |
+
AGENT_MODE=autonomous streamlit run app.py # ์ต์
- tool-using agent loop (์ ์์ฑ ์ฐ์)
|
| 294 |
+
```
|
| 295 |
+
|
| 296 |
### CRAG (Self-correction) ํ ๊ธ
|
| 297 |
|
| 298 |
```bash
|
|
|
|
| 337 |
โโโ agents/
|
| 338 |
โ โโโ orchestrator.py # LangGraph StateGraph + ์กฐ๊ฑด๋ถ ๋ผ์ฐํ
|
| 339 |
โ โโโ detection.py # Tier 1 IsolationForest (SECOM/PHM ๋์คํจ์น)
|
| 340 |
+
โ โโโ planner.py # Central Planner Agent (Plan-and-Execute, conductor ๋ชจ๋)
|
| 341 |
+
โ โโโ cause.py # Tier 2 (conductor: plan ๋ฐ์ / autonomous: tool loop)
|
| 342 |
+
โ โโโ impact.py # Tier 3 (conductor / autonomous ์ ๋ชจ๋)
|
| 343 |
+
โ โโโ response.py # Tier 4 (conductor / autonomous ์ ๋ชจ๋)
|
| 344 |
+
โ โโโ supervisor.py # autonomous ๋ชจ๋ ์ ์ฉ LLM-driven router
|
| 345 |
โ โโโ llm.py # OpenAI ํด๋ผ์ด์ธํธ + LangSmith wrap_openai ํตํฉ
|
| 346 |
โ โโโ tools/ # 7๊ฐ agent ๋๊ตฌ
|
| 347 |
โ โ โโโ knowledge.py # search_knowledge (RAG ๊ฒ์)
|
|
|
|
| 369 |
โ โโโ rag_paradigm/ # D6: 5๋จ๊ณ paradigm ablation
|
| 370 |
โ โโโ agentic_vs_workflow/ # D7: workflow vs agentic ๋น๊ต
|
| 371 |
โ โโโ crag_eval/ # D8: CRAG self-correction ํจ๊ณผ ํ๊ฐ
|
| 372 |
+
โ โโโ reranker_compare/ # D9ยทD10: ํ๊ตญ์ด reranker + ํ์ฅ ์ฝํผ์ค ๊ฐ์ค ๊ฒ์ฆ
|
| 373 |
+
โ โโโ conductor_vs_autonomous/ # D11: Conductor vs Autonomous (latency -54%, ์ธ์ฉ ๋๋ฑ)
|
| 374 |
โโโ docs/orchestrator_graph.mmd # LangGraph ์๋ ์ถ์ถ mermaid
|
| 375 |
โโโ styles/main.css # ๋์์ธ ์์คํ
|
| 376 |
โโโ tests/
|
agents/cause.py
CHANGED
|
@@ -1,13 +1,12 @@
|
|
| 1 |
-
"""Tier 2 ์์ธ ๋ถ์ ์์ด์ ํธ
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
1. system prompt + ์๋ยทTier1 ์ปจํ
์คํธ๋ก ์์ (์ฌ์ retrieval ์์)
|
| 8 |
-
2. tool-calling loop: LLM์ด ํ์ํ ๋๊ตฌ๋ฅผ ํธ์ถ -> ๊ฒฐ๊ณผ๋ฅผ ์ปจํ
์คํธ์ ์ถ๊ฐ
|
| 9 |
-
3. LLM์ด ๋ ํธ์ถํ์ง ์์ ๋(๋๋ MAX_ITER ๋๋ฌ) synthesis ํธ์ถ
|
| 10 |
-
4. response_format=json_schema ๋ก TIER2_SCHEMA ๊ตฌ์กฐํ ์ถ๋ ฅ
|
| 11 |
"""
|
| 12 |
import json
|
| 13 |
|
|
@@ -94,15 +93,93 @@ def _assistant_msg_dict(msg) -> dict:
|
|
| 94 |
return out
|
| 95 |
|
| 96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
@traceable(name="Tier2_Cause_Agent", run_type="chain")
|
| 98 |
def run_cause(
|
| 99 |
-
alarm: dict,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
) -> Tier2:
|
| 101 |
-
"""์์ธ ๋ถ์
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
-
retry_hint=True ๋ฉด
|
| 104 |
-
๋ ์ ๊ทน์ ์ผ๋ก ๋๊ตฌ๋ฅผ ํธ์ถํ๋๋ก ์ ๋ (orchestrator์ confidence retry์ฉ)
|
| 105 |
"""
|
|
|
|
|
|
|
| 106 |
user_prompt = _initial_user_prompt(alarm, tier1)
|
| 107 |
if retry_hint:
|
| 108 |
user_prompt += (
|
|
@@ -154,5 +231,6 @@ def run_cause(
|
|
| 154 |
trace["tool_calls"] = tool_call_log
|
| 155 |
trace["iterations"] = iterations
|
| 156 |
trace["llm_calls"] = iterations + 1
|
|
|
|
| 157 |
|
| 158 |
return result
|
|
|
|
| 1 |
+
"""Tier 2 ์์ธ ๋ถ์ ์์ด์ ํธ
|
| 2 |
|
| 3 |
+
๋ ๋ชจ๋ ์ง์:
|
| 4 |
+
1. **Autonomous (๊ธฐ๋ณธ, plan=None)**: LLM์ด tool์ ์์จ ํธ์ถํ๋ agent loop
|
| 5 |
+
- 2~3 iteration + synthesis = LLM ํธ์ถ 3~4ํ
|
| 6 |
+
2. **Conductor (plan ์ ๊ณต)**: Planner๊ฐ ์ง์ ํ tool ํธ์ถ + ๋จ์ผ LLM synthesis
|
| 7 |
+
- Tool ์ง์ ์คํ + LLM ํธ์ถ 1ํ. ์ฌ๊ทยทloop ์์
|
| 8 |
|
| 9 |
+
๊ฐ์ฉ ๋๊ตฌ: search_knowledge, lookup_incident_history, get_pm_history
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
"""
|
| 11 |
import json
|
| 12 |
|
|
|
|
| 93 |
return out
|
| 94 |
|
| 95 |
|
| 96 |
+
CONDUCTOR_SYSTEM_PROMPT = """๋น์ ์ ๋ฐ๋์ฒด ๊ณต์ ์์ธ ๋ถ์ ์ ๋ฌธ๊ฐ์
๋๋ค.
|
| 97 |
+
Central Planner๊ฐ ์ด๋ฏธ ํ์ํ ์ ๋ณด๋ฅผ ๋ชจ๋ ์์งํด [์์ง๋ ์ปจํ
์คํธ]์ ์ ๋ฆฌํด ๋์์ต๋๋ค.
|
| 98 |
+
๋น์ ์ ์ถ๊ฐ ๋๊ตฌ ํธ์ถ ์์ด ๊ทธ ์ปจํ
์คํธ๋ง ์ฌ์ฉํด ์์ธ 2~3๊ฐ๋ฅผ ์ฐ์ถํ์ธ์.
|
| 99 |
+
|
| 100 |
+
[์ต์ข
์ฐ์ถ๋ฌผ]
|
| 101 |
+
- causes: 2~3๊ฐ. ๊ฐ ์์ธ์ name / pct(๊ธฐ์ฌ๋ %) / evidence(๊ตฌ์ฒด์ ๊ทผ๊ฑฐ) / citations(๋ฌธ์ ID ๋๋ incident ID)
|
| 102 |
+
- pct ํฉ์ 100์ ๊ฐ๊น์์ผ ํจ, ๊ธฐ์ฌ๋ ๋์ ์์ธ๋ถํฐ ์ ๋ ฌ
|
| 103 |
+
- ์ ๊ณต๋์ง ์์ ์ ๋ณด๋ ์ธ์ฉํ์ง ๋ง์ธ์"""
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
def _execute_tier2_plan(plan_tier2: dict, trace_calls: list) -> str:
|
| 107 |
+
"""Planner๊ฐ ์ง์ ํ tool๋ค์ ์ง์ ํธ์ถํ๊ณ ์ปจํ
์คํธ๋ก ๋ณํ"""
|
| 108 |
+
blocks = []
|
| 109 |
+
for query in plan_tier2.get("search_queries", []):
|
| 110 |
+
result = dispatch_tool("search_knowledge", {"query": query})
|
| 111 |
+
trace_calls.append({"name": "search_knowledge", "args": {"query": query}})
|
| 112 |
+
blocks.append(f"[search_knowledge: {query!r}]\n{result}")
|
| 113 |
+
for symptom in plan_tier2.get("incident_symptoms", []):
|
| 114 |
+
result = dispatch_tool("lookup_incident_history", {"symptom": symptom})
|
| 115 |
+
trace_calls.append({"name": "lookup_incident_history", "args": {"symptom": symptom}})
|
| 116 |
+
blocks.append(f"[lookup_incident_history: {symptom!r}]\n{result}")
|
| 117 |
+
for eq_id in plan_tier2.get("equipment_ids", []):
|
| 118 |
+
result = dispatch_tool("get_pm_history", {"equipment_id": eq_id})
|
| 119 |
+
trace_calls.append({"name": "get_pm_history", "args": {"equipment_id": eq_id}})
|
| 120 |
+
blocks.append(f"[get_pm_history: {eq_id!r}]\n{result}")
|
| 121 |
+
return "\n\n".join(blocks) if blocks else "(planner๊ฐ ์ ๋ณด ์์ง ์ง์ ์์)"
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
def _run_cause_conductor(alarm: dict, tier1: Tier1, plan: dict, trace: dict | None) -> Tier2:
|
| 125 |
+
"""Conductor ๋ชจ๋: plan๋๋ก tool ์คํ + 1ํ LLM synthesis"""
|
| 126 |
+
tool_log: list[dict] = []
|
| 127 |
+
knowledge = _execute_tier2_plan(plan.get("tier2", {}), tool_log)
|
| 128 |
+
|
| 129 |
+
sensors = ", ".join(f["name"] for f in tier1["features"])
|
| 130 |
+
user_prompt = f"""## ์ด์ ์๋
|
| 131 |
+
- ๊ณต์ : {alarm['title']}
|
| 132 |
+
- lot: {alarm['lot_id']}
|
| 133 |
+
- ์ด์ ํผ์ฒ: {alarm.get('feature')} {alarm.get('feature_arrow') or ''}
|
| 134 |
+
|
| 135 |
+
## Tier 1 ์ด์ ํ์ง ๊ฒฐ๊ณผ
|
| 136 |
+
- ์ด์ ์ ์: {tier1['score']}
|
| 137 |
+
- ๊ธฐ์ฌ ์ผ์(Top): {sensors}
|
| 138 |
+
|
| 139 |
+
## ์์ง๋ ์ปจํ
์คํธ (Planner ์ง์ )
|
| 140 |
+
{knowledge}
|
| 141 |
+
|
| 142 |
+
์ ์ปจํ
์คํธ๋ง ์ฌ์ฉํด ์์ธ์ ๋ถ์ํ์ธ์."""
|
| 143 |
+
|
| 144 |
+
resp = client().chat.completions.create(
|
| 145 |
+
model=SUBAGENT_MODEL,
|
| 146 |
+
messages=[
|
| 147 |
+
{"role": "system", "content": CONDUCTOR_SYSTEM_PROMPT},
|
| 148 |
+
{"role": "user", "content": user_prompt},
|
| 149 |
+
],
|
| 150 |
+
response_format={
|
| 151 |
+
"type": "json_schema",
|
| 152 |
+
"json_schema": {"name": "tier2", "schema": TIER2_SCHEMA, "strict": True},
|
| 153 |
+
},
|
| 154 |
+
)
|
| 155 |
+
result = json.loads(resp.choices[0].message.content)
|
| 156 |
+
|
| 157 |
+
if trace is not None:
|
| 158 |
+
trace["tool_calls"] = tool_log
|
| 159 |
+
trace["iterations"] = 0
|
| 160 |
+
trace["llm_calls"] = 1
|
| 161 |
+
trace["mode"] = "conductor"
|
| 162 |
+
|
| 163 |
+
return result
|
| 164 |
+
|
| 165 |
+
|
| 166 |
@traceable(name="Tier2_Cause_Agent", run_type="chain")
|
| 167 |
def run_cause(
|
| 168 |
+
alarm: dict,
|
| 169 |
+
tier1: Tier1,
|
| 170 |
+
trace: dict | None = None,
|
| 171 |
+
retry_hint: bool = False,
|
| 172 |
+
plan: dict | None = None,
|
| 173 |
) -> Tier2:
|
| 174 |
+
"""์์ธ ๋ถ์ ์คํ
|
| 175 |
+
|
| 176 |
+
plan ์ ๊ณต ์ conductor ๋ชจ๋ (๋จ์ผ LLM ํธ์ถ, tool ์ง์ ์คํ).
|
| 177 |
+
plan=None์ด๋ฉด ๊ธฐ์กด autonomous tool-calling loop ๋ชจ๋.
|
| 178 |
|
| 179 |
+
retry_hint=True ๋ฉด autonomous ๋ชจ๋์์ ๋ ์ ๊ทน์ ์ผ๋ก ๋๊ตฌ๋ฅผ ํธ์ถํ๋๋ก ์ ๋.
|
|
|
|
| 180 |
"""
|
| 181 |
+
if plan is not None:
|
| 182 |
+
return _run_cause_conductor(alarm, tier1, plan, trace)
|
| 183 |
user_prompt = _initial_user_prompt(alarm, tier1)
|
| 184 |
if retry_hint:
|
| 185 |
user_prompt += (
|
|
|
|
| 231 |
trace["tool_calls"] = tool_call_log
|
| 232 |
trace["iterations"] = iterations
|
| 233 |
trace["llm_calls"] = iterations + 1
|
| 234 |
+
trace["mode"] = "autonomous"
|
| 235 |
|
| 236 |
return result
|
agents/impact.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
| 1 |
-
"""Tier 3 ๊ณต์ ๊ฐ ์ํฅ ํ๊ฐ ์์ด์ ํธ
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
| 5 |
|
| 6 |
๊ฐ์ฉ ๋๊ตฌ: query_wip_status, get_downstream_steps, get_yield_baseline, get_pm_history
|
| 7 |
"""
|
|
@@ -87,8 +88,104 @@ def _initial_user_prompt(alarm: dict, tier1: Tier1, tier2: Tier2) -> str:
|
|
| 87 |
WIPยทdownstreamยทyieldยทPM ์ปจํ
์คํธ๋ ๋๊ตฌ๋ฅผ ํธ์ถํด ์์จ์ ์ผ๋ก ์์งํ์ธ์."""
|
| 88 |
|
| 89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
@traceable(name="Tier3_Impact_Agent", run_type="chain")
|
| 91 |
-
def run_impact(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
messages = [
|
| 93 |
{"role": "system", "content": SYSTEM_PROMPT},
|
| 94 |
{"role": "user", "content": _initial_user_prompt(alarm, tier1, tier2)},
|
|
@@ -141,6 +238,7 @@ def run_impact(alarm: dict, tier1: Tier1, tier2: Tier2, trace: dict | None = Non
|
|
| 141 |
trace["tool_calls"] = tool_call_log
|
| 142 |
trace["iterations"] = iterations
|
| 143 |
trace["llm_calls"] = iterations + 1
|
|
|
|
| 144 |
|
| 145 |
return {
|
| 146 |
"yield_loss": round(float(llm_out["yield_loss"]), 1),
|
|
|
|
| 1 |
+
"""Tier 3 ๊ณต์ ๊ฐ ์ํฅ ํ๊ฐ ์์ด์ ํธ
|
| 2 |
|
| 3 |
+
๋ ๋ชจ๋ ์ง์:
|
| 4 |
+
1. Autonomous (plan=None): LLM์ด tool์ ์์จ ํธ์ถํ๋ agent loop
|
| 5 |
+
2. Conductor (plan ์ ๊ณต): Planner๊ฐ ์ง์ ํ tool ํธ์ถ + ๋จ์ผ LLM synthesis
|
| 6 |
|
| 7 |
๊ฐ์ฉ ๋๊ตฌ: query_wip_status, get_downstream_steps, get_yield_baseline, get_pm_history
|
| 8 |
"""
|
|
|
|
| 88 |
WIPยทdownstreamยทyieldยทPM ์ปจํ
์คํธ๋ ๋๊ตฌ๋ฅผ ํธ์ถํด ์์จ์ ์ผ๋ก ์์งํ์ธ์."""
|
| 89 |
|
| 90 |
|
| 91 |
+
CONDUCTOR_SYSTEM_PROMPT = """๋น์ ์ ๋ฐ๋์ฒด ๊ณต์ ์ํฅ ํ๊ฐ ์ ๋ฌธ๊ฐ์
๋๋ค.
|
| 92 |
+
Central Planner๊ฐ ์ด๋ฏธ ํ์ํ ์ ๋ณด(WIPยทdownstreamยทyieldยทPM)๋ฅผ ๋ชจ๋ ์์งํด [์์ง๋ ์ปจํ
์คํธ]์ ์ ๋ฆฌํด ๋์์ต๋๋ค.
|
| 93 |
+
๋น์ ์ ์ถ๊ฐ ๋๊ตฌ ํธ์ถ ์์ด ๊ทธ ์ปจํ
์คํธ๋ง ์ฌ์ฉํด ์ฐ์ถํ์ธ์.
|
| 94 |
+
|
| 95 |
+
[์ต์ข
์ฐ์ถ๋ฌผ]
|
| 96 |
+
- yield_loss: ๋ณธ ์ด์์ผ๋ก ์ธํ ์์ ์์จ ์์ค(%p, ์์ ํ ์๋ฆฌ)
|
| 97 |
+
- downstream_dependencies: ์ํฅ ๋ฐ๋ ํ๊ณต์ (current ์ ์ธ) - stage / delta / tag / kind"""
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
def _execute_tier3_plan(plan_tier3: dict, trace_calls: list) -> str:
|
| 101 |
+
"""Planner๊ฐ ์ง์ ํ tool๋ค์ ์ง์ ํธ์ถํ๊ณ ์ปจํ
์คํธ๋ก ๋ณํ"""
|
| 102 |
+
blocks = []
|
| 103 |
+
if plan_tier3.get("alarm_id"):
|
| 104 |
+
r = dispatch_tool("query_wip_status", {"alarm_id": plan_tier3["alarm_id"]})
|
| 105 |
+
trace_calls.append({"name": "query_wip_status", "args": {"alarm_id": plan_tier3["alarm_id"]}})
|
| 106 |
+
blocks.append(f"[query_wip_status: {plan_tier3['alarm_id']!r}]\n{r}")
|
| 107 |
+
for stage in plan_tier3.get("downstream_stages", []):
|
| 108 |
+
r = dispatch_tool("get_downstream_steps", {"current_stage": stage})
|
| 109 |
+
trace_calls.append({"name": "get_downstream_steps", "args": {"current_stage": stage}})
|
| 110 |
+
blocks.append(f"[get_downstream_steps: {stage!r}]\n{r}")
|
| 111 |
+
for proc in plan_tier3.get("yield_processes", []):
|
| 112 |
+
r = dispatch_tool("get_yield_baseline", {"process": proc})
|
| 113 |
+
trace_calls.append({"name": "get_yield_baseline", "args": {"process": proc}})
|
| 114 |
+
blocks.append(f"[get_yield_baseline: {proc!r}]\n{r}")
|
| 115 |
+
for eq_id in plan_tier3.get("equipment_ids", []):
|
| 116 |
+
r = dispatch_tool("get_pm_history", {"equipment_id": eq_id})
|
| 117 |
+
trace_calls.append({"name": "get_pm_history", "args": {"equipment_id": eq_id}})
|
| 118 |
+
blocks.append(f"[get_pm_history: {eq_id!r}]\n{r}")
|
| 119 |
+
return "\n\n".join(blocks) if blocks else "(planner๊ฐ ์ ๋ณด ์์ง ์ง์ ์์)"
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
def _run_impact_conductor(
|
| 123 |
+
alarm: dict, tier1: Tier1, tier2: Tier2, plan: dict, trace: dict | None
|
| 124 |
+
) -> Tier3:
|
| 125 |
+
tool_log: list[dict] = []
|
| 126 |
+
knowledge = _execute_tier3_plan(plan.get("tier3", {}), tool_log)
|
| 127 |
+
|
| 128 |
+
cause_lines = "\n".join(
|
| 129 |
+
f"- {c['name']} ({c['pct']}%): {c['evidence'][:120]}" for c in tier2["causes"]
|
| 130 |
+
)
|
| 131 |
+
current_stage = _stage_from_alarm(alarm)
|
| 132 |
+
user_prompt = f"""## ์ด์ ์๋
|
| 133 |
+
- ๊ณต์ : {alarm['title']} (current_stage: {current_stage})
|
| 134 |
+
|
| 135 |
+
## Tier 1: ์ด์ ์ ์ {tier1['score']}
|
| 136 |
+
|
| 137 |
+
## Tier 2 ์์ธ ๋ถ์
|
| 138 |
+
{cause_lines}
|
| 139 |
+
|
| 140 |
+
## ์์ง๋ ์ปจํ
์คํธ (Planner ์ง์ )
|
| 141 |
+
{knowledge}
|
| 142 |
+
|
| 143 |
+
์ ์ปจํ
์คํธ๋ง ์ฌ์ฉํด yield_loss์ downstream_dependencies๋ฅผ ์ฐ์ถํ์ธ์."""
|
| 144 |
+
|
| 145 |
+
resp = client().chat.completions.create(
|
| 146 |
+
model=SUBAGENT_MODEL,
|
| 147 |
+
messages=[
|
| 148 |
+
{"role": "system", "content": CONDUCTOR_SYSTEM_PROMPT},
|
| 149 |
+
{"role": "user", "content": user_prompt},
|
| 150 |
+
],
|
| 151 |
+
response_format={
|
| 152 |
+
"type": "json_schema",
|
| 153 |
+
"json_schema": {"name": "tier3_part", "schema": LLM_PART_SCHEMA, "strict": True},
|
| 154 |
+
},
|
| 155 |
+
)
|
| 156 |
+
llm_out = json.loads(resp.choices[0].message.content)
|
| 157 |
+
|
| 158 |
+
current_dep = {
|
| 159 |
+
"stage": current_stage,
|
| 160 |
+
"delta": f"+{tier1['score']}",
|
| 161 |
+
"tag": "ํ์ฌ",
|
| 162 |
+
"kind": "current",
|
| 163 |
+
}
|
| 164 |
+
if trace is not None:
|
| 165 |
+
trace["tool_calls"] = tool_log
|
| 166 |
+
trace["iterations"] = 0
|
| 167 |
+
trace["llm_calls"] = 1
|
| 168 |
+
trace["mode"] = "conductor"
|
| 169 |
+
|
| 170 |
+
return {
|
| 171 |
+
"yield_loss": round(float(llm_out["yield_loss"]), 1),
|
| 172 |
+
"dependencies": [current_dep] + llm_out["downstream_dependencies"],
|
| 173 |
+
"impact_lots": get_affected_wip(alarm["id"]),
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
|
| 177 |
@traceable(name="Tier3_Impact_Agent", run_type="chain")
|
| 178 |
+
def run_impact(
|
| 179 |
+
alarm: dict,
|
| 180 |
+
tier1: Tier1,
|
| 181 |
+
tier2: Tier2,
|
| 182 |
+
trace: dict | None = None,
|
| 183 |
+
plan: dict | None = None,
|
| 184 |
+
) -> Tier3:
|
| 185 |
+
"""Tier 3 ์ํฅ ํ๊ฐ. plan ์ ๊ณต ์ conductor ๋ชจ๋(LLM 1ํ), ์๋๋ฉด autonomous loop."""
|
| 186 |
+
if plan is not None:
|
| 187 |
+
return _run_impact_conductor(alarm, tier1, tier2, plan, trace)
|
| 188 |
+
|
| 189 |
messages = [
|
| 190 |
{"role": "system", "content": SYSTEM_PROMPT},
|
| 191 |
{"role": "user", "content": _initial_user_prompt(alarm, tier1, tier2)},
|
|
|
|
| 238 |
trace["tool_calls"] = tool_call_log
|
| 239 |
trace["iterations"] = iterations
|
| 240 |
trace["llm_calls"] = iterations + 1
|
| 241 |
+
trace["mode"] = "autonomous"
|
| 242 |
|
| 243 |
return {
|
| 244 |
"yield_loss": round(float(llm_out["yield_loss"]), 1),
|
agents/orchestrator.py
CHANGED
|
@@ -1,24 +1,26 @@
|
|
| 1 |
"""4-Tier ๋ฉํฐ์์ด์ ํธ ์ค์ผ์คํธ๋ ์ดํฐ (LangGraph ๊ธฐ๋ฐ)
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
| 21 |
"""
|
|
|
|
| 22 |
from functools import lru_cache
|
| 23 |
from typing import TypedDict
|
| 24 |
|
|
@@ -28,6 +30,7 @@ from langsmith import traceable
|
|
| 28 |
from agents.cause import run_cause
|
| 29 |
from agents.detection import run_detection
|
| 30 |
from agents.impact import run_impact
|
|
|
|
| 31 |
from agents.response import run_response
|
| 32 |
from agents.supervisor import run_supervisor
|
| 33 |
from core.schema import Tier1, Tier2, Tier3, Tier4, TierData
|
|
@@ -38,6 +41,10 @@ SEVERITY_THRESHOLD = 0.30
|
|
| 38 |
CAUSE_CONFIDENCE_THRESHOLD = 40
|
| 39 |
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
class _GraphState(TypedDict, total=False):
|
| 42 |
alarm: dict
|
| 43 |
tier1: Tier1
|
|
@@ -46,7 +53,8 @@ class _GraphState(TypedDict, total=False):
|
|
| 46 |
tier4: Tier4
|
| 47 |
skipped: bool
|
| 48 |
cause_retried: bool
|
| 49 |
-
supervisor_decision: dict
|
|
|
|
| 50 |
|
| 51 |
|
| 52 |
def _node_detect(state: _GraphState) -> dict:
|
|
@@ -54,7 +62,7 @@ def _node_detect(state: _GraphState) -> dict:
|
|
| 54 |
|
| 55 |
|
| 56 |
def _route_after_detect(state: _GraphState) -> str:
|
| 57 |
-
return "
|
| 58 |
|
| 59 |
|
| 60 |
def _node_noise(state: _GraphState) -> dict:
|
|
@@ -66,52 +74,34 @@ def _node_noise(state: _GraphState) -> dict:
|
|
| 66 |
}
|
| 67 |
|
| 68 |
|
| 69 |
-
|
| 70 |
-
return {"tier2": run_cause(state["alarm"], state["tier1"])}
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
def _route_after_cause(state: _GraphState) -> str:
|
| 74 |
-
if state.get("cause_retried"):
|
| 75 |
-
return "supervisor" # ์ด๋ฏธ ์ฌ์๋ - supervisor๋ก ์งํ
|
| 76 |
-
causes = state["tier2"]["causes"]
|
| 77 |
-
max_pct = max((c.get("pct", 0) for c in causes), default=0)
|
| 78 |
-
return "cause_retry" if max_pct < CAUSE_CONFIDENCE_THRESHOLD else "supervisor"
|
| 79 |
|
|
|
|
|
|
|
| 80 |
|
| 81 |
-
def _node_cause_retry(state: _GraphState) -> dict:
|
| 82 |
-
return {
|
| 83 |
-
"tier2": run_cause(state["alarm"], state["tier1"], retry_hint=True),
|
| 84 |
-
"cause_retried": True,
|
| 85 |
-
}
|
| 86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
-
def _node_supervisor(state: _GraphState) -> dict:
|
| 89 |
-
decision = run_supervisor(state["alarm"], state["tier1"], state["tier2"])
|
| 90 |
-
return {"supervisor_decision": decision}
|
| 91 |
|
|
|
|
|
|
|
| 92 |
|
| 93 |
-
def _route_after_supervisor(state: _GraphState) -> str:
|
| 94 |
-
action = state["supervisor_decision"]["action"]
|
| 95 |
-
if action == "fast_track":
|
| 96 |
-
return "fast_impact"
|
| 97 |
-
return "impact" # proceed_full + escalate ๋ชจ๋ impact ๊ฒฝ์
|
| 98 |
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
return {"tier3": run_impact(state["alarm"], state["tier1"], state["tier2"])}
|
| 102 |
|
| 103 |
|
| 104 |
def _node_fast_impact(state: _GraphState) -> dict:
|
| 105 |
-
"""fast_track: LLM ํธ์ถ ์
|
| 106 |
-
|
| 107 |
-
Tier 4๊ฐ tier3์ ์๊ตฌํ๋ฏ๋ก ์ต์ ์ ๋ณด๋ง ์ฑ์ ์ ๋ฌ.
|
| 108 |
-
yield_loss๋ tier1 score๋ฅผ ๋จ์ ๋ณํ, downstream์ current stage๋ง.
|
| 109 |
-
"""
|
| 110 |
alarm = state["alarm"]
|
| 111 |
tier1 = state["tier1"]
|
| 112 |
return {
|
| 113 |
"tier3": {
|
| 114 |
-
"yield_loss": round(float(tier1["score"]) * 3.0, 1),
|
| 115 |
"dependencies": [{
|
| 116 |
"stage": alarm["title"].split()[0],
|
| 117 |
"delta": f"+{tier1['score']}",
|
|
@@ -123,45 +113,102 @@ def _node_fast_impact(state: _GraphState) -> dict:
|
|
| 123 |
}
|
| 124 |
|
| 125 |
|
| 126 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
tier4 = run_response(state["alarm"], state["tier1"], state["tier2"], state["tier3"])
|
| 128 |
-
# supervisor๊ฐ escalate ๊ฒฐ์ ์ immediate ์ฒซ ํญ๋ชฉ์ human review ํ๋๊ทธ ์ถ๊ฐ
|
| 129 |
decision = state.get("supervisor_decision", {})
|
| 130 |
if decision.get("action") == "escalate" and tier4.get("immediate"):
|
| 131 |
tier4["immediate"][0]["text"] = "๐จ [HUMAN REVIEW ์๊ตฌ] " + tier4["immediate"][0]["text"]
|
| 132 |
return {"tier4": tier4}
|
| 133 |
|
| 134 |
|
| 135 |
-
|
| 136 |
-
|
|
|
|
|
|
|
| 137 |
g = StateGraph(_GraphState)
|
| 138 |
g.add_node("detect", _node_detect)
|
| 139 |
g.add_node("noise", _node_noise)
|
| 140 |
-
g.add_node("cause", _node_cause)
|
| 141 |
-
g.add_node("cause_retry", _node_cause_retry)
|
| 142 |
-
g.add_node("supervisor", _node_supervisor)
|
| 143 |
-
g.add_node("impact", _node_impact)
|
| 144 |
-
g.add_node("fast_impact", _node_fast_impact)
|
| 145 |
-
g.add_node("response", _node_response)
|
| 146 |
-
|
| 147 |
g.add_edge(START, "detect")
|
| 148 |
-
g.add_conditional_edges("detect", _route_after_detect, {
|
| 149 |
-
"cause": "cause",
|
| 150 |
-
"noise": "noise",
|
| 151 |
-
})
|
| 152 |
g.add_edge("noise", END)
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
"
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
"
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
return g.compile()
|
| 166 |
|
| 167 |
|
|
@@ -176,7 +223,7 @@ def _find_alarm(alarm_id: str) -> dict:
|
|
| 176 |
@lru_cache(maxsize=8)
|
| 177 |
def run_orchestrator(alarm_id: str) -> TierData:
|
| 178 |
alarm = _find_alarm(alarm_id)
|
| 179 |
-
graph = build_graph()
|
| 180 |
final = graph.invoke({"alarm": alarm})
|
| 181 |
return {
|
| 182 |
"tier1": final["tier1"],
|
|
|
|
| 1 |
"""4-Tier ๋ฉํฐ์์ด์ ํธ ์ค์ผ์คํธ๋ ์ดํฐ (LangGraph ๊ธฐ๋ฐ)
|
| 2 |
|
| 3 |
+
๋ ๊ฐ์ง ์คํ ๋ชจ๋ ์ง์ (ํ๊ฒฝ๋ณ์ AGENT_MODE):
|
| 4 |
+
- **conductor** (๊ธฐ๋ณธ): Central Planner Agent๊ฐ ์ ์ฒด plan 1ํ ์ฐ์ถ
|
| 5 |
+
๊ฐ Tier executor๊ฐ plan๋๋ก tool ํธ์ถ + LLM 1ํ synthesis
|
| 6 |
+
โ LLM ํธ์ถ ~70% ๊ฐ์, latency ํฐ ํญ ๋จ์ถ
|
| 7 |
+
- **autonomous**: ๊ฐ Tier๊ฐ tool-using agent loop๋ก ์์จ ์คํ
|
| 8 |
+
โ ์ ์์ฑ ๋์ผ๋ LLM ํธ์ถ ๋ง์
|
| 9 |
+
|
| 10 |
+
[๊ทธ๋ํ - conductor ๋ชจ๋]
|
| 11 |
+
START โ detect โ (severity gate) โ planner โ (action ๋ถ๊ธฐ)
|
| 12 |
+
โ
|
| 13 |
+
+โ cause โ impact โ response โ END (proceed_full)
|
| 14 |
+
+โ cause โ fast_impact โ response โ END (fast_track)
|
| 15 |
+
+โ cause โ impact โ response_escalate โ END (escalate, T4์ ๐จ prepend)
|
| 16 |
+
|
| 17 |
+
[๊ทธ๋ํ - autonomous ๋ชจ๋]
|
| 18 |
+
๊ธฐ์กด ๊ตฌ์กฐ (severity gate + cause_retry + supervisor ๋ถ๊ธฐ)
|
| 19 |
+
|
| 20 |
+
์๋ dict์ data.demo.DEFAULT_ALARMS์์ ID๋ก ์กฐํ.
|
| 21 |
+
@traceable (LangSmith) + wrap_openai ๋ก LLMยทtool ํธ์ถ ์๋ ํธ๋ ์ด์ค.
|
| 22 |
"""
|
| 23 |
+
import os
|
| 24 |
from functools import lru_cache
|
| 25 |
from typing import TypedDict
|
| 26 |
|
|
|
|
| 30 |
from agents.cause import run_cause
|
| 31 |
from agents.detection import run_detection
|
| 32 |
from agents.impact import run_impact
|
| 33 |
+
from agents.planner import plan_workflow
|
| 34 |
from agents.response import run_response
|
| 35 |
from agents.supervisor import run_supervisor
|
| 36 |
from core.schema import Tier1, Tier2, Tier3, Tier4, TierData
|
|
|
|
| 41 |
CAUSE_CONFIDENCE_THRESHOLD = 40
|
| 42 |
|
| 43 |
|
| 44 |
+
def _agent_mode() -> str:
|
| 45 |
+
return os.getenv("AGENT_MODE", "conductor").lower()
|
| 46 |
+
|
| 47 |
+
|
| 48 |
class _GraphState(TypedDict, total=False):
|
| 49 |
alarm: dict
|
| 50 |
tier1: Tier1
|
|
|
|
| 53 |
tier4: Tier4
|
| 54 |
skipped: bool
|
| 55 |
cause_retried: bool
|
| 56 |
+
supervisor_decision: dict
|
| 57 |
+
plan: dict # conductor ๋ชจ๋์ Planner ๊ฒฐ๊ณผ
|
| 58 |
|
| 59 |
|
| 60 |
def _node_detect(state: _GraphState) -> dict:
|
|
|
|
| 62 |
|
| 63 |
|
| 64 |
def _route_after_detect(state: _GraphState) -> str:
|
| 65 |
+
return "go" if state["tier1"]["score"] >= SEVERITY_THRESHOLD else "noise"
|
| 66 |
|
| 67 |
|
| 68 |
def _node_noise(state: _GraphState) -> dict:
|
|
|
|
| 74 |
}
|
| 75 |
|
| 76 |
|
| 77 |
+
# ==================== Conductor ๋ชจ๋ ๋
ธ๋ ====================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
+
def _node_planner(state: _GraphState) -> dict:
|
| 80 |
+
return {"plan": plan_workflow(state["alarm"], state["tier1"])}
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
+
def _route_after_planner(state: _GraphState) -> str:
|
| 84 |
+
action = state["plan"].get("action", "proceed_full")
|
| 85 |
+
if action == "fast_track":
|
| 86 |
+
return "fast_track"
|
| 87 |
+
return "proceed" # proceed_full + escalate ๋ชจ๋ ํ์ค ๊ฒฝ๋ก
|
| 88 |
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
+
def _node_cause_conductor(state: _GraphState) -> dict:
|
| 91 |
+
return {"tier2": run_cause(state["alarm"], state["tier1"], plan=state["plan"])}
|
| 92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
+
def _node_impact_conductor(state: _GraphState) -> dict:
|
| 95 |
+
return {"tier3": run_impact(state["alarm"], state["tier1"], state["tier2"], plan=state["plan"])}
|
|
|
|
| 96 |
|
| 97 |
|
| 98 |
def _node_fast_impact(state: _GraphState) -> dict:
|
| 99 |
+
"""fast_track: deterministic ๊ฒฝ๋ ์ฒ๋ฆฌ (LLM ํธ์ถ ์์)"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
alarm = state["alarm"]
|
| 101 |
tier1 = state["tier1"]
|
| 102 |
return {
|
| 103 |
"tier3": {
|
| 104 |
+
"yield_loss": round(float(tier1["score"]) * 3.0, 1),
|
| 105 |
"dependencies": [{
|
| 106 |
"stage": alarm["title"].split()[0],
|
| 107 |
"delta": f"+{tier1['score']}",
|
|
|
|
| 113 |
}
|
| 114 |
|
| 115 |
|
| 116 |
+
def _node_response_conductor(state: _GraphState) -> dict:
|
| 117 |
+
tier4 = run_response(state["alarm"], state["tier1"], state["tier2"], state["tier3"], plan=state["plan"])
|
| 118 |
+
if state["plan"].get("action") == "escalate" and tier4.get("immediate"):
|
| 119 |
+
tier4["immediate"][0]["text"] = "๐จ [HUMAN REVIEW ์๊ตฌ] " + tier4["immediate"][0]["text"]
|
| 120 |
+
return {"tier4": tier4}
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
# ==================== Autonomous ๋ชจ๋ ๋
ธ๋ (๊ธฐ์กด ๋ณด์กด) ====================
|
| 124 |
+
|
| 125 |
+
def _node_cause_autonomous(state: _GraphState) -> dict:
|
| 126 |
+
return {"tier2": run_cause(state["alarm"], state["tier1"])}
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
def _route_after_cause_autonomous(state: _GraphState) -> str:
|
| 130 |
+
if state.get("cause_retried"):
|
| 131 |
+
return "supervisor"
|
| 132 |
+
causes = state["tier2"]["causes"]
|
| 133 |
+
max_pct = max((c.get("pct", 0) for c in causes), default=0)
|
| 134 |
+
return "cause_retry" if max_pct < CAUSE_CONFIDENCE_THRESHOLD else "supervisor"
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
def _node_cause_retry(state: _GraphState) -> dict:
|
| 138 |
+
return {
|
| 139 |
+
"tier2": run_cause(state["alarm"], state["tier1"], retry_hint=True),
|
| 140 |
+
"cause_retried": True,
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
def _node_supervisor(state: _GraphState) -> dict:
|
| 145 |
+
return {"supervisor_decision": run_supervisor(state["alarm"], state["tier1"], state["tier2"])}
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
def _route_after_supervisor(state: _GraphState) -> str:
|
| 149 |
+
return "fast_track" if state["supervisor_decision"]["action"] == "fast_track" else "proceed"
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
def _node_impact_autonomous(state: _GraphState) -> dict:
|
| 153 |
+
return {"tier3": run_impact(state["alarm"], state["tier1"], state["tier2"])}
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
def _node_response_autonomous(state: _GraphState) -> dict:
|
| 157 |
tier4 = run_response(state["alarm"], state["tier1"], state["tier2"], state["tier3"])
|
|
|
|
| 158 |
decision = state.get("supervisor_decision", {})
|
| 159 |
if decision.get("action") == "escalate" and tier4.get("immediate"):
|
| 160 |
tier4["immediate"][0]["text"] = "๐จ [HUMAN REVIEW ์๊ตฌ] " + tier4["immediate"][0]["text"]
|
| 161 |
return {"tier4": tier4}
|
| 162 |
|
| 163 |
|
| 164 |
+
# ==================== Graph ๋น๋ ====================
|
| 165 |
+
|
| 166 |
+
@lru_cache(maxsize=2)
|
| 167 |
+
def build_graph(mode: str = "conductor"):
|
| 168 |
g = StateGraph(_GraphState)
|
| 169 |
g.add_node("detect", _node_detect)
|
| 170 |
g.add_node("noise", _node_noise)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
g.add_edge(START, "detect")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
g.add_edge("noise", END)
|
| 173 |
+
|
| 174 |
+
if mode == "conductor":
|
| 175 |
+
g.add_node("planner", _node_planner)
|
| 176 |
+
g.add_node("cause", _node_cause_conductor)
|
| 177 |
+
g.add_node("impact", _node_impact_conductor)
|
| 178 |
+
g.add_node("fast_impact", _node_fast_impact)
|
| 179 |
+
g.add_node("response", _node_response_conductor)
|
| 180 |
+
|
| 181 |
+
g.add_conditional_edges("detect", _route_after_detect, {"go": "planner", "noise": "noise"})
|
| 182 |
+
g.add_edge("planner", "cause")
|
| 183 |
+
g.add_conditional_edges("cause", _route_after_planner, {
|
| 184 |
+
"proceed": "impact",
|
| 185 |
+
"fast_track": "fast_impact",
|
| 186 |
+
})
|
| 187 |
+
g.add_edge("impact", "response")
|
| 188 |
+
g.add_edge("fast_impact", "response")
|
| 189 |
+
g.add_edge("response", END)
|
| 190 |
+
else:
|
| 191 |
+
# autonomous (๊ธฐ์กด ๊ตฌ์กฐ)
|
| 192 |
+
g.add_node("cause", _node_cause_autonomous)
|
| 193 |
+
g.add_node("cause_retry", _node_cause_retry)
|
| 194 |
+
g.add_node("supervisor", _node_supervisor)
|
| 195 |
+
g.add_node("impact", _node_impact_autonomous)
|
| 196 |
+
g.add_node("fast_impact", _node_fast_impact)
|
| 197 |
+
g.add_node("response", _node_response_autonomous)
|
| 198 |
+
|
| 199 |
+
g.add_conditional_edges("detect", _route_after_detect, {"go": "cause", "noise": "noise"})
|
| 200 |
+
g.add_conditional_edges("cause", _route_after_cause_autonomous, {
|
| 201 |
+
"supervisor": "supervisor",
|
| 202 |
+
"cause_retry": "cause_retry",
|
| 203 |
+
})
|
| 204 |
+
g.add_edge("cause_retry", "supervisor")
|
| 205 |
+
g.add_conditional_edges("supervisor", _route_after_supervisor, {
|
| 206 |
+
"proceed": "impact",
|
| 207 |
+
"fast_track": "fast_impact",
|
| 208 |
+
})
|
| 209 |
+
g.add_edge("impact", "response")
|
| 210 |
+
g.add_edge("fast_impact", "response")
|
| 211 |
+
g.add_edge("response", END)
|
| 212 |
return g.compile()
|
| 213 |
|
| 214 |
|
|
|
|
| 223 |
@lru_cache(maxsize=8)
|
| 224 |
def run_orchestrator(alarm_id: str) -> TierData:
|
| 225 |
alarm = _find_alarm(alarm_id)
|
| 226 |
+
graph = build_graph(_agent_mode())
|
| 227 |
final = graph.invoke({"alarm": alarm})
|
| 228 |
return {
|
| 229 |
"tier1": final["tier1"],
|
agents/planner.py
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Central Planner Agent (Plan-and-Execute pattern)
|
| 2 |
+
|
| 3 |
+
์๋๊ณผ Tier 1 ๊ฒฐ๊ณผ๋ฅผ ๋ณด๊ณ ์ ์ฒด ์ํฌํ๋ก์ฐ plan์ 1ํ LLM ํธ์ถ๋ก ์ฐ์ถํฉ๋๋ค.
|
| 4 |
+
๊ฐ Tier executor๋ plan๋๋ก ๋๊ตฌ๋ฅผ ์ง์ ํธ์ถํ๊ณ LLM 1ํ๋ก ๊ฒฐ๊ณผ๋ฅผ ํฉ์ฑํฉ๋๋ค.
|
| 5 |
+
|
| 6 |
+
๊ธฐ์กด autonomous tool-using loop ๋๋น:
|
| 7 |
+
- LLM ํธ์ถ ~70% ๊ฐ์ (๊ฐ tier loop ์ ๊ฑฐ)
|
| 8 |
+
- ์ฌ๊ท/๋ฌดํ๋ฃจํ ์ํ ์์ฒ ์ฐจ๋จ (LLM์ด tool์ ์์จ ์ ํํ์ง ์์)
|
| 9 |
+
- ํต์ ์ค๋ฒํค๋ ์ต์ํ (synthesis context๋ฅผ ํ ๋ฒ์ ๊ตฌ์ฑ)
|
| 10 |
+
- ๋น์ฉยทlatency ํฐ ํญ ์ ๊ฐ (gpt-4o-mini๋ก planning + gpt-5-mini๋ก synthesis)
|
| 11 |
+
|
| 12 |
+
์ค๊ณ:
|
| 13 |
+
- Planner๊ฐ ๊ตฌ์ฒด์ ํจ์ ํธ์ถ์ด ์๋ "ํ์ํ ์ ๋ณด ์ฑ๋" (query/symptom/equipment_id ๋ฆฌ์คํธ)์ ์ง์
|
| 14 |
+
- ๊ฐ Tier executor๊ฐ ๊ทธ ์ฑ๋์ ๋ฐ์ ๊ฒฐ์ ๋ก ์ ์ผ๋ก tool ํธ์ถ (๋ณ๋ ฌ ๊ฐ๋ฅ)
|
| 15 |
+
- Tier executor๋ ๋จ 1ํ LLM ํธ์ถ๋ก synthesis (tools ์ธ์ ์์ด)
|
| 16 |
+
"""
|
| 17 |
+
import json
|
| 18 |
+
|
| 19 |
+
from langsmith import traceable
|
| 20 |
+
|
| 21 |
+
from agents.llm import client
|
| 22 |
+
from agents.tools.equipment import ALARM_EQUIPMENT
|
| 23 |
+
from core.schema import Tier1
|
| 24 |
+
|
| 25 |
+
PLANNER_MODEL = "gpt-4o-mini"
|
| 26 |
+
|
| 27 |
+
PLAN_SCHEMA = {
|
| 28 |
+
"type": "object",
|
| 29 |
+
"properties": {
|
| 30 |
+
"tier2": {
|
| 31 |
+
"type": "object",
|
| 32 |
+
"properties": {
|
| 33 |
+
"search_queries": {
|
| 34 |
+
"type": "array",
|
| 35 |
+
"items": {"type": "string"},
|
| 36 |
+
"description": "์ฌ๋ด ์ง์ ๊ฒ์ ์ฟผ๋ฆฌ (1~3๊ฐ)",
|
| 37 |
+
},
|
| 38 |
+
"incident_symptoms": {
|
| 39 |
+
"type": "array",
|
| 40 |
+
"items": {"type": "string"},
|
| 41 |
+
"description": "๊ณผ๊ฑฐ incident DB ์กฐํ์ฉ ์ฆ์ (0~2๊ฐ)",
|
| 42 |
+
},
|
| 43 |
+
"equipment_ids": {
|
| 44 |
+
"type": "array",
|
| 45 |
+
"items": {"type": "string"},
|
| 46 |
+
"description": "PM ์ด๋ ฅ ์กฐํ ์ฅ๋น ID (0~1๊ฐ)",
|
| 47 |
+
},
|
| 48 |
+
},
|
| 49 |
+
"required": ["search_queries", "incident_symptoms", "equipment_ids"],
|
| 50 |
+
"additionalProperties": False,
|
| 51 |
+
},
|
| 52 |
+
"tier3": {
|
| 53 |
+
"type": "object",
|
| 54 |
+
"properties": {
|
| 55 |
+
"alarm_id": {"type": "string", "description": "WIP ์กฐํ์ฉ ์๋ ID"},
|
| 56 |
+
"downstream_stages": {
|
| 57 |
+
"type": "array",
|
| 58 |
+
"items": {"type": "string"},
|
| 59 |
+
"description": "ํ๊ณต์ ์์กด์ฑ ์กฐํ (1๊ฐ)",
|
| 60 |
+
},
|
| 61 |
+
"yield_processes": {
|
| 62 |
+
"type": "array",
|
| 63 |
+
"items": {"type": "string"},
|
| 64 |
+
"description": "yield baseline ์กฐํ (1~2๊ฐ)",
|
| 65 |
+
},
|
| 66 |
+
"equipment_ids": {
|
| 67 |
+
"type": "array",
|
| 68 |
+
"items": {"type": "string"},
|
| 69 |
+
"description": "PM ์ด๋ ฅ ์กฐํ ์ฅ๋น ID (0~1๊ฐ)",
|
| 70 |
+
},
|
| 71 |
+
},
|
| 72 |
+
"required": ["alarm_id", "downstream_stages", "yield_processes", "equipment_ids"],
|
| 73 |
+
"additionalProperties": False,
|
| 74 |
+
},
|
| 75 |
+
"tier4": {
|
| 76 |
+
"type": "object",
|
| 77 |
+
"properties": {
|
| 78 |
+
"search_queries": {
|
| 79 |
+
"type": "array",
|
| 80 |
+
"items": {"type": "string"},
|
| 81 |
+
"description": "SOP ๊ฒ์ ์ฟผ๋ฆฌ (1~3๊ฐ)",
|
| 82 |
+
},
|
| 83 |
+
"incident_symptoms": {
|
| 84 |
+
"type": "array",
|
| 85 |
+
"items": {"type": "string"},
|
| 86 |
+
"description": "๊ณผ๊ฑฐ ํด๊ฒฐ์ฑ
์กฐํ (0~2๊ฐ)",
|
| 87 |
+
},
|
| 88 |
+
"equipment_ids": {
|
| 89 |
+
"type": "array",
|
| 90 |
+
"items": {"type": "string"},
|
| 91 |
+
"description": "PM ์๋์ฐ ์กฐํ ์ฅ๋น ID (1๊ฐ)",
|
| 92 |
+
},
|
| 93 |
+
},
|
| 94 |
+
"required": ["search_queries", "incident_symptoms", "equipment_ids"],
|
| 95 |
+
"additionalProperties": False,
|
| 96 |
+
},
|
| 97 |
+
"action": {
|
| 98 |
+
"type": "string",
|
| 99 |
+
"enum": ["proceed_full", "fast_track", "escalate"],
|
| 100 |
+
"description": "์ํฌํ๋ก์ฐ ๋ถ๊ธฐ (Tier 3 skip ์ฌ๋ถ, escalation ํ๋๊ทธ)",
|
| 101 |
+
},
|
| 102 |
+
"severity": {
|
| 103 |
+
"type": "string",
|
| 104 |
+
"enum": ["low", "medium", "high", "critical"],
|
| 105 |
+
},
|
| 106 |
+
"reasoning": {"type": "string"},
|
| 107 |
+
},
|
| 108 |
+
"required": ["tier2", "tier3", "tier4", "action", "severity", "reasoning"],
|
| 109 |
+
"additionalProperties": False,
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
SYSTEM_PROMPT = """๋น์ ์ ๋ฐ๋์ฒด fab ์ธ์๋ํธ ๋์ ์์คํ
์ Central Planner Agent์
๋๋ค.
|
| 113 |
+
์ด์ ์๋๊ณผ Tier 1 ํ์ง ๊ฒฐ๊ณผ๋ฅผ ๋ฐ์ ์ ์ฒด ์ํฌํ๋ก์ฐ(Tier 2 ์์ธ๋ถ์ โ Tier 3 ์ํฅํ๊ฐ โ Tier 4 ๋์๊ถ๊ณ )์ ํ์ํ ์ ๋ณด ์์ง plan์ ํ ๋ฒ์ ์ฐ์ถํฉ๋๋ค.
|
| 114 |
+
|
| 115 |
+
[๊ฐ์ฉ ์ ๋ณด ์ฑ๋ - tier๋ณ]
|
| 116 |
+
|
| 117 |
+
Tier 2 (์์ธ ๋ถ์):
|
| 118 |
+
- search_queries: ์ฌ๋ด ์ง์(INC/FMEA/SOP/FLOW) hybrid ๊ฒ์ (1~3๊ฐ)
|
| 119 |
+
- incident_symptoms: ๊ณผ๊ฑฐ incident DB ๊ตฌ์กฐํ ์กฐํ (0~2๊ฐ)
|
| 120 |
+
- equipment_ids: ์ฅ๋น PM ์ด๋ ฅ ์กฐํ (0~1๊ฐ)
|
| 121 |
+
|
| 122 |
+
Tier 3 (์ํฅ ํ๊ฐ):
|
| 123 |
+
- alarm_id: WIP ์กฐํ (๏ฟฝ๏ฟฝ๋์ 1๊ฐ, ์๋ ID ๊ทธ๋๋ก)
|
| 124 |
+
- downstream_stages: ํ๊ณต์ ์์กด์ฑ (1๊ฐ, ํ์ฌ ๊ณต์ ๋ช
- ์: "Photo", "Etch", "CMP")
|
| 125 |
+
- yield_processes: yield baseline ์กฐํ (1~2๊ฐ)
|
| 126 |
+
- equipment_ids: PM ์ด๋ ฅ ์กฐํ (0~1๊ฐ)
|
| 127 |
+
|
| 128 |
+
Tier 4 (๋์ ๊ถ๊ณ ):
|
| 129 |
+
- search_queries: SOPยทํ์ค ์ ์ฐจ ๊ฒ์ (1~3๊ฐ)
|
| 130 |
+
- incident_symptoms: ๊ณผ๊ฑฐ ํด๊ฒฐ์ฑ
์กฐํ (0~2๊ฐ)
|
| 131 |
+
- equipment_ids: PM ์๋์ฐ ์กฐํ (1๊ฐ, immediate ์กฐ์น์ ์คํ ๊ฐ๋ฅ ์์ )
|
| 132 |
+
|
| 133 |
+
[routing ๊ฒฐ์ ]
|
| 134 |
+
- action:
|
| 135 |
+
- proceed_full (๋๋ถ๋ถ, ํ์ค Tier 2 โ 3 โ 4)
|
| 136 |
+
- fast_track (๋จ์ผ ์์ธ 80%+ ์ฐ์ธ ์ - Tier 3 LLM skip)
|
| 137 |
+
- escalate (๊ณ ์ํยท๋ค๋์ ์ํฅ - ์ ์ ์งํ + human review ํ๋๊ทธ)
|
| 138 |
+
- severity: low / medium / high / critical
|
| 139 |
+
|
| 140 |
+
[์ค์ ์์น]
|
| 141 |
+
- ์๋๊ณผ Tier 1์ ๋ณด๊ณ ๊ฐ์ฅ ์ ๋ณด๊ฐ์น ํฐ ์ฟผ๋ฆฌ/์กฐํ๋ง ์ ๋ณ (๋ถํ์ํ ํธ์ถ ์ ๊ฑฐ)
|
| 142 |
+
- search_queries๋ ๋๋ฉ์ธ ์ฉ์ด๋ฅผ ํ๋ถํ๊ฒ (์: "Photo CD ์ฐํฌ ๋ ์ฆ ์ค์ผ ํค์ด์ฆ")
|
| 143 |
+
- Tier 2์ Tier 4์ search_queries๋ ๋ชฉ์ ์ด ๋ค๋ฆ:
|
| 144 |
+
- Tier 2: ์์ธ ํ๋ณด ํ์์ฉ
|
| 145 |
+
- Tier 4: SOPยท์กฐ์น ์ ์ฐจ ํ์์ฉ
|
| 146 |
+
- reasoning์ ํ ๋ฌธ์ฅ์ผ๋ก plan์ ํต์ฌ ์๋ ๋ช
์"""
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
def _build_user_prompt(alarm: dict, tier1: Tier1) -> str:
|
| 150 |
+
sensors = ", ".join(f["name"] for f in tier1["features"])
|
| 151 |
+
equipment_id = ALARM_EQUIPMENT.get(alarm["id"], "(๋ฏธ๋งคํ)")
|
| 152 |
+
process = alarm["title"].split()[0]
|
| 153 |
+
return f"""## ์ด์ ์๋
|
| 154 |
+
- ๊ณต์ : {alarm['title']} (current_stage: {process})
|
| 155 |
+
- lot: {alarm['lot_id']}
|
| 156 |
+
- ์ด์ ํผ์ฒ: {alarm.get('feature')} {alarm.get('feature_arrow') or ''}
|
| 157 |
+
- ์๋ ID: {alarm['id']}
|
| 158 |
+
- ์ถ์ ์ฅ๋น ID: {equipment_id}
|
| 159 |
+
|
| 160 |
+
## Tier 1 ์ด์ ํ์ง ๊ฒฐ๊ณผ
|
| 161 |
+
- ์ด์ ์ ์: {tier1['score']}
|
| 162 |
+
- ๊ธฐ์ฌ ์ผ์(Top): {sensors}
|
| 163 |
+
|
| 164 |
+
์ ์๋์ ์ ์ฒด ์ํฌํ๋ก์ฐ(Tier 2โ3โ4) plan์ ์ฐ์ถํ์ธ์."""
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
@traceable(name="Planner_Agent", run_type="chain")
|
| 168 |
+
def plan_workflow(alarm: dict, tier1: Tier1) -> dict:
|
| 169 |
+
"""์๋ + Tier 1์ ๋ณด๊ณ ์ ์ฒด ์ํฌํ๋ก์ฐ plan์ ํ ๋ฒ์ ์ฐ์ถ
|
| 170 |
+
|
| 171 |
+
๋ฐํ: PLAN_SCHEMA ํ์ dict (tier2/tier3/tier4 + action/severity/reasoning)
|
| 172 |
+
"""
|
| 173 |
+
resp = client().chat.completions.create(
|
| 174 |
+
model=PLANNER_MODEL,
|
| 175 |
+
messages=[
|
| 176 |
+
{"role": "system", "content": SYSTEM_PROMPT},
|
| 177 |
+
{"role": "user", "content": _build_user_prompt(alarm, tier1)},
|
| 178 |
+
],
|
| 179 |
+
response_format={
|
| 180 |
+
"type": "json_schema",
|
| 181 |
+
"json_schema": {"name": "plan", "schema": PLAN_SCHEMA, "strict": True},
|
| 182 |
+
},
|
| 183 |
+
)
|
| 184 |
+
return json.loads(resp.choices[0].message.content)
|
agents/response.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
| 1 |
-
"""Tier 4 ๋์ ๊ถ๊ณ ์์ด์ ํธ
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
| 5 |
|
| 6 |
๊ฐ์ฉ ๋๊ตฌ: search_knowledge, lookup_incident_history, get_pm_history, check_pm_schedule
|
| 7 |
"""
|
|
@@ -116,10 +117,111 @@ def _initial_user_prompt(alarm: dict, tier1: Tier1, tier2: Tier2, tier3: Tier3)
|
|
| 116 |
ํ์ํ SOPยท๊ณผ๊ฑฐ ํด๊ฒฐ์ฑ
ยทPM ์๋์ฐ๋ ๋๊ตฌ๋ฅผ ํธ์ถํด ์์จ์ ์ผ๋ก ์์งํ์ธ์."""
|
| 117 |
|
| 118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
@traceable(name="Tier4_Response_Agent", run_type="chain")
|
| 120 |
def run_response(
|
| 121 |
-
alarm: dict, tier1: Tier1, tier2: Tier2, tier3: Tier3,
|
|
|
|
|
|
|
| 122 |
) -> Tier4:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
messages = [
|
| 124 |
{"role": "system", "content": SYSTEM_PROMPT},
|
| 125 |
{"role": "user", "content": _initial_user_prompt(alarm, tier1, tier2, tier3)},
|
|
@@ -176,6 +278,7 @@ def run_response(
|
|
| 176 |
trace["tool_calls"] = tool_call_log
|
| 177 |
trace["iterations"] = iterations
|
| 178 |
trace["llm_calls"] = iterations + 1
|
|
|
|
| 179 |
|
| 180 |
return {
|
| 181 |
"immediate": llm_out["immediate"],
|
|
|
|
| 1 |
+
"""Tier 4 ๋์ ๊ถ๊ณ ์์ด์ ํธ
|
| 2 |
|
| 3 |
+
๋ ๋ชจ๋ ์ง์:
|
| 4 |
+
1. Autonomous (plan=None): LLM์ด tool์ ์์จ ํธ์ถํ๋ agent loop
|
| 5 |
+
2. Conductor (plan ์ ๊ณต): Planner๊ฐ ์ง์ ํ tool ํธ์ถ + ๋จ์ผ LLM synthesis
|
| 6 |
|
| 7 |
๊ฐ์ฉ ๋๊ตฌ: search_knowledge, lookup_incident_history, get_pm_history, check_pm_schedule
|
| 8 |
"""
|
|
|
|
| 117 |
ํ์ํ SOPยท๊ณผ๊ฑฐ ํด๊ฒฐ์ฑ
ยทPM ์๋์ฐ๋ ๋๊ตฌ๋ฅผ ํธ์ถํด ์์จ์ ์ผ๋ก ์์งํ์ธ์."""
|
| 118 |
|
| 119 |
|
| 120 |
+
CONDUCTOR_SYSTEM_PROMPT = """๋น์ ์ ๋ฐ๋์ฒด ๊ณต์ ๋์ ๊ถ๊ณ ์ ๋ฌธ๊ฐ์
๋๋ค.
|
| 121 |
+
Central Planner๊ฐ ์ด๋ฏธ ํ์ํ ์ ๋ณด(SOPยท๊ณผ๊ฑฐ ํด๊ฒฐ์ฑ
ยทPM ์๋์ฐ)๋ฅผ ๋ชจ๋ ์์งํด [์์ง๋ ์ปจํ
์คํธ]์ ์ ๋ฆฌํด ๋์์ต๋๋ค.
|
| 122 |
+
๋น์ ์ ์ถ๊ฐ ๋๊ตฌ ํธ์ถ ์์ด ๊ทธ ์ปจํ
์คํธ๋ง ์ฌ์ฉํด ์ฐ์ถํ์ธ์.
|
| 123 |
+
|
| 124 |
+
[์ต์ข
์ฐ์ถ๋ฌผ]
|
| 125 |
+
- immediate: ์ฆ์ ์กฐ์น 2~3๊ฑด (์ ์๊ฐ ๋ด ์คํ ๊ฐ๋ฅ, meta์ ์๊ฐยทhold ๋์ยท๋ถ์ ๋ช
์)
|
| 126 |
+
- longterm: ์ค์ฅ๊ธฐ ์กฐ์น 1~2๊ฑด
|
| 127 |
+
- ref_doc_ids: ๊ถ๊ณ ๊ทผ๊ฑฐ๋ก ์ค์ ์ฌ์ฉํ ๋ฌธ์ ID (search_knowledge๊ฐ ๋ฐํํ doc_id๋ง)"""
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
def _execute_tier4_plan(plan_tier4: dict, trace_calls: list) -> tuple[str, list[str]]:
|
| 131 |
+
"""Planner๊ฐ ์ง์ ํ tool๋ค์ ์ง์ ํธ์ถ, ์ปจํ
์คํธ + ๊ฒ์ doc_id ๋ฆฌ์คํธ ๋ฐํ"""
|
| 132 |
+
blocks = []
|
| 133 |
+
found_docs: list[str] = []
|
| 134 |
+
for query in plan_tier4.get("search_queries", []):
|
| 135 |
+
r = dispatch_tool("search_knowledge", {"query": query})
|
| 136 |
+
trace_calls.append({"name": "search_knowledge", "args": {"query": query}})
|
| 137 |
+
blocks.append(f"[search_knowledge: {query!r}]\n{r}")
|
| 138 |
+
try:
|
| 139 |
+
parsed = json.loads(r)
|
| 140 |
+
found_docs.extend(h["doc_id"] for h in parsed.get("hits", []))
|
| 141 |
+
except (json.JSONDecodeError, KeyError):
|
| 142 |
+
pass
|
| 143 |
+
for symptom in plan_tier4.get("incident_symptoms", []):
|
| 144 |
+
r = dispatch_tool("lookup_incident_history", {"symptom": symptom})
|
| 145 |
+
trace_calls.append({"name": "lookup_incident_history", "args": {"symptom": symptom}})
|
| 146 |
+
blocks.append(f"[lookup_incident_history: {symptom!r}]\n{r}")
|
| 147 |
+
for eq_id in plan_tier4.get("equipment_ids", []):
|
| 148 |
+
r1 = dispatch_tool("get_pm_history", {"equipment_id": eq_id})
|
| 149 |
+
trace_calls.append({"name": "get_pm_history", "args": {"equipment_id": eq_id}})
|
| 150 |
+
blocks.append(f"[get_pm_history: {eq_id!r}]\n{r1}")
|
| 151 |
+
r2 = dispatch_tool("check_pm_schedule", {"equipment_id": eq_id})
|
| 152 |
+
trace_calls.append({"name": "check_pm_schedule", "args": {"equipment_id": eq_id}})
|
| 153 |
+
blocks.append(f"[check_pm_schedule: {eq_id!r}]\n{r2}")
|
| 154 |
+
return "\n\n".join(blocks) if blocks else "(planner๊ฐ ์ ๋ณด ์์ง ์ง์ ์์)", found_docs
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
def _run_response_conductor(
|
| 158 |
+
alarm: dict, tier1: Tier1, tier2: Tier2, tier3: Tier3,
|
| 159 |
+
plan: dict, trace: dict | None,
|
| 160 |
+
) -> Tier4:
|
| 161 |
+
tool_log: list[dict] = []
|
| 162 |
+
knowledge, found_docs = _execute_tier4_plan(plan.get("tier4", {}), tool_log)
|
| 163 |
+
|
| 164 |
+
cause_lines = "\n".join(f"- {c['name']} ({c['pct']}%)" for c in tier2["causes"])
|
| 165 |
+
impact_lots_text = ", ".join(
|
| 166 |
+
f"{l['label']} {l['lots']}lot/{l['wafers']}์ฅ" for l in tier3["impact_lots"]
|
| 167 |
+
)
|
| 168 |
+
user_prompt = f"""## ์ด์ ์๋
|
| 169 |
+
- ๊ณต์ : {alarm['title']}, lot: {alarm['lot_id']}
|
| 170 |
+
|
| 171 |
+
## Tier 1: ์ด์ ์ ์ {tier1['score']}
|
| 172 |
+
|
| 173 |
+
## Tier 2 ์์ธ (๊ธฐ์ฌ๋ ์)
|
| 174 |
+
{cause_lines}
|
| 175 |
+
|
| 176 |
+
## Tier 3 ์ํฅ
|
| 177 |
+
- ์์ ์์จ ์์ค: {tier3['yield_loss']} %p
|
| 178 |
+
- ์ํฅ WIP: {impact_lots_text}
|
| 179 |
+
|
| 180 |
+
## ์์ง๋ ์ปจํ
์คํธ (Planner ์ง์ )
|
| 181 |
+
{knowledge}
|
| 182 |
+
|
| 183 |
+
์ ์ปจํ
์คํธ๋ง ์ฌ์ฉํด immediate, longterm, ref_doc_ids๋ฅผ ์ฐ์ถํ์ธ์."""
|
| 184 |
+
|
| 185 |
+
resp = client().chat.completions.create(
|
| 186 |
+
model=SUBAGENT_MODEL,
|
| 187 |
+
messages=[
|
| 188 |
+
{"role": "system", "content": CONDUCTOR_SYSTEM_PROMPT},
|
| 189 |
+
{"role": "user", "content": user_prompt},
|
| 190 |
+
],
|
| 191 |
+
response_format={
|
| 192 |
+
"type": "json_schema",
|
| 193 |
+
"json_schema": {"name": "tier4_part", "schema": LLM_PART_SCHEMA, "strict": True},
|
| 194 |
+
},
|
| 195 |
+
)
|
| 196 |
+
llm_out = json.loads(resp.choices[0].message.content)
|
| 197 |
+
|
| 198 |
+
ref_ids = llm_out.get("ref_doc_ids") or found_docs[:4]
|
| 199 |
+
refs = [{"id": d, "desc": _doc_description(d)} for d in ref_ids if d]
|
| 200 |
+
|
| 201 |
+
if trace is not None:
|
| 202 |
+
trace["tool_calls"] = tool_log
|
| 203 |
+
trace["iterations"] = 0
|
| 204 |
+
trace["llm_calls"] = 1
|
| 205 |
+
trace["mode"] = "conductor"
|
| 206 |
+
|
| 207 |
+
return {
|
| 208 |
+
"immediate": llm_out["immediate"],
|
| 209 |
+
"longterm": llm_out["longterm"],
|
| 210 |
+
"refs": refs,
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
|
| 214 |
@traceable(name="Tier4_Response_Agent", run_type="chain")
|
| 215 |
def run_response(
|
| 216 |
+
alarm: dict, tier1: Tier1, tier2: Tier2, tier3: Tier3,
|
| 217 |
+
trace: dict | None = None,
|
| 218 |
+
plan: dict | None = None,
|
| 219 |
) -> Tier4:
|
| 220 |
+
"""Tier 4 ๋์ ๊ถ๊ณ . plan ์ ๊ณต ์ conductor ๋ชจ๋(LLM 1ํ), ์๋๋ฉด autonomous loop."""
|
| 221 |
+
if plan is not None:
|
| 222 |
+
return _run_response_conductor(alarm, tier1, tier2, tier3, plan, trace)
|
| 223 |
+
|
| 224 |
+
# autonomous ๋ชจ๋ (LLM์ด tool์ ์์จ ํธ์ถํ๋ ๊ธฐ์กด loop)
|
| 225 |
messages = [
|
| 226 |
{"role": "system", "content": SYSTEM_PROMPT},
|
| 227 |
{"role": "user", "content": _initial_user_prompt(alarm, tier1, tier2, tier3)},
|
|
|
|
| 278 |
trace["tool_calls"] = tool_call_log
|
| 279 |
trace["iterations"] = iterations
|
| 280 |
trace["llm_calls"] = iterations + 1
|
| 281 |
+
trace["mode"] = "autonomous"
|
| 282 |
|
| 283 |
return {
|
| 284 |
"immediate": llm_out["immediate"],
|
experiments/README.md
CHANGED
|
@@ -16,6 +16,7 @@
|
|
| 16 |
| **D8** | CRAG ON vs OFF | self-correction (grader + refinement) | CRAG **ํ์ฑ ์ ์ง** (๊ด์ธก ๊ฐ์น) | [crag_eval/results.md](crag_eval/results.md) |
|
| 17 |
| **D9** | ํ๊ตญ์ด reranker (Dongjin-kr/ko-reranker) | vs BAAI(์์ด) vs hybrid (12 docs) | ๋ ๋ค hybrid์ ๋ฏธ๋ฌ | [reranker_compare/results.md](reranker_compare/results.md) |
|
| 18 |
| **D10** | D9 ํ์: ์ฝํผ์ค 12โ34 ํ์ฅ ํ reranker ์ฌํ๊ฐ | hybrid / BAAI / ko-reranker (34 docs) | **๊ฐ์ค ๊ฒ์ฆ - ํจ๊ณผ ์์ ๋ฐ์ ** | [reranker_compare/results.md](reranker_compare/results.md) |
|
|
|
|
| 19 |
|
| 20 |
## ํต์ฌ ๊ฒฐ์ ์์ฝ
|
| 21 |
|
|
@@ -169,6 +170,28 @@
|
|
| 169 |
|
| 170 |
**ํต์ฌ ๋ฉ์์ง**: ์ ๋ ํ๊ฐ ์์ด๋ ์๋ชป๋ ํต๋
์ ๊ทธ๋๋ก ๋๊ณ ๊ฐ ๋ปํ๊ณ , ์ ๋ ํ๊ฐ ๋๋ถ์ ์ง์ง ์์ธ์ ๋ถ๋ฆฌํ๊ณ ๊ฒ์ฆํ ์ ์์๋ค. ์ฑํ: ์ฝํผ์ค 30+ ํ๊ฒฝ์์๋ `RAG_BACKEND=hybrid_rerank` ๊ถ์ฅ, ๋ฐ๋ชจ์ฉ ์ฝํผ์ค๋ hybrid ์ ์ง.
|
| 171 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
## ์คํ ๋ฐฉ๋ฒ
|
| 173 |
|
| 174 |
```bash
|
|
@@ -195,8 +218,11 @@
|
|
| 195 |
# CRAG ON vs OFF (D8)
|
| 196 |
.venv/bin/python -m experiments.crag_eval.benchmark
|
| 197 |
|
| 198 |
-
# ํ๊ตญ์ด reranker (Dongjin-kr/ko-reranker) ํ๊ฐ (D9)
|
| 199 |
.venv/bin/python -m experiments.reranker_compare.benchmark
|
|
|
|
|
|
|
|
|
|
| 200 |
```
|
| 201 |
|
| 202 |
๊ฐ ์คํ์ `results.md`์ `charts/*.png`๋ฅผ ์์ฑํฉ๋๋ค.
|
|
|
|
| 16 |
| **D8** | CRAG ON vs OFF | self-correction (grader + refinement) | CRAG **ํ์ฑ ์ ์ง** (๊ด์ธก ๊ฐ์น) | [crag_eval/results.md](crag_eval/results.md) |
|
| 17 |
| **D9** | ํ๊ตญ์ด reranker (Dongjin-kr/ko-reranker) | vs BAAI(์์ด) vs hybrid (12 docs) | ๋ ๋ค hybrid์ ๋ฏธ๋ฌ | [reranker_compare/results.md](reranker_compare/results.md) |
|
| 18 |
| **D10** | D9 ํ์: ์ฝํผ์ค 12โ34 ํ์ฅ ํ reranker ์ฌํ๊ฐ | hybrid / BAAI / ko-reranker (34 docs) | **๊ฐ์ค ๊ฒ์ฆ - ํจ๊ณผ ์์ ๋ฐ์ ** | [reranker_compare/results.md](reranker_compare/results.md) |
|
| 19 |
+
| **D11** | Conductor (Plan-and-Execute) vs Autonomous | 4 LLM call vs 10 LLM call | **Conductor ์ฑํ** (์๋ยท๋น์ฉ ์ฐ์, ํ์ง ๋๋ฑ) | [conductor_vs_autonomous/results.md](conductor_vs_autonomous/results.md) |
|
| 20 |
|
| 21 |
## ํต์ฌ ๊ฒฐ์ ์์ฝ
|
| 22 |
|
|
|
|
| 170 |
|
| 171 |
**ํต์ฌ ๋ฉ์์ง**: ์ ๋ ํ๊ฐ ์์ด๋ ์๋ชป๋ ํต๋
์ ๊ทธ๋๋ก ๋๊ณ ๊ฐ ๋ปํ๊ณ , ์ ๋ ํ๊ฐ ๋๋ถ์ ์ง์ง ์์ธ์ ๋ถ๋ฆฌํ๊ณ ๊ฒ์ฆํ ์ ์์๋ค. ์ฑํ: ์ฝํผ์ค 30+ ํ๊ฒฝ์์๋ `RAG_BACKEND=hybrid_rerank` ๊ถ์ฅ, ๋ฐ๋ชจ์ฉ ์ฝํผ์ค๋ hybrid ์ ์ง.
|
| 172 |
|
| 173 |
+
### D11. Conductor (Plan-and-Execute) vs Autonomous โ **Conductor ์ฑํ**
|
| 174 |
+
|
| 175 |
+
| ์งํ | Autonomous | Conductor | ๋ณํ |
|
| 176 |
+
|---|---|---|---|
|
| 177 |
+
| LLM ํธ์ถ / ์๋ | 10.0 | **4.0** | **-60%** |
|
| 178 |
+
| Tool ํธ์ถ / ์๋ | 13.7 | 16.0 | +17% |
|
| 179 |
+
| ์ ๋ํฌ ์ธ์ฉ / ์๋ | 6.0 | **6.0** | **๋๋ฑ** |
|
| 180 |
+
| ์
๋ ฅ ํ ํฐ | 25,849 | 8,042 | **-69%** |
|
| 181 |
+
| ์ถ๋ ฅ ํ ํฐ | 13,385 | 5,895 | **-56%** |
|
| 182 |
+
| **Latency / ์๋** | **131์ด** | **60์ด** | **-54%** |
|
| 183 |
+
| ๋น์ฉ / 1000์๋ | $33.23 | $13.80 | **-58%** |
|
| 184 |
+
|
| 185 |
+

|
| 186 |
+

|
| 187 |
+
|
| 188 |
+
**์์ (D7 โ D11 narrative)**:
|
| 189 |
+
|
| 190 |
+
- **D7**: "workflow โ agentic"์ผ๋ก reasoning traceยท์์จ์ฑ ํ๋ณด (๊ฐ Tier๊ฐ tool ์์จ ํธ์ถ)
|
| 191 |
+
- **D11**: "agentic โ conductor"๋ก ํต์ ํจ์จ ํ๋ณต (Central Planner๊ฐ plan 1ํ ์ฐ์ถ + Tier executor๊ฐ plan๋๋ก ์คํ + LLM 1ํ synthesis)
|
| 192 |
+
- ๋ ํจํด ๋ชจ๋ ์ ๋ ๋น๊ต ํ ์ฑํ. autonomous๋ ํ๊ฒฝ๋ณ์ `AGENT_MODE=autonomous`๋ก ๋ณด์กด (๋ณต์กํ ์๋ยท์์์น ๋ชปํ ์ปจํ
์คํธ ์ ์ ํ์ ์)
|
| 193 |
+
- **์ฌ๊ทยท๋ฌดํ๋ฃจํ ์ํ ์์ฒ ์ฐจ๋จ**: autonomous์ `MAX_TOOL_ITERATIONS=4` ์บก ์์กด์ด plan ๊ณ ์ ์คํ์ผ๋ก ๋ณธ์ง์ ํด๊ฒฐ
|
| 194 |
+
|
| 195 |
## ์คํ ๋ฐฉ๋ฒ
|
| 196 |
|
| 197 |
```bash
|
|
|
|
| 218 |
# CRAG ON vs OFF (D8)
|
| 219 |
.venv/bin/python -m experiments.crag_eval.benchmark
|
| 220 |
|
| 221 |
+
# ํ๊ตญ์ด reranker (Dongjin-kr/ko-reranker) ํ๊ฐ (D9ยทD10)
|
| 222 |
.venv/bin/python -m experiments.reranker_compare.benchmark
|
| 223 |
+
|
| 224 |
+
# Conductor vs Autonomous (D11)
|
| 225 |
+
.venv/bin/python -m experiments.conductor_vs_autonomous.benchmark
|
| 226 |
```
|
| 227 |
|
| 228 |
๊ฐ ์คํ์ `results.md`์ `charts/*.png`๋ฅผ ์์ฑํฉ๋๋ค.
|
experiments/conductor_vs_autonomous/__init__.py
ADDED
|
File without changes
|
experiments/conductor_vs_autonomous/benchmark.py
ADDED
|
@@ -0,0 +1,346 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""D11: Conductor (Plan-and-Execute) vs Autonomous (tool-using loop) ์ ๋ ๋น๊ต
|
| 2 |
+
|
| 3 |
+
๊ฐ์ ์๋(A1ยทA2ยทA3)์ ๋ ๋ชจ๋๋ก ์คํํด ์ธก์ :
|
| 4 |
+
- LLM ํธ์ถ ์ / ์๋ (autonomous: 9~13ํ ์์, conductor: 4~5ํ ์์)
|
| 5 |
+
- Latency (autonomous: ~194s, conductor: ๋ชฉํ ~60s)
|
| 6 |
+
- ํ ํฐยท๋น์ฉ
|
| 7 |
+
- ์ธ์ฉ ๊น์ด (citations ์ ๋ํฌ)
|
| 8 |
+
- RAGAS faithfulness (์ ํ์ - ์๊ฐ ์ ์ฝ ์ํด skip ๊ฐ๋ฅ)
|
| 9 |
+
|
| 10 |
+
๋ชจ๋ ํ ๊ธ: ํ๊ฒฝ๋ณ์ AGENT_MODE=conductor ๋๋ autonomous
|
| 11 |
+
|
| 12 |
+
์คํ: python -m experiments.conductor_vs_autonomous.benchmark
|
| 13 |
+
๊ฒฐ๊ณผ: results.md + charts/*.png
|
| 14 |
+
"""
|
| 15 |
+
import os
|
| 16 |
+
import time
|
| 17 |
+
from pathlib import Path
|
| 18 |
+
|
| 19 |
+
import matplotlib.pyplot as plt
|
| 20 |
+
import numpy as np
|
| 21 |
+
|
| 22 |
+
# ์คํ์ ์ํด CRAG๋ ๋นํ์ฑ (์ ๋ชจ๋ ๋์ผ ์กฐ๊ฑด)
|
| 23 |
+
os.environ.setdefault("CRAG_ENABLED", "false")
|
| 24 |
+
|
| 25 |
+
from agents.cause import run_cause
|
| 26 |
+
from agents.detection import run_detection
|
| 27 |
+
from agents.impact import run_impact
|
| 28 |
+
from agents.llm import client
|
| 29 |
+
from agents.planner import plan_workflow
|
| 30 |
+
from agents.response import run_response
|
| 31 |
+
from data.demo import DEFAULT_ALARMS
|
| 32 |
+
|
| 33 |
+
plt.rcParams["font.family"] = ["Apple SD Gothic Neo", "AppleGothic", "DejaVu Sans"]
|
| 34 |
+
plt.rcParams["axes.unicode_minus"] = False
|
| 35 |
+
|
| 36 |
+
OUT_DIR = Path(__file__).parent
|
| 37 |
+
CHART_DIR = OUT_DIR / "charts"
|
| 38 |
+
ALARMS = ["A1", "A2", "A3"]
|
| 39 |
+
|
| 40 |
+
PRICE_INPUT = 0.25 # gpt-5-mini ์ถ์
|
| 41 |
+
PRICE_OUTPUT = 2.0
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def _capture_tokens(fn, *args, **kwargs):
|
| 45 |
+
"""LLM token usage๋ฅผ ์ง์ captureํ๊ธฐ ์ํ wrapper"""
|
| 46 |
+
captured = {"in": 0, "out": 0}
|
| 47 |
+
real = client().chat.completions.create
|
| 48 |
+
|
| 49 |
+
def patched(**kw):
|
| 50 |
+
r = real(**kw)
|
| 51 |
+
captured["in"] += r.usage.prompt_tokens
|
| 52 |
+
captured["out"] += r.usage.completion_tokens
|
| 53 |
+
return r
|
| 54 |
+
|
| 55 |
+
client().chat.completions.create = patched
|
| 56 |
+
try:
|
| 57 |
+
result = fn(*args, **kwargs)
|
| 58 |
+
finally:
|
| 59 |
+
client().chat.completions.create = real
|
| 60 |
+
return result, captured
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def run_autonomous(alarm: dict) -> dict:
|
| 64 |
+
"""autonomous ๋ชจ๋ (Tier 2/3/4 ๊ฐ agent loop)"""
|
| 65 |
+
t1 = run_detection(alarm)
|
| 66 |
+
traces = {"tier2": {}, "tier3": {}, "tier4": {}}
|
| 67 |
+
tier_lat = {}
|
| 68 |
+
|
| 69 |
+
t0 = time.time()
|
| 70 |
+
(t2, tok_t2) = _capture_tokens(run_cause, alarm, t1, trace=traces["tier2"])
|
| 71 |
+
tier_lat["tier2"] = (time.time() - t0) * 1000
|
| 72 |
+
|
| 73 |
+
t0 = time.time()
|
| 74 |
+
(t3, tok_t3) = _capture_tokens(run_impact, alarm, t1, t2, trace=traces["tier3"])
|
| 75 |
+
tier_lat["tier3"] = (time.time() - t0) * 1000
|
| 76 |
+
|
| 77 |
+
t0 = time.time()
|
| 78 |
+
(t4, tok_t4) = _capture_tokens(run_response, alarm, t1, t2, t3, trace=traces["tier4"])
|
| 79 |
+
tier_lat["tier4"] = (time.time() - t0) * 1000
|
| 80 |
+
|
| 81 |
+
citations = set()
|
| 82 |
+
for c in t2["causes"]: citations.update(c.get("citations", []))
|
| 83 |
+
for r in t4["refs"]: citations.add(r["id"])
|
| 84 |
+
|
| 85 |
+
llm_calls = sum(t.get("llm_calls", 0) for t in traces.values())
|
| 86 |
+
tool_calls = sum(len(t.get("tool_calls", [])) for t in traces.values())
|
| 87 |
+
input_tokens = tok_t2["in"] + tok_t3["in"] + tok_t4["in"]
|
| 88 |
+
output_tokens = tok_t2["out"] + tok_t3["out"] + tok_t4["out"]
|
| 89 |
+
|
| 90 |
+
return {
|
| 91 |
+
"tier2": t2, "tier3": t3, "tier4": t4,
|
| 92 |
+
"tier_latency_ms": tier_lat,
|
| 93 |
+
"total_latency_ms": sum(tier_lat.values()),
|
| 94 |
+
"llm_calls": llm_calls,
|
| 95 |
+
"tool_calls": tool_calls,
|
| 96 |
+
"input_tokens": input_tokens,
|
| 97 |
+
"output_tokens": output_tokens,
|
| 98 |
+
"citations": sorted(citations),
|
| 99 |
+
"traces": traces,
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
def run_conductor(alarm: dict) -> dict:
|
| 104 |
+
"""conductor ๋ชจ๋ (Planner 1ํ + Tier executor ๊ฐ 1ํ)"""
|
| 105 |
+
t1 = run_detection(alarm)
|
| 106 |
+
traces = {"planner": {}, "tier2": {}, "tier3": {}, "tier4": {}}
|
| 107 |
+
tier_lat = {}
|
| 108 |
+
|
| 109 |
+
# Planner
|
| 110 |
+
t0 = time.time()
|
| 111 |
+
(plan, tok_pl) = _capture_tokens(plan_workflow, alarm, t1)
|
| 112 |
+
tier_lat["planner"] = (time.time() - t0) * 1000
|
| 113 |
+
|
| 114 |
+
# Tier 2/3/4 - ๊ฐ 1ํ LLM call (plan-driven)
|
| 115 |
+
t0 = time.time()
|
| 116 |
+
(t2, tok_t2) = _capture_tokens(run_cause, alarm, t1, trace=traces["tier2"], plan=plan)
|
| 117 |
+
tier_lat["tier2"] = (time.time() - t0) * 1000
|
| 118 |
+
|
| 119 |
+
t0 = time.time()
|
| 120 |
+
(t3, tok_t3) = _capture_tokens(run_impact, alarm, t1, t2, trace=traces["tier3"], plan=plan)
|
| 121 |
+
tier_lat["tier3"] = (time.time() - t0) * 1000
|
| 122 |
+
|
| 123 |
+
t0 = time.time()
|
| 124 |
+
(t4, tok_t4) = _capture_tokens(run_response, alarm, t1, t2, t3, trace=traces["tier4"], plan=plan)
|
| 125 |
+
tier_lat["tier4"] = (time.time() - t0) * 1000
|
| 126 |
+
|
| 127 |
+
citations = set()
|
| 128 |
+
for c in t2["causes"]: citations.update(c.get("citations", []))
|
| 129 |
+
for r in t4["refs"]: citations.add(r["id"])
|
| 130 |
+
|
| 131 |
+
llm_calls = 1 + sum(traces[t].get("llm_calls", 0) for t in ("tier2", "tier3", "tier4"))
|
| 132 |
+
tool_calls = sum(len(traces[t].get("tool_calls", [])) for t in ("tier2", "tier3", "tier4"))
|
| 133 |
+
input_tokens = tok_pl["in"] + tok_t2["in"] + tok_t3["in"] + tok_t4["in"]
|
| 134 |
+
output_tokens = tok_pl["out"] + tok_t2["out"] + tok_t3["out"] + tok_t4["out"]
|
| 135 |
+
|
| 136 |
+
return {
|
| 137 |
+
"tier2": t2, "tier3": t3, "tier4": t4,
|
| 138 |
+
"tier_latency_ms": tier_lat,
|
| 139 |
+
"total_latency_ms": sum(tier_lat.values()),
|
| 140 |
+
"llm_calls": llm_calls,
|
| 141 |
+
"tool_calls": tool_calls,
|
| 142 |
+
"input_tokens": input_tokens,
|
| 143 |
+
"output_tokens": output_tokens,
|
| 144 |
+
"citations": sorted(citations),
|
| 145 |
+
"plan": plan,
|
| 146 |
+
"traces": traces,
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
def collect_samples():
|
| 151 |
+
rows = []
|
| 152 |
+
for aid in ALARMS:
|
| 153 |
+
alarm = next(a for a in DEFAULT_ALARMS if a["id"] == aid)
|
| 154 |
+
print(f"\n=== [{aid}] {alarm['title']} ===")
|
| 155 |
+
print(" [Autonomous]")
|
| 156 |
+
auto = run_autonomous(alarm)
|
| 157 |
+
print(f" llm={auto['llm_calls']}, tool={auto['tool_calls']}, "
|
| 158 |
+
f"lat={auto['total_latency_ms']:.0f}ms, cit={len(auto['citations'])}, "
|
| 159 |
+
f"tokens={auto['input_tokens']}+{auto['output_tokens']}")
|
| 160 |
+
print(" [Conductor]")
|
| 161 |
+
cond = run_conductor(alarm)
|
| 162 |
+
print(f" llm={cond['llm_calls']}, tool={cond['tool_calls']}, "
|
| 163 |
+
f"lat={cond['total_latency_ms']:.0f}ms, cit={len(cond['citations'])}, "
|
| 164 |
+
f"tokens={cond['input_tokens']}+{cond['output_tokens']}, "
|
| 165 |
+
f"plan_action={cond['plan']['action']}")
|
| 166 |
+
rows.append({"alarm": aid, "autonomous": auto, "conductor": cond})
|
| 167 |
+
return rows
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
def aggregate(rows):
|
| 171 |
+
def avg(key1, key2):
|
| 172 |
+
return np.mean([r[key1][key2] for r in rows])
|
| 173 |
+
|
| 174 |
+
out = {}
|
| 175 |
+
for mode in ("autonomous", "conductor"):
|
| 176 |
+
out[mode] = {
|
| 177 |
+
"llm_calls": avg(mode, "llm_calls"),
|
| 178 |
+
"tool_calls": avg(mode, "tool_calls"),
|
| 179 |
+
"latency_ms": avg(mode, "total_latency_ms"),
|
| 180 |
+
"input_tokens": avg(mode, "input_tokens"),
|
| 181 |
+
"output_tokens": avg(mode, "output_tokens"),
|
| 182 |
+
"citations": np.mean([len(r[mode]["citations"]) for r in rows]),
|
| 183 |
+
}
|
| 184 |
+
return out
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
def make_charts(agg, rows):
|
| 188 |
+
CHART_DIR.mkdir(exist_ok=True)
|
| 189 |
+
auto, cond = agg["autonomous"], agg["conductor"]
|
| 190 |
+
|
| 191 |
+
# 1. ํธ์ถ ํ์ ๋น๊ต
|
| 192 |
+
fig, ax = plt.subplots(figsize=(9, 5))
|
| 193 |
+
metrics = ["LLM ํธ์ถ", "Tool ํธ์ถ", "์ ๋ํฌ ์ธ์ฉ"]
|
| 194 |
+
auto_vals = [auto["llm_calls"], auto["tool_calls"], auto["citations"]]
|
| 195 |
+
cond_vals = [cond["llm_calls"], cond["tool_calls"], cond["citations"]]
|
| 196 |
+
x = np.arange(len(metrics))
|
| 197 |
+
w = 0.35
|
| 198 |
+
b1 = ax.bar(x - w/2, auto_vals, w, label="Autonomous", color="#94a3b8")
|
| 199 |
+
b2 = ax.bar(x + w/2, cond_vals, w, label="Conductor", color="#3b82f6")
|
| 200 |
+
for bars in (b1, b2):
|
| 201 |
+
for b in bars:
|
| 202 |
+
ax.text(b.get_x() + b.get_width()/2, b.get_height() + 0.1, f"{b.get_height():.1f}",
|
| 203 |
+
ha="center", fontsize=9)
|
| 204 |
+
ax.set_xticks(x); ax.set_xticklabels(metrics)
|
| 205 |
+
ax.set_ylabel("ํ๊ท (3 ์๋)")
|
| 206 |
+
ax.set_title("Autonomous vs Conductor - ํธ์ถ ํ์")
|
| 207 |
+
ax.legend(); ax.grid(axis="y", alpha=0.3)
|
| 208 |
+
fig.tight_layout(); fig.savefig(CHART_DIR / "calls_comparison.png", dpi=150); plt.close(fig)
|
| 209 |
+
|
| 210 |
+
# 2. Latency ๋น๊ต
|
| 211 |
+
fig, ax = plt.subplots(figsize=(9, 5))
|
| 212 |
+
auto_lat = auto["latency_ms"] / 1000
|
| 213 |
+
cond_lat = cond["latency_ms"] / 1000
|
| 214 |
+
bars = ax.bar(["Autonomous", "Conductor"], [auto_lat, cond_lat], color=["#94a3b8", "#3b82f6"])
|
| 215 |
+
for b, v in zip(bars, [auto_lat, cond_lat]):
|
| 216 |
+
ax.text(b.get_x() + b.get_width()/2, v + 5, f"{v:.0f}s", ha="center", fontsize=11, fontweight="bold")
|
| 217 |
+
ax.set_ylabel("ํ๊ท Latency (์ด)")
|
| 218 |
+
ax.set_title(f"Latency ๋น๊ต - Conductor๊ฐ {(1 - cond_lat/auto_lat)*100:.0f}% ๋จ์ถ")
|
| 219 |
+
ax.grid(axis="y", alpha=0.3)
|
| 220 |
+
fig.tight_layout(); fig.savefig(CHART_DIR / "latency_comparison.png", dpi=150); plt.close(fig)
|
| 221 |
+
|
| 222 |
+
# 3. ๋น์ฉ ๋น๊ต
|
| 223 |
+
fig, ax = plt.subplots(figsize=(9, 5))
|
| 224 |
+
auto_cost = (auto["input_tokens"] * PRICE_INPUT + auto["output_tokens"] * PRICE_OUTPUT) / 1_000_000
|
| 225 |
+
cond_cost = (cond["input_tokens"] * PRICE_INPUT + cond["output_tokens"] * PRICE_OUTPUT) / 1_000_000
|
| 226 |
+
bars = ax.bar(["Autonomous", "Conductor"], [auto_cost*1000, cond_cost*1000], color=["#94a3b8", "#3b82f6"])
|
| 227 |
+
for b, v in zip(bars, [auto_cost*1000, cond_cost*1000]):
|
| 228 |
+
ax.text(b.get_x() + b.get_width()/2, v + max(auto_cost, cond_cost)*1000*0.02, f"${v:.2f}",
|
| 229 |
+
ha="center", fontsize=11, fontweight="bold")
|
| 230 |
+
ax.set_ylabel("USD / 1000 ์๋")
|
| 231 |
+
ax.set_title(f"๋น์ฉ ๋น๊ต - Conductor๊ฐ {(1 - cond_cost/auto_cost)*100:.0f}% ์ ๊ฐ")
|
| 232 |
+
ax.grid(axis="y", alpha=0.3)
|
| 233 |
+
fig.tight_layout(); fig.savefig(CHART_DIR / "cost_comparison.png", dpi=150); plt.close(fig)
|
| 234 |
+
|
| 235 |
+
|
| 236 |
+
def write_results(rows, agg):
|
| 237 |
+
auto, cond = agg["autonomous"], agg["conductor"]
|
| 238 |
+
auto_cost = (auto["input_tokens"] * PRICE_INPUT + auto["output_tokens"] * PRICE_OUTPUT) / 1_000_000
|
| 239 |
+
cond_cost = (cond["input_tokens"] * PRICE_INPUT + cond["output_tokens"] * PRICE_OUTPUT) / 1_000_000
|
| 240 |
+
|
| 241 |
+
lines = [
|
| 242 |
+
"# D11: Conductor (Plan-and-Execute) vs Autonomous (tool-using loop)",
|
| 243 |
+
"",
|
| 244 |
+
"๊ฐ์ ์๋ยท๋์ผ LLM ๋ชจ๋ธยทCRAG OFF ๋์ผ ์กฐ๊ฑด์์ ๋ ํจํด์ ์ ๋ ๋น๊ตํฉ๋๋ค.",
|
| 245 |
+
"",
|
| 246 |
+
"- **Autonomous**: ๊ฐ Tier๊ฐ tool-using agent loop (2-3 iteration + synthesis)",
|
| 247 |
+
"- **Conductor**: Central Planner Agent๊ฐ plan 1ํ ์ฐ์ถ + ๊ฐ Tier executor๊ฐ plan๋๋ก tool ์คํ + LLM 1ํ synthesis",
|
| 248 |
+
"",
|
| 249 |
+
"## ์คํ ์ค์ ",
|
| 250 |
+
"",
|
| 251 |
+
f"- ์๋: {', '.join(ALARMS)}",
|
| 252 |
+
"- ์์ฑ ๋ชจ๋ธ: gpt-5-mini (์ ๋ชจ๋ ๋์ผ)",
|
| 253 |
+
"- Planner: gpt-4o-mini (conductor ์ ์ฉ)",
|
| 254 |
+
"- CRAG: ๋นํ์ฑ (๋น๊ต ์กฐ๊ฑด ํต์ผ ์ํด)",
|
| 255 |
+
"",
|
| 256 |
+
"## ๊ฒฐ๊ณผ ์์ฝ (3 ์๋ ํ๊ท )",
|
| 257 |
+
"",
|
| 258 |
+
"| ์งํ | Autonomous | Conductor | ๋ณํ |",
|
| 259 |
+
"|---|---|---|---|",
|
| 260 |
+
f"| LLM ํธ์ถ / ์๋ | {auto['llm_calls']:.1f} | {cond['llm_calls']:.1f} | **-{(1 - cond['llm_calls']/auto['llm_calls'])*100:.0f}%** |",
|
| 261 |
+
f"| Tool ํธ์ถ / ์๋ | {auto['tool_calls']:.1f} | {cond['tool_calls']:.1f} | {(cond['tool_calls']/max(auto['tool_calls'],1) - 1)*100:+.0f}% |",
|
| 262 |
+
f"| ์ ๋ํฌ ์ธ์ฉ / ์๋ | {auto['citations']:.1f} | {cond['citations']:.1f} | {(cond['citations']/max(auto['citations'],1) - 1)*100:+.0f}% |",
|
| 263 |
+
f"| ์
๋ ฅ ํ ํฐ / ์๋ | {auto['input_tokens']:.0f} | {cond['input_tokens']:.0f} | **-{(1 - cond['input_tokens']/auto['input_tokens'])*100:.0f}%** |",
|
| 264 |
+
f"| ์ถ๋ ฅ ํ ํฐ / ์๋ | {auto['output_tokens']:.0f} | {cond['output_tokens']:.0f} | **-{(1 - cond['output_tokens']/auto['output_tokens'])*100:.0f}%** |",
|
| 265 |
+
f"| **Latency / ์๋** | **{auto['latency_ms']/1000:.0f}์ด** | **{cond['latency_ms']/1000:.0f}์ด** | **-{(1 - cond['latency_ms']/auto['latency_ms'])*100:.0f}%** |",
|
| 266 |
+
f"| ๋น์ฉ / 1000์๋ | ${auto_cost*1000:.2f} | ${cond_cost*1000:.2f} | **-{(1 - cond_cost/auto_cost)*100:.0f}%** |",
|
| 267 |
+
"",
|
| 268 |
+
"## ์๊ฐํ",
|
| 269 |
+
"",
|
| 270 |
+
"### ํธ์ถ ํ์",
|
| 271 |
+
"",
|
| 272 |
+
"",
|
| 273 |
+
"### Latency",
|
| 274 |
+
"",
|
| 275 |
+
"",
|
| 276 |
+
"### ๋น์ฉ",
|
| 277 |
+
"",
|
| 278 |
+
"",
|
| 279 |
+
"## ์๋๋ณ ์์ธ",
|
| 280 |
+
"",
|
| 281 |
+
]
|
| 282 |
+
for r in rows:
|
| 283 |
+
lines.append(f"### {r['alarm']}")
|
| 284 |
+
lines.append("")
|
| 285 |
+
lines.append("| ๋ชจ๋ | LLM | Tool | Latency | Citations |")
|
| 286 |
+
lines.append("|---|---|---|---|---|")
|
| 287 |
+
for mode in ("autonomous", "conductor"):
|
| 288 |
+
d = r[mode]
|
| 289 |
+
lines.append(
|
| 290 |
+
f"| {mode} | {d['llm_calls']} | {d['tool_calls']} | "
|
| 291 |
+
f"{d['total_latency_ms']/1000:.0f}s | {len(d['citations'])} |"
|
| 292 |
+
)
|
| 293 |
+
cp = r["conductor"].get("plan", {})
|
| 294 |
+
lines.append("")
|
| 295 |
+
lines.append(f"- Conductor plan: action={cp.get('action')}, severity={cp.get('severity')}")
|
| 296 |
+
lines.append(f" - reasoning: {cp.get('reasoning', '')[:200]}")
|
| 297 |
+
lines.append("")
|
| 298 |
+
|
| 299 |
+
lat_reduce = (1 - cond['latency_ms']/auto['latency_ms']) * 100
|
| 300 |
+
cost_reduce = (1 - cond_cost/auto_cost) * 100
|
| 301 |
+
cit_change = (cond['citations']/max(auto['citations'], 1) - 1) * 100
|
| 302 |
+
|
| 303 |
+
lines += [
|
| 304 |
+
"## ํต์ฌ ์ธ์ฌ์ดํธ",
|
| 305 |
+
"",
|
| 306 |
+
f"1. **Latency {lat_reduce:.0f}% ๋จ์ถ**: {auto['latency_ms']/1000:.0f}์ด โ {cond['latency_ms']/1000:.0f}์ด. ๊ฐ Tier์ agent loop iteration์ด ์ ๊ฑฐ๋์ด LLM ํธ์ถ์ด ์ง๋ณ๋จ",
|
| 307 |
+
f"2. **LLM ํธ์ถ {(1 - cond['llm_calls']/auto['llm_calls'])*100:.0f}% ๊ฐ์**: Planner 1 + Tierร3 (๊ฐ synthesis 1ํ) = 4ํ๋ก ํต์ผ. ์ฌ๊ทยท๋ฌดํ๋ฃจํ ์ํ ์์ฒ ์ฐจ๋จ",
|
| 308 |
+
f"3. **๋น์ฉ {cost_reduce:.0f}% ์ ๊ฐ**: ์
๋ ฅ ํ ํฐ์ด ๊ฐ์ฅ ํฐ ํญ์ผ๋ก ๊ฐ์ (agent loop์ messages ๋์ ํจ๊ณผ ์ ๊ฑฐ)",
|
| 309 |
+
f"4. **์ธ์ฉ ๊น์ด ๋ณํ {cit_change:+.0f}%**: " + ("๊ฑฐ์ ๋๋ฑ" if abs(cit_change) < 15 else f"{'์ฆ๊ฐ' if cit_change > 0 else '๊ฐ์'}, plan์ด retrieval ์ฑ๋์ ์ฌ์ ๊ฒฐ์ "),
|
| 310 |
+
"",
|
| 311 |
+
"## ์ฑํ ๊ฒฐ๋ก ",
|
| 312 |
+
"",
|
| 313 |
+
f"**๊ธฐ๋ณธ ๋ชจ๋: `AGENT_MODE=conductor`** (Plan-and-Execute ํจํด).",
|
| 314 |
+
"",
|
| 315 |
+
f"- ์๋ยท๋น์ฉ ์ฐ์ ๊ฒฐ์ ์ (latency -{lat_reduce:.0f}%, cost -{cost_reduce:.0f}%)",
|
| 316 |
+
"- ํต์ ํ์ ์ต์ํ๋ก production ์ด์ ์์ ์ฑโ",
|
| 317 |
+
"- ์ฌ๊ท ํธ์ถ ์ํ ์์ฒ ์ฐจ๋จ",
|
| 318 |
+
"",
|
| 319 |
+
"**`AGENT_MODE=autonomous` ์ต์
์ ์ง**:",
|
| 320 |
+
"- ๋ณต์กํ ์๋ยท์์์น ๋ชปํ ์ปจํ
์คํธ๊ฐ ํ์ํ ๋ LLM์ ์ ์์ tool ํธ์ถ์ด ์ ๋ฆฌํ ์ ์์",
|
| 321 |
+
"- ํ๊ฒฝ๋ณ์๋ก ์ฆ์ ํ ๊ธ ๊ฐ๋ฅ",
|
| 322 |
+
"",
|
| 323 |
+
"## Portfolio narrative ์์",
|
| 324 |
+
"",
|
| 325 |
+
"- D7์์ \"workflow โ agentic\"์ผ๋ก ์ ํํด reasoning trace ํ๋ณด",
|
| 326 |
+
"- D11์์ \"agentic โ conductor\"๋ก ๋ค์ ์ ํํด ํต์ ํจ์จ ํ๋ณต",
|
| 327 |
+
"- **\"tool-using agent\"์ ์์จ์ฑ๊ณผ \"plan-and-execute\"์ ํจ์จ์ฑ์ trade-off๋ก ๋ช
์์ ์ฑํ**",
|
| 328 |
+
"- production agent ์์คํ
์ค๊ณ์ ํต์ฌ ์์ฌ๊ฒฐ์ ์ ์ ๋ ๋ฐ์ดํฐ๋ก ์
์ฆ",
|
| 329 |
+
"",
|
| 330 |
+
]
|
| 331 |
+
(OUT_DIR / "results.md").write_text("\n".join(lines), encoding="utf-8")
|
| 332 |
+
print(f"--- ์ ์ฅ: {OUT_DIR / 'results.md'} ---")
|
| 333 |
+
|
| 334 |
+
|
| 335 |
+
def main():
|
| 336 |
+
rows = collect_samples()
|
| 337 |
+
agg = aggregate(rows)
|
| 338 |
+
print("\n--- ์ง๊ณ ---")
|
| 339 |
+
for mode, vals in agg.items():
|
| 340 |
+
print(f" {mode}: {vals}")
|
| 341 |
+
make_charts(agg, rows)
|
| 342 |
+
write_results(rows, agg)
|
| 343 |
+
|
| 344 |
+
|
| 345 |
+
if __name__ == "__main__":
|
| 346 |
+
main()
|
experiments/conductor_vs_autonomous/charts/calls_comparison.png
ADDED
|
experiments/conductor_vs_autonomous/charts/cost_comparison.png
ADDED
|
experiments/conductor_vs_autonomous/charts/latency_comparison.png
ADDED
|
experiments/conductor_vs_autonomous/results.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# D11: Conductor (Plan-and-Execute) vs Autonomous (tool-using loop)
|
| 2 |
+
|
| 3 |
+
๊ฐ์ ์๋ยท๋์ผ LLM ๋ชจ๋ธยทCRAG OFF ๋์ผ ์กฐ๊ฑด์์ ๋ ํจํด์ ์ ๋ ๋น๊ตํฉ๋๋ค.
|
| 4 |
+
|
| 5 |
+
- **Autonomous**: ๊ฐ Tier๊ฐ tool-using agent loop (2-3 iteration + synthesis)
|
| 6 |
+
- **Conductor**: Central Planner Agent๊ฐ plan 1ํ ์ฐ์ถ + ๊ฐ Tier executor๊ฐ plan๋๋ก tool ์คํ + LLM 1ํ synthesis
|
| 7 |
+
|
| 8 |
+
## ์คํ ์ค์
|
| 9 |
+
|
| 10 |
+
- ์๋: A1, A2, A3
|
| 11 |
+
- ์์ฑ ๋ชจ๋ธ: gpt-5-mini (์ ๋ชจ๋ ๋์ผ)
|
| 12 |
+
- Planner: gpt-4o-mini (conductor ์ ์ฉ)
|
| 13 |
+
- CRAG: ๋นํ์ฑ (๋น๊ต ์กฐ๊ฑด ํต์ผ ์ํด)
|
| 14 |
+
|
| 15 |
+
## ๊ฒฐ๊ณผ ์์ฝ (3 ์๋ ํ๊ท )
|
| 16 |
+
|
| 17 |
+
| ์งํ | Autonomous | Conductor | ๋ณํ |
|
| 18 |
+
|---|---|---|---|
|
| 19 |
+
| LLM ํธ์ถ / ์๋ | 10.0 | 4.0 | **-60%** |
|
| 20 |
+
| Tool ํธ์ถ / ์๋ | 13.7 | 16.0 | +17% |
|
| 21 |
+
| ์ ๋ํฌ ์ธ์ฉ / ์๋ | 6.0 | 6.0 | +0% |
|
| 22 |
+
| ์
๋ ฅ ํ ํฐ / ์๋ | 25849 | 8042 | **-69%** |
|
| 23 |
+
| ์ถ๋ ฅ ํ ํฐ / ์๋ | 13385 | 5895 | **-56%** |
|
| 24 |
+
| **Latency / ์๋** | **131์ด** | **60์ด** | **-54%** |
|
| 25 |
+
| ๋น์ฉ / 1000์๋ | $33.23 | $13.80 | **-58%** |
|
| 26 |
+
|
| 27 |
+
## ์๊ฐํ
|
| 28 |
+
|
| 29 |
+
### ํธ์ถ ํ์
|
| 30 |
+

|
| 31 |
+
|
| 32 |
+
### Latency
|
| 33 |
+

|
| 34 |
+
|
| 35 |
+
### ๋น์ฉ
|
| 36 |
+

|
| 37 |
+
|
| 38 |
+
## ์๋๋ณ ์์ธ
|
| 39 |
+
|
| 40 |
+
### A1
|
| 41 |
+
|
| 42 |
+
| ๋ชจ๋ | LLM | Tool | Latency | Citations |
|
| 43 |
+
|---|---|---|---|---|
|
| 44 |
+
| autonomous | 9 | 15 | 141s | 6 |
|
| 45 |
+
| conductor | 4 | 16 | 60s | 6 |
|
| 46 |
+
|
| 47 |
+
- Conductor plan: action=proceed_full, severity=high
|
| 48 |
+
- reasoning: CD-X ์ฐํฌ์ ์ด์ ์งํ์ ๊ณ ํ๊ฐ๋ ์ด์ ์ ์๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํ์ฌ ์ ๋ฐ์ ์ธ ์์ธ ๋ถ์๊ณผ ๋์ ๊ถ๊ณ ์ ์ฐจ๋ฅผ ์งํํ๋ ๊ฒ์ด ์ค์ํ๋ค.
|
| 49 |
+
|
| 50 |
+
### A2
|
| 51 |
+
|
| 52 |
+
| ๋ชจ๋ | LLM | Tool | Latency | Citations |
|
| 53 |
+
|---|---|---|---|---|
|
| 54 |
+
| autonomous | 10 | 14 | 133s | 8 |
|
| 55 |
+
| conductor | 4 | 14 | 63s | 7 |
|
| 56 |
+
|
| 57 |
+
- Conductor plan: action=proceed_full, severity=high
|
| 58 |
+
- reasoning: ๋จ์ผ ์์ธ ์ถ์ ์ ์ํ ์ข
ํฉ์ ์ธ ๋ฐ์ดํฐ ์์ง๊ณผ ๋ถ์์ด ํ์ํ๋ฉฐ, ๊ณ ์ธ์ฌํ ์ฒ๋ฆฌ๋ก ๊ณต์ ์ํฅ์ ์ต์ํํด์ผ ํ๋ฏ๋ก ์ ์ฒด ์ํฌํ๋ก์ฐ๋ฅผ ์งํํฉ๋๋ค.
|
| 59 |
+
|
| 60 |
+
### A3
|
| 61 |
+
|
| 62 |
+
| ๋ชจ๋ | LLM | Tool | Latency | Citations |
|
| 63 |
+
|---|---|---|---|---|
|
| 64 |
+
| autonomous | 11 | 12 | 118s | 4 |
|
| 65 |
+
| conductor | 4 | 18 | 59s | 5 |
|
| 66 |
+
|
| 67 |
+
- Conductor plan: action=proceed_full, severity=high
|
| 68 |
+
- reasoning: CMP ๊ณต์ ์์ MRR ์์น์ด ๋ฐ์ํ์ฌ yield์ ํฐ ์ํฅ์ ๋ฏธ์น ์ ์์ผ๋ฏ๋ก ์ ์ฒด ๋ถ์ ๋ฐ ๊ถ๊ณ ์ ์ฐจ๋ฅผ ํตํด ์ ์ํ ๋์ํด์ผ ํจ.
|
| 69 |
+
|
| 70 |
+
## ํต์ฌ ์ธ์ฌ์ดํธ
|
| 71 |
+
|
| 72 |
+
1. **Latency 54% ๋จ์ถ**: 131์ด โ 60์ด. ๊ฐ Tier์ agent loop iteration์ด ์ ๊ฑฐ๋์ด LLM ํธ์ถ์ด ์ง๋ณ๋จ
|
| 73 |
+
2. **LLM ํธ์ถ 60% ๊ฐ์**: Planner 1 + Tierร3 (๊ฐ synthesis 1ํ) = 4ํ๋ก ํต์ผ. ์ฌ๊ทยท๋ฌดํ๋ฃจํ ์ํ ์์ฒ ์ฐจ๋จ
|
| 74 |
+
3. **๋น์ฉ 58% ์ ๊ฐ**: ์
๋ ฅ ํ ํฐ์ด ๊ฐ์ฅ ํฐ ํญ์ผ๋ก ๊ฐ์ (agent loop์ messages ๋์ ํจ๊ณผ ์ ๊ฑฐ)
|
| 75 |
+
4. **์ธ์ฉ ๊น์ด ๋ณํ +0%**: ๊ฑฐ์ ๋๋ฑ
|
| 76 |
+
|
| 77 |
+
## ์ฑํ ๊ฒฐ๋ก
|
| 78 |
+
|
| 79 |
+
**๊ธฐ๋ณธ ๋ชจ๋: `AGENT_MODE=conductor`** (Plan-and-Execute ํจํด).
|
| 80 |
+
|
| 81 |
+
- ์๋ยท๋น์ฉ ์ฐ์ ๊ฒฐ์ ์ (latency -54%, cost -58%)
|
| 82 |
+
- ํต์ ํ์ ์ต์ํ๋ก production ์ด์ ์์ ์ฑโ
|
| 83 |
+
- ์ฌ๊ท ํธ์ถ ์ํ ์์ฒ ์ฐจ๋จ
|
| 84 |
+
|
| 85 |
+
**`AGENT_MODE=autonomous` ์ต์
์ ์ง**:
|
| 86 |
+
- ๋ณต์กํ ์๋ยท์์์น ๋ชปํ ์ปจํ
์คํธ๊ฐ ํ์ํ ๋ LLM์ ์ ์์ tool ํธ์ถ์ด ์ ๋ฆฌํ ์ ์์
|
| 87 |
+
- ํ๊ฒฝ๋ณ์๋ก ์ฆ์ ํ ๊ธ ๊ฐ๋ฅ
|
| 88 |
+
|
| 89 |
+
## Portfolio narrative ์์
|
| 90 |
+
|
| 91 |
+
- D7์์ "workflow โ agentic"์ผ๋ก ์ ํํด reasoning trace ํ๋ณด
|
| 92 |
+
- D11์์ "agentic โ conductor"๋ก ๋ค์ ์ ํํด ํต์ ํจ์จ ํ๋ณต
|
| 93 |
+
- **"tool-using agent"์ ์์จ์ฑ๊ณผ "plan-and-execute"์ ํจ์จ์ฑ์ trade-off๋ก ๋ช
์์ ์ฑํ**
|
| 94 |
+
- production agent ์์คํ
์ค๊ณ์ ํต์ฌ ์์ฌ๊ฒฐ์ ์ ์ ๋ ๋ฐ์ดํฐ๋ก ์
์ฆ
|