Skip to content

fix(analytics): page events past API limit cap - #1076

Open
devsy-app[bot] wants to merge 1 commit into
mainfrom
agent-analytics/events-page-cap-100
Open

fix(analytics): page events past API limit cap#1076
devsy-app[bot] wants to merge 1 commit into
mainfrom
agent-analytics/events-page-cap-100

Conversation

@devsy-app

@devsy-app devsy-app Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Summary

The agent-fleet daily analytics pipeline (hack/analytics/analyze_runs.py) could never run against real OpenHands Cloud data: the real-data path exited 1 silently and produced no output, so the daily agent-analytics job always fell back to the bundled --sample (or failed outright). This PR fixes the real-data API path so the pipeline produces real daily_report.md / pr-gate verdicts going forward.

Root cause

CloudClient.conversation_events issued a single GET to /api/v1/conversation/{id}/events/search with limit=500. The endpoint caps limit at 100 per request and rejects larger values with HTTP 422:

{"detail":[{"type":"less_than_equal","loc":["query","limit"],"msg":"Input should be less than or equal to 100","input":"500"}]}

get() raises typer.Exit(1) on the 422, so the real-data run produced no output at all. The --sample path was unaffected because it never calls the API — which is exactly why the smoke test passed while real runs failed silently.

The one intervention

Page through the events endpoint instead of requesting 500 at once:

  • Add EVENTS_PAGE_SIZE = 100 (the API's per-request cap).
  • conversation_events now loops, requesting limit=min(EVENTS_PAGE_SIZE, remaining) and following the next_page_id cursor (passed as the page_id query param) until the requested total (limit, default 500) is reached or the server returns an empty next_page_id.
  • A short-page / non-dict response guard stops at the end.

Minimal, self-contained, single-file change (~20 lines), no behavioral change to the sample path.

Metric justifying the change

This is a pipeline-repair PR, not a failure-mode intervention. The metric is the failure rate of the real-data path itself:

  • Before fix: 100% of real-data runs failed (HTTP 422 → typer.Exit(1), no output). Verified empirically: limit=200 → 422; limit=100 → 200 OK.
  • After fix: real-data run succeeds (exit 0), paginating a 200-event conversation across 2 pages and a 396-event conversation across 4 pages.

pr-gate verdict

  • Analytics window: 2026-08-15T00:00:00Z2026-08-16T00:00:00Z (yesterday → today)
  • Source: openhands-cloud-api (real data, OPENHANDS_API_KEY available)
  • pr-gate verdict: NOT-ACTIONABLE — 14 runs, 0 failed, 0 recurring error signatures. There is no recurring agent failure mode to intervene on today.

Per the agent-analytics job, a NOT-ACTIONABLE verdict means no failure-mode intervention PR. This PR is instead the pipeline repair that makes the pr-gate mechanism itself functional — without it, the real-data path can never produce a real verdict, so every future window would either fail or silently fall back to synthetic data. The pr-gate rule governs agent failure modes; this repair sits upstream of it.

Verification

Check Result
uv run hack/analytics/analyze_runs.py --sample --out-dir /tmp/analytics-verify (ANALYTICS_NO_UPLOAD=1) ✅ exit 0 — 16 runs, 9 signatures, pr-gate ACTIONABLE (sample unaffected)
uv run hack/analytics/analyze_runs.py --since yesterday --until today --out-dir dist/analytics (real data) ✅ exit 0 — 14 runs, 0 failed, all 5 outputs written (was: exit 1, no output)
uvx --from mypy mypy --strict --ignore-missing-imports --disable-error-code untyped-decorator hack/analytics/analyze_runs.py ✅ Success: no issues found
uvx --from radon radon cc -s max complexity ✅ 8 (< 10); conversation_events = B (6)
task cli:format ✅ clean
task cli:lint:ci ✅ 0 issues
task cli:test ✅ only the documented pre-existing pkg/git TestRepoClone* failures (this change does not touch pkg/git)

temp.sh upload

Skipped: ANALYTICS_NO_UPLOAD=1 was set for the offline sandbox verification run (both sample and real-data). No live upload attempted.

Visualization

failure_heatmap.png is generated by the pipeline at dist/analytics/failure_heatmap.png (real data, 14 runs, 0 failures → empty failure grid, consistent with the NOT-ACTIONABLE verdict).

Expected impact

The real-data analytics path goes from 100% failure to functional. The daily agent-analytics job will now produce real daily_report.md / pr-gate verdicts from live fleet data instead of silently failing or relying on the synthetic sample, so ACTIONABLE failure modes can actually be detected and intervened on in future windows.


This PR was created by an AI agent as part of an automated daily agent analytics job.

The OpenHands Cloud conversation-events endpoint caps `limit` at 100 per
request. `CloudClient.conversation_events` issued a single call with
`limit=500`, which the API rejects with HTTP 422 (`less_than_equal`), so
`get()` raised `typer.Exit(1)` and the real-data run produced no output.
The `--sample` path was unaffected because it never hits the API.

Page through the endpoint in batches of `EVENTS_PAGE_SIZE` (100) using the
`page_id` cursor returned as `next_page_id`, stopping at the requested
total or when the server signals the end. Verified against the live API:
a conversation with 200 events now fetches both pages (limit=200 422s,
limit=100 + page_id paginates to completion).

This is a pipeline-repair PR, not a failure-mode intervention: it makes
the real-data path functional so the pr-gate mechanism can ever produce a
real verdict. The post-fix real-data run for yesterday (2026-08-15) shows
14 runs, 0 failed, pr-gate NOT-ACTIONABLE — there is no recurring agent
failure mode today; the metric justifying this change is the 100% failure
rate of the real-data path itself before the fix.

This commit was created by an AI agent as part of an automated daily
agent analytics job.
@netlify

netlify Bot commented Aug 16, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit b065399
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a81c858b5a69b0008e28cae

@netlify

netlify Bot commented Aug 16, 2026

Copy link
Copy Markdown

Deploy Preview for images-devsy-sh canceled.

Name Link
🔨 Latest commit b065399
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a81c858569d64000870b3fa

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 7 complexity · 0 duplication

Metric Results
Complexity 7
Duplication 0

View in Codacy

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.

Run reviewer

TIP This summary will be updated as you push new changes.

@skevetter
skevetter marked this pull request as ready for review August 17, 2026 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants