Skip to content

Switch Copilot changelog monitor to GitHub Models workflow, align team-metrics docs with Direct API support, and implement team-metrics fallback strategy#375

Open
Copilot wants to merge 14 commits into
mainfrom
copilot/feat-support-team-level-metrics
Open

Switch Copilot changelog monitor to GitHub Models workflow, align team-metrics docs with Direct API support, and implement team-metrics fallback strategy#375
Copilot wants to merge 14 commits into
mainfrom
copilot/feat-support-team-level-metrics

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 18, 2026

GitHub now exposes team-level Copilot metrics inputs via API, and this repo now supports a fallback-aware team metrics strategy in both Direct API and historical modes. This PR updates automation, docs, and team metrics resolution behavior to reflect that reality.

  • Changelog monitoring automation (LLM-based)

    • Replaced the deterministic changelog monitor flow with a GitHub Models-driven workflow that analyzes the GitHub Changelog RSS feed and opens deduplicated repository issues for relevant updates.
    • Updated file:
      • .github/workflows/copilot-metrics-changelog-monitor.yml
    • Removed deterministic flow files:
      • .github/scripts/copilot-changelog-monitor.mjs
      • tests/copilot-changelog-monitor.spec.ts
    • Workflow now includes:
      • models: read permission
      • strict JSON parsing/validation of model output
      • bounded issue-pagination dedupe logic
      • configurable model token budget
  • Docs: remove outdated “team view requires DB mode” guidance

    • Updated README.md operating mode matrix and explanatory text to state that team-scoped views are available in Direct API mode (rolling window).
    • Updated DEPLOYMENT.md architecture and Docker Compose guidance with current behavior.
    • Removed the strategy analysis section from DEPLOYMENT.md to keep deployment docs focused.
  • Team metrics implementation updates (from review feedback)

    • Updated team metrics resolution to try team-scoped aggregate report data first, then fall back to team membership + user-day aggregation when team report data is empty or unavailable.
    • Applied this strategy to both historical and direct API team paths.
    • Updated report URL generation to propagate team_slug when requesting aggregate reports.
  • Regression coverage

    • Extended team-path regression coverage for direct-mode “team report first” behavior and fallback behavior:
      • tests/metrics-util-v2-team-path.spec.ts

Example workflow step introduced:

- name: Analyze changelog with GitHub Models and open issues
  env:
    GITHUB_TOKEN: ${{ github.token }}
    GITHUB_REPOSITORY: ${{ github.repository }}
    CHANGELOG_LOOKBACK_DAYS: '7'
    CHANGELOG_FEED_URL: 'https://github.blog/changelog/feed/'
    ISSUE_TITLE_PREFIX: 'Copilot metrics changelog update:'
    AI_MODEL: 'gpt-4o'
    MODEL_MAX_TOKENS: '4000'
  run: |
    # Node inline script:
    # - fetches changelog RSS
    # - calls GitHub Models for relevance classification
    # - parses strict JSON
    # - deduplicates against existing issues
    # - creates issues for new relevant updates

Copilot AI changed the title [WIP] Add support for team level copilot usage metrics in Direct API mode Add daily Copilot changelog issue monitor and align team-metrics docs with Direct API support May 18, 2026
Copilot AI requested a review from karpikpl May 18, 2026 15:03
@@ -0,0 +1,134 @@
import { resolve } from 'node:path';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I thought we can achieve it using running an agent in CI CD - is there a way to run agent from workflows?

