/agenticops:self-improving-loop [which agent/skill to analyze?]from agenticops
Observes Langfuse production traces, analyzes quality regression, cost anomalies, and failure patterns, then proposes prompt/skill fixes as PR drafts. Runs a 4-stage Observe→Analyze→Propose→PR loop enforcing automation boundaries from the self-improving-agent-loop ADR.
Ships in agenticops. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
다음 상황에서 본 skill을 실행합니다.
continuous-eval이 faithfulness 5%p 하락 또는 user_feedback 부정 비율 임계 초과를 보고했을 때incident-response가 SEV2/3 이벤트의 root cause를 "prompt 품질" 또는 "도구 호출 누락"으로 분류했을 때다음 상황에서는 사용하지 않습니다.
profile.yaml의 observability.trace_mcp에 등록되어 있어야 합니다. Skill은 mcp__<server_name>__* (기본 mcp__langfuse__*) 도구로 호출합니다. 미설정 시 skill은 "trace MCP not configured" 안내와 함께 종료합니다.@latest 대신 PyPI 버전 pin 필수).continuous-eval로 최근 24시간 내 생성되어 있어야 합니다.본 skill은 engineering-playbook의 self-improving-agent-loop.md 5-Stage 설계에서 Rollout·Score·Filter 3단계를 자동화하고, Train/Deploy 2단계는 PR 승인·사람 트리거로 분리합니다. 즉 skill 내부 루프는 4단계입니다.
개선 대상 agent/skill의 최근 trace를 시간·품질·비용 차원으로 그룹화합니다.
MCP 도구 mcp__langfuse__query_traces를 호출하여 trace를 조회합니다 (설정된 observability.trace_mcp 서버를 통해):
{
"name": "$TARGET_AGENT",
"from": "2026-05-27T00:00:00Z",
"limit": 500
}
출력은 .omao/plans/self-improving/traces-raw.jsonl로 저장합니다.
수집 항목은 trace ID, 프롬프트, 응답, reward_score, user_feedback, latency, tool_invocations, token_count입니다. Reward가 낮은 trace(< 0.5)와 user_feedback이 부정인 trace를 우선 분석 대상으로 flag합니다.
수집한 trace를 품질·비용·안전 3축으로 분석합니다.
continuous-eval의 Ragas 결과(faithfulness, answer relevance, context precision)를 동일 기간 baseline과 비교합니다. 5%p 이상 하락한 지표를 regression으로 분류합니다.rate(agent_token_total[1h])를 쿼리하여 토큰 사용량 급증을 확인합니다.toxicity, pii_leakage 값이 한 건이라도 양성으로 라벨된 trace를 격리합니다.분석 결과는 다음 구조의 리포트로 저장합니다.
{
"target": "rag-qa-agent",
"window": "2026-04-14T00:00:00Z/2026-04-21T00:00:00Z",
"regressions": [
{
"dimension": "faithfulness",
"baseline": 0.87,
"current": 0.79,
"delta_pp": -8.0,
"affected_trace_ids": ["tr_abc", "tr_def", "..."],
"hypothesized_cause": "system_prompt revision on 2026-04-16 removed citation instruction"
}
]
}
저장 경로: .omao/plans/self-improving/report-${target}-${timestamp}.json
Regression 원인 가설에 대응하는 수정안을 생성합니다. 모든 수정안은 diff 형식으로 작성하여 사람이 검토할 수 있도록 합니다.
--- a/skills/rag-qa-agent/SKILL.md
+++ b/skills/rag-qa-agent/SKILL.md
@@ -42,7 +42,11 @@
## Instructions
You are a RAG QA agent. Retrieve relevant context and answer the user's question.
-Always respond concisely.
+Always respond concisely and include inline citations in the form [source:doc-id]
+for every claim grounded in retrieved context. If no retrieved context supports
+a claim, state "I cannot verify this from available sources" instead of speculating.
+
+Never output PII tokens (email, SSN, phone) even if present in retrieved context.
수정안 생성 원칙:
faithfulness ≥ 0.87)을 PR body에 명시합니다..omao/plans/self-improving/rollback/ 에 보관합니다.GitHub CLI로 PR draft를 생성합니다.
BRANCH="self-improving/${TARGET_AGENT}-$(date +%Y%m%d-%H%M)"
git checkout -b "$BRANCH"
git add skills/rag-qa-agent/SKILL.md
git commit -m "improve($TARGET_AGENT): restore citation instruction + block PII leakage"
gh pr create --draft \
--title "improve($TARGET_AGENT): address faithfulness -8.0pp regression" \
--body "$(cat <<'EOF'
## Self-Improving Loop Proposal
**Target**: `rag-qa-agent`
**Window**: 2026-04-14 .. 2026-04-21
**Detected Regression**: faithfulness 0.87 → 0.79 (-8.0pp)
### Evidence
- Affected traces: 47 traces, avg reward 0.42 (baseline 0.78)
- Langfuse query: see `.omao/plans/self-improving/report-rag-qa-agent-20260421.json`
### Hypothesized Cause
System prompt revision on 2026-04-16 removed the "include inline citations" instruction.
### Proposed Fix
Restore citation instruction + add explicit PII blocking clause.
### Acceptance Criteria
- [ ] `continuous-eval` faithfulness ≥ 0.87 on golden dataset
- [ ] No PII leakage detected in 48h canary (5% traffic)
- [ ] user_feedback positive rate ≥ baseline (0.71)
### Rollback
`.omao/plans/self-improving/rollback/rag-qa-agent-20260421.md` holds the pre-change content.
### ADR Compliance
Per ADR Self-Improving Loop §2, this proposal does NOT trigger model retraining. Merge of this PR results in prompt-only change; no weight update. `continuous-eval` will verify on next scheduled run.
EOF
)"
Input: self-improving-loop rag-qa-agent
Output:
.omao/plans/self-improving/traces-raw.jsonl — 최근 7일 trace 500건.omao/plans/self-improving/report-rag-qa-agent-20260421.json — regression 분석improve(rag-qa-agent): address faithfulness -8.0pp regression실패 케이스:
observability.trace_mcp) 미설정 또는 접근 불가 → .omao/state/self-improving/error-langfuse.log에 원인 기록, skill 종료.본 skill 실행 종료 직전 다음을 자동 검증합니다. 하나라도 실패 시 PR 생성을 중단합니다.
.omao/plans/self-improving/rollback/에 저장되었는가draft이며 자동 머지 설정이 없는가What SKILL.md sets; muted values are Claude Code's defaults
claude-opus-4-7Three short reads, in order
npx claudepluginhub aws-samples/sample-oh-my-aidlcops --plugin agenticops11 skills in this plugin
/anomaly-detectionCloudWatch 메트릭과 Prometheus 시계열 데이터에서 통계적 이상 징후를 자동 탐지하여 incident-response의 입력 소스로 제공한다. 베이스라인 학습(7일 이동 평균 + 3σ), 다변량 상관 분석, 계절성 보정을 수행하며 탐지된 anomaly를 severity 분류하여 알람을 생성한다./audit-trail모든 사용자 발화·agent 행동·phase 전환·gate 판정을 ISO 8601 타임스탬프와 함께 감사 로그에 기록한다. 사용자 입력은 축약·요약 없이 verbatim blockquote로 보존하며, SOC2·ISMS-P 감사 요구사항에 매핑되는 보존 정책(30·90·365일)을 프로젝트별로 선택한다. 모든 AIDLC skill이 호출 가능한 공통 감사 계층을 제공한다./automated-remediation알려진 장애 패턴에 대해 사전 정의된 Runbook 기반 자동 복구를 실행한다. RCA 결과 또는 incident-response의 가설을 입력으로 받아 매칭되는 remediation playbook을 선택하고, 복구 전/후 상태를 검증하며, 실패 시 에스컬레이션한다. SEV2/3만 자동 복구 대상이며 SEV1은 사람 전용이다.Other plugins' skills for the same job