Skip to content

feat(weave): feedback stats query#6261

Open
bcsherma wants to merge 1 commit intomasterfrom
feedback-stats
Open

feat(weave): feedback stats query#6261
bcsherma wants to merge 1 commit intomasterfrom
feedback-stats

Conversation

@bcsherma
Copy link
Member

@bcsherma bcsherma commented Mar 4, 2026

Description

This PR adds a feedback analytics API so clients can compute aggregate score data across very large sets of calls without reading individual feedback rows.

It introduces two new endpoints:

  • feedback_stats, which returns time-binned aggregates from the feedback table plus full-window summary stats
  • feedback_payload_schema, which discovers aggregate-able payload paths and inferred value types from sampled feedback rows

The new APIs support filtering by:

  • feedback_type, which effectively scopes results to a scorer/scorer type
  • trigger_ref, which is the ref for the monitor that triggered the score

Implementation details:

  • adds new request/response interfaces for feedback stats and schema discovery
  • adds ClickHouse query builders for bucketed stats and window-level aggregates over feedback payload fields
  • adds schema discovery logic for feedback payloads so the UI/client can discover which fields are available to chart
  • wires the new APIs through the ClickHouse trace server, remote HTTP bindings, and the external-to-internal adapter
  • explicitly leaves SQLite feedback stats unsupported for now, while returning an empty schema result there

This also keeps the clickhouse_trace_server_batched.py diff small by moving the feedback stats orchestration into a dedicated helper module while leaving the SQL generation in focused helper files.

Testing

  • Added targeted coverage in tests/trace_server/query_builder/test_feedback_stats.py with strict assertions on the generated sql, see tests for a clear picture of the queries we run.

Copy link
Member Author

bcsherma commented Mar 4, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@wandbot-3000
Copy link

wandbot-3000 bot commented Mar 4, 2026

@bcsherma bcsherma force-pushed the feedback-stats branch 3 times, most recently from f800a99 to e65038b Compare March 5, 2026 22:10
@bcsherma bcsherma marked this pull request as ready for review March 6, 2026 00:56
@bcsherma bcsherma requested a review from a team as a code owner March 6, 2026 00:56
Comment on lines +30 to +31
class _ClickHouseFeedbackStatsServer(Protocol):
def _query(self, sql: str, parameters: dict[str, Any]) -> Any: ...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary? Why not use the real interface?


pb = ParamBuilder()
query_result = build_feedback_stats_query(req, pb)
result = server._query(query_result.sql, query_result.parameters)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be calling a private method? Should the method be made public?

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.

2 participants