Skip to content

[bug] usage analytics của skills hình như chưa hoạt động #181

Description

@mrgoonie

Context

Usage Event Analytics đã có dashboard/resource tabs cho tool, skill, mcp_tool, runtime_tool, và backend có path ghi usage events cho skill activation.

Tuy nhiên khi sử dụng skills thực tế, phần usage analytics của skills trên dashboard hình như không tăng số đếm. Điều này làm dashboard không phản ánh đúng mức độ sử dụng skill, khó biết skill nào đang được invoke nhiều, skill nào lỗi, và skill nào cần cải thiện.

Observed behavior

  • Kích hoạt/sử dụng skills nhưng dashboard Usage Analytics tab skill không thấy số đếm thay đổi.
  • Có cảm giác skill usage events không được ghi, không được rollup, hoặc frontend/API đang không query đúng dữ liệu.
  • Các tab khác như tool/runtime/MCP có thể vẫn hoạt động, nhưng skill analytics cần được kiểm tra riêng.

Expected behavior

Khi một skill được kích hoạt hoặc chạy qua các đường phổ biến, usage analytics phải ghi nhận được:

  • skill name/slug;
  • activation source, ví dụ use_skill, slash command, command invocation;
  • call count;
  • error count nếu có;
  • channel/agent/user/team context nếu có;
  • thời điểm/bucket để dashboard hiển thị theo range filter.

Dashboard Usage Analytics tab skill phải tăng số đếm sau khi skill được sử dụng và dữ liệu được refresh/rollup.

Places to inspect

Relevant areas found in current dev branch:

  • backend skill usage event paths:
    • internal/agent/usage_events.go
      • recordToolUsageEvent(...) maps canonical tool use_skill to UsageEventTypeSkillActivation and UsageResourceTypeSkill
      • recordSkillSlashUsageEvent(...) records slash-command skill activation
    • internal/tools/use_skill.go defines use_skill as observability marker
  • storage/rollup:
    • internal/store/pg/usage_event.go
    • internal/store/sqlitestore/usage_events.go
    • internal/tracing/snapshot_worker.go
  • API/UI:
    • /v1/usage/events/summary
    • /v1/usage/events/breakdown
    • /v1/usage/events/timeseries
    • ui/web/src/pages/usage/hooks/use-usage-event-analytics.ts
    • ui/web/src/pages/usage/components/usage-event-analytics-panel.tsx

Recent related work:

  • usage event analytics dashboard was added recently on dev.
  • skill self-evolution metrics also has a separate skill_usage_metrics path, so confirm dashboard is not accidentally expecting that table instead of usage_events.

Reproduction steps

  1. Start GoClaw on latest dev.
  2. Open Usage Analytics dashboard.
  3. Select the skill resource tab.
  4. Trigger a skill in a normal chat/session, for example via use_skill + reading the skill, or a slash skill command if available.
  5. Refresh dashboard after a reasonable delay / rollup interval.
  6. Observe whether skill call count changes.

Possible causes to verify

  • recordToolUsageEvent may not run for use_skill in some execution paths.
  • tracing.TraceIDFromContext(ctx) may be nil, causing early return and dropping the event.
  • Slash-command activation may use recordSkillSlashUsageEvent, but normal managed skill activation may not consistently pass through the same path.
  • use_skill tool may be hidden/special-cased in a way that does not generate the expected tool result event.
  • Usage events may be inserted, but hourly rollup/snapshot does not include the current bucket yet.
  • UI may only query rollup tables, while recent events are not visible until the next hourly aggregation.
  • resource_type=skill filtering may mismatch stored values.
  • There may be confusion between usage_events and skill_usage_metrics.

Acceptance criteria

  • Skill activation is recorded reliably for normal use_skill flows.
  • Skill activation is recorded reliably for slash-command skill flows.
  • Dashboard Usage Analytics tab skill shows updated counts for selected time range.
  • API endpoints return non-zero rows for skill usage after a skill is used:
    • GET /v1/usage/events/summary?resource_type=skill&...
    • GET /v1/usage/events/breakdown?resource_type=skill&group_by=resource&...
    • GET /v1/usage/events/timeseries?resource_type=skill&...
  • If rollup is intentionally delayed, dashboard should either:
    • include recent unrolled events, or
    • clearly communicate the delay so users do not think tracking is broken.
  • Tests cover both use_skill and slash-command skill activation.
  • Tests cover tenant isolation and channel/agent filters for skill events.
  • No double-counting when a skill is activated once.

Notes

This is likely a tracking/rollup/API/UI integration bug, not a request to redesign the analytics UI. The first goal is to make the existing skill usage counters trustworthy.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions