Skip to content

feat(overview): add /api/autonomy-score endpoint (#688)#893

Draft
vivekchand wants to merge 1 commit intomainfrom
bot-fix/issue-688-autonomy-score-human-nudge-spacing
Draft

feat(overview): add /api/autonomy-score endpoint (#688)#893
vivekchand wants to merge 1 commit intomainfrom
bot-fix/issue-688-autonomy-score-human-nudge-spacing

Conversation

@vivekchand
Copy link
Copy Markdown
Owner

Summary

Adds GET /api/autonomy-score — the north-star autonomy metric from issue #688. The endpoint scans the last 7 days of session JSONL files (already on disk) and computes how far apart human nudges are, what fraction of sessions ran without any follow-up intervention, and whether autonomy is trending in the right direction. No new dependencies, no schema changes, no UI touched.

Changes

  • routes/overview.py — new _compute_autonomy_data(sessions_dir, cutoff_ts) helper (pure function, testable without a server) + GET /api/autonomy-score endpoint that calls it, following the same pattern as api_main_activity() and api_timeline().
  • tests/test_autonomy_score.py — 18 unit tests covering: missing/empty dirs, .deleted./.reset. file exclusion, zero-nudge sessions, gap computation, median correctness, 7-day cutoff window, malformed JSON resilience, custom cutoff, and full return-shape invariants. All pass without a live server.

Response shape

{
  "median_seconds_between_nudges": 1843.5,
  "zero_nudge_ratio": 0.4,
  "trend_slope_7d": 120.3,
  "sessions_analyzed": 10,
  "zero_nudge_sessions": 4,
  "daily_medians": [
    {"day_offset": 0, "median_gap_seconds": 2100.0},
    {"day_offset": 1, "median_gap_seconds": 1800.0}
  ]
}

trend_slope_7d is the OLS slope of daily median nudge gaps over 7 days — positive means the agent is handling more work between human check-ins.

Test plan

  • python3 -m pytest tests/test_autonomy_score.py -v → 18/18 pass (no server needed)
  • python3 -c 'import ast; ast.parse(open("routes/overview.py").read())' → clean
  • curl http://localhost:8900/api/autonomy-score returns the expected shape

Bot meta

Draft PR opened autonomously based on the plan in #688. Marked draft for human review — mark Ready for Review once happy.

Closes #688


Generated by Claude Code

Computes the north-star autonomy metric — how far apart human nudges
are across recent sessions — directly from existing JSONL session files.
No new dependencies, no schema changes.

Returns median_seconds_between_nudges, zero_nudge_ratio (sessions that
ran without any follow-up human message), a 7-day linear trend slope
(positive = autonomy improving), and a daily_medians sparkline series.

Includes 18 unit tests covering empty/missing dirs, zero-nudge sessions,
gap computation, the 7-day cutoff window, malformed JSON resilience, and
return-shape invariants.

Closes #688

Co-Authored-By: ClawMetry Autofix Bot <bot-autofix@clawmetry.dev>
@vivekchand
Copy link
Copy Markdown
Owner Author

Heads-up — main now has routes/autonomy.py with GET /api/autonomy that already serves issue #688's north-star autonomy score (Krentsel's nudge-spacing definition: score, trend_slope_7d, trend_direction, samples_7d, series_daily). This PR adds a parallel GET /api/autonomy-score with raw metrics (median_seconds_between_nudges, zero_nudge_ratio, daily_medians). Up to you whether to merge as complementary raw-metric endpoint or close as duplicative — leaving for your call. CI is green, mergeable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P1] Autonomy score — human-nudge spacing as north-star metric

1 participant