Merge pull request #15 from FabAgentGroup/feat/conductor
Browse filesfeat: Plan-and-Execute Conductor ํจํด - latency -54%, ๋น์ฉ -58%, ํ์ง ๋๋ฑ
Files changed (13)
- README.md+32-7
- agents/cause.py+90-12
- agents/impact.py+102-4
- agents/orchestrator.py+127-80
- agents/planner.pyAdded+184
- agents/response.py+107-4
- experiments/README.md+27-1
- experiments/conductor_vs_autonomous/__init__.pyAdded
- experiments/conductor_vs_autonomous/benchmark.pyAdded+346
- experiments/conductor_vs_autonomous/charts/calls_comparison.pngAdded
- experiments/conductor_vs_autonomous/charts/cost_comparison.pngAdded
- experiments/conductor_vs_autonomous/charts/latency_comparison.pngAdded
- experiments/conductor_vs_autonomous/results.mdAdded+94
22 unmodified lines232425262728293091 unmodified lines122123124125126127102 unmodified lines23023123223323423534 unmodified lines27027127227327427538 unmodified lines31431531631731831932032132232321 unmodified lines34534634734834935035122 unmodified lines## ํต์ฌ ํน์ง- **4-Tier multi-agent system** - ํ์ง(ML) ยท ์์ธ(agentic RAG) ยท ์ํฅ(tool-using) ยท ๋์(tool-using)- **Tool-using agent** - 7๊ฐ ๋๋ฉ์ธ ๋๊ตฌ๋ฅผ LLM์ด ์์จ ์ ํยท๋ฐ๋ณต ํธ์ถ (OpenAI function calling)- **Supervisor agent** - LLM์ด Tier 2 ๊ฒฐ๊ณผ๋ฅผ ๋ณด๊ณ ํ์ workflow path(proceed_full / fast_track / escalate) ๋์ ๊ฒฐ์ - **์กฐ๊ฑด๋ถ ๋ผ์ฐํ ** - LangGraph์์ severity gate + cause confidence retry + supervisor ๋ถ๊ธฐ (3๋จ๊ณ)- **CRAG self-correction** - retrieval grader๊ฐ ๊ฒ์ ํ์ง ํ๊ฐ, ์๊ณ์น ๋ฏธ๋ฌ ์ ์ฟผ๋ฆฌ ์๋ ์ฌ์์ฑ- **LangSmith observability** - ๋ชจ๋ LLMยทtoolยทagent ํธ์ถ ์๋ ํธ๋ ์ด์ค (production-grade)91 unmodified lines| **D8** | CRAG (Self-correction) ON vs OFF | CRAG **ํ์ฑ ์ ์ง** (๊ด์ธก ๊ฐ์น) | ํ์ง ๋ณํ -0.1%p (๋๊ธ), refinement ๋ฐ๋๋ฅ 20%, relevance_score ๋ ธ์ถ, ๋น์ฉ +31% || **D9** | ํ๊ตญ์ด reranker (Dongjin-kr/ko-reranker) vs ์์ด(BAAI) vs hybrid (12 docs) | ๋ ๋ค hybrid์ ๋ฏธ๋ฌ | hybrid 0.734 / BAAI 0.714 / ko 0.703 || **D10** | **D9 ํ์**: ์ฝํผ์ค 12โ34 ํ์ฅ ํ reranker ์ฌํ๊ฐ | **๊ฐ์ค ๊ฒ์ฆ - ํจ๊ณผ ์์ ๋ฐ์ ** | hybrid **0.592** / BAAI **0.709 (+0.117)** / ko **0.675 (+0.083)** |### D6 ํต์ฌ ๊ทธ๋ํ102 unmodified lines- **๊ฒฐ์ **: ์ฝํผ์ค 30+ ํ๊ฒฝ์์๋ `RAG_BACKEND=hybrid_rerank` ๊ถ์ฅ. ๋ฐ๋ชจ์ฉ 12๊ฐ์์ hybrid ์ ์ง- **์๋ฆฌ์ฆ ์์**: D6 โ D9 โ D10์ด portfolio narrative๋ก ์์ฑ. "ํต๋ โ ์ ๋ ๋ฐ๋ฐ โ ๊ฐ์ค โ ์ ๋ ๊ฒ์ฆ"์ ์ฌ์ดํด์ด ์ ๋ ํ๊ฐ์ ๊ฐ์น ์์ฒด๋ฅผ ์ฆ๋ช### 8. Supervisor agent - LLM-driven ๋์ workflow routing- **์์**: ๊ธฐ์กด conditional edge๋ threshold ๊ธฐ๋ฐ(`score < 0.3` โ skip, `max pct < 40` โ retry). "์ง์ง agent๋ผ๋ฉด LLM์ด ๋งฅ๋ฝ์ ๋ณด๊ณ ๊ฒฐ์ ํด์ผ ํ๋ค"34 unmodified linesRAG_BACKEND=keyword streamlit run app.py # ์ต์ : ์์กด์ฑ ์ต์```### CRAG (Self-correction) ํ ๊ธ```bash38 unmodified linesโโโ agents/โ โโโ orchestrator.py # LangGraph StateGraph + ์กฐ๊ฑด๋ถ ๋ผ์ฐํโ โโโ detection.py # Tier 1 IsolationForest (SECOM/PHM ๋์คํจ์น)โ โโโ cause.py # Tier 2 agentic RAG (tool-calling loop)โ โโโ impact.py # Tier 3 tool-using agentโ โโโ response.py # Tier 4 tool-using agentโ โโโ supervisor.py # LLM-driven dynamic workflow router (proceed_full/fast_track/escalate)โ โโโ llm.py # OpenAI ํด๋ผ์ด์ธํธ + LangSmith wrap_openai ํตํฉโ โโโ tools/ # 7๊ฐ agent ๋๊ตฌโ โ โโโ knowledge.py # search_knowledge (RAG ๊ฒ์)21 unmodified linesโ โโโ rag_paradigm/ # D6: 5๋จ๊ณ paradigm ablationโ โโโ agentic_vs_workflow/ # D7: workflow vs agentic ๋น๊ตโ โโโ crag_eval/ # D8: CRAG self-correction ํจ๊ณผ ํ๊ฐโ โโโ reranker_compare/ # D9: ํ๊ตญ์ด reranker(Dongjin-kr/ko-reranker) ํ๊ฐโโโ docs/orchestrator_graph.mmd # LangGraph ์๋ ์ถ์ถ mermaidโโโ styles/main.css # ๋์์ธ ์์คํ โโโ tests/22 unmodified lines23242526272829303191 unmodified lines123124125126127128129102 unmodified lines23223323423523623723823924024124224324424524624724824925025134 unmodified lines28628728828929029129229329429529629729838 unmodified lines33733833934034134234334434534634721 unmodified lines36937037137237337437537622 unmodified lines## ํต์ฌ ํน์ง- **4-Tier multi-agent system** - ํ์ง(ML) ยท ์์ธ(agentic RAG) ยท ์ํฅ(tool-using) ยท ๋์(tool-using)- **Plan-and-Execute ํจํด** (๊ธฐ๋ณธ) - Central Planner Agent๊ฐ ์ ์ฒด ์ํฌํ๋ก์ฐ plan์ 1ํ ์ฐ์ถ, Tier executor๊ฐ plan๋๋ก ์คํ โ ํต์ ์ค๋ฒํค๋ ์ต์ํ (LLM ํธ์ถ -60%, latency -54%)- **Tool-using agent** (์ต์ ) - 7๊ฐ ๋๋ฉ์ธ ๋๊ตฌ๋ฅผ LLM์ด ์์จ ์ ํยท๋ฐ๋ณต ํธ์ถ (`AGENT_MODE=autonomous`)- **Supervisor agent** (autonomous ๋ชจ๋) - LLM์ด Tier 2 ๊ฒฐ๊ณผ๋ฅผ ๋ณด๊ณ ํ์ workflow path(proceed_full / fast_track / escalate) ๋์ ๊ฒฐ์ - **์กฐ๊ฑด๋ถ ๋ผ์ฐํ ** - LangGraph์์ severity gate + cause confidence retry + supervisor ๋ถ๊ธฐ (3๋จ๊ณ)- **CRAG self-correction** - retrieval grader๊ฐ ๊ฒ์ ํ์ง ํ๊ฐ, ์๊ณ์น ๋ฏธ๋ฌ ์ ์ฟผ๋ฆฌ ์๋ ์ฌ์์ฑ- **LangSmith observability** - ๋ชจ๋ LLMยทtoolยทagent ํธ์ถ ์๋ ํธ๋ ์ด์ค (production-grade)91 unmodified lines| **D8** | CRAG (Self-correction) ON vs OFF | CRAG **ํ์ฑ ์ ์ง** (๊ด์ธก ๊ฐ์น) | ํ์ง ๋ณํ -0.1%p (๋๊ธ), refinement ๋ฐ๋๋ฅ 20%, relevance_score ๋ ธ์ถ, ๋น์ฉ +31% || **D9** | ํ๊ตญ์ด reranker (Dongjin-kr/ko-reranker) vs ์์ด(BAAI) vs hybrid (12 docs) | ๋ ๋ค hybrid์ ๋ฏธ๋ฌ | hybrid 0.734 / BAAI 0.714 / ko 0.703 || **D10** | **D9 ํ์**: ์ฝํผ์ค 12โ34 ํ์ฅ ํ reranker ์ฌํ๊ฐ | **๊ฐ์ค ๊ฒ์ฆ - ํจ๊ณผ ์์ ๋ฐ์ ** | hybrid **0.592** / BAAI **0.709 (+0.117)** / ko **0.675 (+0.083)** || **D11** | Conductor (Plan-and-Execute) vs Autonomous (tool-using loop) | **Conductor ์ฑํ** | LLM -60%, Latency **131โ60์ด (-54%)**, ๋น์ฉ -58%, **์ธ์ฉ ๋๋ฑ(6.0)** |### D6 ํต์ฌ ๊ทธ๋ํ102 unmodified lines- **๊ฒฐ์ **: ์ฝํผ์ค 30+ ํ๊ฒฝ์์๋ `RAG_BACKEND=hybrid_rerank` ๊ถ์ฅ. ๋ฐ๋ชจ์ฉ 12๊ฐ์์ hybrid ์ ์ง- **์๋ฆฌ์ฆ ์์**: D6 โ D9 โ D10์ด portfolio narrative๋ก ์์ฑ. "ํต๋ โ ์ ๋ ๋ฐ๋ฐ โ ๊ฐ์ค โ ์ ๋ ๊ฒ์ฆ"์ ์ฌ์ดํด์ด ์ ๋ ํ๊ฐ์ ๊ฐ์น ์์ฒด๋ฅผ ์ฆ๋ช### 11. Conductor ํจํด (Plan-and-Execute) ๋์ - "agentic โ conductor" ์ ํ- **์ํฉ**: 4-tier agentic ์์คํ (D7) ๋์ ํ ์๋๋น ์ฝ 3๋ถ(194์ด)ยทLLM 10~13ํ๋ก ๋ฐ๋ชจ UX ์ ํ. ์ฝํผ์ค ํ์ฅ(D10)์ผ๋ก ์ปจํ ์คํธ ๋ ๋ฌด๊ฑฐ์์ง- **์ง๋จ**: Anthropic์ [Building Effective Agents](https://www.anthropic.com/engineering/building-effective-agents)๊ฐ ๋ช ์ํ๋ฏ "autonomous" ํจํด์ ์ ์์ฑ์ด ๊ฐ์ ์ด์ง๋ง ํต์ ์ค๋ฒํค๋(iteration ๋์ ยท์ฌ๊ท ํธ์ถ ์ํ) ํผ- **์ ํ**: Plan-and-Execute ํจํด - Central Planner Agent๊ฐ ์๋+Tier 1์ ๋ณด๊ณ ์ ์ฒด ์ํฌํ๋ก์ฐ(Tier 2/3/4 ๊ฐ tool ํธ์ถ plan)๋ฅผ 1ํ ์ฐ์ถ, ๊ฐ Tier executor๋ plan๋๋ก tool ์ง์ ์คํ + LLM 1ํ synthesis- **๊ตฌํ**: `agents/planner.py` ์ ๊ท + `cause/impact/response.py`์ conductor ๊ฒฝ๋ก ์ถ๊ฐ (autonomous๋ ์ต์ ์ ์ง). ํ๊ฒฝ๋ณ์ `AGENT_MODE=conductor` (๊ธฐ๋ณธ) / `autonomous`๋ก ํ ๊ธ- **D11 ์ ๋ ๊ฒฐ๊ณผ (3 ์๋, CRAG OFF ๋์ผ ์กฐ๊ฑด)**:- LLM ํธ์ถ: 10.0 โ 4.0 (**-60%**, Planner 1 + Tierร3 synthesis)- Latency: 131์ด โ **60์ด** (**-54%**)- ๋น์ฉ: $33.23 โ $13.80 / 1000์๋ (**-58%**)- ์ธ์ฉ ๊น์ด: 6.0 โ 6.0 (**๋๋ฑ**, ํ์ง ์์ค ์์)- **ํต์ฌ narrative**: D7(workflow โ agentic์ผ๋ก ์์จ์ฑ ํ๋ณด) โ D11(agentic โ conductor๋ก ํจ์จ ํ๋ณต). ๋ ๋จ๊ณ ๋ชจ๋ ์ ๋ ๋ฐ์ดํฐ ๊ธฐ๋ฐ ์์ฌ๊ฒฐ์ . **autonomous์ ์์จ์ฑ vs conductor์ ํจ์จ์ฑ์ trade-off๋ก ๋ช ์ ์ฑํ**- **์ฌ๊ท ์ํ ์์ฒ ์ฐจ๋จ**: ๊ธฐ์กด `MAX_TOOL_ITERATIONS=4` ์บก์ ์์กดํ๋ ๋ฌดํ๋ฃจํ ๋ฐฉ์ง๊ฐ plan ๊ณ ์ ์คํ์ผ๋ก ๋ณธ์ง์ ์ผ๋ก ํด๊ฒฐ### 8. Supervisor agent - LLM-driven ๋์ workflow routing- **์์**: ๊ธฐ์กด conditional edge๋ threshold ๊ธฐ๋ฐ(`score < 0.3` โ skip, `max pct < 40` โ retry). "์ง์ง agent๋ผ๋ฉด LLM์ด ๋งฅ๋ฝ์ ๋ณด๊ณ ๊ฒฐ์ ํด์ผ ํ๋ค"34 unmodified linesRAG_BACKEND=keyword streamlit run app.py # ์ต์ : ์์กด์ฑ ์ต์```### Agent ๋ชจ๋ ํ ๊ธ (D11)```bashAGENT_MODE=conductor streamlit run app.py # ๊ธฐ๋ณธ - Plan-and-Execute (๋น ๋ฅด๊ณ ์ ๋ ด, ํต์ ์ต์)AGENT_MODE=autonomous streamlit run app.py # ์ต์ - tool-using agent loop (์ ์์ฑ ์ฐ์)```### CRAG (Self-correction) ํ ๊ธ```bash38 unmodified linesโโโ agents/โ โโโ orchestrator.py # LangGraph StateGraph + ์กฐ๊ฑด๋ถ ๋ผ์ฐํโ โโโ detection.py # Tier 1 IsolationForest (SECOM/PHM ๋์คํจ์น)โ โโโ planner.py # Central Planner Agent (Plan-and-Execute, conductor ๋ชจ๋)โ โโโ cause.py # Tier 2 (conductor: plan ๋ฐ์ / autonomous: tool loop)โ โโโ impact.py # Tier 3 (conductor / autonomous ์ ๋ชจ๋)โ โโโ response.py # Tier 4 (conductor / autonomous ์ ๋ชจ๋)โ โโโ supervisor.py # autonomous ๋ชจ๋ ์ ์ฉ LLM-driven routerโ โโโ llm.py # OpenAI ํด๋ผ์ด์ธํธ + LangSmith wrap_openai ํตํฉโ โโโ tools/ # 7๊ฐ agent ๋๊ตฌโ โ โโโ knowledge.py # search_knowledge (RAG ๊ฒ์)21 unmodified linesโ โโโ rag_paradigm/ # D6: 5๋จ๊ณ paradigm ablationโ โโโ agentic_vs_workflow/ # D7: workflow vs agentic ๋น๊ตโ โโโ crag_eval/ # D8: CRAG self-correction ํจ๊ณผ ํ๊ฐโ โโโ reranker_compare/ # D9ยทD10: ํ๊ตญ์ด reranker + ํ์ฅ ์ฝํผ์ค ๊ฐ์ค ๊ฒ์ฆโ โโโ conductor_vs_autonomous/ # D11: Conductor vs Autonomous (latency -54%, ์ธ์ฉ ๋๋ฑ)โโโ docs/orchestrator_graph.mmd # LangGraph ์๋ ์ถ์ถ mermaidโโโ styles/main.css # ๋์์ธ ์์คํ โโโ tests/
1234567891011121380 unmodified lines94959697989910010110210310410510610710845 unmodified lines154155156157158"""Tier 2 ์์ธ ๋ถ์ ์์ด์ ํธ (Agentic RAG)LLM์ด ๋๊ตฌ๋ฅผ ์์จ ํธ์ถํด ์ปจํ ์คํธ๋ฅผ ์์งํ ๋ค ์์ธ์ ์ถ์ ํฉ๋๋ค.๊ฐ์ฉ ๋๊ตฌ: search_knowledge, lookup_incident_history, get_pm_historyํ๋ฆ:1. system prompt + ์๋ยทTier1 ์ปจํ ์คํธ๋ก ์์ (์ฌ์ retrieval ์์)2. tool-calling loop: LLM์ด ํ์ํ ๋๊ตฌ๋ฅผ ํธ์ถ -> ๊ฒฐ๊ณผ๋ฅผ ์ปจํ ์คํธ์ ์ถ๊ฐ3. LLM์ด ๋ ํธ์ถํ์ง ์์ ๋(๋๋ MAX_ITER ๋๋ฌ) synthesis ํธ์ถ4. response_format=json_schema ๋ก TIER2_SCHEMA ๊ตฌ์กฐํ ์ถ๋ ฅ"""import json80 unmodified linesreturn out@traceable(name="Tier2_Cause_Agent", run_type="chain")def run_cause(alarm: dict, tier1: Tier1, trace: dict | None = None, retry_hint: bool = False) -> Tier2:"""์์ธ ๋ถ์์ agentic RAG๋ก ์คํretry_hint=True ๋ฉด ์ง์ ๋ถ์์ ๊ธฐ์ฌ๋๊ฐ ๋ฎ์๋ค๋ ์ ํธ๋ฅผ prompt์ ์ถ๊ฐํด๋ ์ ๊ทน์ ์ผ๋ก ๋๊ตฌ๋ฅผ ํธ์ถํ๋๋ก ์ ๋ (orchestrator์ confidence retry์ฉ)"""user_prompt = _initial_user_prompt(alarm, tier1)if retry_hint:user_prompt += (45 unmodified linestrace["tool_calls"] = tool_call_logtrace["iterations"] = iterationstrace["llm_calls"] = iterations + 1return result12345678910111280 unmodified lines9394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418545 unmodified lines231232233234235236"""Tier 2 ์์ธ ๋ถ์ ์์ด์ ํธ๋ ๋ชจ๋ ์ง์:1. **Autonomous (๊ธฐ๋ณธ, plan=None)**: LLM์ด tool์ ์์จ ํธ์ถํ๋ agent loop- 2~3 iteration + synthesis = LLM ํธ์ถ 3~4ํ2. **Conductor (plan ์ ๊ณต)**: Planner๊ฐ ์ง์ ํ tool ํธ์ถ + ๋จ์ผ LLM synthesis- Tool ์ง์ ์คํ + LLM ํธ์ถ 1ํ. ์ฌ๊ทยทloop ์์๊ฐ์ฉ ๋๊ตฌ: search_knowledge, lookup_incident_history, get_pm_history"""import json80 unmodified linesreturn outCONDUCTOR_SYSTEM_PROMPT = """๋น์ ์ ๋ฐ๋์ฒด ๊ณต์ ์์ธ ๋ถ์ ์ ๋ฌธ๊ฐ์ ๋๋ค.Central Planner๊ฐ ์ด๋ฏธ ํ์ํ ์ ๋ณด๋ฅผ ๋ชจ๋ ์์งํด [์์ง๋ ์ปจํ ์คํธ]์ ์ ๋ฆฌํด ๋์์ต๋๋ค.๋น์ ์ ์ถ๊ฐ ๋๊ตฌ ํธ์ถ ์์ด ๊ทธ ์ปจํ ์คํธ๋ง ์ฌ์ฉํด ์์ธ 2~3๊ฐ๋ฅผ ์ฐ์ถํ์ธ์.[์ต์ข ์ฐ์ถ๋ฌผ]- causes: 2~3๊ฐ. ๊ฐ ์์ธ์ name / pct(๊ธฐ์ฌ๋ %) / evidence(๊ตฌ์ฒด์ ๊ทผ๊ฑฐ) / citations(๋ฌธ์ ID ๋๋ incident ID)- pct ํฉ์ 100์ ๊ฐ๊น์์ผ ํจ, ๊ธฐ์ฌ๋ ๋์ ์์ธ๋ถํฐ ์ ๋ ฌ- ์ ๊ณต๋์ง ์์ ์ ๋ณด๋ ์ธ์ฉํ์ง ๋ง์ธ์"""def _execute_tier2_plan(plan_tier2: dict, trace_calls: list) -> str:"""Planner๊ฐ ์ง์ ํ tool๋ค์ ์ง์ ํธ์ถํ๊ณ ์ปจํ ์คํธ๋ก ๋ณํ"""blocks = []for query in plan_tier2.get("search_queries", []):result = dispatch_tool("search_knowledge", {"query": query})trace_calls.append({"name": "search_knowledge", "args": {"query": query}})blocks.append(f"[search_knowledge: {query!r}]\n{result}")for symptom in plan_tier2.get("incident_symptoms", []):result = dispatch_tool("lookup_incident_history", {"symptom": symptom})trace_calls.append({"name": "lookup_incident_history", "args": {"symptom": symptom}})blocks.append(f"[lookup_incident_history: {symptom!r}]\n{result}")for eq_id in plan_tier2.get("equipment_ids", []):result = dispatch_tool("get_pm_history", {"equipment_id": eq_id})trace_calls.append({"name": "get_pm_history", "args": {"equipment_id": eq_id}})blocks.append(f"[get_pm_history: {eq_id!r}]\n{result}")return "\n\n".join(blocks) if blocks else "(planner๊ฐ ์ ๋ณด ์์ง ์ง์ ์์)"def _run_cause_conductor(alarm: dict, tier1: Tier1, plan: dict, trace: dict | None) -> Tier2:"""Conductor ๋ชจ๋: plan๋๋ก tool ์คํ + 1ํ LLM synthesis"""tool_log: list[dict] = []knowledge = _execute_tier2_plan(plan.get("tier2", {}), tool_log)sensors = ", ".join(f["name"] for f in tier1["features"])user_prompt = f"""## ์ด์ ์๋- ๊ณต์ : {alarm['title']}- lot: {alarm['lot_id']}- ์ด์ ํผ์ฒ: {alarm.get('feature')} {alarm.get('feature_arrow') or ''}## Tier 1 ์ด์ ํ์ง ๊ฒฐ๊ณผ- ์ด์ ์ ์: {tier1['score']}- ๊ธฐ์ฌ ์ผ์(Top): {sensors}## ์์ง๋ ์ปจํ ์คํธ (Planner ์ง์ ){knowledge}์ ์ปจํ ์คํธ๋ง ์ฌ์ฉํด ์์ธ์ ๋ถ์ํ์ธ์."""resp = client().chat.completions.create(model=SUBAGENT_MODEL,messages=[{"role": "system", "content": CONDUCTOR_SYSTEM_PROMPT},{"role": "user", "content": user_prompt},],response_format={"type": "json_schema","json_schema": {"name": "tier2", "schema": TIER2_SCHEMA, "strict": True},},)result = json.loads(resp.choices[0].message.content)if trace is not None:trace["tool_calls"] = tool_logtrace["iterations"] = 0trace["llm_calls"] = 1trace["mode"] = "conductor"return result@traceable(name="Tier2_Cause_Agent", run_type="chain")def run_cause(alarm: dict,tier1: Tier1,trace: dict | None = None,retry_hint: bool = False,plan: dict | None = None,) -> Tier2:"""์์ธ ๋ถ์ ์คํplan ์ ๊ณต ์ conductor ๋ชจ๋ (๋จ์ผ LLM ํธ์ถ, tool ์ง์ ์คํ).plan=None์ด๋ฉด ๊ธฐ์กด autonomous tool-calling loop ๋ชจ๋.retry_hint=True ๋ฉด autonomous ๋ชจ๋์์ ๋ ์ ๊ทน์ ์ผ๋ก ๋๊ตฌ๋ฅผ ํธ์ถํ๋๋ก ์ ๋."""if plan is not None:return _run_cause_conductor(alarm, tier1, plan, trace)user_prompt = _initial_user_prompt(alarm, tier1)if retry_hint:user_prompt += (45 unmodified linestrace["tool_calls"] = tool_call_logtrace["iterations"] = iterationstrace["llm_calls"] = iterations + 1trace["mode"] = "autonomous"return result
123456779 unmodified lines878889909192939446 unmodified lines141142143144145146"""Tier 3 ๊ณต์ ๊ฐ ์ํฅ ํ๊ฐ ์์ด์ ํธ (tool-using agent)LLM์ด ๋๊ตฌ๋ฅผ ์์จ ํธ์ถํด WIPยทdownstreamยทyield ๊ธฐ์ค์ ยทPM ์ด๋ ฅ์ ๋ชจ์ ๋คyield_loss์ ์ํฅ ๋ฐ๋ ํ๊ณต์ ๋ชฉ๋ก์ ์ฐ์ถํฉ๋๋ค.๊ฐ์ฉ ๋๊ตฌ: query_wip_status, get_downstream_steps, get_yield_baseline, get_pm_history"""79 unmodified linesWIPยทdownstreamยทyieldยทPM ์ปจํ ์คํธ๋ ๋๊ตฌ๋ฅผ ํธ์ถํด ์์จ์ ์ผ๋ก ์์งํ์ธ์."""@traceable(name="Tier3_Impact_Agent", run_type="chain")def run_impact(alarm: dict, tier1: Tier1, tier2: Tier2, trace: dict | None = None) -> Tier3:messages = [{"role": "system", "content": SYSTEM_PROMPT},{"role": "user", "content": _initial_user_prompt(alarm, tier1, tier2)},46 unmodified linestrace["tool_calls"] = tool_call_logtrace["iterations"] = iterationstrace["llm_calls"] = iterations + 1return {"yield_loss": round(float(llm_out["yield_loss"]), 1),1234567879 unmodified lines88899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019146 unmodified lines238239240241242243244"""Tier 3 ๊ณต์ ๊ฐ ์ํฅ ํ๊ฐ ์์ด์ ํธ๋ ๋ชจ๋ ์ง์:1. Autonomous (plan=None): LLM์ด tool์ ์์จ ํธ์ถํ๋ agent loop2. Conductor (plan ์ ๊ณต): Planner๊ฐ ์ง์ ํ tool ํธ์ถ + ๋จ์ผ LLM synthesis๊ฐ์ฉ ๋๊ตฌ: query_wip_status, get_downstream_steps, get_yield_baseline, get_pm_history"""79 unmodified linesWIPยทdownstreamยทyieldยทPM ์ปจํ ์คํธ๋ ๋๊ตฌ๋ฅผ ํธ์ถํด ์์จ์ ์ผ๋ก ์์งํ์ธ์."""CONDUCTOR_SYSTEM_PROMPT = """๋น์ ์ ๋ฐ๋์ฒด ๊ณต์ ์ํฅ ํ๊ฐ ์ ๋ฌธ๊ฐ์ ๋๋ค.Central Planner๊ฐ ์ด๋ฏธ ํ์ํ ์ ๋ณด(WIPยทdownstreamยทyieldยทPM)๋ฅผ ๋ชจ๋ ์์งํด [์์ง๋ ์ปจํ ์คํธ]์ ์ ๋ฆฌํด ๋์์ต๋๋ค.๋น์ ์ ์ถ๊ฐ ๋๊ตฌ ํธ์ถ ์์ด ๊ทธ ์ปจํ ์คํธ๋ง ์ฌ์ฉํด ์ฐ์ถํ์ธ์.[์ต์ข ์ฐ์ถ๋ฌผ]- yield_loss: ๋ณธ ์ด์์ผ๋ก ์ธํ ์์ ์์จ ์์ค(%p, ์์ ํ ์๋ฆฌ)- downstream_dependencies: ์ํฅ ๋ฐ๋ ํ๊ณต์ (current ์ ์ธ) - stage / delta / tag / kind"""def _execute_tier3_plan(plan_tier3: dict, trace_calls: list) -> str:"""Planner๊ฐ ์ง์ ํ tool๋ค์ ์ง์ ํธ์ถํ๊ณ ์ปจํ ์คํธ๋ก ๋ณํ"""blocks = []if plan_tier3.get("alarm_id"):r = dispatch_tool("query_wip_status", {"alarm_id": plan_tier3["alarm_id"]})trace_calls.append({"name": "query_wip_status", "args": {"alarm_id": plan_tier3["alarm_id"]}})blocks.append(f"[query_wip_status: {plan_tier3['alarm_id']!r}]\n{r}")for stage in plan_tier3.get("downstream_stages", []):r = dispatch_tool("get_downstream_steps", {"current_stage": stage})trace_calls.append({"name": "get_downstream_steps", "args": {"current_stage": stage}})blocks.append(f"[get_downstream_steps: {stage!r}]\n{r}")for proc in plan_tier3.get("yield_processes", []):r = dispatch_tool("get_yield_baseline", {"process": proc})trace_calls.append({"name": "get_yield_baseline", "args": {"process": proc}})blocks.append(f"[get_yield_baseline: {proc!r}]\n{r}")for eq_id in plan_tier3.get("equipment_ids", []):r = dispatch_tool("get_pm_history", {"equipment_id": eq_id})trace_calls.append({"name": "get_pm_history", "args": {"equipment_id": eq_id}})blocks.append(f"[get_pm_history: {eq_id!r}]\n{r}")return "\n\n".join(blocks) if blocks else "(planner๊ฐ ์ ๋ณด ์์ง ์ง์ ์์)"def _run_impact_conductor(alarm: dict, tier1: Tier1, tier2: Tier2, plan: dict, trace: dict | None) -> Tier3:tool_log: list[dict] = []knowledge = _execute_tier3_plan(plan.get("tier3", {}), tool_log)cause_lines = "\n".join(f"- {c['name']} ({c['pct']}%): {c['evidence'][:120]}" for c in tier2["causes"])current_stage = _stage_from_alarm(alarm)user_prompt = f"""## ์ด์ ์๋- ๊ณต์ : {alarm['title']} (current_stage: {current_stage})## Tier 1: ์ด์ ์ ์ {tier1['score']}## Tier 2 ์์ธ ๋ถ์{cause_lines}## ์์ง๋ ์ปจํ ์คํธ (Planner ์ง์ ){knowledge}์ ์ปจํ ์คํธ๋ง ์ฌ์ฉํด yield_loss์ downstream_dependencies๋ฅผ ์ฐ์ถํ์ธ์."""resp = client().chat.completions.create(model=SUBAGENT_MODEL,messages=[{"role": "system", "content": CONDUCTOR_SYSTEM_PROMPT},{"role": "user", "content": user_prompt},],response_format={"type": "json_schema","json_schema": {"name": "tier3_part", "schema": LLM_PART_SCHEMA, "strict": True},},)llm_out = json.loads(resp.choices[0].message.content)current_dep = {"stage": current_stage,"delta": f"+{tier1['score']}","tag": "ํ์ฌ","kind": "current",}if trace is not None:trace["tool_calls"] = tool_logtrace["iterations"] = 0trace["llm_calls"] = 1trace["mode"] = "conductor"return {"yield_loss": round(float(llm_out["yield_loss"]), 1),"dependencies": [current_dep] + llm_out["downstream_dependencies"],"impact_lots": get_affected_wip(alarm["id"]),}@traceable(name="Tier3_Impact_Agent", run_type="chain")def run_impact(alarm: dict,tier1: Tier1,tier2: Tier2,trace: dict | None = None,plan: dict | None = None,) -> Tier3:"""Tier 3 ์ํฅ ํ๊ฐ. plan ์ ๊ณต ์ conductor ๋ชจ๋(LLM 1ํ), ์๋๋ฉด autonomous loop."""if plan is not None:return _run_impact_conductor(alarm, tier1, tier2, plan, trace)messages = [{"role": "system", "content": SYSTEM_PROMPT},{"role": "user", "content": _initial_user_prompt(alarm, tier1, tier2)},46 unmodified linestrace["tool_calls"] = tool_call_logtrace["iterations"] = iterationstrace["llm_calls"] = iterations + 1trace["mode"] = "autonomous"return {"yield_loss": round(float(llm_out["yield_loss"]), 1),
1234567891011121314151617181920212223243 unmodified lines2829303132334 unmodified lines3839404142432 unmodified lines464748495051521 unmodified line545556575859605 unmodified lines666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161175 unmodified lines1231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661678 unmodified lines176177178179180181182"""4-Tier ๋ฉํฐ์์ด์ ํธ ์ค์ผ์คํธ๋ ์ดํฐ (LangGraph ๊ธฐ๋ฐ)๊ฐ Tier๊ฐ tool-using LLM agent์ด๋ฉฐ, LangGraph๋ก ์กฐ์ ํฉ๋๋ค.[๊ทธ๋ํ ๊ตฌ์กฐ]START -> detectdetect --(score >= 0.3)--> causedetect --(score < 0.3)---> noise -> END (severity gate)cause --(max pct < 40)---> cause_retry -> supervisorcause --(max pct >= 40)--> supervisorsupervisor --(LLM ๊ฒฐ์ )-+-> impact -> response -> END (proceed_full / escalate)+-> fast_impact -> response -> END (fast_track: Tier 3 skip)Supervisor (`agents.supervisor`)๋ LLM์ด Tier 2 ๊ฒฐ๊ณผ๋ฅผ ๋ณด๊ณ ๋์ ์ผ๋ก routing ๊ฒฐ์ .- proceed_full: ํ์ค (Tier 3 + 4)- fast_track: ์์ธ ๋จ๋ ์ฐ์ธ ์ Tier 3 skip- escalate: ๊ณ ์ํ - ์ ์ ์งํ + human review ํ๋๊ทธ (tier4.metadata์ ๊ธฐ๋ก)[์บ์ฑ] build_graph 1ํ ์ปดํ์ผ, run_orchestrator ์๋๋น 8๊ฐ LRU[Observability] @traceable + wrap_openai (ํ๊ฒฝ๋ณ์ LANGSMITH_TRACING=true ์ ํ์ฑ)"""from functools import lru_cachefrom typing import TypedDict3 unmodified linesfrom agents.cause import run_causefrom agents.detection import run_detectionfrom agents.impact import run_impactfrom agents.response import run_responsefrom agents.supervisor import run_supervisorfrom core.schema import Tier1, Tier2, Tier3, Tier4, TierData4 unmodified linesCAUSE_CONFIDENCE_THRESHOLD = 40class _GraphState(TypedDict, total=False):alarm: dicttier1: Tier12 unmodified linestier4: Tier4skipped: boolcause_retried: boolsupervisor_decision: dict # {action, severity, reasoning}def _node_detect(state: _GraphState) -> dict:1 unmodified linedef _route_after_detect(state: _GraphState) -> str:return "cause" if state["tier1"]["score"] >= SEVERITY_THRESHOLD else "noise"def _node_noise(state: _GraphState) -> dict:5 unmodified lines}def _node_cause(state: _GraphState) -> dict:return {"tier2": run_cause(state["alarm"], state["tier1"])}def _route_after_cause(state: _GraphState) -> str:if state.get("cause_retried"):return "supervisor" # ์ด๋ฏธ ์ฌ์๋ - supervisor๋ก ์งํcauses = state["tier2"]["causes"]max_pct = max((c.get("pct", 0) for c in causes), default=0)return "cause_retry" if max_pct < CAUSE_CONFIDENCE_THRESHOLD else "supervisor"def _node_cause_retry(state: _GraphState) -> dict:return {"tier2": run_cause(state["alarm"], state["tier1"], retry_hint=True),"cause_retried": True,}def _node_supervisor(state: _GraphState) -> dict:decision = run_supervisor(state["alarm"], state["tier1"], state["tier2"])return {"supervisor_decision": decision}def _route_after_supervisor(state: _GraphState) -> str:action = state["supervisor_decision"]["action"]if action == "fast_track":return "fast_impact"return "impact" # proceed_full + escalate ๋ชจ๋ impact ๊ฒฝ์def _node_impact(state: _GraphState) -> dict:return {"tier3": run_impact(state["alarm"], state["tier1"], state["tier2"])}def _node_fast_impact(state: _GraphState) -> dict:"""fast_track: LLM ํธ์ถ ์์ด ๊ฒฐ์ ๋ก ์ lightweight impactTier 4๊ฐ tier3์ ์๊ตฌํ๋ฏ๋ก ์ต์ ์ ๋ณด๋ง ์ฑ์ ์ ๋ฌ.yield_loss๋ tier1 score๋ฅผ ๋จ์ ๋ณํ, downstream์ current stage๋ง."""alarm = state["alarm"]tier1 = state["tier1"]return {"tier3": {"yield_loss": round(float(tier1["score"]) * 3.0, 1), # ๋จ์ ์ถ์ "dependencies": [{"stage": alarm["title"].split()[0],"delta": f"+{tier1['score']}",5 unmodified lines}def _node_response(state: _GraphState) -> dict:tier4 = run_response(state["alarm"], state["tier1"], state["tier2"], state["tier3"])# supervisor๊ฐ escalate ๊ฒฐ์ ์ immediate ์ฒซ ํญ๋ชฉ์ human review ํ๋๊ทธ ์ถ๊ฐdecision = state.get("supervisor_decision", {})if decision.get("action") == "escalate" and tier4.get("immediate"):tier4["immediate"][0]["text"] = "๐จ [HUMAN REVIEW ์๊ตฌ] " + tier4["immediate"][0]["text"]return {"tier4": tier4}@lru_cache(maxsize=1)def build_graph():g = StateGraph(_GraphState)g.add_node("detect", _node_detect)g.add_node("noise", _node_noise)g.add_node("cause", _node_cause)g.add_node("cause_retry", _node_cause_retry)g.add_node("supervisor", _node_supervisor)g.add_node("impact", _node_impact)g.add_node("fast_impact", _node_fast_impact)g.add_node("response", _node_response)g.add_edge(START, "detect")g.add_conditional_edges("detect", _route_after_detect, {"cause": "cause","noise": "noise",})g.add_edge("noise", END)g.add_conditional_edges("cause", _route_after_cause, {"supervisor": "supervisor","cause_retry": "cause_retry",})g.add_edge("cause_retry", "supervisor")g.add_conditional_edges("supervisor", _route_after_supervisor, {"impact": "impact","fast_impact": "fast_impact",})g.add_edge("impact", "response")g.add_edge("fast_impact", "response")g.add_edge("response", END)return g.compile()8 unmodified lines@lru_cache(maxsize=8)def run_orchestrator(alarm_id: str) -> TierData:alarm = _find_alarm(alarm_id)graph = build_graph()final = graph.invoke({"alarm": alarm})return {"tier1": final["tier1"],12345678910111213141516171819202122232425263 unmodified lines303132333435364 unmodified lines414243444546474849502 unmodified lines53545556575859601 unmodified line626364656667685 unmodified lines74757677787980818283848586878889909192939495969798991001011021031041051061075 unmodified lines1131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132148 unmodified lines223224225226227228229"""4-Tier ๋ฉํฐ์์ด์ ํธ ์ค์ผ์คํธ๋ ์ดํฐ (LangGraph ๊ธฐ๋ฐ)๋ ๊ฐ์ง ์คํ ๋ชจ๋ ์ง์ (ํ๊ฒฝ๋ณ์ AGENT_MODE):- **conductor** (๊ธฐ๋ณธ): Central Planner Agent๊ฐ ์ ์ฒด plan 1ํ ์ฐ์ถ๊ฐ Tier executor๊ฐ plan๋๋ก tool ํธ์ถ + LLM 1ํ synthesisโ LLM ํธ์ถ ~70% ๊ฐ์, latency ํฐ ํญ ๋จ์ถ- **autonomous**: ๊ฐ Tier๊ฐ tool-using agent loop๋ก ์์จ ์คํโ ์ ์์ฑ ๋์ผ๋ LLM ํธ์ถ ๋ง์[๊ทธ๋ํ - conductor ๋ชจ๋]START โ detect โ (severity gate) โ planner โ (action ๋ถ๊ธฐ)โ+โ cause โ impact โ response โ END (proceed_full)+โ cause โ fast_impact โ response โ END (fast_track)+โ cause โ impact โ response_escalate โ END (escalate, T4์ ๐จ prepend)[๊ทธ๋ํ - autonomous ๋ชจ๋]๊ธฐ์กด ๊ตฌ์กฐ (severity gate + cause_retry + supervisor ๋ถ๊ธฐ)์๋ dict์ data.demo.DEFAULT_ALARMS์์ ID๋ก ์กฐํ.@traceable (LangSmith) + wrap_openai ๋ก LLMยทtool ํธ์ถ ์๋ ํธ๋ ์ด์ค."""import osfrom functools import lru_cachefrom typing import TypedDict3 unmodified linesfrom agents.cause import run_causefrom agents.detection import run_detectionfrom agents.impact import run_impactfrom agents.planner import plan_workflowfrom agents.response import run_responsefrom agents.supervisor import run_supervisorfrom core.schema import Tier1, Tier2, Tier3, Tier4, TierData4 unmodified linesCAUSE_CONFIDENCE_THRESHOLD = 40def _agent_mode() -> str:return os.getenv("AGENT_MODE", "conductor").lower()class _GraphState(TypedDict, total=False):alarm: dicttier1: Tier12 unmodified linestier4: Tier4skipped: boolcause_retried: boolsupervisor_decision: dictplan: dict # conductor ๋ชจ๋์ Planner ๊ฒฐ๊ณผdef _node_detect(state: _GraphState) -> dict:1 unmodified linedef _route_after_detect(state: _GraphState) -> str:return "go" if state["tier1"]["score"] >= SEVERITY_THRESHOLD else "noise"def _node_noise(state: _GraphState) -> dict:5 unmodified lines}# ==================== Conductor ๋ชจ๋ ๋ ธ๋ ====================def _node_planner(state: _GraphState) -> dict:return {"plan": plan_workflow(state["alarm"], state["tier1"])}def _route_after_planner(state: _GraphState) -> str:action = state["plan"].get("action", "proceed_full")if action == "fast_track":return "fast_track"return "proceed" # proceed_full + escalate ๋ชจ๋ ํ์ค ๊ฒฝ๋กdef _node_cause_conductor(state: _GraphState) -> dict:return {"tier2": run_cause(state["alarm"], state["tier1"], plan=state["plan"])}def _node_impact_conductor(state: _GraphState) -> dict:return {"tier3": run_impact(state["alarm"], state["tier1"], state["tier2"], plan=state["plan"])}def _node_fast_impact(state: _GraphState) -> dict:"""fast_track: deterministic ๊ฒฝ๋ ์ฒ๋ฆฌ (LLM ํธ์ถ ์์)"""alarm = state["alarm"]tier1 = state["tier1"]return {"tier3": {"yield_loss": round(float(tier1["score"]) * 3.0, 1),"dependencies": [{"stage": alarm["title"].split()[0],"delta": f"+{tier1['score']}",5 unmodified lines}def _node_response_conductor(state: _GraphState) -> dict:tier4 = run_response(state["alarm"], state["tier1"], state["tier2"], state["tier3"], plan=state["plan"])if state["plan"].get("action") == "escalate" and tier4.get("immediate"):tier4["immediate"][0]["text"] = "๐จ [HUMAN REVIEW ์๊ตฌ] " + tier4["immediate"][0]["text"]return {"tier4": tier4}# ==================== Autonomous ๋ชจ๋ ๋ ธ๋ (๊ธฐ์กด ๋ณด์กด) ====================def _node_cause_autonomous(state: _GraphState) -> dict:return {"tier2": run_cause(state["alarm"], state["tier1"])}def _route_after_cause_autonomous(state: _GraphState) -> str:if state.get("cause_retried"):return "supervisor"causes = state["tier2"]["causes"]max_pct = max((c.get("pct", 0) for c in causes), default=0)return "cause_retry" if max_pct < CAUSE_CONFIDENCE_THRESHOLD else "supervisor"def _node_cause_retry(state: _GraphState) -> dict:return {"tier2": run_cause(state["alarm"], state["tier1"], retry_hint=True),"cause_retried": True,}def _node_supervisor(state: _GraphState) -> dict:return {"supervisor_decision": run_supervisor(state["alarm"], state["tier1"], state["tier2"])}def _route_after_supervisor(state: _GraphState) -> str:return "fast_track" if state["supervisor_decision"]["action"] == "fast_track" else "proceed"def _node_impact_autonomous(state: _GraphState) -> dict:return {"tier3": run_impact(state["alarm"], state["tier1"], state["tier2"])}def _node_response_autonomous(state: _GraphState) -> dict:tier4 = run_response(state["alarm"], state["tier1"], state["tier2"], state["tier3"])decision = state.get("supervisor_decision", {})if decision.get("action") == "escalate" and tier4.get("immediate"):tier4["immediate"][0]["text"] = "๐จ [HUMAN REVIEW ์๊ตฌ] " + tier4["immediate"][0]["text"]return {"tier4": tier4}# ==================== Graph ๋น๋ ====================@lru_cache(maxsize=2)def build_graph(mode: str = "conductor"):g = StateGraph(_GraphState)g.add_node("detect", _node_detect)g.add_node("noise", _node_noise)g.add_edge(START, "detect")g.add_edge("noise", END)if mode == "conductor":g.add_node("planner", _node_planner)g.add_node("cause", _node_cause_conductor)g.add_node("impact", _node_impact_conductor)g.add_node("fast_impact", _node_fast_impact)g.add_node("response", _node_response_conductor)g.add_conditional_edges("detect", _route_after_detect, {"go": "planner", "noise": "noise"})g.add_edge("planner", "cause")g.add_conditional_edges("cause", _route_after_planner, {"proceed": "impact","fast_track": "fast_impact",})g.add_edge("impact", "response")g.add_edge("fast_impact", "response")g.add_edge("response", END)else:# autonomous (๊ธฐ์กด ๊ตฌ์กฐ)g.add_node("cause", _node_cause_autonomous)g.add_node("cause_retry", _node_cause_retry)g.add_node("supervisor", _node_supervisor)g.add_node("impact", _node_impact_autonomous)g.add_node("fast_impact", _node_fast_impact)g.add_node("response", _node_response_autonomous)g.add_conditional_edges("detect", _route_after_detect, {"go": "cause", "noise": "noise"})g.add_conditional_edges("cause", _route_after_cause_autonomous, {"supervisor": "supervisor","cause_retry": "cause_retry",})g.add_edge("cause_retry", "supervisor")g.add_conditional_edges("supervisor", _route_after_supervisor, {"proceed": "impact","fast_track": "fast_impact",})g.add_edge("impact", "response")g.add_edge("fast_impact", "response")g.add_edge("response", END)return g.compile()8 unmodified lines@lru_cache(maxsize=8)def run_orchestrator(alarm_id: str) -> TierData:alarm = _find_alarm(alarm_id)graph = build_graph(_agent_mode())final = graph.invoke({"alarm": alarm})return {"tier1": final["tier1"],
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184"""Central Planner Agent (Plan-and-Execute pattern)
์๋๊ณผ Tier 1 ๊ฒฐ๊ณผ๋ฅผ ๋ณด๊ณ ์ ์ฒด ์ํฌํ๋ก์ฐ plan์ 1ํ LLM ํธ์ถ๋ก ์ฐ์ถํฉ๋๋ค.๊ฐ Tier executor๋ plan๋๋ก ๋๊ตฌ๋ฅผ ์ง์ ํธ์ถํ๊ณ LLM 1ํ๋ก ๊ฒฐ๊ณผ๋ฅผ ํฉ์ฑํฉ๋๋ค.
๊ธฐ์กด autonomous tool-using loop ๋๋น:- LLM ํธ์ถ ~70% ๊ฐ์ (๊ฐ tier loop ์ ๊ฑฐ)- ์ฌ๊ท/๋ฌดํ๋ฃจํ ์ํ ์์ฒ ์ฐจ๋จ (LLM์ด tool์ ์์จ ์ ํํ์ง ์์)- ํต์ ์ค๋ฒํค๋ ์ต์ํ (synthesis context๋ฅผ ํ ๋ฒ์ ๊ตฌ์ฑ)- ๋น์ฉยทlatency ํฐ ํญ ์ ๊ฐ (gpt-4o-mini๋ก planning + gpt-5-mini๋ก synthesis)
์ค๊ณ:- Planner๊ฐ ๊ตฌ์ฒด์ ํจ์ ํธ์ถ์ด ์๋ "ํ์ํ ์ ๋ณด ์ฑ๋" (query/symptom/equipment_id ๋ฆฌ์คํธ)์ ์ง์ - ๊ฐ Tier executor๊ฐ ๊ทธ ์ฑ๋์ ๋ฐ์ ๊ฒฐ์ ๋ก ์ ์ผ๋ก tool ํธ์ถ (๋ณ๋ ฌ ๊ฐ๋ฅ)- Tier executor๋ ๋จ 1ํ LLM ํธ์ถ๋ก synthesis (tools ์ธ์ ์์ด)"""import json
from langsmith import traceable
from agents.llm import clientfrom agents.tools.equipment import ALARM_EQUIPMENTfrom core.schema import Tier1
PLANNER_MODEL = "gpt-4o-mini"
PLAN_SCHEMA = { "type": "object", "properties": { "tier2": { "type": "object", "properties": { "search_queries": { "type": "array", "items": {"type": "string"}, "description": "์ฌ๋ด ์ง์ ๊ฒ์ ์ฟผ๋ฆฌ (1~3๊ฐ)", }, "incident_symptoms": { "type": "array", "items": {"type": "string"}, "description": "๊ณผ๊ฑฐ incident DB ์กฐํ์ฉ ์ฆ์ (0~2๊ฐ)", }, "equipment_ids": { "type": "array", "items": {"type": "string"}, "description": "PM ์ด๋ ฅ ์กฐํ ์ฅ๋น ID (0~1๊ฐ)", }, }, "required": ["search_queries", "incident_symptoms", "equipment_ids"], "additionalProperties": False, }, "tier3": { "type": "object", "properties": { "alarm_id": {"type": "string", "description": "WIP ์กฐํ์ฉ ์๋ ID"}, "downstream_stages": { "type": "array", "items": {"type": "string"}, "description": "ํ๊ณต์ ์์กด์ฑ ์กฐํ (1๊ฐ)", }, "yield_processes": { "type": "array", "items": {"type": "string"}, "description": "yield baseline ์กฐํ (1~2๊ฐ)", }, "equipment_ids": { "type": "array", "items": {"type": "string"}, "description": "PM ์ด๋ ฅ ์กฐํ ์ฅ๋น ID (0~1๊ฐ)", }, }, "required": ["alarm_id", "downstream_stages", "yield_processes", "equipment_ids"], "additionalProperties": False, }, "tier4": { "type": "object", "properties": { "search_queries": { "type": "array", "items": {"type": "string"}, "description": "SOP ๊ฒ์ ์ฟผ๋ฆฌ (1~3๊ฐ)", }, "incident_symptoms": { "type": "array", "items": {"type": "string"}, "description": "๊ณผ๊ฑฐ ํด๊ฒฐ์ฑ
์กฐํ (0~2๊ฐ)", }, "equipment_ids": { "type": "array", "items": {"type": "string"}, "description": "PM ์๋์ฐ ์กฐํ ์ฅ๋น ID (1๊ฐ)", }, }, "required": ["search_queries", "incident_symptoms", "equipment_ids"], "additionalProperties": False, }, "action": { "type": "string", "enum": ["proceed_full", "fast_track", "escalate"], "description": "์ํฌํ๋ก์ฐ ๋ถ๊ธฐ (Tier 3 skip ์ฌ๋ถ, escalation ํ๋๊ทธ)", }, "severity": { "type": "string", "enum": ["low", "medium", "high", "critical"], }, "reasoning": {"type": "string"}, }, "required": ["tier2", "tier3", "tier4", "action", "severity", "reasoning"], "additionalProperties": False,}
SYSTEM_PROMPT = """๋น์ ์ ๋ฐ๋์ฒด fab ์ธ์๋ํธ ๋์ ์์คํ
์ Central Planner Agent์
๋๋ค.์ด์ ์๋๊ณผ Tier 1 ํ์ง ๊ฒฐ๊ณผ๋ฅผ ๋ฐ์ ์ ์ฒด ์ํฌํ๋ก์ฐ(Tier 2 ์์ธ๋ถ์ โ Tier 3 ์ํฅํ๊ฐ โ Tier 4 ๋์๊ถ๊ณ )์ ํ์ํ ์ ๋ณด ์์ง plan์ ํ ๋ฒ์ ์ฐ์ถํฉ๋๋ค.
[๊ฐ์ฉ ์ ๋ณด ์ฑ๋ - tier๋ณ]
Tier 2 (์์ธ ๋ถ์):- search_queries: ์ฌ๋ด ์ง์(INC/FMEA/SOP/FLOW) hybrid ๊ฒ์ (1~3๊ฐ)- incident_symptoms: ๊ณผ๊ฑฐ incident DB ๊ตฌ์กฐํ ์กฐํ (0~2๊ฐ)- equipment_ids: ์ฅ๋น PM ์ด๋ ฅ ์กฐํ (0~1๊ฐ)
Tier 3 (์ํฅ ํ๊ฐ):- alarm_id: WIP ์กฐํ (๏ฟฝ๏ฟฝ๋์ 1๊ฐ, ์๋ ID ๊ทธ๋๋ก)- downstream_stages: ํ๊ณต์ ์์กด์ฑ (1๊ฐ, ํ์ฌ ๊ณต์ ๋ช
- ์: "Photo", "Etch", "CMP")- yield_processes: yield baseline ์กฐํ (1~2๊ฐ)- equipment_ids: PM ์ด๋ ฅ ์กฐํ (0~1๊ฐ)
Tier 4 (๋์ ๊ถ๊ณ ):- search_queries: SOPยทํ์ค ์ ์ฐจ ๊ฒ์ (1~3๊ฐ)- incident_symptoms: ๊ณผ๊ฑฐ ํด๊ฒฐ์ฑ
์กฐํ (0~2๊ฐ)- equipment_ids: PM ์๋์ฐ ์กฐํ (1๊ฐ, immediate ์กฐ์น์ ์คํ ๊ฐ๋ฅ ์์ )
[routing ๊ฒฐ์ ]- action: - proceed_full (๋๋ถ๋ถ, ํ์ค Tier 2 โ 3 โ 4) - fast_track (๋จ์ผ ์์ธ 80%+ ์ฐ์ธ ์ - Tier 3 LLM skip) - escalate (๊ณ ์ํยท๋ค๋์ ์ํฅ - ์ ์ ์งํ + human review ํ๋๊ทธ)- severity: low / medium / high / critical
[์ค์ ์์น]- ์๋๊ณผ Tier 1์ ๋ณด๊ณ ๊ฐ์ฅ ์ ๋ณด๊ฐ์น ํฐ ์ฟผ๋ฆฌ/์กฐํ๋ง ์ ๋ณ (๋ถํ์ํ ํธ์ถ ์ ๊ฑฐ)- search_queries๋ ๋๋ฉ์ธ ์ฉ์ด๋ฅผ ํ๋ถํ๊ฒ (์: "Photo CD ์ฐํฌ ๋ ์ฆ ์ค์ผ ํค์ด์ฆ")- Tier 2์ Tier 4์ search_queries๋ ๋ชฉ์ ์ด ๋ค๋ฆ: - Tier 2: ์์ธ ํ๋ณด ํ์์ฉ - Tier 4: SOPยท์กฐ์น ์ ์ฐจ ํ์์ฉ- reasoning์ ํ ๋ฌธ์ฅ์ผ๋ก plan์ ํต์ฌ ์๋ ๋ช
์"""
def _build_user_prompt(alarm: dict, tier1: Tier1) -> str: sensors = ", ".join(f["name"] for f in tier1["features"]) equipment_id = ALARM_EQUIPMENT.get(alarm["id"], "(๋ฏธ๋งคํ)") process = alarm["title"].split()[0] return f"""## ์ด์ ์๋- ๊ณต์ : {alarm['title']} (current_stage: {process})- lot: {alarm['lot_id']}- ์ด์ ํผ์ฒ: {alarm.get('feature')} {alarm.get('feature_arrow') or ''}- ์๋ ID: {alarm['id']}- ์ถ์ ์ฅ๋น ID: {equipment_id}
## Tier 1 ์ด์ ํ์ง ๊ฒฐ๊ณผ- ์ด์ ์ ์: {tier1['score']}- ๊ธฐ์ฌ ์ผ์(Top): {sensors}
์ ์๋์ ์ ์ฒด ์ํฌํ๋ก์ฐ(Tier 2โ3โ4) plan์ ์ฐ์ถํ์ธ์."""
@traceable(name="Planner_Agent", run_type="chain")def plan_workflow(alarm: dict, tier1: Tier1) -> dict: """์๋ + Tier 1์ ๋ณด๊ณ ์ ์ฒด ์ํฌํ๋ก์ฐ plan์ ํ ๋ฒ์ ์ฐ์ถ
๋ฐํ: PLAN_SCHEMA ํ์ dict (tier2/tier3/tier4 + action/severity/reasoning) """ resp = client().chat.completions.create( model=PLANNER_MODEL, messages=[ {"role": "system", "content": SYSTEM_PROMPT}, {"role": "user", "content": _build_user_prompt(alarm, tier1)}, ], response_format={ "type": "json_schema", "json_schema": {"name": "plan", "schema": PLAN_SCHEMA, "strict": True}, }, ) return json.loads(resp.choices[0].message.content)1234567108 unmodified lines11611711811912012112212312412550 unmodified lines176177178179180181"""Tier 4 ๋์ ๊ถ๊ณ ์์ด์ ํธ (tool-using agent)LLM์ด ๋๊ตฌ๋ฅผ ์์จ ํธ์ถํด SOPยท๊ณผ๊ฑฐ incidentยทPM ์๋์ฐ๋ฅผ ๋ชจ์ ๋ค์ฆ์ ์กฐ์น(immediate)์ ์ค์ฅ๊ธฐ ์กฐ์น(longterm)๋ฅผ ์ฐ์ถํฉ๋๋ค.๊ฐ์ฉ ๋๊ตฌ: search_knowledge, lookup_incident_history, get_pm_history, check_pm_schedule"""108 unmodified linesํ์ํ SOPยท๊ณผ๊ฑฐ ํด๊ฒฐ์ฑ ยทPM ์๋์ฐ๋ ๋๊ตฌ๋ฅผ ํธ์ถํด ์์จ์ ์ผ๋ก ์์งํ์ธ์."""@traceable(name="Tier4_Response_Agent", run_type="chain")def run_response(alarm: dict, tier1: Tier1, tier2: Tier2, tier3: Tier3, trace: dict | None = None) -> Tier4:messages = [{"role": "system", "content": SYSTEM_PROMPT},{"role": "user", "content": _initial_user_prompt(alarm, tier1, tier2, tier3)},50 unmodified linestrace["tool_calls"] = tool_call_logtrace["iterations"] = iterationstrace["llm_calls"] = iterations + 1return {"immediate": llm_out["immediate"],12345678108 unmodified lines11711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622750 unmodified lines278279280281282283284"""Tier 4 ๋์ ๊ถ๊ณ ์์ด์ ํธ๋ ๋ชจ๋ ์ง์:1. Autonomous (plan=None): LLM์ด tool์ ์์จ ํธ์ถํ๋ agent loop2. Conductor (plan ์ ๊ณต): Planner๊ฐ ์ง์ ํ tool ํธ์ถ + ๋จ์ผ LLM synthesis๊ฐ์ฉ ๋๊ตฌ: search_knowledge, lookup_incident_history, get_pm_history, check_pm_schedule"""108 unmodified linesํ์ํ SOPยท๊ณผ๊ฑฐ ํด๊ฒฐ์ฑ ยทPM ์๋์ฐ๋ ๋๊ตฌ๋ฅผ ํธ์ถํด ์์จ์ ์ผ๋ก ์์งํ์ธ์."""CONDUCTOR_SYSTEM_PROMPT = """๋น์ ์ ๋ฐ๋์ฒด ๊ณต์ ๋์ ๊ถ๊ณ ์ ๋ฌธ๊ฐ์ ๋๋ค.Central Planner๊ฐ ์ด๋ฏธ ํ์ํ ์ ๋ณด(SOPยท๊ณผ๊ฑฐ ํด๊ฒฐ์ฑ ยทPM ์๋์ฐ)๋ฅผ ๋ชจ๋ ์์งํด [์์ง๋ ์ปจํ ์คํธ]์ ์ ๋ฆฌํด ๋์์ต๋๋ค.๋น์ ์ ์ถ๊ฐ ๋๊ตฌ ํธ์ถ ์์ด ๊ทธ ์ปจํ ์คํธ๋ง ์ฌ์ฉํด ์ฐ์ถํ์ธ์.[์ต์ข ์ฐ์ถ๋ฌผ]- immediate: ์ฆ์ ์กฐ์น 2~3๊ฑด (์ ์๊ฐ ๋ด ์คํ ๊ฐ๋ฅ, meta์ ์๊ฐยทhold ๋์ยท๋ถ์ ๋ช ์)- longterm: ์ค์ฅ๊ธฐ ์กฐ์น 1~2๊ฑด- ref_doc_ids: ๊ถ๊ณ ๊ทผ๊ฑฐ๋ก ์ค์ ์ฌ์ฉํ ๋ฌธ์ ID (search_knowledge๊ฐ ๋ฐํํ doc_id๋ง)"""def _execute_tier4_plan(plan_tier4: dict, trace_calls: list) -> tuple[str, list[str]]:"""Planner๊ฐ ์ง์ ํ tool๋ค์ ์ง์ ํธ์ถ, ์ปจํ ์คํธ + ๊ฒ์ doc_id ๋ฆฌ์คํธ ๋ฐํ"""blocks = []found_docs: list[str] = []for query in plan_tier4.get("search_queries", []):r = dispatch_tool("search_knowledge", {"query": query})trace_calls.append({"name": "search_knowledge", "args": {"query": query}})blocks.append(f"[search_knowledge: {query!r}]\n{r}")try:parsed = json.loads(r)found_docs.extend(h["doc_id"] for h in parsed.get("hits", []))except (json.JSONDecodeError, KeyError):passfor symptom in plan_tier4.get("incident_symptoms", []):r = dispatch_tool("lookup_incident_history", {"symptom": symptom})trace_calls.append({"name": "lookup_incident_history", "args": {"symptom": symptom}})blocks.append(f"[lookup_incident_history: {symptom!r}]\n{r}")for eq_id in plan_tier4.get("equipment_ids", []):r1 = dispatch_tool("get_pm_history", {"equipment_id": eq_id})trace_calls.append({"name": "get_pm_history", "args": {"equipment_id": eq_id}})blocks.append(f"[get_pm_history: {eq_id!r}]\n{r1}")r2 = dispatch_tool("check_pm_schedule", {"equipment_id": eq_id})trace_calls.append({"name": "check_pm_schedule", "args": {"equipment_id": eq_id}})blocks.append(f"[check_pm_schedule: {eq_id!r}]\n{r2}")return "\n\n".join(blocks) if blocks else "(planner๊ฐ ์ ๋ณด ์์ง ์ง์ ์์)", found_docsdef _run_response_conductor(alarm: dict, tier1: Tier1, tier2: Tier2, tier3: Tier3,plan: dict, trace: dict | None,) -> Tier4:tool_log: list[dict] = []knowledge, found_docs = _execute_tier4_plan(plan.get("tier4", {}), tool_log)cause_lines = "\n".join(f"- {c['name']} ({c['pct']}%)" for c in tier2["causes"])impact_lots_text = ", ".join(f"{l['label']} {l['lots']}lot/{l['wafers']}์ฅ" for l in tier3["impact_lots"])user_prompt = f"""## ์ด์ ์๋- ๊ณต์ : {alarm['title']}, lot: {alarm['lot_id']}## Tier 1: ์ด์ ์ ์ {tier1['score']}## Tier 2 ์์ธ (๊ธฐ์ฌ๋ ์){cause_lines}## Tier 3 ์ํฅ- ์์ ์์จ ์์ค: {tier3['yield_loss']} %p- ์ํฅ WIP: {impact_lots_text}## ์์ง๋ ์ปจํ ์คํธ (Planner ์ง์ ){knowledge}์ ์ปจํ ์คํธ๋ง ์ฌ์ฉํด immediate, longterm, ref_doc_ids๋ฅผ ์ฐ์ถํ์ธ์."""resp = client().chat.completions.create(model=SUBAGENT_MODEL,messages=[{"role": "system", "content": CONDUCTOR_SYSTEM_PROMPT},{"role": "user", "content": user_prompt},],response_format={"type": "json_schema","json_schema": {"name": "tier4_part", "schema": LLM_PART_SCHEMA, "strict": True},},)llm_out = json.loads(resp.choices[0].message.content)ref_ids = llm_out.get("ref_doc_ids") or found_docs[:4]refs = [{"id": d, "desc": _doc_description(d)} for d in ref_ids if d]if trace is not None:trace["tool_calls"] = tool_logtrace["iterations"] = 0trace["llm_calls"] = 1trace["mode"] = "conductor"return {"immediate": llm_out["immediate"],"longterm": llm_out["longterm"],"refs": refs,}@traceable(name="Tier4_Response_Agent", run_type="chain")def run_response(alarm: dict, tier1: Tier1, tier2: Tier2, tier3: Tier3,trace: dict | None = None,plan: dict | None = None,) -> Tier4:"""Tier 4 ๋์ ๊ถ๊ณ . plan ์ ๊ณต ์ conductor ๋ชจ๋(LLM 1ํ), ์๋๋ฉด autonomous loop."""if plan is not None:return _run_response_conductor(alarm, tier1, tier2, tier3, plan, trace)# autonomous ๋ชจ๋ (LLM์ด tool์ ์์จ ํธ์ถํ๋ ๊ธฐ์กด loop)messages = [{"role": "system", "content": SYSTEM_PROMPT},{"role": "user", "content": _initial_user_prompt(alarm, tier1, tier2, tier3)},50 unmodified linestrace["tool_calls"] = tool_call_logtrace["iterations"] = iterationstrace["llm_calls"] = iterations + 1trace["mode"] = "autonomous"return {"immediate": llm_out["immediate"],
15 unmodified lines161718192021147 unmodified lines16917017117217317420 unmodified lines19519619719819920020120215 unmodified lines| **D8** | CRAG ON vs OFF | self-correction (grader + refinement) | CRAG **ํ์ฑ ์ ์ง** (๊ด์ธก ๊ฐ์น) | [crag_eval/results.md](crag_eval/results.md) || **D9** | ํ๊ตญ์ด reranker (Dongjin-kr/ko-reranker) | vs BAAI(์์ด) vs hybrid (12 docs) | ๋ ๋ค hybrid์ ๋ฏธ๋ฌ | [reranker_compare/results.md](reranker_compare/results.md) || **D10** | D9 ํ์: ์ฝํผ์ค 12โ34 ํ์ฅ ํ reranker ์ฌํ๊ฐ | hybrid / BAAI / ko-reranker (34 docs) | **๊ฐ์ค ๊ฒ์ฆ - ํจ๊ณผ ์์ ๋ฐ์ ** | [reranker_compare/results.md](reranker_compare/results.md) |## ํต์ฌ ๊ฒฐ์ ์์ฝ147 unmodified lines**ํต์ฌ ๋ฉ์์ง**: ์ ๋ ํ๊ฐ ์์ด๋ ์๋ชป๋ ํต๋ ์ ๊ทธ๋๋ก ๋๊ณ ๊ฐ ๋ปํ๊ณ , ์ ๋ ํ๊ฐ ๋๋ถ์ ์ง์ง ์์ธ์ ๋ถ๋ฆฌํ๊ณ ๊ฒ์ฆํ ์ ์์๋ค. ์ฑํ: ์ฝํผ์ค 30+ ํ๊ฒฝ์์๋ `RAG_BACKEND=hybrid_rerank` ๊ถ์ฅ, ๋ฐ๋ชจ์ฉ ์ฝํผ์ค๋ hybrid ์ ์ง.## ์คํ ๋ฐฉ๋ฒ```bash20 unmodified lines# CRAG ON vs OFF (D8).venv/bin/python -m experiments.crag_eval.benchmark# ํ๊ตญ์ด reranker (Dongjin-kr/ko-reranker) ํ๊ฐ (D9).venv/bin/python -m experiments.reranker_compare.benchmark```๊ฐ ์คํ์ `results.md`์ `charts/*.png`๋ฅผ ์์ฑํฉ๋๋ค.15 unmodified lines16171819202122147 unmodified lines17017117217317417517617717817918018118218318418518618718818919019119219319419519619720 unmodified lines21821922022122222322422522622722815 unmodified lines| **D8** | CRAG ON vs OFF | self-correction (grader + refinement) | CRAG **ํ์ฑ ์ ์ง** (๊ด์ธก ๊ฐ์น) | [crag_eval/results.md](crag_eval/results.md) || **D9** | ํ๊ตญ์ด reranker (Dongjin-kr/ko-reranker) | vs BAAI(์์ด) vs hybrid (12 docs) | ๋ ๋ค hybrid์ ๋ฏธ๋ฌ | [reranker_compare/results.md](reranker_compare/results.md) || **D10** | D9 ํ์: ์ฝํผ์ค 12โ34 ํ์ฅ ํ reranker ์ฌํ๊ฐ | hybrid / BAAI / ko-reranker (34 docs) | **๊ฐ์ค ๊ฒ์ฆ - ํจ๊ณผ ์์ ๋ฐ์ ** | [reranker_compare/results.md](reranker_compare/results.md) || **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) |## ํต์ฌ ๊ฒฐ์ ์์ฝ147 unmodified lines**ํต์ฌ ๋ฉ์์ง**: ์ ๋ ํ๊ฐ ์์ด๋ ์๋ชป๋ ํต๋ ์ ๊ทธ๋๋ก ๋๊ณ ๊ฐ ๋ปํ๊ณ , ์ ๋ ํ๊ฐ ๋๋ถ์ ์ง์ง ์์ธ์ ๋ถ๋ฆฌํ๊ณ ๊ฒ์ฆํ ์ ์์๋ค. ์ฑํ: ์ฝํผ์ค 30+ ํ๊ฒฝ์์๋ `RAG_BACKEND=hybrid_rerank` ๊ถ์ฅ, ๋ฐ๋ชจ์ฉ ์ฝํผ์ค๋ hybrid ์ ์ง.### D11. Conductor (Plan-and-Execute) vs Autonomous โ **Conductor ์ฑํ**| ์งํ | Autonomous | Conductor | ๋ณํ ||---|---|---|---|| LLM ํธ์ถ / ์๋ | 10.0 | **4.0** | **-60%** || Tool ํธ์ถ / ์๋ | 13.7 | 16.0 | +17% || ์ ๋ํฌ ์ธ์ฉ / ์๋ | 6.0 | **6.0** | **๋๋ฑ** || ์ ๋ ฅ ํ ํฐ | 25,849 | 8,042 | **-69%** || ์ถ๋ ฅ ํ ํฐ | 13,385 | 5,895 | **-56%** || **Latency / ์๋** | **131์ด** | **60์ด** | **-54%** || ๋น์ฉ / 1000์๋ | $33.23 | $13.80 | **-58%** |**์์ (D7 โ D11 narrative)**:- **D7**: "workflow โ agentic"์ผ๋ก reasoning traceยท์์จ์ฑ ํ๋ณด (๊ฐ Tier๊ฐ tool ์์จ ํธ์ถ)- **D11**: "agentic โ conductor"๋ก ํต์ ํจ์จ ํ๋ณต (Central Planner๊ฐ plan 1ํ ์ฐ์ถ + Tier executor๊ฐ plan๋๋ก ์คํ + LLM 1ํ synthesis)- ๋ ํจํด ๋ชจ๋ ์ ๋ ๋น๊ต ํ ์ฑํ. autonomous๋ ํ๊ฒฝ๋ณ์ `AGENT_MODE=autonomous`๋ก ๋ณด์กด (๋ณต์กํ ์๋ยท์์์น ๋ชปํ ์ปจํ ์คํธ ์ ์ ํ์ ์)- **์ฌ๊ทยท๋ฌดํ๋ฃจํ ์ํ ์์ฒ ์ฐจ๋จ**: autonomous์ `MAX_TOOL_ITERATIONS=4` ์บก ์์กด์ด plan ๊ณ ์ ์คํ์ผ๋ก ๋ณธ์ง์ ํด๊ฒฐ## ์คํ ๋ฐฉ๋ฒ```bash20 unmodified lines# CRAG ON vs OFF (D8).venv/bin/python -m experiments.crag_eval.benchmark# ํ๊ตญ์ด reranker (Dongjin-kr/ko-reranker) ํ๊ฐ (D9ยทD10).venv/bin/python -m experiments.reranker_compare.benchmark# Conductor vs Autonomous (D11).venv/bin/python -m experiments.conductor_vs_autonomous.benchmark```๊ฐ ์คํ์ `results.md`์ `charts/*.png`๋ฅผ ์์ฑํฉ๋๋ค.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346"""D11: Conductor (Plan-and-Execute) vs Autonomous (tool-using loop) ์ ๋ ๋น๊ต
๊ฐ์ ์๋(A1ยทA2ยทA3)์ ๋ ๋ชจ๋๋ก ์คํํด ์ธก์ :- LLM ํธ์ถ ์ / ์๋ (autonomous: 9~13ํ ์์, conductor: 4~5ํ ์์)- Latency (autonomous: ~194s, conductor: ๋ชฉํ ~60s)- ํ ํฐยท๋น์ฉ- ์ธ์ฉ ๊น์ด (citations ์ ๋ํฌ)- RAGAS faithfulness (์ ํ์ - ์๊ฐ ์ ์ฝ ์ํด skip ๊ฐ๋ฅ)
๋ชจ๋ ํ ๊ธ: ํ๊ฒฝ๋ณ์ AGENT_MODE=conductor ๋๋ autonomous
์คํ: python -m experiments.conductor_vs_autonomous.benchmark๊ฒฐ๊ณผ: results.md + charts/*.png"""import osimport timefrom pathlib import Path
import matplotlib.pyplot as pltimport numpy as np
# ์คํ์ ์ํด CRAG๋ ๋นํ์ฑ (์ ๋ชจ๋ ๋์ผ ์กฐ๊ฑด)os.environ.setdefault("CRAG_ENABLED", "false")
from agents.cause import run_causefrom agents.detection import run_detectionfrom agents.impact import run_impactfrom agents.llm import clientfrom agents.planner import plan_workflowfrom agents.response import run_responsefrom data.demo import DEFAULT_ALARMS
plt.rcParams["font.family"] = ["Apple SD Gothic Neo", "AppleGothic", "DejaVu Sans"]plt.rcParams["axes.unicode_minus"] = False
OUT_DIR = Path(__file__).parentCHART_DIR = OUT_DIR / "charts"ALARMS = ["A1", "A2", "A3"]
PRICE_INPUT = 0.25 # gpt-5-mini ์ถ์ PRICE_OUTPUT = 2.0
def _capture_tokens(fn, *args, **kwargs): """LLM token usage๋ฅผ ์ง์ captureํ๊ธฐ ์ํ wrapper""" captured = {"in": 0, "out": 0} real = client().chat.completions.create
def patched(**kw): r = real(**kw) captured["in"] += r.usage.prompt_tokens captured["out"] += r.usage.completion_tokens return r
client().chat.completions.create = patched try: result = fn(*args, **kwargs) finally: client().chat.completions.create = real return result, captured
def run_autonomous(alarm: dict) -> dict: """autonomous ๋ชจ๋ (Tier 2/3/4 ๊ฐ agent loop)""" t1 = run_detection(alarm) traces = {"tier2": {}, "tier3": {}, "tier4": {}} tier_lat = {}
t0 = time.time() (t2, tok_t2) = _capture_tokens(run_cause, alarm, t1, trace=traces["tier2"]) tier_lat["tier2"] = (time.time() - t0) * 1000
t0 = time.time() (t3, tok_t3) = _capture_tokens(run_impact, alarm, t1, t2, trace=traces["tier3"]) tier_lat["tier3"] = (time.time() - t0) * 1000
t0 = time.time() (t4, tok_t4) = _capture_tokens(run_response, alarm, t1, t2, t3, trace=traces["tier4"]) tier_lat["tier4"] = (time.time() - t0) * 1000
citations = set() for c in t2["causes"]: citations.update(c.get("citations", [])) for r in t4["refs"]: citations.add(r["id"])
llm_calls = sum(t.get("llm_calls", 0) for t in traces.values()) tool_calls = sum(len(t.get("tool_calls", [])) for t in traces.values()) input_tokens = tok_t2["in"] + tok_t3["in"] + tok_t4["in"] output_tokens = tok_t2["out"] + tok_t3["out"] + tok_t4["out"]
return { "tier2": t2, "tier3": t3, "tier4": t4, "tier_latency_ms": tier_lat, "total_latency_ms": sum(tier_lat.values()), "llm_calls": llm_calls, "tool_calls": tool_calls, "input_tokens": input_tokens, "output_tokens": output_tokens, "citations": sorted(citations), "traces": traces, }
def run_conductor(alarm: dict) -> dict: """conductor ๋ชจ๋ (Planner 1ํ + Tier executor ๊ฐ 1ํ)""" t1 = run_detection(alarm) traces = {"planner": {}, "tier2": {}, "tier3": {}, "tier4": {}} tier_lat = {}
# Planner t0 = time.time() (plan, tok_pl) = _capture_tokens(plan_workflow, alarm, t1) tier_lat["planner"] = (time.time() - t0) * 1000
# Tier 2/3/4 - ๊ฐ 1ํ LLM call (plan-driven) t0 = time.time() (t2, tok_t2) = _capture_tokens(run_cause, alarm, t1, trace=traces["tier2"], plan=plan) tier_lat["tier2"] = (time.time() - t0) * 1000
t0 = time.time() (t3, tok_t3) = _capture_tokens(run_impact, alarm, t1, t2, trace=traces["tier3"], plan=plan) tier_lat["tier3"] = (time.time() - t0) * 1000
t0 = time.time() (t4, tok_t4) = _capture_tokens(run_response, alarm, t1, t2, t3, trace=traces["tier4"], plan=plan) tier_lat["tier4"] = (time.time() - t0) * 1000
citations = set() for c in t2["causes"]: citations.update(c.get("citations", [])) for r in t4["refs"]: citations.add(r["id"])
llm_calls = 1 + sum(traces[t].get("llm_calls", 0) for t in ("tier2", "tier3", "tier4")) tool_calls = sum(len(traces[t].get("tool_calls", [])) for t in ("tier2", "tier3", "tier4")) input_tokens = tok_pl["in"] + tok_t2["in"] + tok_t3["in"] + tok_t4["in"] output_tokens = tok_pl["out"] + tok_t2["out"] + tok_t3["out"] + tok_t4["out"]
return { "tier2": t2, "tier3": t3, "tier4": t4, "tier_latency_ms": tier_lat, "total_latency_ms": sum(tier_lat.values()), "llm_calls": llm_calls, "tool_calls": tool_calls, "input_tokens": input_tokens, "output_tokens": output_tokens, "citations": sorted(citations), "plan": plan, "traces": traces, }
def collect_samples(): rows = [] for aid in ALARMS: alarm = next(a for a in DEFAULT_ALARMS if a["id"] == aid) print(f"\n=== [{aid}] {alarm['title']} ===") print(" [Autonomous]") auto = run_autonomous(alarm) print(f" llm={auto['llm_calls']}, tool={auto['tool_calls']}, " f"lat={auto['total_latency_ms']:.0f}ms, cit={len(auto['citations'])}, " f"tokens={auto['input_tokens']}+{auto['output_tokens']}") print(" [Conductor]") cond = run_conductor(alarm) print(f" llm={cond['llm_calls']}, tool={cond['tool_calls']}, " f"lat={cond['total_latency_ms']:.0f}ms, cit={len(cond['citations'])}, " f"tokens={cond['input_tokens']}+{cond['output_tokens']}, " f"plan_action={cond['plan']['action']}") rows.append({"alarm": aid, "autonomous": auto, "conductor": cond}) return rows
def aggregate(rows): def avg(key1, key2): return np.mean([r[key1][key2] for r in rows])
out = {} for mode in ("autonomous", "conductor"): out[mode] = { "llm_calls": avg(mode, "llm_calls"), "tool_calls": avg(mode, "tool_calls"), "latency_ms": avg(mode, "total_latency_ms"), "input_tokens": avg(mode, "input_tokens"), "output_tokens": avg(mode, "output_tokens"), "citations": np.mean([len(r[mode]["citations"]) for r in rows]), } return out
def make_charts(agg, rows): CHART_DIR.mkdir(exist_ok=True) auto, cond = agg["autonomous"], agg["conductor"]
# 1. ํธ์ถ ํ์ ๋น๊ต fig, ax = plt.subplots(figsize=(9, 5)) metrics = ["LLM ํธ์ถ", "Tool ํธ์ถ", "์ ๋ํฌ ์ธ์ฉ"] auto_vals = [auto["llm_calls"], auto["tool_calls"], auto["citations"]] cond_vals = [cond["llm_calls"], cond["tool_calls"], cond["citations"]] x = np.arange(len(metrics)) w = 0.35 b1 = ax.bar(x - w/2, auto_vals, w, label="Autonomous", color="#94a3b8") b2 = ax.bar(x + w/2, cond_vals, w, label="Conductor", color="#3b82f6") for bars in (b1, b2): for b in bars: ax.text(b.get_x() + b.get_width()/2, b.get_height() + 0.1, f"{b.get_height():.1f}", ha="center", fontsize=9) ax.set_xticks(x); ax.set_xticklabels(metrics) ax.set_ylabel("ํ๊ท (3 ์๋)") ax.set_title("Autonomous vs Conductor - ํธ์ถ ํ์") ax.legend(); ax.grid(axis="y", alpha=0.3) fig.tight_layout(); fig.savefig(CHART_DIR / "calls_comparison.png", dpi=150); plt.close(fig)
# 2. Latency ๋น๊ต fig, ax = plt.subplots(figsize=(9, 5)) auto_lat = auto["latency_ms"] / 1000 cond_lat = cond["latency_ms"] / 1000 bars = ax.bar(["Autonomous", "Conductor"], [auto_lat, cond_lat], color=["#94a3b8", "#3b82f6"]) for b, v in zip(bars, [auto_lat, cond_lat]): ax.text(b.get_x() + b.get_width()/2, v + 5, f"{v:.0f}s", ha="center", fontsize=11, fontweight="bold") ax.set_ylabel("ํ๊ท Latency (์ด)") ax.set_title(f"Latency ๋น๊ต - Conductor๊ฐ {(1 - cond_lat/auto_lat)*100:.0f}% ๋จ์ถ") ax.grid(axis="y", alpha=0.3) fig.tight_layout(); fig.savefig(CHART_DIR / "latency_comparison.png", dpi=150); plt.close(fig)
# 3. ๋น์ฉ ๋น๊ต fig, ax = plt.subplots(figsize=(9, 5)) auto_cost = (auto["input_tokens"] * PRICE_INPUT + auto["output_tokens"] * PRICE_OUTPUT) / 1_000_000 cond_cost = (cond["input_tokens"] * PRICE_INPUT + cond["output_tokens"] * PRICE_OUTPUT) / 1_000_000 bars = ax.bar(["Autonomous", "Conductor"], [auto_cost*1000, cond_cost*1000], color=["#94a3b8", "#3b82f6"]) for b, v in zip(bars, [auto_cost*1000, cond_cost*1000]): ax.text(b.get_x() + b.get_width()/2, v + max(auto_cost, cond_cost)*1000*0.02, f"${v:.2f}", ha="center", fontsize=11, fontweight="bold") ax.set_ylabel("USD / 1000 ์๋") ax.set_title(f"๋น์ฉ ๋น๊ต - Conductor๊ฐ {(1 - cond_cost/auto_cost)*100:.0f}% ์ ๊ฐ") ax.grid(axis="y", alpha=0.3) fig.tight_layout(); fig.savefig(CHART_DIR / "cost_comparison.png", dpi=150); plt.close(fig)
def write_results(rows, agg): auto, cond = agg["autonomous"], agg["conductor"] auto_cost = (auto["input_tokens"] * PRICE_INPUT + auto["output_tokens"] * PRICE_OUTPUT) / 1_000_000 cond_cost = (cond["input_tokens"] * PRICE_INPUT + cond["output_tokens"] * PRICE_OUTPUT) / 1_000_000
lines = [ "# D11: Conductor (Plan-and-Execute) vs Autonomous (tool-using loop)", "", "๊ฐ์ ์๋ยท๋์ผ LLM ๋ชจ๋ธยทCRAG OFF ๋์ผ ์กฐ๊ฑด์์ ๋ ํจํด์ ์ ๋ ๋น๊ตํฉ๋๋ค.", "", "- **Autonomous**: ๊ฐ Tier๊ฐ tool-using agent loop (2-3 iteration + synthesis)", "- **Conductor**: Central Planner Agent๊ฐ plan 1ํ ์ฐ์ถ + ๊ฐ Tier executor๊ฐ plan๋๋ก tool ์คํ + LLM 1ํ synthesis", "", "## ์คํ ์ค์ ", "", f"- ์๋: {', '.join(ALARMS)}", "- ์์ฑ ๋ชจ๋ธ: gpt-5-mini (์ ๋ชจ๋ ๋์ผ)", "- Planner: gpt-4o-mini (conductor ์ ์ฉ)", "- CRAG: ๋นํ์ฑ (๋น๊ต ์กฐ๊ฑด ํต์ผ ์ํด)", "", "## ๊ฒฐ๊ณผ ์์ฝ (3 ์๋ ํ๊ท )", "", "| ์งํ | Autonomous | Conductor | ๋ณํ |", "|---|---|---|---|", f"| LLM ํธ์ถ / ์๋ | {auto['llm_calls']:.1f} | {cond['llm_calls']:.1f} | **-{(1 - cond['llm_calls']/auto['llm_calls'])*100:.0f}%** |", f"| Tool ํธ์ถ / ์๋ | {auto['tool_calls']:.1f} | {cond['tool_calls']:.1f} | {(cond['tool_calls']/max(auto['tool_calls'],1) - 1)*100:+.0f}% |", f"| ์ ๋ํฌ ์ธ์ฉ / ์๋ | {auto['citations']:.1f} | {cond['citations']:.1f} | {(cond['citations']/max(auto['citations'],1) - 1)*100:+.0f}% |", f"| ์
๋ ฅ ํ ํฐ / ์๋ | {auto['input_tokens']:.0f} | {cond['input_tokens']:.0f} | **-{(1 - cond['input_tokens']/auto['input_tokens'])*100:.0f}%** |", f"| ์ถ๋ ฅ ํ ํฐ / ์๋ | {auto['output_tokens']:.0f} | {cond['output_tokens']:.0f} | **-{(1 - cond['output_tokens']/auto['output_tokens'])*100:.0f}%** |", f"| **Latency / ์๋** | **{auto['latency_ms']/1000:.0f}์ด** | **{cond['latency_ms']/1000:.0f}์ด** | **-{(1 - cond['latency_ms']/auto['latency_ms'])*100:.0f}%** |", f"| ๋น์ฉ / 1000์๋ | ${auto_cost*1000:.2f} | ${cond_cost*1000:.2f} | **-{(1 - cond_cost/auto_cost)*100:.0f}%** |", "", "## ์๊ฐํ", "", "### ํธ์ถ ํ์", "", "", "### Latency", "", "", "### ๋น์ฉ", "", "", "## ์๋๋ณ ์์ธ", "", ] for r in rows: lines.append(f"### {r['alarm']}") lines.append("") lines.append("| ๋ชจ๋ | LLM | Tool | Latency | Citations |") lines.append("|---|---|---|---|---|") for mode in ("autonomous", "conductor"): d = r[mode] lines.append( f"| {mode} | {d['llm_calls']} | {d['tool_calls']} | " f"{d['total_latency_ms']/1000:.0f}s | {len(d['citations'])} |" ) cp = r["conductor"].get("plan", {}) lines.append("") lines.append(f"- Conductor plan: action={cp.get('action')}, severity={cp.get('severity')}") lines.append(f" - reasoning: {cp.get('reasoning', '')[:200]}") lines.append("")
lat_reduce = (1 - cond['latency_ms']/auto['latency_ms']) * 100 cost_reduce = (1 - cond_cost/auto_cost) * 100 cit_change = (cond['citations']/max(auto['citations'], 1) - 1) * 100
lines += [ "## ํต์ฌ ์ธ์ฌ์ดํธ", "", f"1. **Latency {lat_reduce:.0f}% ๋จ์ถ**: {auto['latency_ms']/1000:.0f}์ด โ {cond['latency_ms']/1000:.0f}์ด. ๊ฐ Tier์ agent loop iteration์ด ์ ๊ฑฐ๋์ด LLM ํธ์ถ์ด ์ง๋ณ๋จ", f"2. **LLM ํธ์ถ {(1 - cond['llm_calls']/auto['llm_calls'])*100:.0f}% ๊ฐ์**: Planner 1 + Tierร3 (๊ฐ synthesis 1ํ) = 4ํ๋ก ํต์ผ. ์ฌ๊ทยท๋ฌดํ๋ฃจํ ์ํ ์์ฒ ์ฐจ๋จ", f"3. **๋น์ฉ {cost_reduce:.0f}% ์ ๊ฐ**: ์
๋ ฅ ํ ํฐ์ด ๊ฐ์ฅ ํฐ ํญ์ผ๋ก ๊ฐ์ (agent loop์ messages ๋์ ํจ๊ณผ ์ ๊ฑฐ)", f"4. **์ธ์ฉ ๊น์ด ๋ณํ {cit_change:+.0f}%**: " + ("๊ฑฐ์ ๋๋ฑ" if abs(cit_change) < 15 else f"{'์ฆ๊ฐ' if cit_change > 0 else '๊ฐ์'}, plan์ด retrieval ์ฑ๋์ ์ฌ์ ๊ฒฐ์ "), "", "## ์ฑํ ๊ฒฐ๋ก ", "", f"**๊ธฐ๋ณธ ๋ชจ๋: `AGENT_MODE=conductor`** (Plan-and-Execute ํจํด).", "", f"- ์๋ยท๋น์ฉ ์ฐ์ ๊ฒฐ์ ์ (latency -{lat_reduce:.0f}%, cost -{cost_reduce:.0f}%)", "- ํต์ ํ์ ์ต์ํ๋ก production ์ด์ ์์ ์ฑโ", "- ์ฌ๊ท ํธ์ถ ์ํ ์์ฒ ์ฐจ๋จ", "", "**`AGENT_MODE=autonomous` ์ต์
์ ์ง**:", "- ๋ณต์กํ ์๋ยท์์์น ๋ชปํ ์ปจํ
์คํธ๊ฐ ํ์ํ ๋ LLM์ ์ ์์ tool ํธ์ถ์ด ์ ๋ฆฌํ ์ ์์", "- ํ๊ฒฝ๋ณ์๋ก ์ฆ์ ํ ๊ธ ๊ฐ๋ฅ", "", "## Portfolio narrative ์์", "", "- D7์์ \"workflow โ agentic\"์ผ๋ก ์ ํํด reasoning trace ํ๋ณด", "- D11์์ \"agentic โ conductor\"๋ก ๋ค์ ์ ํํด ํต์ ํจ์จ ํ๋ณต", "- **\"tool-using agent\"์ ์์จ์ฑ๊ณผ \"plan-and-execute\"์ ํจ์จ์ฑ์ trade-off๋ก ๋ช
์์ ์ฑํ**", "- production agent ์์คํ
์ค๊ณ์ ํต์ฌ ์์ฌ๊ฒฐ์ ์ ์ ๋ ๋ฐ์ดํฐ๋ก ์
์ฆ", "", ] (OUT_DIR / "results.md").write_text("\n".join(lines), encoding="utf-8") print(f"--- ์ ์ฅ: {OUT_DIR / 'results.md'} ---")
def main(): rows = collect_samples() agg = aggregate(rows) print("\n--- ์ง๊ณ ---") for mode, vals in agg.items(): print(f" {mode}: {vals}") make_charts(agg, rows) write_results(rows, agg)
if __name__ == "__main__": main()12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394# D11: Conductor (Plan-and-Execute) vs Autonomous (tool-using loop)
๊ฐ์ ์๋ยท๋์ผ LLM ๋ชจ๋ธยทCRAG OFF ๋์ผ ์กฐ๊ฑด์์ ๋ ํจํด์ ์ ๋ ๋น๊ตํฉ๋๋ค.
- **Autonomous**: ๊ฐ Tier๊ฐ tool-using agent loop (2-3 iteration + synthesis)- **Conductor**: Central Planner Agent๊ฐ plan 1ํ ์ฐ์ถ + ๊ฐ Tier executor๊ฐ plan๋๋ก tool ์คํ + LLM 1ํ synthesis
## ์คํ ์ค์
- ์๋: A1, A2, A3- ์์ฑ ๋ชจ๋ธ: gpt-5-mini (์ ๋ชจ๋ ๋์ผ)- Planner: gpt-4o-mini (conductor ์ ์ฉ)- CRAG: ๋นํ์ฑ (๋น๊ต ์กฐ๊ฑด ํต์ผ ์ํด)
## ๊ฒฐ๊ณผ ์์ฝ (3 ์๋ ํ๊ท )
| ์งํ | Autonomous | Conductor | ๋ณํ ||---|---|---|---|| LLM ํธ์ถ / ์๋ | 10.0 | 4.0 | **-60%** || Tool ํธ์ถ / ์๋ | 13.7 | 16.0 | +17% || ์ ๋ํฌ ์ธ์ฉ / ์๋ | 6.0 | 6.0 | +0% || ์
๋ ฅ ํ ํฐ / ์๋ | 25849 | 8042 | **-69%** || ์ถ๋ ฅ ํ ํฐ / ์๋ | 13385 | 5895 | **-56%** || **Latency / ์๋** | **131์ด** | **60์ด** | **-54%** || ๋น์ฉ / 1000์๋ | $33.23 | $13.80 | **-58%** |
## ์๊ฐํ
### ํธ์ถ ํ์
### Latency
### ๋น์ฉ
## ์๋๋ณ ์์ธ
### A1
| ๋ชจ๋ | LLM | Tool | Latency | Citations ||---|---|---|---|---|| autonomous | 9 | 15 | 141s | 6 || conductor | 4 | 16 | 60s | 6 |
- Conductor plan: action=proceed_full, severity=high - reasoning: CD-X ์ฐํฌ์ ์ด์ ์งํ์ ๊ณ ํ๊ฐ๋ ์ด์ ์ ์๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํ์ฌ ์ ๋ฐ์ ์ธ ์์ธ ๋ถ์๊ณผ ๋์ ๊ถ๊ณ ์ ์ฐจ๋ฅผ ์งํํ๋ ๊ฒ์ด ์ค์ํ๋ค.
### A2
| ๋ชจ๋ | LLM | Tool | Latency | Citations ||---|---|---|---|---|| autonomous | 10 | 14 | 133s | 8 || conductor | 4 | 14 | 63s | 7 |
- Conductor plan: action=proceed_full, severity=high - reasoning: ๋จ์ผ ์์ธ ์ถ์ ์ ์ํ ์ข
ํฉ์ ์ธ ๋ฐ์ดํฐ ์์ง๊ณผ ๋ถ์์ด ํ์ํ๋ฉฐ, ๊ณ ์ธ์ฌํ ์ฒ๋ฆฌ๋ก ๊ณต์ ์ํฅ์ ์ต์ํํด์ผ ํ๋ฏ๋ก ์ ์ฒด ์ํฌํ๋ก์ฐ๋ฅผ ์งํํฉ๋๋ค.
### A3
| ๋ชจ๋ | LLM | Tool | Latency | Citations ||---|---|---|---|---|| autonomous | 11 | 12 | 118s | 4 || conductor | 4 | 18 | 59s | 5 |
- Conductor plan: action=proceed_full, severity=high - reasoning: CMP ๊ณต์ ์์ MRR ์์น์ด ๋ฐ์ํ์ฌ yield์ ํฐ ์ํฅ์ ๋ฏธ์น ์ ์์ผ๋ฏ๋ก ์ ์ฒด ๋ถ์ ๋ฐ ๊ถ๊ณ ์ ์ฐจ๋ฅผ ํตํด ์ ์ํ ๋์ํด์ผ ํจ.
## ํต์ฌ ์ธ์ฌ์ดํธ
1. **Latency 54% ๋จ์ถ**: 131์ด โ 60์ด. ๊ฐ Tier์ agent loop iteration์ด ์ ๊ฑฐ๋์ด LLM ํธ์ถ์ด ์ง๋ณ๋จ2. **LLM ํธ์ถ 60% ๊ฐ์**: Planner 1 + Tierร3 (๊ฐ synthesis 1ํ) = 4ํ๋ก ํต์ผ. ์ฌ๊ทยท๋ฌดํ๋ฃจํ ์ํ ์์ฒ ์ฐจ๋จ3. **๋น์ฉ 58% ์ ๊ฐ**: ์
๋ ฅ ํ ํฐ์ด ๊ฐ์ฅ ํฐ ํญ์ผ๋ก ๊ฐ์ (agent loop์ messages ๋์ ํจ๊ณผ ์ ๊ฑฐ)4. **์ธ์ฉ ๊น์ด ๋ณํ +0%**: ๊ฑฐ์ ๋๋ฑ
## ์ฑํ ๊ฒฐ๋ก
**๊ธฐ๋ณธ ๋ชจ๋: `AGENT_MODE=conductor`** (Plan-and-Execute ํจํด).
- ์๋ยท๋น์ฉ ์ฐ์ ๊ฒฐ์ ์ (latency -54%, cost -58%)- ํต์ ํ์ ์ต์ํ๋ก production ์ด์ ์์ ์ฑโ- ์ฌ๊ท ํธ์ถ ์ํ ์์ฒ ์ฐจ๋จ
**`AGENT_MODE=autonomous` ์ต์
์ ์ง**:- ๋ณต์กํ ์๋ยท์์์น ๋ชปํ ์ปจํ
์คํธ๊ฐ ํ์ํ ๋ LLM์ ์ ์์ tool ํธ์ถ์ด ์ ๋ฆฌํ ์ ์์- ํ๊ฒฝ๋ณ์๋ก ์ฆ์ ํ ๊ธ ๊ฐ๋ฅ
## Portfolio narrative ์์
- D7์์ "workflow โ agentic"์ผ๋ก ์ ํํด reasoning trace ํ๋ณด- D11์์ "agentic โ conductor"๋ก ๋ค์ ์ ํํด ํต์ ํจ์จ ํ๋ณต- **"tool-using agent"์ ์์จ์ฑ๊ณผ "plan-and-execute"์ ํจ์จ์ฑ์ trade-off๋ก ๋ช
์์ ์ฑํ**- production agent ์์คํ
์ค๊ณ์ ํต์ฌ ์์ฌ๊ฒฐ์ ์ ์ ๋ ๋ฐ์ดํฐ๋ก ์
์ฆREADME.md+32-7
agents/cause.py+90-12
agents/impact.py+102-4
agents/orchestrator.py+127-80
agents/planner.pyAdded+184
agents/response.py+107-4
experiments/README.md+27-1
experiments/conductor_vs_autonomous/__init__.pyAdded
experiments/conductor_vs_autonomous/benchmark.pyAdded+346
experiments/conductor_vs_autonomous/charts/calls_comparison.pngAdded

experiments/conductor_vs_autonomous/charts/cost_comparison.pngAdded

experiments/conductor_vs_autonomous/charts/latency_comparison.pngAdded

experiments/conductor_vs_autonomous/results.mdAdded+94