diff --git a/.github/workflows/copilot-token-audit.lock.yml b/.github/workflows/copilot-token-audit.lock.yml index 5c7b2f62f9..9845d0b520 100644 --- a/.github/workflows/copilot-token-audit.lock.yml +++ b/.github/workflows/copilot-token-audit.lock.yml @@ -1,4 +1,4 @@ -# gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"8be38532535c0e76fcb3a774385ee6fc1cd2b69498e8b3031bb63eb753f69b03","strict":true,"agent_id":"copilot"} +# gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"467577d5171eeab646a24dee35465fba5737a7b032d2b5838b87e598bed1ed3f","strict":true,"agent_id":"copilot"} # gh-aw-manifest: {"version":1,"secrets":["GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GH_AW_OTEL_ENDPOINT","GH_AW_OTEL_HEADERS","GITHUB_TOKEN"],"actions":[{"repo":"actions/checkout","sha":"de0fac2e4500dabe0009e67214ff5f5447ce83dd","version":"v6.0.2"},{"repo":"actions/download-artifact","sha":"3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c","version":"v8.0.1"},{"repo":"actions/github-script","sha":"3a2844b7e9c422d3c10d287c895573f7108da1b3","version":"v9"},{"repo":"actions/setup-go","sha":"4a3601121dd01d1626a1e23e37211e3254c1c06c","version":"v6.4.0"},{"repo":"actions/setup-node","sha":"48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e","version":"v6.4.0"},{"repo":"actions/setup-python","sha":"a309ff8b426b58ec0e2a45f0f869d46889d02405","version":"v6.2.0"},{"repo":"actions/upload-artifact","sha":"043fb46d1a93c77aae656e7c1c64a875d1fc6a0a","version":"v7.0.1"},{"repo":"docker/build-push-action","sha":"bcafcacb16a39f128d818304e6c9c0c18556b85f","version":"v7.1.0"},{"repo":"docker/setup-buildx-action","sha":"4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd","version":"v4.0.0"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.25.41"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.25.41"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.25.41"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.3.6","digest":"sha256:2bb8eef86006a4c5963c55616a9c51c32f27bfdecb023b8aa6f91f6718d9171c","pinned_image":"ghcr.io/github/gh-aw-mcpg:v0.3.6@sha256:2bb8eef86006a4c5963c55616a9c51c32f27bfdecb023b8aa6f91f6718d9171c"},{"image":"ghcr.io/github/github-mcp-server:v1.0.3","digest":"sha256:2ac27ef03461ef2b877031b838a7d1fd7f12b12d4ace7796d8cad91446d55959","pinned_image":"ghcr.io/github/github-mcp-server:v1.0.3@sha256:2ac27ef03461ef2b877031b838a7d1fd7f12b12d4ace7796d8cad91446d55959"},{"image":"node:lts-alpine","digest":"sha256:d1b3b4da11eefd5941e7f0b9cf17783fc99d9c6fc34884a665f40a06dbdfc94f","pinned_image":"node:lts-alpine@sha256:d1b3b4da11eefd5941e7f0b9cf17783fc99d9c6fc34884a665f40a06dbdfc94f"}]} # ___ _ _ # / _ \ | | (_) @@ -16,7 +16,7 @@ # # This file was automatically generated by gh-aw. DO NOT EDIT. # -# To update this file, edit the corresponding .md file and run: +# To update this file, edit githubnext/agentic-ops/workflows/copilot-token-audit.md@c780d8324935fe1fb30fce545832c10a8f904039 and run: # gh aw compile # Not all edits will cause changes to this file. # @@ -24,6 +24,8 @@ # # Daily audit of Copilot token usage across all agentic workflows with historical trend tracking # +# Source: githubnext/agentic-ops/workflows/copilot-token-audit.md@c780d8324935fe1fb30fce545832c10a8f904039 +# # Secrets used: # - GH_AW_GITHUB_MCP_SERVER_TOKEN # - GH_AW_GITHUB_TOKEN @@ -74,6 +76,7 @@ run-name: "Daily Copilot Token Usage Audit" env: OTEL_EXPORTER_OTLP_ENDPOINT: ${{ secrets.GH_AW_OTEL_ENDPOINT }} OTEL_SERVICE_NAME: gh-aw + COPILOT_OTEL_FILE_EXPORTER_PATH: /tmp/gh-aw/copilot-otel.jsonl OTEL_EXPORTER_OTLP_HEADERS: ${{ secrets.GH_AW_OTEL_HEADERS }} GH_AW_OTLP_ENDPOINTS: '[{"url":"${{ secrets.GH_AW_OTEL_ENDPOINT }}","headers":"${{ secrets.GH_AW_OTEL_HEADERS }}"}]' @@ -187,24 +190,24 @@ jobs: run: | bash "${RUNNER_TEMP}/gh-aw/actions/create_prompt_first.sh" { - cat << 'GH_AW_PROMPT_09726b0da643185a_EOF' + cat << 'GH_AW_PROMPT_ea7b82c9b6db7357_EOF' - GH_AW_PROMPT_09726b0da643185a_EOF + GH_AW_PROMPT_ea7b82c9b6db7357_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/xpia.md" cat "${RUNNER_TEMP}/gh-aw/prompts/temp_folder_prompt.md" cat "${RUNNER_TEMP}/gh-aw/prompts/markdown.md" cat "${RUNNER_TEMP}/gh-aw/prompts/agentic_workflows_guide.md" cat "${RUNNER_TEMP}/gh-aw/prompts/repo_memory_prompt.md" cat "${RUNNER_TEMP}/gh-aw/prompts/safe_outputs_prompt.md" - cat << 'GH_AW_PROMPT_09726b0da643185a_EOF' + cat << 'GH_AW_PROMPT_ea7b82c9b6db7357_EOF' - Tools: create_discussion, upload_asset(max:5), missing_tool, missing_data, noop + Tools: create_issue, upload_asset(max:5), missing_tool, missing_data, noop upload_asset: provide a file path; returns a URL; assets are published after the workflow completes (safeoutputs). - GH_AW_PROMPT_09726b0da643185a_EOF + GH_AW_PROMPT_ea7b82c9b6db7357_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/mcp_cli_tools_prompt.md" - cat << 'GH_AW_PROMPT_09726b0da643185a_EOF' + cat << 'GH_AW_PROMPT_ea7b82c9b6db7357_EOF' The following GitHub context information is available for this workflow: {{#if __GH_AW_GITHUB_ACTOR__ }} @@ -233,12 +236,12 @@ jobs: {{/if}} - GH_AW_PROMPT_09726b0da643185a_EOF + GH_AW_PROMPT_ea7b82c9b6db7357_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/github_mcp_tools_with_safeoutputs_prompt.md" - cat << 'GH_AW_PROMPT_09726b0da643185a_EOF' + cat << 'GH_AW_PROMPT_ea7b82c9b6db7357_EOF' {{#runtime-import .github/workflows/copilot-token-audit.md}} - GH_AW_PROMPT_09726b0da643185a_EOF + GH_AW_PROMPT_ea7b82c9b6db7357_EOF } > "$GH_AW_PROMPT" - name: Interpolate variables and render templates uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 @@ -539,15 +542,15 @@ jobs: mkdir -p "${RUNNER_TEMP}/gh-aw/safeoutputs" mkdir -p /tmp/gh-aw/safeoutputs mkdir -p /tmp/gh-aw/mcp-logs/safeoutputs - cat > "${RUNNER_TEMP}/gh-aw/safeoutputs/config.json" << GH_AW_SAFE_OUTPUTS_CONFIG_0a50ca827976ca43_EOF - {"create_discussion":{"category":"audits","close_older_discussions":true,"expires":72,"fallback_to_issue":true,"max":1,"title_prefix":"[copilot-token-audit] "},"create_report_incomplete_issue":{},"missing_data":{},"missing_tool":{},"noop":{"max":1,"report-as-issue":"true"},"push_repo_memory":{"memories":[{"dir":"/tmp/gh-aw/repo-memory/default","id":"default","max_file_count":100,"max_file_size":102400,"max_patch_size":51200}]},"report_incomplete":{},"upload_asset":{"allowed-exts":[".png",".jpg",".jpeg",".svg"],"branch":"assets/${GITHUB_WORKFLOW}","max":5,"max-size":10240}} - GH_AW_SAFE_OUTPUTS_CONFIG_0a50ca827976ca43_EOF + cat > "${RUNNER_TEMP}/gh-aw/safeoutputs/config.json" << GH_AW_SAFE_OUTPUTS_CONFIG_e8fefb804a755680_EOF + {"create_issue":{"close_older_issues":true,"expires":72,"max":1,"title_prefix":"[copilot-token-audit] "},"create_report_incomplete_issue":{},"missing_data":{},"missing_tool":{},"noop":{"max":1,"report-as-issue":"true"},"push_repo_memory":{"memories":[{"dir":"/tmp/gh-aw/repo-memory/default","id":"default","max_file_count":100,"max_file_size":102400,"max_patch_size":51200}]},"report_incomplete":{},"upload_asset":{"allowed-exts":[".png",".jpg",".jpeg",".svg"],"branch":"assets/${GITHUB_WORKFLOW}","max":5,"max-size":10240}} + GH_AW_SAFE_OUTPUTS_CONFIG_e8fefb804a755680_EOF - name: Generate Safe Outputs Tools env: GH_AW_TOOLS_META_JSON: | { "description_suffixes": { - "create_discussion": " CONSTRAINTS: Maximum 1 discussion(s) can be created. Title will be prefixed with \"[copilot-token-audit] \". Discussions will be created in category \"audits\".", + "create_issue": " CONSTRAINTS: Maximum 1 issue(s) can be created. Title will be prefixed with \"[copilot-token-audit] \".", "upload_asset": " CONSTRAINTS: Maximum 5 asset(s) can be uploaded. Maximum file size: 10240KB. Allowed file extensions: [.png .jpg .jpeg .svg]." }, "repo_params": {}, @@ -555,7 +558,7 @@ jobs: } GH_AW_VALIDATION_JSON: | { - "create_discussion": { + "create_issue": { "defaultMax": 1, "fields": { "body": { @@ -564,15 +567,22 @@ jobs: "sanitize": true, "maxLength": 65000 }, - "category": { - "type": "string", - "sanitize": true, - "maxLength": 128 + "labels": { + "type": "array", + "itemType": "string", + "itemSanitize": true, + "itemMaxLength": 128 + }, + "parent": { + "issueOrPRNumber": true }, "repo": { "type": "string", "maxLength": 256 }, + "temporary_id": { + "type": "string" + }, "title": { "required": true, "type": "string", @@ -748,7 +758,7 @@ jobs: mkdir -p /home/runner/.copilot GH_AW_NODE=$(which node 2>/dev/null || command -v node 2>/dev/null || echo node) - cat << GH_AW_MCP_CONFIG_ab3de58a3e571516_EOF | "$GH_AW_NODE" "${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.cjs" + cat << GH_AW_MCP_CONFIG_127afb9acd60d2b6_EOF | "$GH_AW_NODE" "${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.cjs" { "mcpServers": { "agenticworkflows": { @@ -814,7 +824,7 @@ jobs: } } } - GH_AW_MCP_CONFIG_ab3de58a3e571516_EOF + GH_AW_MCP_CONFIG_127afb9acd60d2b6_EOF - name: Mount MCP servers as CLIs id: mount-mcp-clis continue-on-error: true @@ -1060,6 +1070,7 @@ jobs: /tmp/gh-aw/agent/ /tmp/gh-aw/github_rate_limits.jsonl /tmp/gh-aw/otel.jsonl + /tmp/gh-aw/copilot-otel.jsonl /tmp/gh-aw/safeoutputs.jsonl /tmp/gh-aw/agent_output.json /tmp/gh-aw/aw-*.patch @@ -1084,7 +1095,6 @@ jobs: runs-on: ubuntu-slim permissions: contents: read - discussions: write issues: write concurrency: group: "gh-aw-conclusion-copilot-token-audit" @@ -1134,6 +1144,8 @@ jobs: GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }} GH_AW_NOOP_MAX: "1" GH_AW_WORKFLOW_NAME: "Daily Copilot Token Usage Audit" + GH_AW_WORKFLOW_SOURCE: "githubnext/agentic-ops/workflows/copilot-token-audit.md@c780d8324935fe1fb30fce545832c10a8f904039" + GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/githubnext/agentic-ops/blob/c780d8324935fe1fb30fce545832c10a8f904039/workflows/copilot-token-audit.md" GH_AW_TRACKER_ID: "copilot-token-audit" GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} GH_AW_AGENT_CONCLUSION: ${{ needs.agent.result }} @@ -1151,6 +1163,8 @@ jobs: env: GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }} GH_AW_WORKFLOW_NAME: "Daily Copilot Token Usage Audit" + GH_AW_WORKFLOW_SOURCE: "githubnext/agentic-ops/workflows/copilot-token-audit.md@c780d8324935fe1fb30fce545832c10a8f904039" + GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/githubnext/agentic-ops/blob/c780d8324935fe1fb30fce545832c10a8f904039/workflows/copilot-token-audit.md" GH_AW_TRACKER_ID: "copilot-token-audit" GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} GH_AW_DETECTION_CONCLUSION: ${{ needs.detection.outputs.detection_conclusion }} @@ -1169,6 +1183,8 @@ jobs: GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }} GH_AW_MISSING_TOOL_CREATE_ISSUE: "true" GH_AW_WORKFLOW_NAME: "Daily Copilot Token Usage Audit" + GH_AW_WORKFLOW_SOURCE: "githubnext/agentic-ops/workflows/copilot-token-audit.md@c780d8324935fe1fb30fce545832c10a8f904039" + GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/githubnext/agentic-ops/blob/c780d8324935fe1fb30fce545832c10a8f904039/workflows/copilot-token-audit.md" GH_AW_TRACKER_ID: "copilot-token-audit" with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} @@ -1184,6 +1200,8 @@ jobs: GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }} GH_AW_REPORT_INCOMPLETE_CREATE_ISSUE: "true" GH_AW_WORKFLOW_NAME: "Daily Copilot Token Usage Audit" + GH_AW_WORKFLOW_SOURCE: "githubnext/agentic-ops/workflows/copilot-token-audit.md@c780d8324935fe1fb30fce545832c10a8f904039" + GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/githubnext/agentic-ops/blob/c780d8324935fe1fb30fce545832c10a8f904039/workflows/copilot-token-audit.md" GH_AW_TRACKER_ID: "copilot-token-audit" with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} @@ -1199,6 +1217,8 @@ jobs: env: GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }} GH_AW_WORKFLOW_NAME: "Daily Copilot Token Usage Audit" + GH_AW_WORKFLOW_SOURCE: "githubnext/agentic-ops/workflows/copilot-token-audit.md@c780d8324935fe1fb30fce545832c10a8f904039" + GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/githubnext/agentic-ops/blob/c780d8324935fe1fb30fce545832c10a8f904039/workflows/copilot-token-audit.md" GH_AW_TRACKER_ID: "copilot-token-audit" GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} GH_AW_AGENT_CONCLUSION: ${{ needs.agent.result }} @@ -1211,8 +1231,6 @@ jobs: GH_AW_AGENTIC_ENGINE_TIMEOUT: ${{ needs.agent.outputs.agentic_engine_timeout }} GH_AW_MODEL_NOT_SUPPORTED_ERROR: ${{ needs.agent.outputs.model_not_supported_error }} GH_AW_ENGINE_API_HOSTS: "api.enterprise.githubcopilot.com,api.githubcopilot.com,api.business.githubcopilot.com,api.individual.githubcopilot.com" - GH_AW_CREATE_DISCUSSION_ERRORS: ${{ needs.safe_outputs.outputs.create_discussion_errors }} - GH_AW_CREATE_DISCUSSION_ERROR_COUNT: ${{ needs.safe_outputs.outputs.create_discussion_error_count }} GH_AW_LOCKDOWN_CHECK_FAILED: ${{ needs.activation.outputs.lockdown_check_failed }} GH_AW_STALE_LOCK_FILE_FAILED: ${{ needs.activation.outputs.stale_lock_file_failed }} GH_AW_PUSH_REPO_MEMORY_RESULT: ${{ needs.push_repo_memory.result }} @@ -1533,7 +1551,6 @@ jobs: runs-on: ubuntu-slim permissions: contents: read - discussions: write issues: write timeout-minutes: 15 env: @@ -1547,11 +1564,15 @@ jobs: GH_AW_TRACKER_ID: "copilot-token-audit" GH_AW_WORKFLOW_ID: "copilot-token-audit" GH_AW_WORKFLOW_NAME: "Daily Copilot Token Usage Audit" + GH_AW_WORKFLOW_SOURCE: "githubnext/agentic-ops/workflows/copilot-token-audit.md@c780d8324935fe1fb30fce545832c10a8f904039" + GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/githubnext/agentic-ops/blob/c780d8324935fe1fb30fce545832c10a8f904039/workflows/copilot-token-audit.md" outputs: code_push_failure_count: ${{ steps.process_safe_outputs.outputs.code_push_failure_count }} code_push_failure_errors: ${{ steps.process_safe_outputs.outputs.code_push_failure_errors }} create_discussion_error_count: ${{ steps.process_safe_outputs.outputs.create_discussion_error_count }} create_discussion_errors: ${{ steps.process_safe_outputs.outputs.create_discussion_errors }} + created_issue_number: ${{ steps.process_safe_outputs.outputs.created_issue_number }} + created_issue_url: ${{ steps.process_safe_outputs.outputs.created_issue_url }} process_safe_outputs_processed_count: ${{ steps.process_safe_outputs.outputs.processed_count }} process_safe_outputs_temporary_id_map: ${{ steps.process_safe_outputs.outputs.temporary_id_map }} steps: @@ -1606,7 +1627,7 @@ jobs: GH_AW_ALLOWED_DOMAINS: "api.business.githubcopilot.com,api.enterprise.githubcopilot.com,api.github.com,api.githubcopilot.com,api.individual.githubcopilot.com,api.snapcraft.io,archive.ubuntu.com,azure.archive.ubuntu.com,crl.geotrust.com,crl.globalsign.com,crl.identrust.com,crl.sectigo.com,crl.thawte.com,crl.usertrust.com,crl.verisign.com,crl3.digicert.com,crl4.digicert.com,crls.ssl.com,github.com,host.docker.internal,json-schema.org,json.schemastore.org,keyserver.ubuntu.com,ocsp.digicert.com,ocsp.geotrust.com,ocsp.globalsign.com,ocsp.identrust.com,ocsp.sectigo.com,ocsp.ssl.com,ocsp.thawte.com,ocsp.usertrust.com,ocsp.verisign.com,packagecloud.io,packages.cloud.google.com,packages.microsoft.com,ppa.launchpad.net,raw.githubusercontent.com,registry.npmjs.org,s.symcb.com,s.symcd.com,security.ubuntu.com,telemetry.enterprise.githubcopilot.com,ts-crl.ws.symantec.com,ts-ocsp.ws.symantec.com,www.googleapis.com" GITHUB_SERVER_URL: ${{ github.server_url }} GITHUB_API_URL: ${{ github.api_url }} - GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG: "{\"create_discussion\":{\"category\":\"audits\",\"close_older_discussions\":true,\"expires\":72,\"fallback_to_issue\":true,\"max\":1,\"title_prefix\":\"[copilot-token-audit] \"},\"create_report_incomplete_issue\":{},\"missing_data\":{},\"missing_tool\":{},\"noop\":{\"max\":1,\"report-as-issue\":\"true\"},\"report_incomplete\":{},\"upload_asset\":{\"allowed-exts\":[\".png\",\".jpg\",\".jpeg\",\".svg\"],\"branch\":\"assets/${{ github.workflow }}\",\"max\":5,\"max-size\":10240}}" + GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG: "{\"create_issue\":{\"close_older_issues\":true,\"expires\":72,\"max\":1,\"title_prefix\":\"[copilot-token-audit] \"},\"create_report_incomplete_issue\":{},\"missing_data\":{},\"missing_tool\":{},\"noop\":{\"max\":1,\"report-as-issue\":\"true\"},\"report_incomplete\":{},\"upload_asset\":{\"allowed-exts\":[\".png\",\".jpg\",\".jpeg\",\".svg\"],\"branch\":\"assets/${{ github.workflow }}\",\"max\":5,\"max-size\":10240}}" with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | @@ -1707,6 +1728,8 @@ jobs: GH_AW_ASSETS_MAX_SIZE_KB: 10240 GH_AW_ASSETS_ALLOWED_EXTS: ".png,.jpg,.jpeg,.svg" GH_AW_WORKFLOW_NAME: "Daily Copilot Token Usage Audit" + GH_AW_WORKFLOW_SOURCE: "githubnext/agentic-ops/workflows/copilot-token-audit.md@c780d8324935fe1fb30fce545832c10a8f904039" + GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/githubnext/agentic-ops/blob/c780d8324935fe1fb30fce545832c10a8f904039/workflows/copilot-token-audit.md" GH_AW_TRACKER_ID: "copilot-token-audit" GH_AW_ENGINE_ID: "copilot" GH_AW_ENGINE_VERSION: "1.0.40" diff --git a/.github/workflows/copilot-token-audit.md b/.github/workflows/copilot-token-audit.md index cfb5728c9b..9d0cff1c9f 100644 --- a/.github/workflows/copilot-token-audit.md +++ b/.github/workflows/copilot-token-audit.md @@ -16,12 +16,11 @@ observability: tracker-id: copilot-token-audit engine: copilot safe-outputs: - create-discussion: + create-issue: expires: 3d - category: "audits" title-prefix: "[copilot-token-audit] " max: 1 - close-older-discussions: true + close-older-issues: true upload-asset: max: 5 allowed-exts: [.png, .jpg, .jpeg, .svg] @@ -80,6 +79,7 @@ steps: timeout-minutes: 25 features: copilot-requests: true +source: githubnext/agentic-ops/workflows/copilot-token-audit.md@c780d8324935fe1fb30fce545832c10a8f904039 --- # Daily Copilot Token Usage Audit @@ -90,7 +90,7 @@ You are the Copilot Token Auditor — a workflow that tracks daily token consump 1. Parse the pre-downloaded Copilot workflow logs and compute per-workflow token usage metrics. 2. Persist today's snapshot to repo-memory so the optimizer (and future runs of this audit) can read historical data. -3. Publish a concise audit discussion summarizing today's usage, trends, and cost highlights. +3. Publish a concise audit issue summarizing today's usage, trends, and cost highlights. ## Data Sources @@ -189,7 +189,7 @@ Do not append a synthetic zero-valued entry to `rolling-summary.json` when eithe - the raw `.runs` array is empty - the raw `.runs` array is non-empty but there are zero completed runs in the current window -Report those two cases differently in the discussion as described below so the empty-window diagnosis stays precise while the historical trend remains unchanged. +Report those two cases differently in the issue as described below so the empty-window diagnosis stays precise while the historical trend remains unchanged. ## Phase 3 — Generate Charts @@ -204,19 +204,19 @@ Chart requirements: - Use 300 DPI and a white background. - Add clear axis labels and titles. - Save only PNG files. -- If there are fewer than 2 rolling-summary points, skip the trend chart and explain why in the discussion. +- If there are fewer than 2 rolling-summary points, skip the trend chart and explain why in the issue. - After generating each chart, call `upload_asset` with its file path. -- In the discussion template below, replace `UPLOAD_URL_WORKFLOW_PLACEHOLDER` with the URL returned for `token_by_workflow.png`. -- In the discussion template below, replace `UPLOAD_URL_TREND_PLACEHOLDER` with the URL returned for `token_trend.png`. +- In the issue template below, replace `UPLOAD_URL_WORKFLOW_PLACEHOLDER` with the URL returned for `token_by_workflow.png`. +- In the issue template below, replace `UPLOAD_URL_TREND_PLACEHOLDER` with the URL returned for `token_trend.png`. - If a chart is skipped, omit that image markdown line entirely instead of leaving a placeholder behind. -## Phase 4 — Publish Audit Discussion +## Phase 4 — Publish Audit Issue -Create a discussion with these sections: +Create an issue with these sections: ### Formatting Requirements -- Use `###` for main sections and `####` for subsections inside the discussion body. +- Use `###` for main sections and `####` for subsections inside the issue body. - Keep the executive summary and final observations visible without collapsible sections. - Put verbose tables or supporting detail inside `
...` blocks. - If you cite specific workflow runs, format them as links like `[§12345](https://github.com/${{ github.repository }}/actions/runs/12345)` and include up to 3 under `**References:**`. @@ -268,14 +268,14 @@ Summarize token and cost changes from `rolling-summary.json` when historical dat ## Important Notes - Use `// 0` (null coalescing) in jq and `.get(field, 0)` in Python for nullable numeric fields. -- Distinguish between these two cases in the discussion: +- Distinguish between these two cases in the issue: - the raw `.runs` array is empty - the raw `.runs` array is non-empty but none of the runs are `status == "completed"` - Report those cases differently: - if `len(runs) == 0` (or `jq '.runs | length' == 0`), say the collection window returned no runs - if `len(runs) > 0` and there are zero completed runs, say the collection window had runs but none completed yet - Do not claim the raw log file was empty unless you verified `len(runs) == 0` (or `jq '.runs | length' == 0`). -- Keep the discussion concise — the optimizer workflow will do the deep analysis. +- Keep the issue concise — the optimizer workflow will do the deep analysis. ## Experiment OTEL Span Attributes diff --git a/.github/workflows/copilot-token-optimizer.lock.yml b/.github/workflows/copilot-token-optimizer.lock.yml index be81961ee9..54f7881a32 100644 --- a/.github/workflows/copilot-token-optimizer.lock.yml +++ b/.github/workflows/copilot-token-optimizer.lock.yml @@ -1,4 +1,4 @@ -# gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"9d01169949a866a476d4e166b66e32901f4050b164f6f72a4b633a12de28de16","strict":true,"agent_id":"copilot"} +# gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"30693633e609808269a671dd875897ba024114d02ee0ceded2ca578f33bfca8b","strict":true,"agent_id":"copilot"} # gh-aw-manifest: {"version":1,"secrets":["COPILOT_GITHUB_TOKEN","GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GITHUB_TOKEN"],"actions":[{"repo":"actions/checkout","sha":"de0fac2e4500dabe0009e67214ff5f5447ce83dd","version":"v6.0.2"},{"repo":"actions/download-artifact","sha":"3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c","version":"v8.0.1"},{"repo":"actions/github-script","sha":"3a2844b7e9c422d3c10d287c895573f7108da1b3","version":"v9"},{"repo":"actions/upload-artifact","sha":"043fb46d1a93c77aae656e7c1c64a875d1fc6a0a","version":"v7.0.1"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.25.41"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.25.41"},{"image":"ghcr.io/github/gh-aw-firewall/cli-proxy:0.25.41"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.25.41"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.3.6","digest":"sha256:2bb8eef86006a4c5963c55616a9c51c32f27bfdecb023b8aa6f91f6718d9171c","pinned_image":"ghcr.io/github/gh-aw-mcpg:v0.3.6@sha256:2bb8eef86006a4c5963c55616a9c51c32f27bfdecb023b8aa6f91f6718d9171c"},{"image":"ghcr.io/github/github-mcp-server:v1.0.3","digest":"sha256:2ac27ef03461ef2b877031b838a7d1fd7f12b12d4ace7796d8cad91446d55959","pinned_image":"ghcr.io/github/github-mcp-server:v1.0.3@sha256:2ac27ef03461ef2b877031b838a7d1fd7f12b12d4ace7796d8cad91446d55959"},{"image":"node:lts-alpine","digest":"sha256:d1b3b4da11eefd5941e7f0b9cf17783fc99d9c6fc34884a665f40a06dbdfc94f","pinned_image":"node:lts-alpine@sha256:d1b3b4da11eefd5941e7f0b9cf17783fc99d9c6fc34884a665f40a06dbdfc94f"}]} # ___ _ _ # / _ \ | | (_) @@ -16,7 +16,7 @@ # # This file was automatically generated by gh-aw. DO NOT EDIT. # -# To update this file, edit the corresponding .md file and run: +# To update this file, edit githubnext/agentic-ops/workflows/copilot-token-optimizer.md@c780d8324935fe1fb30fce545832c10a8f904039 and run: # gh aw compile # Not all edits will cause changes to this file. # @@ -24,6 +24,8 @@ # # Daily optimizer that identifies a high-token-usage Copilot workflow, audits its runs, and recommends efficiency improvements # +# Source: githubnext/agentic-ops/workflows/copilot-token-optimizer.md@c780d8324935fe1fb30fce545832c10a8f904039 +# # Secrets used: # - COPILOT_GITHUB_TOKEN # - GH_AW_GITHUB_MCP_SERVER_TOKEN @@ -180,21 +182,21 @@ jobs: run: | bash "${RUNNER_TEMP}/gh-aw/actions/create_prompt_first.sh" { - cat << 'GH_AW_PROMPT_404f8342621716f3_EOF' + cat << 'GH_AW_PROMPT_f798ecc76f107cda_EOF' - GH_AW_PROMPT_404f8342621716f3_EOF + GH_AW_PROMPT_f798ecc76f107cda_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/xpia.md" cat "${RUNNER_TEMP}/gh-aw/prompts/temp_folder_prompt.md" cat "${RUNNER_TEMP}/gh-aw/prompts/markdown.md" cat "${RUNNER_TEMP}/gh-aw/prompts/repo_memory_prompt.md" cat "${RUNNER_TEMP}/gh-aw/prompts/safe_outputs_prompt.md" - cat << 'GH_AW_PROMPT_404f8342621716f3_EOF' + cat << 'GH_AW_PROMPT_f798ecc76f107cda_EOF' Tools: create_issue, missing_tool, missing_data, noop - GH_AW_PROMPT_404f8342621716f3_EOF + GH_AW_PROMPT_f798ecc76f107cda_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/mcp_cli_tools_prompt.md" - cat << 'GH_AW_PROMPT_404f8342621716f3_EOF' + cat << 'GH_AW_PROMPT_f798ecc76f107cda_EOF' The following GitHub context information is available for this workflow: {{#if __GH_AW_GITHUB_ACTOR__ }} @@ -223,12 +225,12 @@ jobs: {{/if}} - GH_AW_PROMPT_404f8342621716f3_EOF + GH_AW_PROMPT_f798ecc76f107cda_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/cli_proxy_with_safeoutputs_prompt.md" - cat << 'GH_AW_PROMPT_404f8342621716f3_EOF' + cat << 'GH_AW_PROMPT_f798ecc76f107cda_EOF' {{#runtime-import .github/workflows/copilot-token-optimizer.md}} - GH_AW_PROMPT_404f8342621716f3_EOF + GH_AW_PROMPT_f798ecc76f107cda_EOF } > "$GH_AW_PROMPT" - name: Interpolate variables and render templates uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 @@ -461,9 +463,9 @@ jobs: mkdir -p "${RUNNER_TEMP}/gh-aw/safeoutputs" mkdir -p /tmp/gh-aw/safeoutputs mkdir -p /tmp/gh-aw/mcp-logs/safeoutputs - cat > "${RUNNER_TEMP}/gh-aw/safeoutputs/config.json" << 'GH_AW_SAFE_OUTPUTS_CONFIG_aa3b2bd0bfb870d0_EOF' + cat > "${RUNNER_TEMP}/gh-aw/safeoutputs/config.json" << 'GH_AW_SAFE_OUTPUTS_CONFIG_18cbf72a63269c0e_EOF' {"create_issue":{"close_older_issues":true,"expires":168,"max":1,"title_prefix":"[copilot-token-optimizer] "},"create_report_incomplete_issue":{},"missing_data":{},"missing_tool":{},"noop":{"max":1,"report-as-issue":"true"},"push_repo_memory":{"memories":[{"dir":"/tmp/gh-aw/repo-memory/default","id":"default","max_file_count":100,"max_file_size":102400,"max_patch_size":51200}]},"report_incomplete":{}} - GH_AW_SAFE_OUTPUTS_CONFIG_aa3b2bd0bfb870d0_EOF + GH_AW_SAFE_OUTPUTS_CONFIG_18cbf72a63269c0e_EOF - name: Generate Safe Outputs Tools env: GH_AW_TOOLS_META_JSON: | @@ -660,7 +662,7 @@ jobs: mkdir -p /home/runner/.copilot GH_AW_NODE=$(which node 2>/dev/null || command -v node 2>/dev/null || echo node) - cat << GH_AW_MCP_CONFIG_8e694f5e06409a5c_EOF | "$GH_AW_NODE" "${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.cjs" + cat << GH_AW_MCP_CONFIG_1ce8b4c4023744a7_EOF | "$GH_AW_NODE" "${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.cjs" { "mcpServers": { "safeoutputs": { @@ -685,7 +687,7 @@ jobs: "payloadDir": "${MCP_GATEWAY_PAYLOAD_DIR}" } } - GH_AW_MCP_CONFIG_8e694f5e06409a5c_EOF + GH_AW_MCP_CONFIG_1ce8b4c4023744a7_EOF - name: Mount MCP servers as CLIs id: mount-mcp-clis continue-on-error: true @@ -991,6 +993,8 @@ jobs: GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }} GH_AW_NOOP_MAX: "1" GH_AW_WORKFLOW_NAME: "Copilot Token Usage Optimizer" + GH_AW_WORKFLOW_SOURCE: "githubnext/agentic-ops/workflows/copilot-token-optimizer.md@c780d8324935fe1fb30fce545832c10a8f904039" + GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/githubnext/agentic-ops/blob/c780d8324935fe1fb30fce545832c10a8f904039/workflows/copilot-token-optimizer.md" GH_AW_TRACKER_ID: "copilot-token-optimizer" GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} GH_AW_AGENT_CONCLUSION: ${{ needs.agent.result }} @@ -1009,6 +1013,8 @@ jobs: GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }} GH_AW_MISSING_TOOL_CREATE_ISSUE: "true" GH_AW_WORKFLOW_NAME: "Copilot Token Usage Optimizer" + GH_AW_WORKFLOW_SOURCE: "githubnext/agentic-ops/workflows/copilot-token-optimizer.md@c780d8324935fe1fb30fce545832c10a8f904039" + GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/githubnext/agentic-ops/blob/c780d8324935fe1fb30fce545832c10a8f904039/workflows/copilot-token-optimizer.md" GH_AW_TRACKER_ID: "copilot-token-optimizer" with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} @@ -1024,6 +1030,8 @@ jobs: GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }} GH_AW_REPORT_INCOMPLETE_CREATE_ISSUE: "true" GH_AW_WORKFLOW_NAME: "Copilot Token Usage Optimizer" + GH_AW_WORKFLOW_SOURCE: "githubnext/agentic-ops/workflows/copilot-token-optimizer.md@c780d8324935fe1fb30fce545832c10a8f904039" + GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/githubnext/agentic-ops/blob/c780d8324935fe1fb30fce545832c10a8f904039/workflows/copilot-token-optimizer.md" GH_AW_TRACKER_ID: "copilot-token-optimizer" with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} @@ -1039,6 +1047,8 @@ jobs: env: GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }} GH_AW_WORKFLOW_NAME: "Copilot Token Usage Optimizer" + GH_AW_WORKFLOW_SOURCE: "githubnext/agentic-ops/workflows/copilot-token-optimizer.md@c780d8324935fe1fb30fce545832c10a8f904039" + GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/githubnext/agentic-ops/blob/c780d8324935fe1fb30fce545832c10a8f904039/workflows/copilot-token-optimizer.md" GH_AW_TRACKER_ID: "copilot-token-optimizer" GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} GH_AW_AGENT_CONCLUSION: ${{ needs.agent.result }} @@ -1181,6 +1191,8 @@ jobs: GH_AW_TRACKER_ID: "copilot-token-optimizer" GH_AW_WORKFLOW_ID: "copilot-token-optimizer" GH_AW_WORKFLOW_NAME: "Copilot Token Usage Optimizer" + GH_AW_WORKFLOW_SOURCE: "githubnext/agentic-ops/workflows/copilot-token-optimizer.md@c780d8324935fe1fb30fce545832c10a8f904039" + GH_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/githubnext/agentic-ops/blob/c780d8324935fe1fb30fce545832c10a8f904039/workflows/copilot-token-optimizer.md" outputs: code_push_failure_count: ${{ steps.process_safe_outputs.outputs.code_push_failure_count }} code_push_failure_errors: ${{ steps.process_safe_outputs.outputs.code_push_failure_errors }} diff --git a/.github/workflows/copilot-token-optimizer.md b/.github/workflows/copilot-token-optimizer.md index 7b3e0dcedf..27792f5628 100644 --- a/.github/workflows/copilot-token-optimizer.md +++ b/.github/workflows/copilot-token-optimizer.md @@ -109,6 +109,7 @@ steps: else echo "ℹ️ No previous optimization history found." fi +source: githubnext/agentic-ops/workflows/copilot-token-optimizer.md@c780d8324935fe1fb30fce545832c10a8f904039 --- # Copilot Token Usage Optimizer