| name | debugging-agent |
| description | Self-Improving Agent that monitors all other agent skills, analyzes their logs,
detects issues, and proposes improvements.
AUTO-TRIGGERS:
- Every 30 minutes (scheduled)
- When error rate > 5% (any agent)
- When 3+ recurring errors in 24h (same error type)
- When performance degrades > 2x baseline
|
| allowed-tools | ["view_file","grep_search","run_command"] |
| metadata | {"category":"system","version":1,"triggers":{"auto":[{"schedule":"*/30 * * * *"},{"condition":"error_rate > 0.05"},{"condition":"recurring_errors >= 3"},{"condition":"performance_degradation > 2.0"}],"manual":[{"command":"analyze-logs"},{"command":"propose-improvements"}]},"outputs":[{"type":"improvement-proposal","format":"markdown","location":"backend/ai/skills/logs/system/debugging-agent/proposals/"}],"dependencies":["backend.ai.skills.common.agent_logger","backend.ai.skills.common.log_schema"]} |
Debugging Agent
Self-Improving Agent System์ ํต์ฌ ์ปดํฌ๋ํธ
๋ค๋ฅธ ๋ชจ๋ agent์ ๋ก๊ทธ๋ฅผ ๋ถ์ํ์ฌ ๋ฌธ์ ๋ฅผ ๋ฐ๊ฒฌํ๊ณ ๊ฐ์ ์์ ์ ์ํฉ๋๋ค.
๐ Core Workflow
1. Log Collection (๋ก๊ทธ ์์ง)
python backend/ai/skills/system/debugging-agent/scripts/log_reader.py \
--days 1 \
--categories system,war-room,analysis
์์ง ๋์:
backend/ai/skills/logs/*/*/execution-*.jsonl
backend/ai/skills/logs/*/*/errors-*.jsonl
backend/ai/skills/logs/*/*/performance-*.jsonl
Output:
{
"agents": ["signal-consolidation", "war-room-debate", ...],
"total_executions": 50,
"total_errors": 3,
"time_range": "2025-12-25 to 2025-12-26"
}
2. Pattern Detection (ํจํด ๊ฐ์ง)
python backend/ai/skills/system/debugging-agent/scripts/pattern_detector.py \
--input logs_summary.json \
--output patterns.json
๊ฐ์ง ํจํด:
A. Recurring Errors (๋ฐ๋ณต ์๋ฌ)
- ์กฐ๊ฑด: ๋์ผํ error type์ด 24์๊ฐ ๋ด 3ํ ์ด์
- ์์:
TypeError: missing required positional argument (3ํ)
- ์ฐ์ ์์: HIGH
B. Performance Degradation (์ฑ๋ฅ ์ ํ)
- ์กฐ๊ฑด: duration_ms๊ฐ baseline ๋๋น 2๋ฐฐ ์ด์
- ์์: ํ๊ท 1000ms โ ์ต๊ทผ 2500ms
- ์ฐ์ ์์: MEDIUM
C. High Error Rate (๋์ ์๋ฌ์จ)
- ์กฐ๊ฑด: error rate > 5%
- ์์: 50 executions, 4 errors = 8%
- ์ฐ์ ์์: CRITICAL
D. API Rate Limits (API ์ ํ)
- ์กฐ๊ฑด: "rate limit" ๊ด๋ จ ์๋ฌ 5ํ ์ด์
- ์ฐ์ ์์: HIGH
Output:
{
"patterns": [
{
"type": "recurring_error",
"agent": "war-room-debate",
"error_type": "TypeError",
"count": 3,
"impact": "CRITICAL",
"first_seen": "2025-12-25T18:30:00",
"last_seen": "2025-12-26T09:15:00"
}
]
}
3. Context Synthesis (๋งฅ๋ฝ ํตํฉ)
๊ด๋ จ agent์ SKILL.md๋ฅผ ์ฝ์ด์ ์ปจํ
์คํธ ํ์
:
cat backend/ai/skills/war-room/war-room-debate/SKILL.md
cat backend/api/war_room_router.py
ํ์
๋ด์ฉ:
- Agent์ ์ญํ ๊ณผ ์ฑ
์
- ์
๋ ฅ/์ถ๋ ฅ ํ์
- ์์กด์ฑ (DB, APIs, etc.)
- ์ต๊ทผ ๋ณ๊ฒฝ์ฌํญ
4. Improvement Proposal (๊ฐ์ ์ ์์ฑ)
python backend/ai/skills/system/debugging-agent/scripts/improvement_proposer.py \
--patterns patterns.json \
--output proposals/proposal-20251226-100822.md
Proposal ํฌ๋งท:
# Improvement Proposal: Fix War Room TypeError
**Generated**: 2025-12-26 10:08:22
**Agent**: war-room-debate
**Priority**: CRITICAL
**Confidence**: 87%
---
## ๐ Issue Summary
**Pattern Detected**: Recurring Error (3 occurrences in 24h)
**Error**:
```
TypeError: missing required positional argument for AIDebateSession
```
**Impact**:
- War Room debates failing
- No trading signals generated
- User experience degraded
---
## ๐ Root Cause Analysis
**Evidence**:
1. Error occurs in `war_room_router.py:L622`
2. `AIDebateSession.__init__()` called with missing argument
3. Recent code change added new required field
**Root Cause**:
Schema mismatch between `AIDebateSession` model and router code.
---
## ๐ก Proposed Solution
### Option 1: Add Missing Argument (Recommended)
**File**: `backend/api/war_room_router.py`
```python
# Line 622 - Add missing argument
session = AIDebateSession(
ticker=ticker,
consensus_action=pm_decision["consensus_action"],
# ... existing fields ...
dividend_risk_vote=next((v["action"] for v in votes if v["agent"] == "dividend_risk"), None), # โ ADD THIS
created_at=datetime.now()
)
```
**Confidence**: 90% (high evidence)
### Option 2: Make Field Optional
Alternatively, update the model to make the field optional.
**Confidence**: 70% (lower impact but safer)
---
## ๐ฏ Expected Impact
- โ
Eliminates TypeError
- โ
War Room debates resume
- โ
Trading signals restored
- โ ๏ธ Requires testing with all agents
---
## ๐งช Verification Plan
Apply fix to
Run War Room debate:
Verify no TypeError
Check logs for successful execution
---
: LOW
:
May need to update other agent votes similarly
Database migration if schema changed
:
Revert commit if issues arise
Monitor error logs for 24h
---
:
Error Reproducibility: 100% (3/3 occurrences)
Historical Success: 80% (similar fixes worked)
Impact Clarity: 90% (clear user impact)
Root Cause Evidence: 85% (stack trace clear)
Solution Simplicity: 85% (1-line fix)
: 87%
๐ฏ Confidence Scoring (5 Metrics)
Proposal confidence๋ 5๊ฐ์ง ๋ฉํธ๋ฆญ์ ๊ฐ์ค ํ๊ท :
-
Error Reproducibility (30%)
- 100% if error occurs every time
- 0% if random/sporadic
-
Historical Success (25%)
- Similar fixes worked before?
- Based on past proposals
-
Impact Clarity (20%)
- Clear user/system impact?
- Measurable consequences?
-
Root Cause Evidence (15%)
- Stack trace available?
- Clear error message?
-
Solution Simplicity (10%)
- Simple 1-line fix vs complex refactor
- Lower risk = higher confidence
Formula:
confidence = (
reproducibility * 0.30 +
historical_success * 0.25 +
impact_clarity * 0.20 +
root_cause_evidence * 0.15 +
solution_simplicity * 0.10
)
๐ Usage Examples
Manual Trigger
python backend/ai/skills/system/debugging-agent/scripts/log_reader.py --days 1
python backend/ai/skills/system/debugging-agent/scripts/pattern_detector.py
python backend/ai/skills/system/debugging-agent/scripts/improvement_proposer.py
Scheduled Execution (via orchestrator)
import schedule
def run_debugging_agent():
subprocess.run(["python", "backend/ai/skills/system/debugging-agent/scripts/log_reader.py"])
subprocess.run(["python", "backend/ai/skills/system/debugging-agent/scripts/pattern_detector.py"])
subprocess.run(["python", "backend/ai/skills/system/debugging-agent/scripts/improvement_proposer.py"])
schedule.every(30).minutes.do(run_debugging_agent)
๐ Output Structure
backend/ai/skills/logs/system/debugging-agent/
โโโ execution-2025-12-26.jsonl # Debugging agent's own logs
โโโ errors-2025-12-26.jsonl
โโโ proposals/
โโโ proposal-20251226-100822.md # Improvement proposal
โโโ proposal-20251226-103045.md
โโโ accepted/
โโโ proposal-20251226-100822.md # User accepted
โ ๏ธ Important Notes
- Read-Only Access: Debugging Agent๋ ๋ก๊ทธ๋ง ์ฝ๊ณ ์ฝ๋๋ ์์ ํ์ง ์์
- User Approval Required: ๋ชจ๋ ์ ์์ ์ฌ์ฉ์ ์น์ธ ํ์
- Audit Trail: ๋ชจ๋ ์ ์๊ณผ ๊ฒฐ๊ณผ๋ proposals/ ๋๋ ํ ๋ฆฌ์ ๋ณด๊ด
- Safety First: Confidence < 70%์ธ ์ ์์ ๊ฒฝ๊ณ ํ์
๐ Next Steps
After Phase 2 complete:
- Phase 3: Skill Orchestrator (scheduling, notifications)
- (Optional) Phase 4: CI/CD Integration (auto-apply patches)
Created: 2025-12-26
Version: 1.0
Status: In Development