计划执行与检查节点
executing-plans
按既定实施计划完成工作,保持过程检查和反馈。
audit-langfuse-llm【效率与协作】PDCA quality audit of LLM features: traces, prompts, costs, evals, grounding, hallucination. Use for "audit LLM quality", "check Langfuse", or "audit AI costs". Jailbreaks → audit-llm-security. Cost caps → plan-llm-cost-guardrails.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Degree of freedom: MIXED — Phases 0–1, 4 [HIGH freedom]; Phases 2–3
CLI traces and playwright [LOW freedom — run exactly]. Read
protocol-browser-anti-stall before any browser step. Phase 0 first: Phases 2–3 verify the feature map it produces.
Observe: after Playwright chat,
langfuse-cli api traces listshows no new row;app/api/chat/route.tscallsopenai.chatwith no Langfuse wrap. Interpret: the live path is uninstrumented — the static map was wrong. Classify: missing instrumentation (pipeline break). Severity: P0 — prod chat is invisible. Finding: chat | P0 | no trace after live send | wrap the SDK call.
audit-llm-security; token caps → plan-llm-cost-guardrailsSearch for environment variables and config files (in order):
.env, .env.local, .env.production — look for LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY, LANGFUSE_BASE_URL, LANGFUSE_HOSTlangfuse.config.ts, langfuse.config.js — dedicated config filesinstrumentation.ts / instrumentation.js — Next.js instrumentation with LangfuseGlob("**/supabase/functions/**/index.ts") and search for Langfuse importsGrep(pattern: "LANGFUSE_PUBLIC_KEY|LANGFUSE_SECRET_KEY|LANGFUSE_BASE_URL|LANGFUSE_HOST", glob: ".env*")
Grep(pattern: "langfuse|Langfuse|@langfuse", glob: "*.{ts,js,tsx,jsx,py,rb,go}")
Record: LANGFUSE_HOST, public-key present (never the secret), import sites, CLI env ready.
Grep(pattern: "openai|OpenAI|anthropic|Anthropic|@google/generative-ai|gemini|cohere|mistral|groq|together|replicate", glob: "*.{ts,js,py}")
Grep(pattern: "langchain|LangChain|@langchain|vercel/ai|ai/core|createOpenAI|createAnthropic", glob: "*.{ts,js,py}")
Record: providers, frameworks, and the exact model ID strings in use, with each one's tier (frontier, mid, or small).
SemanticSearch(query: "Where are LLM/AI features called in the codebase?", target_directories: [])
Build a feature map:
| Feature | File(s) | Provider | Model | Traced? |
|---|---|---|---|---|
| e.g. Chat | app/api/chat/route.ts | OpenAI | <model id> (frontier) | Yes |
Grep(pattern: "createScore|langfuse.score|annotation|eval|judge|dataset", glob: "*.{ts,js,py}")
Grep(pattern: "getPrompt|langfuse.prompt|fetchPrompt|compilePrompt", glob: "*.{ts,js,py}")
Record: prompt source (Langfuse vs hardcoded vs config), eval setup, version/label.
firecrawl:firecrawl_search
{
"query": "LLM observability best practices production monitoring [current year]",
"limit": 5
}
firecrawl:firecrawl_search
{
"query": "prompt engineering evaluation scoring hallucination detection [current year]",
"limit": 5
}
firecrawl:firecrawl_search
{
"query": "LLM cost optimization token usage model selection production [current year]",
"limit": 5
}
Scrape the top 2–3 results:
firecrawl:firecrawl_scrape
{
"url": "<BEST_RESULT_URL>",
"formats": ["markdown"]
}
Langfuse docs for the detected setup:
firecrawl:firecrawl_search
{
"query": "site:langfuse.com docs tracing prompts evaluation scores",
"limit": 5
}
context7:resolve-library-id
{
"libraryName": "<DETECTED_FRAMEWORK e.g. langchain or vercel-ai>"
}
context7:query-docs
{
"libraryId": "<RESOLVED_ID>",
"query": "Langfuse integration tracing observability"
}
Shell + Langfuse CLI. Require LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY in the env.
npx langfuse-cli api traces list --limit 50
For each AI feature identified in Phase 0c, verify:
Red flags:
npx langfuse-cli api prompts list
For each prompt:
npx langfuse-cli api prompts get --name "<PROMPT_NAME>"
Evaluate:
production label? Are there staging/experiment labels for A/B testing?{{variables}} not string concatenation?If prompts are hardcoded in source code instead of managed via Langfuse:
Grep(pattern: "You are|system.*message|systemPrompt|SYSTEM_PROMPT", glob: "*.{ts,js,py}")
Flag hardcoded prompts as a finding — they should be migrated to Langfuse for versioning and A/B testing.
From trace data, analyze:
npx langfuse-cli api traces list --limit 50
Build a cost table from generation details (model, tokens, latency, cost):
| Feature | Model | Avg Input Tokens | Avg Output Tokens | Avg Latency | Est. Cost/Call |
|---|
Red flags:
npx langfuse-cli api scores list --limit 50
Evaluate:
Red flags:
npx langfuse-cli api sessions list --limit 20
Verify:
npx langfuse-cli api datasets list
Evaluate:
For each Phase 0c feature, trigger it live. Timeouts 15s; sleep 2 → snapshot (not one long block).
PW="npx --yes @playwright/cli@latest"
$PW -s=langfuse-audit open --headed "<APP_URL>"
Navigate to the feature, interact with it (fill form, click button, send message), and capture:
snapshot)console) — look for errorsrequests) — look for failed API callsAfter triggering each feature, wait 5-10 seconds, then verify the trace landed:
npx langfuse-cli api traces list --limit 5
Check:
sentry:search_issues
{
"organizationSlug": "<ORG_SLUG>",
"projectSlugOrId": "<PROJECT_SLUG>",
"query": "is:unresolved ai OR llm OR openai OR anthropic OR langfuse OR completion OR embedding"
}
Check for:
If the project stores AI outputs in the database:
supabase:list_tables
{
"schemas": ["public"]
}
Find tables that store AI outputs and verify data landed:
supabase:execute_sql
{
"query": "SELECT id, created_at, <ai_output_column> FROM <table> ORDER BY created_at DESC LIMIT 5"
}
For features where the AI should reference source data (RAG, summarization, data extraction):
execute_sql)Red flags:
Generate a structured report with the following sections.
═══════════════════════════════════════════════════════
LANGFUSE LLM QUALITY AUDIT REPORT
Project: <PROJECT_NAME>
Date: <DATE>
Langfuse Host: <HOST_URL>
═══════════════════════════════════════════════════════
## 1. TRACE COVERAGE
| Feature | Traced? | Generations? | Input/Output? | Metadata? | Status |
|---------|---------|-------------|---------------|-----------|--------|
| ... | ... | ... | ... | ... | ✅/❌ |
Coverage: X/Y features traced (Z%)
Missing instrumentation: [list features with no traces]
## 2. PROMPT QUALITY
| Prompt | Version | Label | System Msg | Few-Shot | Guardrails | Variables | Score |
|--------|---------|-------|------------|----------|------------|-----------|-------|
| ... | ... | ... | ... | ... | ... | ... | A-F |
Hardcoded prompts found: [list files with inline prompts]
Recommendations: [specific improvements per prompt]
## 3. COST EFFICIENCY
| Feature | Model | Avg Tokens (in/out) | Avg Latency | Est. Cost/Call | Recommendation |
|---------|-------|---------------------|-------------|----------------|----------------|
| ... | ... | ... | ... | ... | ... |
Monthly estimate: $X (at current usage rate)
Savings opportunity: $Y (by implementing recommendations)
## 4. EVAL HEALTH
| Metric | Status | Details |
|------------------|-----------|----------------------------------|
| Automated evals | ✅/❌ | [count and types] |
| Manual reviews | ✅/❌ | [annotation queue status] |
| Score distribution| ✅/❌ | [healthy spread vs clustered] |
| Datasets | ✅/❌ | [count, freshness, coverage] |
| Regression tests | ✅/❌ | [dataset run frequency] |
## 5. PIPELINE INTEGRITY
| Step | Status | Evidence |
|-------------------------|--------|-------------------------------------|
| FE triggers AI feature | ✅/❌ | [Playwright observation] |
| API receives request | ✅/❌ | [network request captured] |
| LLM call executes | ✅/❌ | [trace generation exists] |
| Trace lands in Langfuse | ✅/❌ | [CLI verification] |
| Result stored in DB | ✅/❌ | [Supabase query result] |
| Result displayed in FE | ✅/❌ | [Playwright snapshot] |
| Eval score recorded | ✅/❌ | [score attached to trace] |
## 6. GROUNDING & HALLUCINATION
| Feature | Source Data | AI Output Match | Hallucinations | Score |
|---------|-------------|-----------------|----------------|-------|
| ... | ... | ... | ... | A-F |
## 7. SENTRY LLM ERRORS
| Issue | Error Type | Events | Impact | Fix Needed |
|-------|------------|--------|--------|------------|
| ... | ... | ... | ... | ... |
## 8. CRITICAL FINDINGS (Action Required)
P0 — Must fix immediately:
1. [finding with evidence]
P1 — Should fix this sprint:
1. [finding with evidence]
P2 — Improvement opportunity:
1. [finding with evidence]
## 9. RECOMMENDATIONS
| # | Category | Current State | Recommended State | Effort | Impact |
|---|----------|---------------|-------------------|--------|--------|
| 1 | ... | ... | ... | S/M/L | S/M/L |
## 10. PDCA IMPROVEMENT RESULTS
| Prompt | Baseline Score | Iter 1 Score | Iter 2 Score | Iter 3 Score | Final Score | Action Taken |
|--------|---------------|-------------|-------------|-------------|-------------|--------------|
| ... | ... | ... | ... | ... | ... | Promoted / Rolled back / Needs manual |
audit-llm-security — OWASP LLM Top 10 (injection, agency, leaks) — not quality/evalsplan-llm-cost-guardrails — token budgets and quota abuseplan-privacy-compliance — PII in tracesbackend-observability / debug-sentry-monitor — non-LLM telemetry