Repository navigation
chore(automation): agent-fleet analytics pipeline - #947
Conversation
Add a daily agent-fleet analytics pipeline that monitors the previous day's agent runs, clusters failure modes with Python data-science tooling (scikit-learn KMeans), and ships one deterministic intervention to reduce recurring errors. Pipeline (hack/analytics/analyze_runs.py): - PEP 723 self-contained uv script (deps: typer, numpy, scikit-learn, pandas, seaborn, matplotlib, prettytable) - Pulls conversation event logs via OpenHands Cloud API, normalizes into runs.csv - KMeans clusters failure signatures (failure_clusters.csv), ranks top errors (top_errors.csv) - seaborn heatmap (failure_heatmap.png), prettytable daily report (daily_report.md) - Uploads zipped outputs to temp.sh; appends a pr-gate verdict (ACTIONABLE/NOT-ACTIONABLE) - Agent only opens a PR when verdict is ACTIONABLE; skips gracefully on upload failure Generated agent (.agents/agents/agent-analytics/) via hack/automations/agents.yaml. Go toolchain updated to use uv (never pip/venv); main_test.go bans pip/venv globally. Constraints: mypy --strict clean, radon max complexity 8 (<10), max 4 args/function, no leading underscores, no inline comments, no lazy imports. This PR was created by an AI agent on behalf of the user.
✅ Deploy Preview for images-devsy-sh canceled.
|
✅ Deploy Preview for devsydev canceled.
|
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| BestPractice | 1 medium |
| Security | 1 medium |
| Complexity | 1 medium |
🟢 Metrics 269 complexity · 3 duplication
Metric Results Complexity 269 Duplication 3
AI Reviewer: run a review on demand. To trigger the first review automatically, go to your organization or repository integration settings. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
Reduce agent friction when committing by fixing the two most common errors and simplifying the commit+PR flow to one command each. Changes to hack/sign_commit (hack/sign_commit/main.go): - changedFiles() now detects ALL working-tree changes (staged, unstaged, and untracked) vs origin/main, not just committed diffs. Previously agents with uncommitted changes got 'no changed files to commit'. - ensureBranch() auto-creates the remote branch from origin/main when it does not yet exist. Previously agents got '404 Not Found' on new branches. - Added -pr flag: commit + open draft PR in one step. - Added -pr-only flag: open a draft PR without committing. - Added -title and -draft flags for PR creation. Agent prompt simplification (hack/automations/template.md.tmpl): - Commit step: removed git add, the WARNING block, the Pre-PR check, and the reset/recovery flow. Now just: checkout branch + sign-commit. - PR step: removed the 6-line TOKEN/curl/JSON dance. Now just: sign-commit --pr-only -title ... -b ... - Status-check follow-up: removed git add (tool auto-detects changes). All 14 agent.md files regenerated. Tests updated to match new flow. Verification: - go test ./hack/sign_commit/ ./hack/automations/ — pass - gofmt — clean - go vet — clean - E2E smoke test: working-tree detection + branch auto-creation + verified commit all confirmed working end-to-end. This PR was created by an AI agent on behalf of the user.
Move the duplicated verify step (mkdir, git fetch, lint:ci, test, and the
KNOWN PRE-EXISTING FAILURE note) from inline agents.yaml review_steps into a
generated verifyBlock() function in main.go. This eliminates ~8 lines of
boilerplate duplicated across 9 Go agents.
Changes:
- Removed unused git_add_glob field from the agent struct and all 14 YAML
entries (sign_commit now auto-detects working-tree changes).
- Added verify_type field: set to 'go' for 9 agents, 'go+desktop' for
lint-fixer. Agents with custom verify steps (docs-keeper, ci-optimizer,
ui-polish, agent-analytics) leave it empty.
- Added verify_extras field for per-agent additions (gRPC build for
pkg-tunnel-network, e2e suite for integration-test and devcontainer-spec,
npm check for lint-fixer).
- verifyBlock() generates the standard verify step with the correct step
number (commit_step_number - 1) and any extras.
- Template inserts {{.VerifyBlock}} between review_steps and FORMATTING GATE.
- Removed the inline verify block from 9 agents' review_steps in agents.yaml.
Result: agents.yaml dropped from 489 to 474 lines. The generated agent.md
files are identical in content — the verify text now comes from one place
instead of being copy-pasted 9 times.
Verification: go test ./hack/... pass, gofmt clean, go vet clean,
go run ./hack/automations -check idempotent.
This PR was created by an AI agent on behalf of the user.
Fix all 12 golangci-lint errors flagged by CI: sign_commit/main.go: - goconst: extract 'main' and 'body' string literals into constants (mainBranch, bodyKey) - lll: shorten -all flag description, wrap -pr-only flag description - cyclop: extract prOnly branch resolution into createPRFromOptions helper sign_commit/main_test.go: - cyclop: extract gitRun() and writeFile() helpers to reduce TestChangedFilesDetectsWorkingTree complexity from 12 to under 8 - errcheck: replace unchecked exec.Command().Run() with gitRun() helper - goconst: use testMainBranch const instead of literal 'main' - golines: writeFile helper eliminates long os.WriteFile lines automations/main.go: - lll: split knownGitFailure const into concatenated string parts Verification: golangci-lint run --new-from-rev=origin/main reports 0 issues. All tests pass. gofmt clean. go vet clean. This PR was created by an AI agent on behalf of the user.
Add a code quality directive to the FORMATTING GATE section of the agent prompt template: write self-documenting code with clear names, small functions, and obvious structure. Avoid wordy comments — prefer no comments unless the code expresses something genuinely unintuitive (a non-obvious invariant, workaround, or trade-off). Regenerated all 14 agent.md files from the updated template. This PR was created by an AI agent on behalf of the user.
Blocking bug: events fetch uses
|
Signed-off-by: GitHub <noreply@github.com>
Summary
Add a daily agent-fleet analytics pipeline that monitors the previous day's agent runs, clusters failure modes with Python data-science tooling (scikit-learn KMeans), and ships one deterministic intervention to reduce recurring errors — lowering agent cognitive load so reasoning budget stays on the primary task.
Pipeline (
hack/analytics/analyze_runs.py)A PEP 723 self-contained uv script (always run via
uv run, never pip/venv) with inline deps:typer,numpy,scikit-learn,pandas,seaborn,matplotlib,prettytable.runs.csvfailure_clusters.csvtop_errors.csvfailure_heatmap.pngdaily_report.mdAfter writing outputs it zips the five files, uploads to
https://temp.sh/upload(3-day expiry, plain-text share URL; setANALYTICS_NO_UPLOAD=1to skip), and appends a## pr-gateverdict (ACTIONABLE / NOT-ACTIONABLE) todaily_report.md.PR-gate logic: ACTIONABLE when the top failure signature recurs across >=2 runs at >=10% share of failed runs. The
agent-analyticsagent only opens a PR when the verdict is ACTIONABLE — otherwise it reports "no actionable failure mode found" and stops. Upload failures degrade gracefully (skip with reason; pipeline never crashes).Generated agent
.agents/agents/agent-analytics/agent.md— generated viahack/automations/agents.yaml(regenerate withgo run ./hack/automations; verify idempotency withgo run ./hack/automations -check). The agent reviews the analytics output and ships ONE deterministic intervention per run (script fix, prompt clarification, or small code change) justified by a metric from the data.Go toolchain changes
hack/automations/main.go— supportuv(Python agents use PEP 723 self-contained scripts)hack/automations/main_test.go—pythonAgentsallowlist permitsuv runforagent-analytics; banspip install/venvglobally for all generated agentsVerification
mypy --strictradonmax complexitygo test ./hack/automations/ .gofmtgo run ./hack/automations -checkANALYTICS_NO_UPLOAD=1smokeConstraints met
uvonly (no pip/venv) — PEP 723 inline depsmypy --strictcleanThis PR was created by an AI agent on behalf of the user.