Spaces:
Chris4K
/
Paused

Aksel Joonas Reedi commited on
Commit
f9305f6
·
unverified ·
1 Parent(s): 72f615f

feat(kpis): per-tool counts, research engagement, surface split (#160)

Browse files

* feat(kpis): per-tool counts, research engagement, surface split

Adds intra-session telemetry to the KPI rollup so the observatory
dashboard can answer "is the agent reaching for research?" and
"which tools dropped out of the mix?". Production data (Apr 21->27,
21k+ sessions) shows the sessions-with-research rate dropped from
~78% on Apr 21 to ~56% on Apr 27 — without per-tool counts in the
rollup, that signal was invisible to the dashboard.

Also resolves the long-standing drift between this repo's
scripts/build_kpis.py and the observatory's backend/build_kpis.py
(both pipelines write to smolagents/ml-intern-kpis; whichever ran
last dropped the other's columns). The observatory copy was the
superset; this PR brings scripts/ up to it. Going forward both
copies are byte-identical.

Drift fix (incoming from observatory):
- cost_per_session_mean / _p50 / _p95
- tool_calls_total / _succeeded / _failed counts
- successful_sessions / errored_sessions / regenerated_sessions counts
- sandboxes_created / _cpu / _gpu
- pro_cta_by_source_json removed (was dropped by observatory; the
dashboard never charted it, so no consumer to break)

New fields (added in both copies via the parallel observatory PR):
- research_calls, sessions_with_research
- research_calls_per_session_p50/p95 (among sessions that did any)
- distinct_tools_per_session_p50/p95 (vocabulary breadth)
- tool_calls_per_session_p50/p95
- tool_calls_per_turn_p50/p95
- tool_calls_by_name_json, sessions_using_tool_json
- sessions_by_model_json (CLI/anthropic vs frontend/bedrock)

Per-tool counts come off tool_call events (data["tool"]) rather
than tool_output (success-only), so the existing tool_calls_total
counter is unchanged.

Tests: 6 new cases in tests/unit/test_build_kpis.py covering the
new private session fields, research-only-among-doers percentile,
breadth/intensity aggregates, and the model split. All 19 KPI +
scheduler tests pass.

The matching observatory commit is e78c2d7 — visualization PRs
(headline cell, "Research tool" / "Tool mix" / "Surface split"
sections) live there.

* fix(kpis): address review feedback

Three P1s and a P2 from automated review:

- Restore hf_jobs_blocked + pro_cta_clicks in _aggregate output.
_session_metrics still computed both, but the aggregate had silently
dropped them — dead computation and a schema regression vs the
original main schema. Cheap to keep; no consumer required.
- Filter zero-tool-call sessions out of distinct_tools_per_session and
tool_calls_per_session percentiles, matching the existing research
doer-only filter. Quiet hours full of status-check / abandoned
sessions otherwise drag every median to 0.
tool_calls_per_turn keeps its turns>0-only filter on purpose: a
5-turn session that did 0 tool calls is a meaningful 0 there.
- Update module docstring to list every aggregate column added in this
series (cost_per_session_*, tool_calls_succeeded/_failed, *_sessions
outcome counts, sandboxes_*).
- Drop the unreachable hardware-set check in sandbox classification:
"cpu-basic"/"cpu-upgrade" both start with "cpu-", so the disjunction
was dead. Simplified to a startswith check.

Two new tests:
- test_breadth_intensity_percentiles_exclude_zero_tool_sessions locks
in the doer-only filter so it can't silently regress.
- test_pro_clicks_and_blocked_jobs_in_aggregate guards the restored
aggregate columns.

Matching observatory commit lands its mirror of build_kpis.py.

2 files changed +262 -24
Files changed (2)
scripts/build_kpis.py+133-16
tests/unit/test_build_kpis.py+129-8