From agenticops
Observes Langfuse traces via API, analyzes quality regressions, cost spikes, and failure patterns using Prometheus/CloudWatch, proposes PR drafts for prompt/skill fixes in 4-stage loop.
npx claudepluginhub aws-samples/sample-oh-my-aidlcops --plugin agenticopsThis skill is limited to using the following tools:
다음 상황에서 본 skill을 실행합니다.
Mandates invoking relevant skills via tools before any response in coding sessions. Covers access, priorities, and adaptations for Claude Code, Copilot CLI, Gemini CLI.
Share bugs, ideas, or general feedback.
다음 상황에서 본 skill을 실행합니다.
continuous-eval이 faithfulness 5%p 하락 또는 user_feedback 부정 비율 임계 초과를 보고했을 때incident-response가 SEV2/3 이벤트의 root cause를 "prompt 품질" 또는 "도구 호출 누락"으로 분류했을 때다음 상황에서는 사용하지 않습니다.
@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를 시간·품질·비용 차원으로 그룹화합니다.
LANGFUSE_HOST="${LANGFUSE_HOST:-http://langfuse.svc.cluster.local}"
TARGET_AGENT="$1" # 예: rag-qa-agent, code-reviewer-skill
WINDOW_HOURS="${WINDOW_HOURS:-168}" # 기본 7일
curl -s -u "$LANGFUSE_PUBLIC_KEY:$LANGFUSE_SECRET_KEY" \
"$LANGFUSE_HOST/api/public/traces?name=$TARGET_AGENT&from=$(date -u -d "-${WINDOW_HOURS} hours" +%Y-%m-%dT%H:%M:%SZ)&limit=500" \
| jq -c '.data[]' \
> .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실패 케이스:
.omao/state/self-improving/error-langfuse.log에 원인 기록, skill 종료.본 skill 실행 종료 직전 다음을 자동 검증합니다. 하나라도 실패 시 PR 생성을 중단합니다.
.omao/plans/self-improving/rollback/에 저장되었는가draft이며 자동 머지 설정이 없는가