pwc-chat-health
Skill315 starsChanged 22 days agoApache-2.0View on GitHub
Audit the health and answer quality of Papers With Code production research chat (paperswithcode.co/chat) over a time window — turn failures and their root causes, time to first event and total latency, provider calls, MCP tool errors, catalog misses, execution-limit hits, scope refusals, web-search budget, capacity 429s, feedback, and a sampled read of real answers. Use this whenever the user asks to review, audit, or check production chats, chat health, chat errors, chat latency, what users ask the chat, which tasks or methods the chat could not find, or whether a chat fix worked in traffic — even if they only mention one suspicious failure. Do not use it for staging chat qualification or to change chat configuration.
- Reads credentials
In this repository35 other files it gives its agents.
- AGENTS.mdAGENTS.md
- frontend/public/llms.txtllms.txt
- add-benchmarkSkill
- add-conferenceSkill
- add-evalsSkill
- add-external-paperSkill
- add-methodSkill
- add-taskSkill
- complete-task-based-on-hfSkill
- complete-taskSkill
- complete-task-v2Skill
- create-thumbnailSkill
- create-trendsSkill
- curate-daily-papersSkill
- enrich-paperSkill
- grill-meSkill
- handoffSkill
- hf-cliSkill
- implementSkill
- lean-code-cleanupSkill
- port-evals-to-hubSkill
- process-x-bookmarksSkill
- pwc-brandSkill
- pwc-cliSkill
- pwc-cron-healthSkill
- pwc-deploySkill
- remote-paper-curationSkill
- reply-github-issueSkill
- resolve-model-paperSkill
- s2-cliSkill
- skill-creatorSkill
- to-ticketsSkill
- update-ai-deadlinesSkill
- verify-evalsSkill
- s2-cliSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
13 rules. About 0 are common, 5 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 14
Read the repository AGENTS.md and docs/database.md.
- Very specific: line 15
Read the chat reliability section of docs/autonomous-operations.md and docs/chat-trackio.md.
- Very specific: line 24
Use bounded SELECTs in a read-only transaction only.
- Distinctive: line 26
Write any turn dumps to the session scratchpad, never into the repository, and do not upload them.
- Distinctive: line 27
Do not open Trackio trace content unless the user names an incident.
- Distinctive: line 42
Never turn missing evidence into green.
- Very specific: line 57
Run the bundled script from the developer checkout.
- Distinctive: line 67
Read it with these rules:
- Very specific: line 97
Web search off: check circuit_state and trip_reason in the snapshot's budget row.
- Very specific: line 99
Before calling a tool error a live bug, compare its timestamps with the last MCP restart (journalctl -u paperswithcode-mcp@production).
- Very specific: line 116
Use psql -At with row_to_json, not COPY, which doubles backslashes.
- Distinctive: line 164
Do not use git stash in this repository.
- Very specific: line 170
every real error_code in the window has a mechanism or is listed as unverified.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Papers With Code production chat audit
Audit production chat as an independent verifier. The alert monitor and synthetic probe only catch loud outages; most regressions so far (wrong tool routing, catalog gaps, timeouts on one reasoning effort, a silently tripped web-search circuit) were found only by reading the data.
Read before auditing
- Read the repository
AGENTS.mdanddocs/database.md. - Read the chat reliability section of
docs/autonomous-operations.mdanddocs/chat-trackio.md. - Find the previous audit (memory notes named
chat-health-audit-*, or the user's last report) and list what it asked the next audit to re-check. Verifying an earlier fix in traffic is part of the job.
The live chat prompt and tool wrappers come from the deployed release, not this checkout. Read backend/chat_sandbox_worker/pi_worker/src/ from the active release or origin/main when a finding depends on them.
Safety boundary
This skill is read-only and must not expose user content.
- Use bounded
SELECTs in a read-only transaction only. Never update rows, reset circuits, change env files, restart units, or deploy, even when the fix is obvious. Propose it. - Report aggregates, error codes, tool names, and catalog lookup terms. Do not quote user prompts or answers, usernames, HF user IDs, session IDs in public places, or author names. A paraphrase of the request type ("thesis chapter draft in Chinese") is fine.
- Write any turn dumps to the session scratchpad, never into the repository, and do not upload them.
- Do not open Trackio trace content unless the user names an incident; aggregates do not need it.
Evidence planes
Classify each plane as healthy, degraded, unhealthy, or unverified:
| Plane | Question |
| Reliability | What share of user turns failed, with which error_code, on which release, and why? |
| Latency | Are time to first event (TTFE) and total time in line with the baseline, by traffic class and reasoning effort? |
| Tools and grounding | Do tool calls succeed, and do answers use tools when they should? Which misses are catalog gaps vs routing bugs? |
| Answer quality | In a sample of real turns, are answers grounded, current, linked correctly, and not falsely refused? |
| Capacity and budgets | Were turns turned away (nginx 429), and are the web-search, OpenAI, and per-user budgets healthy? |
| Telemetry | Are feedback, Trackio export, the alert monitor, and the synthetic probe working? |
Never turn missing evidence into green.
Phase 1: pin the scope
Capture the UTC audit time and the window (default: since the previous audit, else 24 h; use 7 days for trend questions). Then:
pwc-status
readlink -f /srv/paperswithcode/environments/production/currentNote every production release in the window. The snapshot's failures_by_release shows which release each failure ran on; a failure on a release that was replaced by a fix is not an open defect.
Phase 2: take the aggregate snapshot
Run the bundled script from the developer checkout. It opens one read-only transaction against the database in backend/keys.env (the production database; production chat lives in schema public) and prints content-free JSON:
uv run --no-sync --env-file backend/keys.env python -B \
.agents/skills/pwc-chat-health/scripts/chat_health_snapshot.py --hours 24 \
> "$SCRATCHPAD/chat-health.json"It reports user-turn status × error_code, volume, failures by release, latency percentiles by traffic class × effort × terminal status, OpenAI provider calls by model × effort × outcome, tool calls and classified tool errors, catalog misses, execution-limit turns, no-tool answers with and without paper context, scope refusals, sessions with size-related failures, feedback, and the web-search budget row.
Read it with these rules:
cancelledandcancel_control_missingare users pressing stop.supersededrows were retried. Real failures arestatus = 'error'plus superseded rows with a provider or infrastructureerror_code.effortcomes from the user row; turns atmaxbehave differently from everything else, so always split latency and failures by effort.reasoning_cappedcounts provider calls that spent the whole reasoning budget (8000 tokens). Those calls endincompleteand are the usual cause of 180 s turn timeouts.no_tool_answerswith paper context is expected to be high (the paper is in the prompt). Without paper context it should be low; compare with the previous audit.execution_limiterrors are the per-turn tool budget, not tool bugs. Report the number of turns that hit it.
Phase 3: sources outside the database
# Capacity rejections never create DB rows.
sudo awk '$9 == 429 && $7 ~ /^\/api\/v1\/chat/' /var/log/nginx/paperswithcode_access.log | awk '{print $7}' | sort | uniq -c
# Monitors.
systemctl list-timers --all --no-pager | grep -E 'chat-alert-monitor|chat-synthetic-probe'
journalctl -u pwc-cron-run-chat-synthetic-probe.service --since '-24h' --no-pager | tail -n 40
# Trackio export and runtime warnings (content-free).
journalctl -u 'paperswithcode-production-backend@*' --since '-24h' --no-pager | grep -ciE 'trackio.*(dropped|failed)'Rotate into paperswithcode_access.log.1 and *.gz (with zcat) when the window is longer than the current file. The backend journal is dominated by access-log lines and may reach back only a few hours; check its first timestamp (journalctl -u 'paperswithcode-production-backend@*' -o short-iso | head -1) and mark older journal evidence unverified.
Phase 4: root-cause every failure class
For each real error_code, find the mechanism, not just the count:
- provider_error / timeouts: join the turn's
chat_openai_provider_callsrows onturn_id(outcome,reasoning_tokens,provider_latency_ms,call_sequence). The known pattern is a max-effort call endingincompleteat the reasoning cap, then the turn hitting the 180 s deadline. - context_too_large / transcript_mirror_error / openai_user_concurrency_limited: check session size (
chat_sessions.transcript_bytes,message_count) and whether one session failed repeatedly. - gateway_unavailable, external_worker_lost, drain-time errors: compare timestamps with deploys. Failures clustered within a minute of a release switch are deploy drains.
- openai_budget_exhausted: per-user monthly cap; the stored
limit_microusdis fixed when the month's row is created. - Web search off: check
circuit_stateandtrip_reasonin the snapshot's budget row.trippedwithprovider_budgetand no cooldown stays off until someone re-arms it.
Before calling a tool error a live bug, compare its timestamps with the last MCP restart (journalctl -u paperswithcode-mcp@production). Errors that stop after a deploy were fixed.
Phase 5: read a sample of real turns
Aggregates do not show answer quality. Dump a bounded sample (for example 30 random completed turns plus every failed or refused turn) to the scratchpad and read it offline:
set -a; . backend/keys.env; set +a
PGPASSWORD=$PWC_DB_PASSWORD PGOPTIONS='-c default_transaction_read_only=on' \
psql -h "$PWC_DB_HOST" -p "$PWC_DB_PORT" -U "$PWC_DB_USER" -d "$PWC_DB_NAME" -X -At \
-c "select row_to_json(t) from (select u.turn_id, u.created_at, u.reasoning_effort, u.content as prompt,
a.content as answer, a.display_blocks, a.finish_reason
from chat_messages u join chat_messages a on a.turn_id = u.turn_id and a.role = 'assistant'
where u.role = 'user' and u.created_at >= now() - interval '24 hours'
order by random() limit 30) t" > "$SCRATCHPAD/chat-sample.jsonl"Use psql -At with row_to_json, not COPY, which doubles backslashes. For each turn, check:
- the answer used catalog tools for catalog questions, and cites real
paper:links and GitHub URLs (spot-check that they resolve); - "latest / recent / SOTA" questions cite recent papers (the catalog has current-year papers);
- refusals (
finish_reason = 'scope_blocked'is the server classifier;I can only help with AI…with a normal finish reason is the model) were genuinely off-topic; - long writing or multi-step asks completed rather than timing out.
Phase 6: verify catalog misses
catalog_misses lists task, method, benchmark, framework, and paper lookups that returned not_found. Before reporting a gap, confirm it against the catalog (pwc CLI or a read-only query) — the lookup may have used an alias or the wrong entity type. Methods are general techniques; a specific model name is a paper, so its method miss is not a gap. Repeated misses across audits are the strongest candidates for the add-task / add-method skills.
Reporting
Lead with the outcome, window, and audit time.
Summary
- Turns, sessions, users; real failure count and rate; releases in the window
- TTFE and total p50/p90 for new chats and follow-ups, with the effort split where it differs
- Plane classifications
- Fixes from the previous audit confirmed or still failing in traffic
- Statement that nothing was changed
Findings
One entry per defect, most user-visible first: what happened (counts), the mechanism, evidence (tables, code path with file:line from the live release), and the smallest fix. Separate code bugs, configuration or budget problems, catalog gaps, and expected behavior.
Catalog gaps
Verified missing tasks and methods, with how often users hit them.
Unverified scope
What could not be checked (journal retention, sample size, unreachable source) and the read-only evidence still needed.
Baseline (late October 2026)
About 700–950 user turns a day; real failures under 1%; new-chat TTFE p50 about 3–4 s, p90 about 5–6 s; follow-up TTFE p90 about 10 s; total p90 about 25–35 s; max-effort follow-ups much slower (p90 above 30 s TTFE). Fewer than 2% of turns hit the tool budget. Treat a clear step change from the previous audit as a finding even if the absolute number looks fine.
Known gotchas
chat_turn_latencyhas nocreated_at; filter onadmitted_at. Itsfailure_stage(before_dispatch,awaiting_first_event,streaming) tells you how far a failed turn got; it is empty for stopped and interrupted turns.primary_paper_contexton user rows can be JSONnull, not SQLNULL; usejsonb_typeof(...) = 'object'.- Tool blocks are
display_blocksentries withkind = 'tool',statussuccessorerror, and the error text atcontent[0].text. chat_turn_latency.system_prompt_sha256comes from deploy-time chat config, not the Pi worker prompt, so it does not change when the prompt does.- Feedback goes to
chat_feedback(valueis true for thumbs up); volume is a handful a week, so an empty window is normal. - Reading
/etc/paperswithcode/production.envis blocked in auto mode;backend/keys.envpoints at the same database. - Production deploys from other sessions are frequent. Attribute each failure to its release before calling it open.
- Do not use
git stashin this repository; the stash is shared across worktrees.
Completion gate
Before finishing, confirm:
- every real
error_codein the window has a mechanism or is listed as unverified; - latency is split by traffic class and effort and compared with the previous audit;
- nginx 429s, the monitors, and the web-search budget were checked;
- a sample of real turns was read;
- catalog misses were verified before being called gaps;
- the report quotes no user content and no state was changed.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