because this is non-deterministic, agent should go to blog, read announcements and decide what to do.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good question. For this scheduled check, I kept a deterministic workflow/script path (commit 553b136) because there isn’t a stable first-class “run Copilot agent in Actions and auto-decide” pattern we can rely on here without introducing external LLM orchestration, extra secrets, and nondeterministic issue noise. If you want, I can add an opt-in workflow_dispatch experimental job that calls a model for triage while keeping the current deterministic daily guardrail.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot I think the deterministic doesn't make sense, I'd rather use github models. Is there a workflow permission that would allow it, or I need a PAT with that access?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot please work on this comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You can start with ${{ github.token }} (no PAT) for a workflow calling GitHub Models, as long as the job has the needed permission (typically models: read, plus any repo scopes like contents: read / issues: write you use). If org/repo policy denies model access for GITHUB_TOKEN, then use a fine-grained PAT secret with models:read. In this repo, the Models path is already validated against models:read tokens (current head: f335546). No UI changes here, so no screenshot is applicable.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot so make the change, remove files from deterministic flow, add a workflow that uses LLM to do it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Implemented in 0374913: removed the deterministic changelog monitor files and switched to an LLM-based workflow using GitHub Models (models: read permission) to analyze the changelog feed and open deduplicated issues. Also added bounded issue pagination and stricter model-output parsing/validation. No UI changes were made in this update, so screenshot is N/A.

Comment thread DEPLOYMENT.md
1. Downloading per-user daily metrics from the organization/enterprise endpoint
2. Resolving team membership via the GitHub Teams API
3. Filtering and aggregating per-user data in-memory for each team
This application computes team metrics by combining Copilot usage report data with team membership data, then aggregating results for the selected team.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this is wrong, I don't need this analysis as part of the Deployment.md - that should be part of the PR - comment so I can decide which route to go.

support for teams smaller than 5 people.
comparing teams
is it going to work with all team types? enterprise teams?

for those requests, should we try teams API first (depending on date rage), fallback to direct user calls if data is not there?

Make sure that with historical mode, user data is saved so we can query any team, any user for any data in the past

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done — I removed that analysis block from DEPLOYMENT.md in commit f335546.

Recommended route for implementation:

  • Support teams <5: keep fallback to Teams API + user-day usage aggregation, because user-teams-1-day can omit small teams.
  • Team comparison: yes, still works if both compared teams are materialized through the same fallback-aware membership resolution.
  • Team types: org teams are straightforward; enterprise teams should work when membership resolution handles enterprise endpoints and org overrides consistently.
  • Fetch order: for direct mode, try team report mapping first for the requested range, then fallback to Teams API membership + user-day report when team mapping is missing/incomplete.
  • Historical mode: keep persisting raw user-day records on sync so any team/user can be recomputed for any past date range later.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot start working on implementation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Implemented in commit 3c482e4: team-scoped metrics now try native team report data first, then fall back to team-membership + user-day aggregation when team report data is empty/unavailable (covers small/incomplete team mappings). Added regression tests for direct-mode preference and fallback behavior. No UI changes in this commit, so screenshot is N/A.

Copilot AI changed the title Add daily Copilot changelog issue monitor and align team-metrics docs with Direct API support Add daily Copilot changelog issue monitor, align team-metrics docs with Direct API support, and implement team-metrics fallback strategy May 20, 2026
Copilot AI changed the title Add daily Copilot changelog issue monitor, align team-metrics docs with Direct API support, and implement team-metrics fallback strategy Switch Copilot changelog monitor to GitHub Models workflow, align team-metrics docs with Direct API support, and implement team-metrics fallback strategy May 20, 2026
@karpikpl karpikpl added the deploy Deploys to preview env label May 27, 2026
@karpikpl karpikpl marked this pull request as ready for review May 27, 2026 04:40
@github-actions
Copy link
Copy Markdown
Contributor

🚀 Preview Deployment Ready

Preview URL: https://cmv-app.happyground-1e6ee49e.eastus2.azurecontainerapps.io

Deployed: PR #375 | 528d833 | 2026-05-27T04:44:34Z

This is a shared preview environment. It shows the latest deploy-labeled PR.
The environment will be cleaned up when the PR is merged.

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

Labels

deploy Deploys to preview env

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feat: Support Team level copilot usage metrics in Direct API mode

2 participants