feat(overview): add /api/autonomy-score endpoint (#688)#893
Draft
vivekchand wants to merge 1 commit intomainfrom
Draft
feat(overview): add /api/autonomy-score endpoint (#688)#893vivekchand wants to merge 1 commit intomainfrom
vivekchand wants to merge 1 commit intomainfrom
Conversation
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>
Owner
Author
|
Heads-up — main now has |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-scoreendpoint that calls it, following the same pattern asapi_main_activity()andapi_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_7dis 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())'→ cleancurl http://localhost:8900/api/autonomy-scorereturns the expected shapeBot 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