From 7e25ece0b205d5e5713593de79f1f1c18ee85072 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 14 May 2026 18:01:02 +0000 Subject: [PATCH 1/2] Initial plan From 85c3149847ca7d1012720b6404c66ce93386471a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 14 May 2026 18:06:16 +0000 Subject: [PATCH 2/2] feat: make published workflows agent agnostic Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com> --- .../workflows/agentic-token-audit.lock.yml | 122 +++++++++--------- .../workflows/agentic-token-audit.md | 34 +++-- ...k.yml => agentic-token-optimizer.lock.yml} | 102 +++++++-------- .../workflows/agentic-token-optimizer.md | 20 ++- .github/workflows/agentics-maintenance.yml | 8 +- .github/workflows/ci.yml | 14 +- .github/workflows/copilot-setup-steps.yml | 6 +- .github/workflows/install-workflows.yml | 10 +- .github/workflows/release.lock.yml | 26 ++-- .github/workflows/release.md | 1 - README.md | 10 +- .../agentic-token-audit.lock.yml | 122 +++++++++--------- .../agentic-token-audit.md | 34 +++-- ...k.yml => agentic-token-optimizer.lock.yml} | 100 +++++++------- .../agentic-token-optimizer.md | 20 ++- 15 files changed, 310 insertions(+), 319 deletions(-) rename workflows/copilot-token-audit.lock.yml => .github/workflows/agentic-token-audit.lock.yml (94%) rename workflows/copilot-token-audit.md => .github/workflows/agentic-token-audit.md (89%) rename .github/workflows/{copilot-token-optimizer.lock.yml => agentic-token-optimizer.lock.yml} (94%) rename workflows/copilot-token-optimizer.md => .github/workflows/agentic-token-optimizer.md (93%) rename .github/workflows/copilot-token-audit.lock.yml => workflows/agentic-token-audit.lock.yml (94%) rename .github/workflows/copilot-token-audit.md => workflows/agentic-token-audit.md (89%) rename workflows/{copilot-token-optimizer.lock.yml => agentic-token-optimizer.lock.yml} (94%) rename .github/workflows/copilot-token-optimizer.md => workflows/agentic-token-optimizer.md (93%) diff --git a/workflows/copilot-token-audit.lock.yml b/.github/workflows/agentic-token-audit.lock.yml similarity index 94% rename from workflows/copilot-token-audit.lock.yml rename to .github/workflows/agentic-token-audit.lock.yml index 1f9d350..a8a41c9 100644 --- a/workflows/copilot-token-audit.lock.yml +++ b/.github/workflows/agentic-token-audit.lock.yml @@ -1,4 +1,4 @@ -# gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"5cf839e412e5e8c60ef8661d831feb2da7748859c777bd55f2a63f208f493128","compiler_version":"v0.72.1","strict":true,"agent_id":"copilot"} +# gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"3a16aa3075a74984fcfb2b6f88464e83e046cc68df75a4df533232dff5080063","compiler_version":"v0.72.1","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/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":"github/gh-aw-actions/setup","sha":"bc56a0cad2f450c562810785ef38649c04db812a","version":"v0.72.1"}],"containers":[{"image":"alpine:latest","digest":"sha256:5b10f432ef3da1b8d4c7eb6c487f2f5a8f096bc91145e68878dd4a5019afde11","pinned_image":"alpine:latest@sha256:5b10f432ef3da1b8d4c7eb6c487f2f5a8f096bc91145e68878dd4a5019afde11"},{"image":"ghcr.io/github/gh-aw-firewall/agent:0.25.41","digest":"sha256:cb2b565d070116d4b67e355775340528b5a2c3cb18b2c9049638bcc2df681770","pinned_image":"ghcr.io/github/gh-aw-firewall/agent:0.25.41@sha256:cb2b565d070116d4b67e355775340528b5a2c3cb18b2c9049638bcc2df681770"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.25.41","digest":"sha256:fadd0de387209f69a9a7a1b8722bb5e7fdfb80ba9749a5c60f0e4cd7582a74d0","pinned_image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.25.41@sha256:fadd0de387209f69a9a7a1b8722bb5e7fdfb80ba9749a5c60f0e4cd7582a74d0"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.25.41","digest":"sha256:1260445d25968dbf3ae70143964177a0e5914cf2ce07a6117f7d3caec6c3e3c4","pinned_image":"ghcr.io/github/gh-aw-firewall/squid:0.25.41@sha256:1260445d25968dbf3ae70143964177a0e5914cf2ce07a6117f7d3caec6c3e3c4"},{"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"}]} # ___ _ _ # / _ \ | | (_) @@ -22,7 +22,7 @@ # # For more information: https://github.github.com/gh-aw/introduction/overview/ # -# Daily audit of Copilot token usage across all agentic workflows with historical trend tracking +# Daily audit of token usage across all agentic workflows with historical trend tracking # # Secrets used: # - COPILOT_GITHUB_TOKEN @@ -49,10 +49,10 @@ # - ghcr.io/github/github-mcp-server:v1.0.3@sha256:2ac27ef03461ef2b877031b838a7d1fd7f12b12d4ace7796d8cad91446d55959 # - node:lts-alpine@sha256:d1b3b4da11eefd5941e7f0b9cf17783fc99d9c6fc34884a665f40a06dbdfc94f -name: "Daily Copilot Token Usage Audit" +name: "Daily Agentic Workflow Token Usage Audit" "on": schedule: - - cron: "11 11 * * 1-5" + - cron: "22 12 * * 1-5" # Friendly format: daily around 12:00 on weekdays (scattered) workflow_dispatch: inputs: @@ -67,7 +67,7 @@ permissions: {} concurrency: group: "gh-aw-${{ github.workflow }}" -run-name: "Daily Copilot Token Usage Audit" +run-name: "Daily Agentic Workflow Token Usage Audit" jobs: activation: @@ -92,8 +92,8 @@ jobs: destination: ${{ runner.temp }}/gh-aw/actions job-name: ${{ github.job }} env: - GH_AW_SETUP_WORKFLOW_NAME: "Daily Copilot Token Usage Audit" - GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/copilot-token-audit.lock.yml@${{ github.ref }} + GH_AW_SETUP_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/agentic-token-audit.lock.yml@${{ github.ref }} GH_AW_INFO_VERSION: "1.0.40" - name: Generate agentic run info id: generate_aw_info @@ -104,7 +104,7 @@ jobs: GH_AW_INFO_VERSION: "1.0.40" GH_AW_INFO_AGENT_VERSION: "1.0.40" GH_AW_INFO_CLI_VERSION: "v0.72.1" - GH_AW_INFO_WORKFLOW_NAME: "Daily Copilot Token Usage Audit" + GH_AW_INFO_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" GH_AW_INFO_EXPERIMENTAL: "false" GH_AW_INFO_SUPPORTS_TOOLS_ALLOWLIST: "true" GH_AW_INFO_STAGED: "false" @@ -151,7 +151,7 @@ jobs: id: check-lock-file uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 env: - GH_AW_WORKFLOW_FILE: "copilot-token-audit.lock.yml" + GH_AW_WORKFLOW_FILE: "agentic-token-audit.lock.yml" GH_AW_CONTEXT_WORKFLOW_REF: "${{ github.workflow_ref }}" with: script: | @@ -186,24 +186,24 @@ jobs: run: | bash "${RUNNER_TEMP}/gh-aw/actions/create_prompt_first.sh" { - cat << 'GH_AW_PROMPT_cb6587147033c980_EOF' + cat << 'GH_AW_PROMPT_86e79ee1acc5156c_EOF' - GH_AW_PROMPT_cb6587147033c980_EOF + GH_AW_PROMPT_86e79ee1acc5156c_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_cb6587147033c980_EOF' + cat << 'GH_AW_PROMPT_86e79ee1acc5156c_EOF' 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_cb6587147033c980_EOF + GH_AW_PROMPT_86e79ee1acc5156c_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/mcp_cli_tools_prompt.md" - cat << 'GH_AW_PROMPT_cb6587147033c980_EOF' + cat << 'GH_AW_PROMPT_86e79ee1acc5156c_EOF' The following GitHub context information is available for this workflow: {{#if __GH_AW_GITHUB_ACTOR__ }} @@ -232,12 +232,12 @@ jobs: {{/if}} - GH_AW_PROMPT_cb6587147033c980_EOF + GH_AW_PROMPT_86e79ee1acc5156c_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/github_mcp_tools_with_safeoutputs_prompt.md" - cat << 'GH_AW_PROMPT_cb6587147033c980_EOF' + cat << 'GH_AW_PROMPT_86e79ee1acc5156c_EOF' - {{#runtime-import copilot-token-audit.md}} - GH_AW_PROMPT_cb6587147033c980_EOF + {{#runtime-import .github/workflows/agentic-token-audit.md}} + GH_AW_PROMPT_86e79ee1acc5156c_EOF } > "$GH_AW_PROMPT" - name: Interpolate variables and render templates uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 @@ -266,7 +266,7 @@ jobs: GH_AW_MCP_CLI_SERVERS_LIST: '- `safeoutputs` — run `safeoutputs --help` to see available tools' GH_AW_MEMORY_BRANCH_NAME: 'memory/token-audit' GH_AW_MEMORY_CONSTRAINTS: "\n\n**Constraints:**\n- **Allowed Files**: Only files matching patterns: *.json, *.jsonl, *.csv, *.md\n- **Max File Size**: 102400 bytes (0.10 MB) per file\n- **Max File Count**: 100 files per commit\n- **Max Patch Size**: 51200 bytes (50 KB) total per push (max: 100 KB)\n" - GH_AW_MEMORY_DESCRIPTION: ' Historical daily Copilot token usage snapshots (shared with copilot-token-optimizer)' + GH_AW_MEMORY_DESCRIPTION: ' Historical daily workflow token usage snapshots (shared with agentic-token-optimizer)' GH_AW_MEMORY_DIR: '/tmp/gh-aw/repo-memory/default/' GH_AW_MEMORY_TARGET_REPO: ' of the current repository' GH_AW_WIKI_NOTE: '' @@ -341,7 +341,7 @@ jobs: GH_AW_ASSETS_BRANCH: "assets/${{ github.workflow }}" GH_AW_ASSETS_MAX_SIZE_KB: 10240 GH_AW_MCP_LOG_DIR: /tmp/gh-aw/mcp-logs/safeoutputs - GH_AW_WORKFLOW_ID_SANITIZED: copilottokenaudit + GH_AW_WORKFLOW_ID_SANITIZED: agentictokenaudit outputs: agentic_engine_timeout: ${{ steps.detect-copilot-errors.outputs.agentic_engine_timeout || 'false' }} checkout_pr_success: ${{ steps.checkout-pr.outputs.checkout_pr_success || 'true' }} @@ -363,8 +363,8 @@ jobs: job-name: ${{ github.job }} trace-id: ${{ needs.activation.outputs.setup-trace-id }} env: - GH_AW_SETUP_WORKFLOW_NAME: "Daily Copilot Token Usage Audit" - GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/copilot-token-audit.lock.yml@${{ github.ref }} + GH_AW_SETUP_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/agentic-token-audit.lock.yml@${{ github.ref }} GH_AW_INFO_VERSION: "1.0.40" - name: Set runtime paths id: set-runtime-paths @@ -396,8 +396,8 @@ jobs: python3 -m pip install --quiet --target /tmp/gh-aw/token-audit/site-packages pandas matplotlib seaborn - env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Download Copilot workflow logs - run: "set -euo pipefail\nmkdir -p /tmp/gh-aw/token-audit\n\n# Download last 24 hours of Copilot logs as JSON\n# Allow partial results — gh aw logs streams incrementally, so even if\n# it hits an API rate limit partway through, the JSON written so far is\n# still valid and should be processed by the agent.\nLOGS_EXIT=0\ngh aw logs \\\n --engine copilot \\\n --start-date -1d \\\n --json \\\n -c 100 \\\n > /tmp/gh-aw/token-audit/copilot-logs.json || LOGS_EXIT=$?\n\nif [ -s /tmp/gh-aw/token-audit/copilot-logs.json ]; then\n TOTAL=$(jq '.runs | length' /tmp/gh-aw/token-audit/copilot-logs.json)\n echo \"✅ Downloaded $TOTAL Copilot workflow runs (last 24 hours)\"\n if [ \"$LOGS_EXIT\" -ne 0 ]; then\n echo \"⚠️ gh aw logs exited with code $LOGS_EXIT (partial results — likely API rate limit)\"\n fi\nelse\n echo \"❌ No log data downloaded (exit code $LOGS_EXIT)\"\n echo '{\"runs\":[],\"summary\":{}}' > /tmp/gh-aw/token-audit/copilot-logs.json\nfi\n" + name: Download agentic workflow logs + run: "set -euo pipefail\nmkdir -p /tmp/gh-aw/token-audit\n\n# Download last 24 hours of agentic workflow logs as JSON\n# Allow partial results — gh aw logs streams incrementally, so even if\n# it hits an API rate limit partway through, the JSON written so far is\n# still valid and should be processed by the agent.\nLOGS_EXIT=0\ngh aw logs \\\n --start-date -1d \\\n --json \\\n -c 100 \\\n > /tmp/gh-aw/token-audit/workflow-logs.json || LOGS_EXIT=$?\n\nif [ -s /tmp/gh-aw/token-audit/workflow-logs.json ]; then\n TOTAL=$(jq '.runs | length' /tmp/gh-aw/token-audit/workflow-logs.json)\n echo \"✅ Downloaded $TOTAL agentic workflow runs (last 24 hours)\"\n if [ \"$LOGS_EXIT\" -ne 0 ]; then\n echo \"⚠️ gh aw logs exited with code $LOGS_EXIT (partial results — likely API rate limit)\"\n fi\nelse\n echo \"❌ No log data downloaded (exit code $LOGS_EXIT)\"\n echo '{\"runs\":[],\"summary\":{}}' > /tmp/gh-aw/token-audit/workflow-logs.json\nfi\n" # Repo memory git-based storage configuration from frontmatter processed below - name: Clone repo-memory branch (default) @@ -505,15 +505,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_64723312ee166f5f_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_64723312ee166f5f_EOF + cat > "${RUNNER_TEMP}/gh-aw/safeoutputs/config.json" << GH_AW_SAFE_OUTPUTS_CONFIG_f95f30b4264aeb1f_EOF + {"create_issue":{"close_older_issues":true,"expires":72,"max":1,"title_prefix":"[agentic-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_f95f30b4264aeb1f_EOF - name: Generate Safe Outputs Tools env: GH_AW_TOOLS_META_JSON: | { "description_suffixes": { - "create_issue": " CONSTRAINTS: Maximum 1 issue(s) can be created. Title will be prefixed with \"[copilot-token-audit] \".", + "create_issue": " CONSTRAINTS: Maximum 1 issue(s) can be created. Title will be prefixed with \"[agentic-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": {}, @@ -721,7 +721,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_cb19aa5c12a7907f_EOF | "$GH_AW_NODE" "${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.cjs" + cat << GH_AW_MCP_CONFIG_8516d51d55ad3b05_EOF | "$GH_AW_NODE" "${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.cjs" { "mcpServers": { "agenticworkflows": { @@ -783,7 +783,7 @@ jobs: "payloadDir": "${MCP_GATEWAY_PAYLOAD_DIR}" } } - GH_AW_MCP_CONFIG_cb19aa5c12a7907f_EOF + GH_AW_MCP_CONFIG_8516d51d55ad3b05_EOF - name: Mount MCP servers as CLIs id: mount-mcp-clis continue-on-error: true @@ -1046,7 +1046,7 @@ jobs: contents: read issues: write concurrency: - group: "gh-aw-conclusion-copilot-token-audit" + group: "gh-aw-conclusion-agentic-token-audit" cancel-in-progress: false outputs: incomplete_count: ${{ steps.report_incomplete.outputs.incomplete_count }} @@ -1062,8 +1062,8 @@ jobs: job-name: ${{ github.job }} trace-id: ${{ needs.activation.outputs.setup-trace-id }} env: - GH_AW_SETUP_WORKFLOW_NAME: "Daily Copilot Token Usage Audit" - GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/copilot-token-audit.lock.yml@${{ github.ref }} + GH_AW_SETUP_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/agentic-token-audit.lock.yml@${{ github.ref }} GH_AW_INFO_VERSION: "1.0.40" - name: Download agent output artifact id: download-agent-output @@ -1085,8 +1085,8 @@ jobs: env: 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_TRACKER_ID: "copilot-token-audit" + GH_AW_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" + GH_AW_TRACKER_ID: "agentic-token-audit" GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} GH_AW_AGENT_CONCLUSION: ${{ needs.agent.result }} GH_AW_NOOP_REPORT_AS_ISSUE: "true" @@ -1102,8 +1102,8 @@ jobs: uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 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_TRACKER_ID: "copilot-token-audit" + GH_AW_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" + GH_AW_TRACKER_ID: "agentic-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 }} GH_AW_DETECTION_REASON: ${{ needs.detection.outputs.detection_reason }} @@ -1120,8 +1120,8 @@ jobs: env: 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_TRACKER_ID: "copilot-token-audit" + GH_AW_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" + GH_AW_TRACKER_ID: "agentic-token-audit" with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | @@ -1135,8 +1135,8 @@ jobs: env: 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_TRACKER_ID: "copilot-token-audit" + GH_AW_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" + GH_AW_TRACKER_ID: "agentic-token-audit" with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | @@ -1150,11 +1150,11 @@ jobs: uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 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_TRACKER_ID: "copilot-token-audit" + GH_AW_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" + GH_AW_TRACKER_ID: "agentic-token-audit" GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} GH_AW_AGENT_CONCLUSION: ${{ needs.agent.result }} - GH_AW_WORKFLOW_ID: "copilot-token-audit" + GH_AW_WORKFLOW_ID: "agentic-token-audit" GH_AW_ACTION_FAILURE_ISSUE_EXPIRES_HOURS: "168" GH_AW_ENGINE_ID: "copilot" GH_AW_SECRET_VERIFICATION_RESULT: ${{ needs.activation.outputs.secret_verification_result }} @@ -1205,8 +1205,8 @@ jobs: job-name: ${{ github.job }} trace-id: ${{ needs.activation.outputs.setup-trace-id }} env: - GH_AW_SETUP_WORKFLOW_NAME: "Daily Copilot Token Usage Audit" - GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/copilot-token-audit.lock.yml@${{ github.ref }} + GH_AW_SETUP_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/agentic-token-audit.lock.yml@${{ github.ref }} GH_AW_INFO_VERSION: "1.0.40" - name: Download agent output artifact id: download-agent-output @@ -1272,8 +1272,8 @@ jobs: if: always() && steps.detection_guard.outputs.run_detection == 'true' uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 env: - WORKFLOW_NAME: "Daily Copilot Token Usage Audit" - WORKFLOW_DESCRIPTION: "Daily audit of Copilot token usage across all agentic workflows with historical trend tracking" + WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" + WORKFLOW_DESCRIPTION: "Daily audit of token usage across all agentic workflows with historical trend tracking" HAS_PATCH: ${{ needs.agent.outputs.has_patch }} with: script: | @@ -1400,8 +1400,8 @@ jobs: job-name: ${{ github.job }} trace-id: ${{ needs.activation.outputs.setup-trace-id }} env: - GH_AW_SETUP_WORKFLOW_NAME: "Daily Copilot Token Usage Audit" - GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/copilot-token-audit.lock.yml@${{ github.ref }} + GH_AW_SETUP_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/agentic-token-audit.lock.yml@${{ github.ref }} GH_AW_INFO_VERSION: "1.0.40" - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -1463,16 +1463,16 @@ jobs: issues: write timeout-minutes: 15 env: - GH_AW_CALLER_WORKFLOW_ID: "${{ github.repository }}/copilot-token-audit" + GH_AW_CALLER_WORKFLOW_ID: "${{ github.repository }}/agentic-token-audit" GH_AW_DETECTION_CONCLUSION: ${{ needs.detection.outputs.detection_conclusion }} GH_AW_DETECTION_REASON: ${{ needs.detection.outputs.detection_reason }} GH_AW_EFFECTIVE_TOKENS: ${{ needs.agent.outputs.effective_tokens }} GH_AW_ENGINE_ID: "copilot" GH_AW_ENGINE_MODEL: ${{ needs.agent.outputs.model }} GH_AW_ENGINE_VERSION: "1.0.40" - 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_TRACKER_ID: "agentic-token-audit" + GH_AW_WORKFLOW_ID: "agentic-token-audit" + GH_AW_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" 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 }} @@ -1491,8 +1491,8 @@ jobs: job-name: ${{ github.job }} trace-id: ${{ needs.activation.outputs.setup-trace-id }} env: - GH_AW_SETUP_WORKFLOW_NAME: "Daily Copilot Token Usage Audit" - GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/copilot-token-audit.lock.yml@${{ github.ref }} + GH_AW_SETUP_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/agentic-token-audit.lock.yml@${{ github.ref }} GH_AW_INFO_VERSION: "1.0.40" - name: Download agent output artifact id: download-agent-output @@ -1525,7 +1525,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_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}}" + GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG: "{\"create_issue\":{\"close_older_issues\":true,\"expires\":72,\"max\":1,\"title_prefix\":\"[agentic-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: | @@ -1564,8 +1564,8 @@ jobs: job-name: ${{ github.job }} trace-id: ${{ needs.activation.outputs.setup-trace-id }} env: - GH_AW_SETUP_WORKFLOW_NAME: "Daily Copilot Token Usage Audit" - GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/copilot-token-audit.lock.yml@${{ github.ref }} + GH_AW_SETUP_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/agentic-token-audit.lock.yml@${{ github.ref }} GH_AW_INFO_VERSION: "1.0.40" - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -1618,8 +1618,8 @@ jobs: GH_AW_ASSETS_BRANCH: "assets/${{ github.workflow }}" 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_TRACKER_ID: "copilot-token-audit" + GH_AW_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" + GH_AW_TRACKER_ID: "agentic-token-audit" GH_AW_ENGINE_ID: "copilot" GH_AW_ENGINE_VERSION: "1.0.40" GH_AW_ENGINE_MODEL: ${{ needs.agent.outputs.model }} diff --git a/workflows/copilot-token-audit.md b/.github/workflows/agentic-token-audit.md similarity index 89% rename from workflows/copilot-token-audit.md rename to .github/workflows/agentic-token-audit.md index 629dc34..972f382 100644 --- a/workflows/copilot-token-audit.md +++ b/.github/workflows/agentic-token-audit.md @@ -1,5 +1,5 @@ --- -description: Daily audit of Copilot token usage across all agentic workflows with historical trend tracking +description: Daily audit of token usage across all agentic workflows with historical trend tracking on: schedule: - cron: "daily around 12:00 on weekdays" @@ -9,12 +9,11 @@ permissions: actions: read issues: read pull-requests: read -tracker-id: copilot-token-audit -engine: copilot +tracker-id: agentic-token-audit safe-outputs: create-issue: expires: 3d - title-prefix: "[copilot-token-audit] " + title-prefix: "[agentic-token-audit] " max: 1 close-older-issues: true upload-asset: @@ -26,7 +25,7 @@ tools: - "*" repo-memory: branch-name: "memory/token-audit" - description: "Historical daily Copilot token usage snapshots (shared with copilot-token-optimizer)" + description: "Historical daily workflow token usage snapshots (shared with agentic-token-optimizer)" file-glob: ["*.json", "*.jsonl", "*.csv", "*.md"] max-file-size: 102400 max-patch-size: 51200 @@ -41,45 +40,44 @@ steps: - name: Install Python chart dependencies run: | python3 -m pip install --quiet --target /tmp/gh-aw/token-audit/site-packages pandas matplotlib seaborn - - name: Download Copilot workflow logs + - name: Download agentic workflow logs env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | set -euo pipefail mkdir -p /tmp/gh-aw/token-audit - # Download last 24 hours of Copilot logs as JSON + # Download last 24 hours of agentic workflow logs as JSON # Allow partial results — gh aw logs streams incrementally, so even if # it hits an API rate limit partway through, the JSON written so far is # still valid and should be processed by the agent. LOGS_EXIT=0 gh aw logs \ - --engine copilot \ --start-date -1d \ --json \ -c 100 \ - > /tmp/gh-aw/token-audit/copilot-logs.json || LOGS_EXIT=$? + > /tmp/gh-aw/token-audit/workflow-logs.json || LOGS_EXIT=$? - if [ -s /tmp/gh-aw/token-audit/copilot-logs.json ]; then - TOTAL=$(jq '.runs | length' /tmp/gh-aw/token-audit/copilot-logs.json) - echo "✅ Downloaded $TOTAL Copilot workflow runs (last 24 hours)" + if [ -s /tmp/gh-aw/token-audit/workflow-logs.json ]; then + TOTAL=$(jq '.runs | length' /tmp/gh-aw/token-audit/workflow-logs.json) + echo "✅ Downloaded $TOTAL agentic workflow runs (last 24 hours)" if [ "$LOGS_EXIT" -ne 0 ]; then echo "⚠️ gh aw logs exited with code $LOGS_EXIT (partial results — likely API rate limit)" fi else echo "❌ No log data downloaded (exit code $LOGS_EXIT)" - echo '{"runs":[],"summary":{}}' > /tmp/gh-aw/token-audit/copilot-logs.json + echo '{"runs":[],"summary":{}}' > /tmp/gh-aw/token-audit/workflow-logs.json fi timeout-minutes: 25 --- -# Daily Copilot Token Usage Audit +# Daily Agentic Workflow Token Usage Audit -You are the Copilot Token Auditor — a workflow that tracks daily token consumption across all Copilot-powered agentic workflows in this repository and maintains a historical record for trend analysis. +You are the Agentic Workflow Token Auditor — a workflow that tracks daily token consumption across all agentic workflows in this repository and maintains a historical record for trend analysis. ## Mission -1. Parse the pre-downloaded Copilot workflow logs and compute per-workflow token usage metrics. +1. Parse the pre-downloaded agentic 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 issue summarizing today's usage, trends, and cost highlights. @@ -87,7 +85,7 @@ You are the Copilot Token Auditor — a workflow that tracks daily token consump ### Pre-downloaded logs -The workflow logs are at `/tmp/gh-aw/token-audit/copilot-logs.json`. The file is the raw JSON output of `gh aw logs --json` with this top-level shape: +The workflow logs are at `/tmp/gh-aw/token-audit/workflow-logs.json`. The file is the raw JSON output of `gh aw logs --json` with this top-level shape: ```json { @@ -128,7 +126,7 @@ Previous snapshots live at `/tmp/gh-aw/repo-memory/default/`. Each daily snapsho Write a Python script to `/tmp/gh-aw/token-audit/process_audit.py` and run it. The script must: -1. Load `/tmp/gh-aw/token-audit/copilot-logs.json` and extract `.runs`. +1. Load `/tmp/gh-aw/token-audit/workflow-logs.json` and extract `.runs`. 2. Filter to `status == "completed"` runs only. 3. Group by `workflow_name` and compute per-workflow aggregates: - `run_count`, `total_tokens`, `avg_tokens`, `total_cost`, `avg_cost`, `total_turns`, `avg_turns`, `total_action_minutes`, `error_count`, `warning_count` diff --git a/.github/workflows/copilot-token-optimizer.lock.yml b/.github/workflows/agentic-token-optimizer.lock.yml similarity index 94% rename from .github/workflows/copilot-token-optimizer.lock.yml rename to .github/workflows/agentic-token-optimizer.lock.yml index 61a791c..723ceb2 100644 --- a/.github/workflows/copilot-token-optimizer.lock.yml +++ b/.github/workflows/agentic-token-optimizer.lock.yml @@ -1,4 +1,4 @@ -# gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"9d01169949a866a476d4e166b66e32901f4050b164f6f72a4b633a12de28de16","compiler_version":"v0.72.1","strict":true,"agent_id":"copilot"} +# gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"2f14ef0c5a6f64ced477941b8fd6b3d846ef0ee12f45e704afa8853b511626a5","compiler_version":"v0.72.1","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"},{"repo":"github/gh-aw-actions/setup","sha":"bc56a0cad2f450c562810785ef38649c04db812a","version":"v0.72.1"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.25.41","digest":"sha256:cb2b565d070116d4b67e355775340528b5a2c3cb18b2c9049638bcc2df681770","pinned_image":"ghcr.io/github/gh-aw-firewall/agent:0.25.41@sha256:cb2b565d070116d4b67e355775340528b5a2c3cb18b2c9049638bcc2df681770"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.25.41","digest":"sha256:fadd0de387209f69a9a7a1b8722bb5e7fdfb80ba9749a5c60f0e4cd7582a74d0","pinned_image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.25.41@sha256:fadd0de387209f69a9a7a1b8722bb5e7fdfb80ba9749a5c60f0e4cd7582a74d0"},{"image":"ghcr.io/github/gh-aw-firewall/cli-proxy:0.25.41"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.25.41","digest":"sha256:1260445d25968dbf3ae70143964177a0e5914cf2ce07a6117f7d3caec6c3e3c4","pinned_image":"ghcr.io/github/gh-aw-firewall/squid:0.25.41@sha256:1260445d25968dbf3ae70143964177a0e5914cf2ce07a6117f7d3caec6c3e3c4"},{"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"}]} # ___ _ _ # / _ \ | | (_) @@ -22,7 +22,7 @@ # # For more information: https://github.github.com/gh-aw/introduction/overview/ # -# Daily optimizer that identifies a high-token-usage Copilot workflow, audits its runs, and recommends efficiency improvements +# Daily optimizer that identifies a high-token-usage agentic workflow, audits its runs, and recommends efficiency improvements # # Secrets used: # - COPILOT_GITHUB_TOKEN @@ -47,10 +47,10 @@ # - ghcr.io/github/github-mcp-server:v1.0.3@sha256:2ac27ef03461ef2b877031b838a7d1fd7f12b12d4ace7796d8cad91446d55959 # - node:lts-alpine@sha256:d1b3b4da11eefd5941e7f0b9cf17783fc99d9c6fc34884a665f40a06dbdfc94f -name: "Copilot Token Usage Optimizer" +name: "Agentic Workflow Token Usage Optimizer" "on": schedule: - - cron: "52 13 * * 1-5" + - cron: "22 14 * * 1-5" # Friendly format: daily around 14:00 on weekdays (scattered) workflow_dispatch: inputs: @@ -65,7 +65,7 @@ permissions: {} concurrency: group: "gh-aw-${{ github.workflow }}" -run-name: "Copilot Token Usage Optimizer" +run-name: "Agentic Workflow Token Usage Optimizer" jobs: activation: @@ -90,8 +90,8 @@ jobs: destination: ${{ runner.temp }}/gh-aw/actions job-name: ${{ github.job }} env: - GH_AW_SETUP_WORKFLOW_NAME: "Copilot Token Usage Optimizer" - GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/copilot-token-optimizer.lock.yml@${{ github.ref }} + GH_AW_SETUP_WORKFLOW_NAME: "Agentic Workflow Token Usage Optimizer" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/agentic-token-optimizer.lock.yml@${{ github.ref }} GH_AW_INFO_VERSION: "1.0.40" - name: Generate agentic run info id: generate_aw_info @@ -102,7 +102,7 @@ jobs: GH_AW_INFO_VERSION: "1.0.40" GH_AW_INFO_AGENT_VERSION: "1.0.40" GH_AW_INFO_CLI_VERSION: "v0.72.1" - GH_AW_INFO_WORKFLOW_NAME: "Copilot Token Usage Optimizer" + GH_AW_INFO_WORKFLOW_NAME: "Agentic Workflow Token Usage Optimizer" GH_AW_INFO_EXPERIMENTAL: "false" GH_AW_INFO_SUPPORTS_TOOLS_ALLOWLIST: "true" GH_AW_INFO_STAGED: "false" @@ -149,7 +149,7 @@ jobs: id: check-lock-file uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 env: - GH_AW_WORKFLOW_FILE: "copilot-token-optimizer.lock.yml" + GH_AW_WORKFLOW_FILE: "agentic-token-optimizer.lock.yml" GH_AW_CONTEXT_WORKFLOW_REF: "${{ github.workflow_ref }}" with: script: | @@ -184,21 +184,21 @@ jobs: run: | bash "${RUNNER_TEMP}/gh-aw/actions/create_prompt_first.sh" { - cat << 'GH_AW_PROMPT_404f8342621716f3_EOF' + cat << 'GH_AW_PROMPT_26fa2cbe45dd666d_EOF' - GH_AW_PROMPT_404f8342621716f3_EOF + GH_AW_PROMPT_26fa2cbe45dd666d_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_26fa2cbe45dd666d_EOF' Tools: create_issue, missing_tool, missing_data, noop - GH_AW_PROMPT_404f8342621716f3_EOF + GH_AW_PROMPT_26fa2cbe45dd666d_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/mcp_cli_tools_prompt.md" - cat << 'GH_AW_PROMPT_404f8342621716f3_EOF' + cat << 'GH_AW_PROMPT_26fa2cbe45dd666d_EOF' The following GitHub context information is available for this workflow: {{#if __GH_AW_GITHUB_ACTOR__ }} @@ -227,12 +227,12 @@ jobs: {{/if}} - GH_AW_PROMPT_404f8342621716f3_EOF + GH_AW_PROMPT_26fa2cbe45dd666d_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/cli_proxy_with_safeoutputs_prompt.md" - cat << 'GH_AW_PROMPT_404f8342621716f3_EOF' + cat << 'GH_AW_PROMPT_26fa2cbe45dd666d_EOF' - {{#runtime-import .github/workflows/copilot-token-optimizer.md}} - GH_AW_PROMPT_404f8342621716f3_EOF + {{#runtime-import .github/workflows/agentic-token-optimizer.md}} + GH_AW_PROMPT_26fa2cbe45dd666d_EOF } > "$GH_AW_PROMPT" - name: Interpolate variables and render templates uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 @@ -261,7 +261,7 @@ jobs: GH_AW_MCP_CLI_SERVERS_LIST: '- `safeoutputs` — run `safeoutputs --help` to see available tools' GH_AW_MEMORY_BRANCH_NAME: 'memory/token-audit' GH_AW_MEMORY_CONSTRAINTS: "\n\n**Constraints:**\n- **Allowed Files**: Only files matching patterns: *.json, *.jsonl, *.csv, *.md\n- **Max File Size**: 102400 bytes (0.10 MB) per file\n- **Max File Count**: 100 files per commit\n- **Max Patch Size**: 51200 bytes (50 KB) total per push (max: 100 KB)\n" - GH_AW_MEMORY_DESCRIPTION: ' Historical daily Copilot token usage snapshots (shared with copilot-token-audit)' + GH_AW_MEMORY_DESCRIPTION: ' Historical daily workflow token usage snapshots (shared with agentic-token-audit)' GH_AW_MEMORY_DIR: '/tmp/gh-aw/repo-memory/default/' GH_AW_MEMORY_TARGET_REPO: ' of the current repository' GH_AW_WIKI_NOTE: '' @@ -336,7 +336,7 @@ jobs: GH_AW_ASSETS_BRANCH: "" GH_AW_ASSETS_MAX_SIZE_KB: 0 GH_AW_MCP_LOG_DIR: /tmp/gh-aw/mcp-logs/safeoutputs - GH_AW_WORKFLOW_ID_SANITIZED: copilottokenoptimizer + GH_AW_WORKFLOW_ID_SANITIZED: agentictokenoptimizer outputs: agentic_engine_timeout: ${{ steps.detect-copilot-errors.outputs.agentic_engine_timeout || 'false' }} checkout_pr_success: ${{ steps.checkout-pr.outputs.checkout_pr_success || 'true' }} @@ -358,8 +358,8 @@ jobs: job-name: ${{ github.job }} trace-id: ${{ needs.activation.outputs.setup-trace-id }} env: - GH_AW_SETUP_WORKFLOW_NAME: "Copilot Token Usage Optimizer" - GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/copilot-token-optimizer.lock.yml@${{ github.ref }} + GH_AW_SETUP_WORKFLOW_NAME: "Agentic Workflow Token Usage Optimizer" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/agentic-token-optimizer.lock.yml@${{ github.ref }} GH_AW_INFO_VERSION: "1.0.40" - name: Set runtime paths id: set-runtime-paths @@ -381,8 +381,8 @@ jobs: GH_TOKEN: ${{ github.token }} - env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Download recent Copilot workflow logs - run: "set -euo pipefail\nmkdir -p /tmp/gh-aw/token-audit\n\necho \"📥 Downloading Copilot workflow logs (last 7 days)...\"\n\nLOGS_EXIT=0\ngh aw logs \\\n --engine copilot \\\n --start-date -7d \\\n --json \\\n -c 50 \\\n > /tmp/gh-aw/token-audit/all-runs.json || LOGS_EXIT=$?\n\nif [ -s /tmp/gh-aw/token-audit/all-runs.json ]; then\n TOTAL=$(jq '.runs | length' /tmp/gh-aw/token-audit/all-runs.json)\n echo \"✅ Downloaded $TOTAL Copilot workflow runs (last 7 days)\"\n if [ \"$LOGS_EXIT\" -ne 0 ]; then\n echo \"⚠️ gh aw logs exited with code $LOGS_EXIT (partial results — likely API rate limit)\"\n fi\nelse\n echo \"❌ No log data downloaded (exit code $LOGS_EXIT)\"\n echo '{\"runs\":[],\"summary\":{}}' > /tmp/gh-aw/token-audit/all-runs.json\nfi\n" + name: Download recent agentic workflow logs + run: "set -euo pipefail\nmkdir -p /tmp/gh-aw/token-audit\n\necho \"📥 Downloading agentic workflow logs (last 7 days)...\"\n\nLOGS_EXIT=0\ngh aw logs \\\n --start-date -7d \\\n --json \\\n -c 50 \\\n > /tmp/gh-aw/token-audit/all-runs.json || LOGS_EXIT=$?\n\nif [ -s /tmp/gh-aw/token-audit/all-runs.json ]; then\n TOTAL=$(jq '.runs | length' /tmp/gh-aw/token-audit/all-runs.json)\n echo \"✅ Downloaded $TOTAL agentic workflow runs (last 7 days)\"\n if [ \"$LOGS_EXIT\" -ne 0 ]; then\n echo \"⚠️ gh aw logs exited with code $LOGS_EXIT (partial results — likely API rate limit)\"\n fi\nelse\n echo \"❌ No log data downloaded (exit code $LOGS_EXIT)\"\n echo '{\"runs\":[],\"summary\":{}}' > /tmp/gh-aw/token-audit/all-runs.json\nfi\n" - name: Aggregate top workflows by token usage run: "set -euo pipefail\nmkdir -p /tmp/gh-aw/token-audit\n\njq '{\n generated_at: (now | todateiso8601),\n window_days: 7,\n top_workflows: (\n [.runs[]\n | select(.status == \"completed\")\n | {\n workflow_name: .workflow_name,\n tokens: (.token_usage // 0),\n cost: (.estimated_cost // 0),\n turns: (.turns // 0),\n action_minutes: (.action_minutes // 0)\n }\n ]\n | group_by(.workflow_name)\n | map({\n workflow_name: .[0].workflow_name,\n run_count: length,\n total_tokens: (map(.tokens) | add),\n avg_tokens: ((map(.tokens) | add) / length),\n total_cost: (map(.cost) | add),\n total_turns: (map(.turns) | add),\n total_action_minutes: (map(.action_minutes) | add)\n })\n | sort_by(.total_tokens)\n | reverse\n | .[:10]\n )\n}' /tmp/gh-aw/token-audit/all-runs.json > /tmp/gh-aw/token-audit/top-workflows.json\n\necho \"✅ Generated top workflow summary at /tmp/gh-aw/token-audit/top-workflows.json\"\njq '.top_workflows' /tmp/gh-aw/token-audit/top-workflows.json\n" - name: Load optimization history @@ -464,15 +464,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_aa3b2bd0bfb870d0_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 + cat > "${RUNNER_TEMP}/gh-aw/safeoutputs/config.json" << 'GH_AW_SAFE_OUTPUTS_CONFIG_375a635b6d55f43f_EOF' + {"create_issue":{"close_older_issues":true,"expires":168,"max":1,"title_prefix":"[agentic-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_375a635b6d55f43f_EOF - name: Generate Safe Outputs Tools env: GH_AW_TOOLS_META_JSON: | { "description_suffixes": { - "create_issue": " CONSTRAINTS: Maximum 1 issue(s) can be created. Title will be prefixed with \"[copilot-token-optimizer] \"." + "create_issue": " CONSTRAINTS: Maximum 1 issue(s) can be created. Title will be prefixed with \"[agentic-token-optimizer] \"." }, "repo_params": {}, "dynamic_tools": [] @@ -663,7 +663,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_7497ae1d8022a838_EOF | "$GH_AW_NODE" "${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.cjs" { "mcpServers": { "safeoutputs": { @@ -688,7 +688,7 @@ jobs: "payloadDir": "${MCP_GATEWAY_PAYLOAD_DIR}" } } - GH_AW_MCP_CONFIG_8e694f5e06409a5c_EOF + GH_AW_MCP_CONFIG_7497ae1d8022a838_EOF - name: Mount MCP servers as CLIs id: mount-mcp-clis continue-on-error: true @@ -948,7 +948,7 @@ jobs: contents: read issues: write concurrency: - group: "gh-aw-conclusion-copilot-token-optimizer" + group: "gh-aw-conclusion-agentic-token-optimizer" cancel-in-progress: false outputs: incomplete_count: ${{ steps.report_incomplete.outputs.incomplete_count }} @@ -964,8 +964,8 @@ jobs: job-name: ${{ github.job }} trace-id: ${{ needs.activation.outputs.setup-trace-id }} env: - GH_AW_SETUP_WORKFLOW_NAME: "Copilot Token Usage Optimizer" - GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/copilot-token-optimizer.lock.yml@${{ github.ref }} + GH_AW_SETUP_WORKFLOW_NAME: "Agentic Workflow Token Usage Optimizer" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/agentic-token-optimizer.lock.yml@${{ github.ref }} GH_AW_INFO_VERSION: "1.0.40" - name: Download agent output artifact id: download-agent-output @@ -987,8 +987,8 @@ jobs: env: 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_TRACKER_ID: "copilot-token-optimizer" + GH_AW_WORKFLOW_NAME: "Agentic Workflow Token Usage Optimizer" + GH_AW_TRACKER_ID: "agentic-token-optimizer" GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} GH_AW_AGENT_CONCLUSION: ${{ needs.agent.result }} GH_AW_NOOP_REPORT_AS_ISSUE: "true" @@ -1005,8 +1005,8 @@ jobs: env: 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_TRACKER_ID: "copilot-token-optimizer" + GH_AW_WORKFLOW_NAME: "Agentic Workflow Token Usage Optimizer" + GH_AW_TRACKER_ID: "agentic-token-optimizer" with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | @@ -1020,8 +1020,8 @@ jobs: env: 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_TRACKER_ID: "copilot-token-optimizer" + GH_AW_WORKFLOW_NAME: "Agentic Workflow Token Usage Optimizer" + GH_AW_TRACKER_ID: "agentic-token-optimizer" with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | @@ -1035,11 +1035,11 @@ jobs: uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 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_TRACKER_ID: "copilot-token-optimizer" + GH_AW_WORKFLOW_NAME: "Agentic Workflow Token Usage Optimizer" + GH_AW_TRACKER_ID: "agentic-token-optimizer" GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} GH_AW_AGENT_CONCLUSION: ${{ needs.agent.result }} - GH_AW_WORKFLOW_ID: "copilot-token-optimizer" + GH_AW_WORKFLOW_ID: "agentic-token-optimizer" GH_AW_ACTION_FAILURE_ISSUE_EXPIRES_HOURS: "168" GH_AW_ENGINE_ID: "copilot" GH_AW_SECRET_VERIFICATION_RESULT: ${{ needs.activation.outputs.secret_verification_result }} @@ -1092,8 +1092,8 @@ jobs: job-name: ${{ github.job }} trace-id: ${{ needs.activation.outputs.setup-trace-id }} env: - GH_AW_SETUP_WORKFLOW_NAME: "Copilot Token Usage Optimizer" - GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/copilot-token-optimizer.lock.yml@${{ github.ref }} + GH_AW_SETUP_WORKFLOW_NAME: "Agentic Workflow Token Usage Optimizer" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/agentic-token-optimizer.lock.yml@${{ github.ref }} GH_AW_INFO_VERSION: "1.0.40" - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -1154,14 +1154,14 @@ jobs: issues: write timeout-minutes: 15 env: - GH_AW_CALLER_WORKFLOW_ID: "${{ github.repository }}/copilot-token-optimizer" + GH_AW_CALLER_WORKFLOW_ID: "${{ github.repository }}/agentic-token-optimizer" GH_AW_EFFECTIVE_TOKENS: ${{ needs.agent.outputs.effective_tokens }} GH_AW_ENGINE_ID: "copilot" GH_AW_ENGINE_MODEL: ${{ needs.agent.outputs.model }} GH_AW_ENGINE_VERSION: "1.0.40" - GH_AW_TRACKER_ID: "copilot-token-optimizer" - GH_AW_WORKFLOW_ID: "copilot-token-optimizer" - GH_AW_WORKFLOW_NAME: "Copilot Token Usage Optimizer" + GH_AW_TRACKER_ID: "agentic-token-optimizer" + GH_AW_WORKFLOW_ID: "agentic-token-optimizer" + GH_AW_WORKFLOW_NAME: "Agentic Workflow Token Usage Optimizer" 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 }} @@ -1180,8 +1180,8 @@ jobs: job-name: ${{ github.job }} trace-id: ${{ needs.activation.outputs.setup-trace-id }} env: - GH_AW_SETUP_WORKFLOW_NAME: "Copilot Token Usage Optimizer" - GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/copilot-token-optimizer.lock.yml@${{ github.ref }} + GH_AW_SETUP_WORKFLOW_NAME: "Agentic Workflow Token Usage Optimizer" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/agentic-token-optimizer.lock.yml@${{ github.ref }} GH_AW_INFO_VERSION: "1.0.40" - name: Download agent output artifact id: download-agent-output @@ -1214,7 +1214,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_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\"},\"report_incomplete\":{}}" + GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG: "{\"create_issue\":{\"close_older_issues\":true,\"expires\":168,\"max\":1,\"title_prefix\":\"[agentic-token-optimizer] \"},\"create_report_incomplete_issue\":{},\"missing_data\":{},\"missing_tool\":{},\"noop\":{\"max\":1,\"report-as-issue\":\"true\"},\"report_incomplete\":{}}" with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | diff --git a/workflows/copilot-token-optimizer.md b/.github/workflows/agentic-token-optimizer.md similarity index 93% rename from workflows/copilot-token-optimizer.md rename to .github/workflows/agentic-token-optimizer.md index 7b3e0dc..92dfea4 100644 --- a/workflows/copilot-token-optimizer.md +++ b/.github/workflows/agentic-token-optimizer.md @@ -1,5 +1,5 @@ --- -description: Daily optimizer that identifies a high-token-usage Copilot workflow, audits its runs, and recommends efficiency improvements +description: Daily optimizer that identifies a high-token-usage agentic workflow, audits its runs, and recommends efficiency improvements on: schedule: - cron: "daily around 14:00 on weekdays" @@ -9,8 +9,7 @@ permissions: actions: read issues: read pull-requests: read -tracker-id: copilot-token-optimizer -engine: copilot +tracker-id: agentic-token-optimizer tools: github: mode: gh-proxy @@ -19,31 +18,30 @@ tools: - "*" repo-memory: branch-name: "memory/token-audit" - description: "Historical daily Copilot token usage snapshots (shared with copilot-token-audit)" + description: "Historical daily workflow token usage snapshots (shared with agentic-token-audit)" file-glob: ["*.json", "*.jsonl", "*.csv", "*.md"] max-file-size: 102400 max-patch-size: 51200 safe-outputs: create-issue: expires: 7d - title-prefix: "[copilot-token-optimizer] " + title-prefix: "[agentic-token-optimizer] " close-older-issues: true max: 1 threat-detection: false timeout-minutes: 30 steps: - - name: Download recent Copilot workflow logs + - name: Download recent agentic workflow logs env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | set -euo pipefail mkdir -p /tmp/gh-aw/token-audit - echo "📥 Downloading Copilot workflow logs (last 7 days)..." + echo "📥 Downloading agentic workflow logs (last 7 days)..." LOGS_EXIT=0 gh aw logs \ - --engine copilot \ --start-date -7d \ --json \ -c 50 \ @@ -51,7 +49,7 @@ steps: if [ -s /tmp/gh-aw/token-audit/all-runs.json ]; then TOTAL=$(jq '.runs | length' /tmp/gh-aw/token-audit/all-runs.json) - echo "✅ Downloaded $TOTAL Copilot workflow runs (last 7 days)" + echo "✅ Downloaded $TOTAL agentic workflow runs (last 7 days)" if [ "$LOGS_EXIT" -ne 0 ]; then echo "⚠️ gh aw logs exited with code $LOGS_EXIT (partial results — likely API rate limit)" fi @@ -111,9 +109,9 @@ steps: fi --- -# Copilot Token Usage Optimizer +# Agentic Workflow Token Usage Optimizer -You are the Copilot Token Optimizer. Pick one high-cost workflow, audit recent runs, and create a conservative optimization issue with measurable savings. +You are the Agentic Workflow Token Optimizer. Pick one high-cost workflow, audit recent runs, and create a conservative optimization issue with measurable savings. ## Objectives diff --git a/.github/workflows/agentics-maintenance.yml b/.github/workflows/agentics-maintenance.yml index 00651d5..a92b313 100644 --- a/.github/workflows/agentics-maintenance.yml +++ b/.github/workflows/agentics-maintenance.yml @@ -174,7 +174,7 @@ jobs: await main(); - name: Install gh-aw - uses: github/gh-aw-actions/setup-cli@f8495a686e66770ae977f82732f34d7340ee42a4 # v0.72.1 + uses: github/gh-aw-actions/setup-cli@v0.72.1 with: version: v0.72.1 @@ -309,7 +309,7 @@ jobs: await main(); - name: Install gh-aw - uses: github/gh-aw-actions/setup-cli@f8495a686e66770ae977f82732f34d7340ee42a4 # v0.72.1 + uses: github/gh-aw-actions/setup-cli@v0.72.1 with: version: v0.72.1 @@ -355,7 +355,7 @@ jobs: await main(); - name: Install gh-aw - uses: github/gh-aw-actions/setup-cli@f8495a686e66770ae977f82732f34d7340ee42a4 # v0.72.1 + uses: github/gh-aw-actions/setup-cli@v0.72.1 with: version: v0.72.1 @@ -489,7 +489,7 @@ jobs: await main(); - name: Install gh-aw - uses: github/gh-aw-actions/setup-cli@f8495a686e66770ae977f82732f34d7340ee42a4 # v0.72.1 + uses: github/gh-aw-actions/setup-cli@v0.72.1 with: version: v0.72.1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 24e5fae..f2af540 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,7 +44,7 @@ jobs: TARGET_REPO=$(mktemp -d) git init "$TARGET_REPO" cd "$TARGET_REPO" - gh aw add "${{ github.workspace }}/workflows/copilot-token-audit.md" "${{ github.workspace }}/workflows/copilot-token-optimizer.md" + gh aw add "${{ github.workspace }}/workflows/agentic-token-audit.md" "${{ github.workspace }}/workflows/agentic-token-optimizer.md" gh aw compile --validate --no-emit env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -68,7 +68,7 @@ jobs: TARGET_REPO=$(mktemp -d) git init "$TARGET_REPO" cd "$TARGET_REPO" - gh aw add "${{ github.repository }}/copilot-token-audit" "${{ github.repository }}/copilot-token-optimizer" + gh aw add "${{ github.repository }}/agentic-token-audit" "${{ github.repository }}/agentic-token-optimizer" gh aw compile --validate --no-emit env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -98,10 +98,10 @@ jobs: installed=true for path in \ - .github/workflows/copilot-token-audit.md \ - .github/workflows/copilot-token-audit.lock.yml \ - .github/workflows/copilot-token-optimizer.md \ - .github/workflows/copilot-token-optimizer.lock.yml; do + .github/workflows/agentic-token-audit.md \ + .github/workflows/agentic-token-audit.lock.yml \ + .github/workflows/agentic-token-optimizer.md \ + .github/workflows/agentic-token-optimizer.lock.yml; do if [[ ! -f "$path" ]]; then echo "Missing installed workflow file: $path" installed=false @@ -123,6 +123,6 @@ jobs: if: steps.detect-workflows.outputs.installed == 'true' run: | set -euo pipefail - gh aw run copilot-token-audit copilot-token-optimizer --ref main + gh aw run agentic-token-audit agentic-token-optimizer --ref main env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index c57772f..002ecad 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -43,7 +43,7 @@ jobs: cd "$temp_dir" git init -q - gh aw add "${{ github.repository }}/copilot-token-audit" "${{ github.repository }}/copilot-token-optimizer" + gh aw add "${{ github.repository }}/agentic-token-audit" "${{ github.repository }}/agentic-token-optimizer" gh aw compile --validate --no-emit - name: Validate published workflows env: @@ -59,8 +59,8 @@ jobs: run: | set -euo pipefail - gh aw run copilot-token-audit --ref "${{ github.ref_name }}" - gh aw run copilot-token-optimizer --ref "${{ github.ref_name }}" + gh aw run agentic-token-audit --ref "${{ github.ref_name }}" + gh aw run agentic-token-optimizer --ref "${{ github.ref_name }}" - name: Upload trial results if: ${{ always() }} uses: actions/upload-artifact@v4 diff --git a/.github/workflows/install-workflows.yml b/.github/workflows/install-workflows.yml index 9af478f..15db21d 100644 --- a/.github/workflows/install-workflows.yml +++ b/.github/workflows/install-workflows.yml @@ -32,7 +32,7 @@ jobs: TARGET_REPO=$(mktemp -d) git init "$TARGET_REPO" cd "$TARGET_REPO" - gh aw add "${{ github.workspace }}/workflows/copilot-token-audit.md" "${{ github.workspace }}/workflows/copilot-token-optimizer.md" + gh aw add "${{ github.workspace }}/workflows/agentic-token-audit.md" "${{ github.workspace }}/workflows/agentic-token-optimizer.md" gh aw compile --validate --no-emit env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -75,13 +75,13 @@ jobs: RUN_BRANCH="ci/install-workflows-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" git switch --create "$RUN_BRANCH" - gh aw add --force "${{ github.workspace }}/workflows/copilot-token-audit.md" "${{ github.workspace }}/workflows/copilot-token-optimizer.md" + gh aw add --force "${{ github.workspace }}/workflows/agentic-token-audit.md" "${{ github.workspace }}/workflows/agentic-token-optimizer.md" gh aw compile git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git add .github/workflows/copilot-token-audit.md .github/workflows/copilot-token-audit.lock.yml - git add .github/workflows/copilot-token-optimizer.md .github/workflows/copilot-token-optimizer.lock.yml + git add .github/workflows/agentic-token-audit.md .github/workflows/agentic-token-audit.lock.yml + git add .github/workflows/agentic-token-optimizer.md .github/workflows/agentic-token-optimizer.lock.yml if git diff --cached --quiet; then echo "No installed workflow changes to push." echo "pr_url=" >> "$GITHUB_OUTPUT" @@ -117,4 +117,4 @@ jobs: echo echo "- No workflow installation changes were produced." fi - } >> "$GITHUB_STEP_SUMMARY" \ No newline at end of file + } >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/release.lock.yml b/.github/workflows/release.lock.yml index cf33c00..4c8233a 100644 --- a/.github/workflows/release.lock.yml +++ b/.github/workflows/release.lock.yml @@ -1,4 +1,4 @@ -# gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"fa97f85f51fd27deefff0a30053dedb3136c7adbe026fc6f39956dbef31cb39d","compiler_version":"v0.72.1","strict":true,"agent_id":"copilot"} +# gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"c799008aa57ae401e20f053978918b36f58e8e3c5d388ab30c721129c9ee59a0","compiler_version":"v0.72.1","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":"34e114876b0b11c390a56381ad16ebd13914f8d5","version":"v4"},{"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"},{"repo":"github/gh-aw-actions/setup","sha":"bc56a0cad2f450c562810785ef38649c04db812a","version":"v0.72.1"},{"repo":"github/gh-aw-actions/setup-cli","sha":"f8495a686e66770ae977f82732f34d7340ee42a4","version":"f8495a686e66770ae977f82732f34d7340ee42a4"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.25.41","digest":"sha256:cb2b565d070116d4b67e355775340528b5a2c3cb18b2c9049638bcc2df681770","pinned_image":"ghcr.io/github/gh-aw-firewall/agent:0.25.41@sha256:cb2b565d070116d4b67e355775340528b5a2c3cb18b2c9049638bcc2df681770"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.25.41","digest":"sha256:fadd0de387209f69a9a7a1b8722bb5e7fdfb80ba9749a5c60f0e4cd7582a74d0","pinned_image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.25.41@sha256:fadd0de387209f69a9a7a1b8722bb5e7fdfb80ba9749a5c60f0e4cd7582a74d0"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.25.41","digest":"sha256:1260445d25968dbf3ae70143964177a0e5914cf2ce07a6117f7d3caec6c3e3c4","pinned_image":"ghcr.io/github/gh-aw-firewall/squid:0.25.41@sha256:1260445d25968dbf3ae70143964177a0e5914cf2ce07a6117f7d3caec6c3e3c4"},{"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"}]} # ___ _ _ # / _ \ | | (_) @@ -196,20 +196,20 @@ jobs: run: | bash "${RUNNER_TEMP}/gh-aw/actions/create_prompt_first.sh" { - cat << 'GH_AW_PROMPT_030af307c5551b52_EOF' + cat << 'GH_AW_PROMPT_3a1e09a3d5e0a833_EOF' - GH_AW_PROMPT_030af307c5551b52_EOF + GH_AW_PROMPT_3a1e09a3d5e0a833_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/safe_outputs_prompt.md" - cat << 'GH_AW_PROMPT_030af307c5551b52_EOF' + cat << 'GH_AW_PROMPT_3a1e09a3d5e0a833_EOF' Tools: update_release, missing_tool, missing_data, noop - GH_AW_PROMPT_030af307c5551b52_EOF + GH_AW_PROMPT_3a1e09a3d5e0a833_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/mcp_cli_tools_prompt.md" - cat << 'GH_AW_PROMPT_030af307c5551b52_EOF' + cat << 'GH_AW_PROMPT_3a1e09a3d5e0a833_EOF' The following GitHub context information is available for this workflow: {{#if __GH_AW_GITHUB_ACTOR__ }} @@ -238,12 +238,12 @@ jobs: {{/if}} - GH_AW_PROMPT_030af307c5551b52_EOF + GH_AW_PROMPT_3a1e09a3d5e0a833_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/github_mcp_tools_with_safeoutputs_prompt.md" - cat << 'GH_AW_PROMPT_030af307c5551b52_EOF' + cat << 'GH_AW_PROMPT_3a1e09a3d5e0a833_EOF' {{#runtime-import .github/workflows/release.md}} - GH_AW_PROMPT_030af307c5551b52_EOF + GH_AW_PROMPT_3a1e09a3d5e0a833_EOF } > "$GH_AW_PROMPT" - name: Interpolate variables and render templates uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 @@ -450,9 +450,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_dabd2f491ceb6419_EOF' + cat > "${RUNNER_TEMP}/gh-aw/safeoutputs/config.json" << 'GH_AW_SAFE_OUTPUTS_CONFIG_1cc74fd6b63ad8c0_EOF' {"create_report_incomplete_issue":{},"missing_data":{},"missing_tool":{},"noop":{"max":1,"report-as-issue":"true"},"report_incomplete":{},"update_release":{"max":1}} - GH_AW_SAFE_OUTPUTS_CONFIG_dabd2f491ceb6419_EOF + GH_AW_SAFE_OUTPUTS_CONFIG_1cc74fd6b63ad8c0_EOF - name: Generate Safe Outputs Tools env: GH_AW_TOOLS_META_JSON: | @@ -644,7 +644,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_9beaedcd952d733f_EOF | "$GH_AW_NODE" "${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.cjs" + cat << GH_AW_MCP_CONFIG_f6f73cfbae644b0b_EOF | "$GH_AW_NODE" "${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.cjs" { "mcpServers": { "github": { @@ -685,7 +685,7 @@ jobs: "payloadDir": "${MCP_GATEWAY_PAYLOAD_DIR}" } } - GH_AW_MCP_CONFIG_9beaedcd952d733f_EOF + GH_AW_MCP_CONFIG_f6f73cfbae644b0b_EOF - name: Mount MCP servers as CLIs id: mount-mcp-clis continue-on-error: true diff --git a/.github/workflows/release.md b/.github/workflows/release.md index 929c407..d336c7f 100644 --- a/.github/workflows/release.md +++ b/.github/workflows/release.md @@ -18,7 +18,6 @@ on: type: string permissions: contents: read -engine: copilot timeout-minutes: 20 tools: bash: diff --git a/README.md b/README.md index 9328499..21aea62 100644 --- a/README.md +++ b/README.md @@ -2,17 +2,17 @@ [![CI](https://github.com/githubnext/agentic-ops/actions/workflows/ci.yml/badge.svg)](https://github.com/githubnext/agentic-ops/actions/workflows/ci.yml) -This repo contains a small set of GitHub Agentic Workflows for auditing Copilot token usage and highlighting workflows that should be optimized. +This repo contains a small set of GitHub Agentic Workflows for auditing token usage across agentic workflows and highlighting workflows that should be optimized. ## Usage To add one of these workflows to your repo, use `gh aw add //`. ```bash -gh aw add githubnext/agentic-ops/copilot-token-audit githubnext/agentic-ops/copilot-token-optimizer +gh aw add githubnext/agentic-ops/agentic-token-audit githubnext/agentic-ops/agentic-token-optimizer ``` -This adds the workflow to `.github/workflows/`. For guided setup, use `gh aw add-wizard githubnext/agentic-ops/copilot-token-audit`. +This adds the workflow to `.github/workflows/`. For guided setup, use `gh aw add-wizard githubnext/agentic-ops/agentic-token-audit`. Release history lives in [CHANGELOG.md](CHANGELOG.md). @@ -20,5 +20,5 @@ Release history lives in [CHANGELOG.md](CHANGELOG.md). | Workflow | What it does | | ----- | --- | -| [`Daily Copilot Token Usage Audit`](https://github.com/githubnext/agentic-ops/blob/main/workflows/copilot-token-audit.md?plain=1) | Collects recent Copilot workflow usage and creates a daily audit snapshot. | -| [`Copilot Token Usage Optimizer`](https://github.com/githubnext/agentic-ops/blob/main/workflows/copilot-token-optimizer.md?plain=1) | Analyzes expensive workflows and proposes conservative token-reduction changes. | +| [`Daily Agentic Workflow Token Usage Audit`](https://github.com/githubnext/agentic-ops/blob/main/workflows/agentic-token-audit.md?plain=1) | Collects recent agentic workflow usage and creates a daily audit snapshot. | +| [`Agentic Workflow Token Usage Optimizer`](https://github.com/githubnext/agentic-ops/blob/main/workflows/agentic-token-optimizer.md?plain=1) | Analyzes expensive workflows and proposes conservative token-reduction changes. | diff --git a/.github/workflows/copilot-token-audit.lock.yml b/workflows/agentic-token-audit.lock.yml similarity index 94% rename from .github/workflows/copilot-token-audit.lock.yml rename to workflows/agentic-token-audit.lock.yml index 8df1689..91c0d86 100644 --- a/.github/workflows/copilot-token-audit.lock.yml +++ b/workflows/agentic-token-audit.lock.yml @@ -1,4 +1,4 @@ -# gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"5cf839e412e5e8c60ef8661d831feb2da7748859c777bd55f2a63f208f493128","compiler_version":"v0.72.1","strict":true,"agent_id":"copilot"} +# gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"3a16aa3075a74984fcfb2b6f88464e83e046cc68df75a4df533232dff5080063","compiler_version":"v0.72.1","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/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":"github/gh-aw-actions/setup","sha":"bc56a0cad2f450c562810785ef38649c04db812a","version":"v0.72.1"}],"containers":[{"image":"alpine:latest","digest":"sha256:5b10f432ef3da1b8d4c7eb6c487f2f5a8f096bc91145e68878dd4a5019afde11","pinned_image":"alpine:latest@sha256:5b10f432ef3da1b8d4c7eb6c487f2f5a8f096bc91145e68878dd4a5019afde11"},{"image":"ghcr.io/github/gh-aw-firewall/agent:0.25.41","digest":"sha256:cb2b565d070116d4b67e355775340528b5a2c3cb18b2c9049638bcc2df681770","pinned_image":"ghcr.io/github/gh-aw-firewall/agent:0.25.41@sha256:cb2b565d070116d4b67e355775340528b5a2c3cb18b2c9049638bcc2df681770"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.25.41","digest":"sha256:fadd0de387209f69a9a7a1b8722bb5e7fdfb80ba9749a5c60f0e4cd7582a74d0","pinned_image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.25.41@sha256:fadd0de387209f69a9a7a1b8722bb5e7fdfb80ba9749a5c60f0e4cd7582a74d0"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.25.41","digest":"sha256:1260445d25968dbf3ae70143964177a0e5914cf2ce07a6117f7d3caec6c3e3c4","pinned_image":"ghcr.io/github/gh-aw-firewall/squid:0.25.41@sha256:1260445d25968dbf3ae70143964177a0e5914cf2ce07a6117f7d3caec6c3e3c4"},{"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"}]} # ___ _ _ # / _ \ | | (_) @@ -22,7 +22,7 @@ # # For more information: https://github.github.com/gh-aw/introduction/overview/ # -# Daily audit of Copilot token usage across all agentic workflows with historical trend tracking +# Daily audit of token usage across all agentic workflows with historical trend tracking # # Secrets used: # - COPILOT_GITHUB_TOKEN @@ -49,10 +49,10 @@ # - ghcr.io/github/github-mcp-server:v1.0.3@sha256:2ac27ef03461ef2b877031b838a7d1fd7f12b12d4ace7796d8cad91446d55959 # - node:lts-alpine@sha256:d1b3b4da11eefd5941e7f0b9cf17783fc99d9c6fc34884a665f40a06dbdfc94f -name: "Daily Copilot Token Usage Audit" +name: "Daily Agentic Workflow Token Usage Audit" "on": schedule: - - cron: "52 11 * * 1-5" + - cron: "40 12 * * 1-5" # Friendly format: daily around 12:00 on weekdays (scattered) workflow_dispatch: inputs: @@ -67,7 +67,7 @@ permissions: {} concurrency: group: "gh-aw-${{ github.workflow }}" -run-name: "Daily Copilot Token Usage Audit" +run-name: "Daily Agentic Workflow Token Usage Audit" jobs: activation: @@ -92,8 +92,8 @@ jobs: destination: ${{ runner.temp }}/gh-aw/actions job-name: ${{ github.job }} env: - GH_AW_SETUP_WORKFLOW_NAME: "Daily Copilot Token Usage Audit" - GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/copilot-token-audit.lock.yml@${{ github.ref }} + GH_AW_SETUP_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/agentic-token-audit.lock.yml@${{ github.ref }} GH_AW_INFO_VERSION: "1.0.40" - name: Generate agentic run info id: generate_aw_info @@ -104,7 +104,7 @@ jobs: GH_AW_INFO_VERSION: "1.0.40" GH_AW_INFO_AGENT_VERSION: "1.0.40" GH_AW_INFO_CLI_VERSION: "v0.72.1" - GH_AW_INFO_WORKFLOW_NAME: "Daily Copilot Token Usage Audit" + GH_AW_INFO_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" GH_AW_INFO_EXPERIMENTAL: "false" GH_AW_INFO_SUPPORTS_TOOLS_ALLOWLIST: "true" GH_AW_INFO_STAGED: "false" @@ -151,7 +151,7 @@ jobs: id: check-lock-file uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 env: - GH_AW_WORKFLOW_FILE: "copilot-token-audit.lock.yml" + GH_AW_WORKFLOW_FILE: "agentic-token-audit.lock.yml" GH_AW_CONTEXT_WORKFLOW_REF: "${{ github.workflow_ref }}" with: script: | @@ -186,24 +186,24 @@ jobs: run: | bash "${RUNNER_TEMP}/gh-aw/actions/create_prompt_first.sh" { - cat << 'GH_AW_PROMPT_cb6587147033c980_EOF' + cat << 'GH_AW_PROMPT_86e79ee1acc5156c_EOF' - GH_AW_PROMPT_cb6587147033c980_EOF + GH_AW_PROMPT_86e79ee1acc5156c_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_cb6587147033c980_EOF' + cat << 'GH_AW_PROMPT_86e79ee1acc5156c_EOF' 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_cb6587147033c980_EOF + GH_AW_PROMPT_86e79ee1acc5156c_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/mcp_cli_tools_prompt.md" - cat << 'GH_AW_PROMPT_cb6587147033c980_EOF' + cat << 'GH_AW_PROMPT_86e79ee1acc5156c_EOF' The following GitHub context information is available for this workflow: {{#if __GH_AW_GITHUB_ACTOR__ }} @@ -232,12 +232,12 @@ jobs: {{/if}} - GH_AW_PROMPT_cb6587147033c980_EOF + GH_AW_PROMPT_86e79ee1acc5156c_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/github_mcp_tools_with_safeoutputs_prompt.md" - cat << 'GH_AW_PROMPT_cb6587147033c980_EOF' + cat << 'GH_AW_PROMPT_86e79ee1acc5156c_EOF' - {{#runtime-import .github/workflows/copilot-token-audit.md}} - GH_AW_PROMPT_cb6587147033c980_EOF + {{#runtime-import agentic-token-audit.md}} + GH_AW_PROMPT_86e79ee1acc5156c_EOF } > "$GH_AW_PROMPT" - name: Interpolate variables and render templates uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 @@ -266,7 +266,7 @@ jobs: GH_AW_MCP_CLI_SERVERS_LIST: '- `safeoutputs` — run `safeoutputs --help` to see available tools' GH_AW_MEMORY_BRANCH_NAME: 'memory/token-audit' GH_AW_MEMORY_CONSTRAINTS: "\n\n**Constraints:**\n- **Allowed Files**: Only files matching patterns: *.json, *.jsonl, *.csv, *.md\n- **Max File Size**: 102400 bytes (0.10 MB) per file\n- **Max File Count**: 100 files per commit\n- **Max Patch Size**: 51200 bytes (50 KB) total per push (max: 100 KB)\n" - GH_AW_MEMORY_DESCRIPTION: ' Historical daily Copilot token usage snapshots (shared with copilot-token-optimizer)' + GH_AW_MEMORY_DESCRIPTION: ' Historical daily workflow token usage snapshots (shared with agentic-token-optimizer)' GH_AW_MEMORY_DIR: '/tmp/gh-aw/repo-memory/default/' GH_AW_MEMORY_TARGET_REPO: ' of the current repository' GH_AW_WIKI_NOTE: '' @@ -341,7 +341,7 @@ jobs: GH_AW_ASSETS_BRANCH: "assets/${{ github.workflow }}" GH_AW_ASSETS_MAX_SIZE_KB: 10240 GH_AW_MCP_LOG_DIR: /tmp/gh-aw/mcp-logs/safeoutputs - GH_AW_WORKFLOW_ID_SANITIZED: copilottokenaudit + GH_AW_WORKFLOW_ID_SANITIZED: agentictokenaudit outputs: agentic_engine_timeout: ${{ steps.detect-copilot-errors.outputs.agentic_engine_timeout || 'false' }} checkout_pr_success: ${{ steps.checkout-pr.outputs.checkout_pr_success || 'true' }} @@ -363,8 +363,8 @@ jobs: job-name: ${{ github.job }} trace-id: ${{ needs.activation.outputs.setup-trace-id }} env: - GH_AW_SETUP_WORKFLOW_NAME: "Daily Copilot Token Usage Audit" - GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/copilot-token-audit.lock.yml@${{ github.ref }} + GH_AW_SETUP_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/agentic-token-audit.lock.yml@${{ github.ref }} GH_AW_INFO_VERSION: "1.0.40" - name: Set runtime paths id: set-runtime-paths @@ -396,8 +396,8 @@ jobs: python3 -m pip install --quiet --target /tmp/gh-aw/token-audit/site-packages pandas matplotlib seaborn - env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Download Copilot workflow logs - run: "set -euo pipefail\nmkdir -p /tmp/gh-aw/token-audit\n\n# Download last 24 hours of Copilot logs as JSON\n# Allow partial results — gh aw logs streams incrementally, so even if\n# it hits an API rate limit partway through, the JSON written so far is\n# still valid and should be processed by the agent.\nLOGS_EXIT=0\ngh aw logs \\\n --engine copilot \\\n --start-date -1d \\\n --json \\\n -c 100 \\\n > /tmp/gh-aw/token-audit/copilot-logs.json || LOGS_EXIT=$?\n\nif [ -s /tmp/gh-aw/token-audit/copilot-logs.json ]; then\n TOTAL=$(jq '.runs | length' /tmp/gh-aw/token-audit/copilot-logs.json)\n echo \"✅ Downloaded $TOTAL Copilot workflow runs (last 24 hours)\"\n if [ \"$LOGS_EXIT\" -ne 0 ]; then\n echo \"⚠️ gh aw logs exited with code $LOGS_EXIT (partial results — likely API rate limit)\"\n fi\nelse\n echo \"❌ No log data downloaded (exit code $LOGS_EXIT)\"\n echo '{\"runs\":[],\"summary\":{}}' > /tmp/gh-aw/token-audit/copilot-logs.json\nfi\n" + name: Download agentic workflow logs + run: "set -euo pipefail\nmkdir -p /tmp/gh-aw/token-audit\n\n# Download last 24 hours of agentic workflow logs as JSON\n# Allow partial results — gh aw logs streams incrementally, so even if\n# it hits an API rate limit partway through, the JSON written so far is\n# still valid and should be processed by the agent.\nLOGS_EXIT=0\ngh aw logs \\\n --start-date -1d \\\n --json \\\n -c 100 \\\n > /tmp/gh-aw/token-audit/workflow-logs.json || LOGS_EXIT=$?\n\nif [ -s /tmp/gh-aw/token-audit/workflow-logs.json ]; then\n TOTAL=$(jq '.runs | length' /tmp/gh-aw/token-audit/workflow-logs.json)\n echo \"✅ Downloaded $TOTAL agentic workflow runs (last 24 hours)\"\n if [ \"$LOGS_EXIT\" -ne 0 ]; then\n echo \"⚠️ gh aw logs exited with code $LOGS_EXIT (partial results — likely API rate limit)\"\n fi\nelse\n echo \"❌ No log data downloaded (exit code $LOGS_EXIT)\"\n echo '{\"runs\":[],\"summary\":{}}' > /tmp/gh-aw/token-audit/workflow-logs.json\nfi\n" # Repo memory git-based storage configuration from frontmatter processed below - name: Clone repo-memory branch (default) @@ -505,15 +505,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_64723312ee166f5f_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_64723312ee166f5f_EOF + cat > "${RUNNER_TEMP}/gh-aw/safeoutputs/config.json" << GH_AW_SAFE_OUTPUTS_CONFIG_f95f30b4264aeb1f_EOF + {"create_issue":{"close_older_issues":true,"expires":72,"max":1,"title_prefix":"[agentic-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_f95f30b4264aeb1f_EOF - name: Generate Safe Outputs Tools env: GH_AW_TOOLS_META_JSON: | { "description_suffixes": { - "create_issue": " CONSTRAINTS: Maximum 1 issue(s) can be created. Title will be prefixed with \"[copilot-token-audit] \".", + "create_issue": " CONSTRAINTS: Maximum 1 issue(s) can be created. Title will be prefixed with \"[agentic-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": {}, @@ -721,7 +721,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_cb19aa5c12a7907f_EOF | "$GH_AW_NODE" "${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.cjs" + cat << GH_AW_MCP_CONFIG_8516d51d55ad3b05_EOF | "$GH_AW_NODE" "${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.cjs" { "mcpServers": { "agenticworkflows": { @@ -783,7 +783,7 @@ jobs: "payloadDir": "${MCP_GATEWAY_PAYLOAD_DIR}" } } - GH_AW_MCP_CONFIG_cb19aa5c12a7907f_EOF + GH_AW_MCP_CONFIG_8516d51d55ad3b05_EOF - name: Mount MCP servers as CLIs id: mount-mcp-clis continue-on-error: true @@ -1046,7 +1046,7 @@ jobs: contents: read issues: write concurrency: - group: "gh-aw-conclusion-copilot-token-audit" + group: "gh-aw-conclusion-agentic-token-audit" cancel-in-progress: false outputs: incomplete_count: ${{ steps.report_incomplete.outputs.incomplete_count }} @@ -1062,8 +1062,8 @@ jobs: job-name: ${{ github.job }} trace-id: ${{ needs.activation.outputs.setup-trace-id }} env: - GH_AW_SETUP_WORKFLOW_NAME: "Daily Copilot Token Usage Audit" - GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/copilot-token-audit.lock.yml@${{ github.ref }} + GH_AW_SETUP_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/agentic-token-audit.lock.yml@${{ github.ref }} GH_AW_INFO_VERSION: "1.0.40" - name: Download agent output artifact id: download-agent-output @@ -1085,8 +1085,8 @@ jobs: env: 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_TRACKER_ID: "copilot-token-audit" + GH_AW_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" + GH_AW_TRACKER_ID: "agentic-token-audit" GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} GH_AW_AGENT_CONCLUSION: ${{ needs.agent.result }} GH_AW_NOOP_REPORT_AS_ISSUE: "true" @@ -1102,8 +1102,8 @@ jobs: uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 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_TRACKER_ID: "copilot-token-audit" + GH_AW_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" + GH_AW_TRACKER_ID: "agentic-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 }} GH_AW_DETECTION_REASON: ${{ needs.detection.outputs.detection_reason }} @@ -1120,8 +1120,8 @@ jobs: env: 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_TRACKER_ID: "copilot-token-audit" + GH_AW_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" + GH_AW_TRACKER_ID: "agentic-token-audit" with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | @@ -1135,8 +1135,8 @@ jobs: env: 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_TRACKER_ID: "copilot-token-audit" + GH_AW_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" + GH_AW_TRACKER_ID: "agentic-token-audit" with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | @@ -1150,11 +1150,11 @@ jobs: uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 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_TRACKER_ID: "copilot-token-audit" + GH_AW_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" + GH_AW_TRACKER_ID: "agentic-token-audit" GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} GH_AW_AGENT_CONCLUSION: ${{ needs.agent.result }} - GH_AW_WORKFLOW_ID: "copilot-token-audit" + GH_AW_WORKFLOW_ID: "agentic-token-audit" GH_AW_ACTION_FAILURE_ISSUE_EXPIRES_HOURS: "168" GH_AW_ENGINE_ID: "copilot" GH_AW_SECRET_VERIFICATION_RESULT: ${{ needs.activation.outputs.secret_verification_result }} @@ -1205,8 +1205,8 @@ jobs: job-name: ${{ github.job }} trace-id: ${{ needs.activation.outputs.setup-trace-id }} env: - GH_AW_SETUP_WORKFLOW_NAME: "Daily Copilot Token Usage Audit" - GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/copilot-token-audit.lock.yml@${{ github.ref }} + GH_AW_SETUP_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/agentic-token-audit.lock.yml@${{ github.ref }} GH_AW_INFO_VERSION: "1.0.40" - name: Download agent output artifact id: download-agent-output @@ -1272,8 +1272,8 @@ jobs: if: always() && steps.detection_guard.outputs.run_detection == 'true' uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 env: - WORKFLOW_NAME: "Daily Copilot Token Usage Audit" - WORKFLOW_DESCRIPTION: "Daily audit of Copilot token usage across all agentic workflows with historical trend tracking" + WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" + WORKFLOW_DESCRIPTION: "Daily audit of token usage across all agentic workflows with historical trend tracking" HAS_PATCH: ${{ needs.agent.outputs.has_patch }} with: script: | @@ -1400,8 +1400,8 @@ jobs: job-name: ${{ github.job }} trace-id: ${{ needs.activation.outputs.setup-trace-id }} env: - GH_AW_SETUP_WORKFLOW_NAME: "Daily Copilot Token Usage Audit" - GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/copilot-token-audit.lock.yml@${{ github.ref }} + GH_AW_SETUP_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/agentic-token-audit.lock.yml@${{ github.ref }} GH_AW_INFO_VERSION: "1.0.40" - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -1463,16 +1463,16 @@ jobs: issues: write timeout-minutes: 15 env: - GH_AW_CALLER_WORKFLOW_ID: "${{ github.repository }}/copilot-token-audit" + GH_AW_CALLER_WORKFLOW_ID: "${{ github.repository }}/agentic-token-audit" GH_AW_DETECTION_CONCLUSION: ${{ needs.detection.outputs.detection_conclusion }} GH_AW_DETECTION_REASON: ${{ needs.detection.outputs.detection_reason }} GH_AW_EFFECTIVE_TOKENS: ${{ needs.agent.outputs.effective_tokens }} GH_AW_ENGINE_ID: "copilot" GH_AW_ENGINE_MODEL: ${{ needs.agent.outputs.model }} GH_AW_ENGINE_VERSION: "1.0.40" - 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_TRACKER_ID: "agentic-token-audit" + GH_AW_WORKFLOW_ID: "agentic-token-audit" + GH_AW_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" 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 }} @@ -1491,8 +1491,8 @@ jobs: job-name: ${{ github.job }} trace-id: ${{ needs.activation.outputs.setup-trace-id }} env: - GH_AW_SETUP_WORKFLOW_NAME: "Daily Copilot Token Usage Audit" - GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/copilot-token-audit.lock.yml@${{ github.ref }} + GH_AW_SETUP_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/agentic-token-audit.lock.yml@${{ github.ref }} GH_AW_INFO_VERSION: "1.0.40" - name: Download agent output artifact id: download-agent-output @@ -1525,7 +1525,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_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}}" + GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG: "{\"create_issue\":{\"close_older_issues\":true,\"expires\":72,\"max\":1,\"title_prefix\":\"[agentic-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: | @@ -1564,8 +1564,8 @@ jobs: job-name: ${{ github.job }} trace-id: ${{ needs.activation.outputs.setup-trace-id }} env: - GH_AW_SETUP_WORKFLOW_NAME: "Daily Copilot Token Usage Audit" - GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/copilot-token-audit.lock.yml@${{ github.ref }} + GH_AW_SETUP_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/agentic-token-audit.lock.yml@${{ github.ref }} GH_AW_INFO_VERSION: "1.0.40" - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -1618,8 +1618,8 @@ jobs: GH_AW_ASSETS_BRANCH: "assets/${{ github.workflow }}" 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_TRACKER_ID: "copilot-token-audit" + GH_AW_WORKFLOW_NAME: "Daily Agentic Workflow Token Usage Audit" + GH_AW_TRACKER_ID: "agentic-token-audit" GH_AW_ENGINE_ID: "copilot" GH_AW_ENGINE_VERSION: "1.0.40" GH_AW_ENGINE_MODEL: ${{ needs.agent.outputs.model }} diff --git a/.github/workflows/copilot-token-audit.md b/workflows/agentic-token-audit.md similarity index 89% rename from .github/workflows/copilot-token-audit.md rename to workflows/agentic-token-audit.md index 629dc34..972f382 100644 --- a/.github/workflows/copilot-token-audit.md +++ b/workflows/agentic-token-audit.md @@ -1,5 +1,5 @@ --- -description: Daily audit of Copilot token usage across all agentic workflows with historical trend tracking +description: Daily audit of token usage across all agentic workflows with historical trend tracking on: schedule: - cron: "daily around 12:00 on weekdays" @@ -9,12 +9,11 @@ permissions: actions: read issues: read pull-requests: read -tracker-id: copilot-token-audit -engine: copilot +tracker-id: agentic-token-audit safe-outputs: create-issue: expires: 3d - title-prefix: "[copilot-token-audit] " + title-prefix: "[agentic-token-audit] " max: 1 close-older-issues: true upload-asset: @@ -26,7 +25,7 @@ tools: - "*" repo-memory: branch-name: "memory/token-audit" - description: "Historical daily Copilot token usage snapshots (shared with copilot-token-optimizer)" + description: "Historical daily workflow token usage snapshots (shared with agentic-token-optimizer)" file-glob: ["*.json", "*.jsonl", "*.csv", "*.md"] max-file-size: 102400 max-patch-size: 51200 @@ -41,45 +40,44 @@ steps: - name: Install Python chart dependencies run: | python3 -m pip install --quiet --target /tmp/gh-aw/token-audit/site-packages pandas matplotlib seaborn - - name: Download Copilot workflow logs + - name: Download agentic workflow logs env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | set -euo pipefail mkdir -p /tmp/gh-aw/token-audit - # Download last 24 hours of Copilot logs as JSON + # Download last 24 hours of agentic workflow logs as JSON # Allow partial results — gh aw logs streams incrementally, so even if # it hits an API rate limit partway through, the JSON written so far is # still valid and should be processed by the agent. LOGS_EXIT=0 gh aw logs \ - --engine copilot \ --start-date -1d \ --json \ -c 100 \ - > /tmp/gh-aw/token-audit/copilot-logs.json || LOGS_EXIT=$? + > /tmp/gh-aw/token-audit/workflow-logs.json || LOGS_EXIT=$? - if [ -s /tmp/gh-aw/token-audit/copilot-logs.json ]; then - TOTAL=$(jq '.runs | length' /tmp/gh-aw/token-audit/copilot-logs.json) - echo "✅ Downloaded $TOTAL Copilot workflow runs (last 24 hours)" + if [ -s /tmp/gh-aw/token-audit/workflow-logs.json ]; then + TOTAL=$(jq '.runs | length' /tmp/gh-aw/token-audit/workflow-logs.json) + echo "✅ Downloaded $TOTAL agentic workflow runs (last 24 hours)" if [ "$LOGS_EXIT" -ne 0 ]; then echo "⚠️ gh aw logs exited with code $LOGS_EXIT (partial results — likely API rate limit)" fi else echo "❌ No log data downloaded (exit code $LOGS_EXIT)" - echo '{"runs":[],"summary":{}}' > /tmp/gh-aw/token-audit/copilot-logs.json + echo '{"runs":[],"summary":{}}' > /tmp/gh-aw/token-audit/workflow-logs.json fi timeout-minutes: 25 --- -# Daily Copilot Token Usage Audit +# Daily Agentic Workflow Token Usage Audit -You are the Copilot Token Auditor — a workflow that tracks daily token consumption across all Copilot-powered agentic workflows in this repository and maintains a historical record for trend analysis. +You are the Agentic Workflow Token Auditor — a workflow that tracks daily token consumption across all agentic workflows in this repository and maintains a historical record for trend analysis. ## Mission -1. Parse the pre-downloaded Copilot workflow logs and compute per-workflow token usage metrics. +1. Parse the pre-downloaded agentic 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 issue summarizing today's usage, trends, and cost highlights. @@ -87,7 +85,7 @@ You are the Copilot Token Auditor — a workflow that tracks daily token consump ### Pre-downloaded logs -The workflow logs are at `/tmp/gh-aw/token-audit/copilot-logs.json`. The file is the raw JSON output of `gh aw logs --json` with this top-level shape: +The workflow logs are at `/tmp/gh-aw/token-audit/workflow-logs.json`. The file is the raw JSON output of `gh aw logs --json` with this top-level shape: ```json { @@ -128,7 +126,7 @@ Previous snapshots live at `/tmp/gh-aw/repo-memory/default/`. Each daily snapsho Write a Python script to `/tmp/gh-aw/token-audit/process_audit.py` and run it. The script must: -1. Load `/tmp/gh-aw/token-audit/copilot-logs.json` and extract `.runs`. +1. Load `/tmp/gh-aw/token-audit/workflow-logs.json` and extract `.runs`. 2. Filter to `status == "completed"` runs only. 3. Group by `workflow_name` and compute per-workflow aggregates: - `run_count`, `total_tokens`, `avg_tokens`, `total_cost`, `avg_cost`, `total_turns`, `avg_turns`, `total_action_minutes`, `error_count`, `warning_count` diff --git a/workflows/copilot-token-optimizer.lock.yml b/workflows/agentic-token-optimizer.lock.yml similarity index 94% rename from workflows/copilot-token-optimizer.lock.yml rename to workflows/agentic-token-optimizer.lock.yml index be75252..71861d9 100644 --- a/workflows/copilot-token-optimizer.lock.yml +++ b/workflows/agentic-token-optimizer.lock.yml @@ -1,4 +1,4 @@ -# gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"9d01169949a866a476d4e166b66e32901f4050b164f6f72a4b633a12de28de16","compiler_version":"v0.72.1","strict":true,"agent_id":"copilot"} +# gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"2f14ef0c5a6f64ced477941b8fd6b3d846ef0ee12f45e704afa8853b511626a5","compiler_version":"v0.72.1","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"},{"repo":"github/gh-aw-actions/setup","sha":"bc56a0cad2f450c562810785ef38649c04db812a","version":"v0.72.1"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.25.41","digest":"sha256:cb2b565d070116d4b67e355775340528b5a2c3cb18b2c9049638bcc2df681770","pinned_image":"ghcr.io/github/gh-aw-firewall/agent:0.25.41@sha256:cb2b565d070116d4b67e355775340528b5a2c3cb18b2c9049638bcc2df681770"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.25.41","digest":"sha256:fadd0de387209f69a9a7a1b8722bb5e7fdfb80ba9749a5c60f0e4cd7582a74d0","pinned_image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.25.41@sha256:fadd0de387209f69a9a7a1b8722bb5e7fdfb80ba9749a5c60f0e4cd7582a74d0"},{"image":"ghcr.io/github/gh-aw-firewall/cli-proxy:0.25.41"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.25.41","digest":"sha256:1260445d25968dbf3ae70143964177a0e5914cf2ce07a6117f7d3caec6c3e3c4","pinned_image":"ghcr.io/github/gh-aw-firewall/squid:0.25.41@sha256:1260445d25968dbf3ae70143964177a0e5914cf2ce07a6117f7d3caec6c3e3c4"},{"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"}]} # ___ _ _ # / _ \ | | (_) @@ -22,7 +22,7 @@ # # For more information: https://github.github.com/gh-aw/introduction/overview/ # -# Daily optimizer that identifies a high-token-usage Copilot workflow, audits its runs, and recommends efficiency improvements +# Daily optimizer that identifies a high-token-usage agentic workflow, audits its runs, and recommends efficiency improvements # # Secrets used: # - COPILOT_GITHUB_TOKEN @@ -47,7 +47,7 @@ # - ghcr.io/github/github-mcp-server:v1.0.3@sha256:2ac27ef03461ef2b877031b838a7d1fd7f12b12d4ace7796d8cad91446d55959 # - node:lts-alpine@sha256:d1b3b4da11eefd5941e7f0b9cf17783fc99d9c6fc34884a665f40a06dbdfc94f -name: "Copilot Token Usage Optimizer" +name: "Agentic Workflow Token Usage Optimizer" "on": schedule: - cron: "19 14 * * 1-5" @@ -65,7 +65,7 @@ permissions: {} concurrency: group: "gh-aw-${{ github.workflow }}" -run-name: "Copilot Token Usage Optimizer" +run-name: "Agentic Workflow Token Usage Optimizer" jobs: activation: @@ -90,8 +90,8 @@ jobs: destination: ${{ runner.temp }}/gh-aw/actions job-name: ${{ github.job }} env: - GH_AW_SETUP_WORKFLOW_NAME: "Copilot Token Usage Optimizer" - GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/copilot-token-optimizer.lock.yml@${{ github.ref }} + GH_AW_SETUP_WORKFLOW_NAME: "Agentic Workflow Token Usage Optimizer" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/agentic-token-optimizer.lock.yml@${{ github.ref }} GH_AW_INFO_VERSION: "1.0.40" - name: Generate agentic run info id: generate_aw_info @@ -102,7 +102,7 @@ jobs: GH_AW_INFO_VERSION: "1.0.40" GH_AW_INFO_AGENT_VERSION: "1.0.40" GH_AW_INFO_CLI_VERSION: "v0.72.1" - GH_AW_INFO_WORKFLOW_NAME: "Copilot Token Usage Optimizer" + GH_AW_INFO_WORKFLOW_NAME: "Agentic Workflow Token Usage Optimizer" GH_AW_INFO_EXPERIMENTAL: "false" GH_AW_INFO_SUPPORTS_TOOLS_ALLOWLIST: "true" GH_AW_INFO_STAGED: "false" @@ -149,7 +149,7 @@ jobs: id: check-lock-file uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 env: - GH_AW_WORKFLOW_FILE: "copilot-token-optimizer.lock.yml" + GH_AW_WORKFLOW_FILE: "agentic-token-optimizer.lock.yml" GH_AW_CONTEXT_WORKFLOW_REF: "${{ github.workflow_ref }}" with: script: | @@ -184,21 +184,21 @@ jobs: run: | bash "${RUNNER_TEMP}/gh-aw/actions/create_prompt_first.sh" { - cat << 'GH_AW_PROMPT_404f8342621716f3_EOF' + cat << 'GH_AW_PROMPT_26fa2cbe45dd666d_EOF' - GH_AW_PROMPT_404f8342621716f3_EOF + GH_AW_PROMPT_26fa2cbe45dd666d_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_26fa2cbe45dd666d_EOF' Tools: create_issue, missing_tool, missing_data, noop - GH_AW_PROMPT_404f8342621716f3_EOF + GH_AW_PROMPT_26fa2cbe45dd666d_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/mcp_cli_tools_prompt.md" - cat << 'GH_AW_PROMPT_404f8342621716f3_EOF' + cat << 'GH_AW_PROMPT_26fa2cbe45dd666d_EOF' The following GitHub context information is available for this workflow: {{#if __GH_AW_GITHUB_ACTOR__ }} @@ -227,12 +227,12 @@ jobs: {{/if}} - GH_AW_PROMPT_404f8342621716f3_EOF + GH_AW_PROMPT_26fa2cbe45dd666d_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/cli_proxy_with_safeoutputs_prompt.md" - cat << 'GH_AW_PROMPT_404f8342621716f3_EOF' + cat << 'GH_AW_PROMPT_26fa2cbe45dd666d_EOF' - {{#runtime-import copilot-token-optimizer.md}} - GH_AW_PROMPT_404f8342621716f3_EOF + {{#runtime-import agentic-token-optimizer.md}} + GH_AW_PROMPT_26fa2cbe45dd666d_EOF } > "$GH_AW_PROMPT" - name: Interpolate variables and render templates uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 @@ -261,7 +261,7 @@ jobs: GH_AW_MCP_CLI_SERVERS_LIST: '- `safeoutputs` — run `safeoutputs --help` to see available tools' GH_AW_MEMORY_BRANCH_NAME: 'memory/token-audit' GH_AW_MEMORY_CONSTRAINTS: "\n\n**Constraints:**\n- **Allowed Files**: Only files matching patterns: *.json, *.jsonl, *.csv, *.md\n- **Max File Size**: 102400 bytes (0.10 MB) per file\n- **Max File Count**: 100 files per commit\n- **Max Patch Size**: 51200 bytes (50 KB) total per push (max: 100 KB)\n" - GH_AW_MEMORY_DESCRIPTION: ' Historical daily Copilot token usage snapshots (shared with copilot-token-audit)' + GH_AW_MEMORY_DESCRIPTION: ' Historical daily workflow token usage snapshots (shared with agentic-token-audit)' GH_AW_MEMORY_DIR: '/tmp/gh-aw/repo-memory/default/' GH_AW_MEMORY_TARGET_REPO: ' of the current repository' GH_AW_WIKI_NOTE: '' @@ -336,7 +336,7 @@ jobs: GH_AW_ASSETS_BRANCH: "" GH_AW_ASSETS_MAX_SIZE_KB: 0 GH_AW_MCP_LOG_DIR: /tmp/gh-aw/mcp-logs/safeoutputs - GH_AW_WORKFLOW_ID_SANITIZED: copilottokenoptimizer + GH_AW_WORKFLOW_ID_SANITIZED: agentictokenoptimizer outputs: agentic_engine_timeout: ${{ steps.detect-copilot-errors.outputs.agentic_engine_timeout || 'false' }} checkout_pr_success: ${{ steps.checkout-pr.outputs.checkout_pr_success || 'true' }} @@ -358,8 +358,8 @@ jobs: job-name: ${{ github.job }} trace-id: ${{ needs.activation.outputs.setup-trace-id }} env: - GH_AW_SETUP_WORKFLOW_NAME: "Copilot Token Usage Optimizer" - GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/copilot-token-optimizer.lock.yml@${{ github.ref }} + GH_AW_SETUP_WORKFLOW_NAME: "Agentic Workflow Token Usage Optimizer" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/agentic-token-optimizer.lock.yml@${{ github.ref }} GH_AW_INFO_VERSION: "1.0.40" - name: Set runtime paths id: set-runtime-paths @@ -381,8 +381,8 @@ jobs: GH_TOKEN: ${{ github.token }} - env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Download recent Copilot workflow logs - run: "set -euo pipefail\nmkdir -p /tmp/gh-aw/token-audit\n\necho \"📥 Downloading Copilot workflow logs (last 7 days)...\"\n\nLOGS_EXIT=0\ngh aw logs \\\n --engine copilot \\\n --start-date -7d \\\n --json \\\n -c 50 \\\n > /tmp/gh-aw/token-audit/all-runs.json || LOGS_EXIT=$?\n\nif [ -s /tmp/gh-aw/token-audit/all-runs.json ]; then\n TOTAL=$(jq '.runs | length' /tmp/gh-aw/token-audit/all-runs.json)\n echo \"✅ Downloaded $TOTAL Copilot workflow runs (last 7 days)\"\n if [ \"$LOGS_EXIT\" -ne 0 ]; then\n echo \"⚠️ gh aw logs exited with code $LOGS_EXIT (partial results — likely API rate limit)\"\n fi\nelse\n echo \"❌ No log data downloaded (exit code $LOGS_EXIT)\"\n echo '{\"runs\":[],\"summary\":{}}' > /tmp/gh-aw/token-audit/all-runs.json\nfi\n" + name: Download recent agentic workflow logs + run: "set -euo pipefail\nmkdir -p /tmp/gh-aw/token-audit\n\necho \"📥 Downloading agentic workflow logs (last 7 days)...\"\n\nLOGS_EXIT=0\ngh aw logs \\\n --start-date -7d \\\n --json \\\n -c 50 \\\n > /tmp/gh-aw/token-audit/all-runs.json || LOGS_EXIT=$?\n\nif [ -s /tmp/gh-aw/token-audit/all-runs.json ]; then\n TOTAL=$(jq '.runs | length' /tmp/gh-aw/token-audit/all-runs.json)\n echo \"✅ Downloaded $TOTAL agentic workflow runs (last 7 days)\"\n if [ \"$LOGS_EXIT\" -ne 0 ]; then\n echo \"⚠️ gh aw logs exited with code $LOGS_EXIT (partial results — likely API rate limit)\"\n fi\nelse\n echo \"❌ No log data downloaded (exit code $LOGS_EXIT)\"\n echo '{\"runs\":[],\"summary\":{}}' > /tmp/gh-aw/token-audit/all-runs.json\nfi\n" - name: Aggregate top workflows by token usage run: "set -euo pipefail\nmkdir -p /tmp/gh-aw/token-audit\n\njq '{\n generated_at: (now | todateiso8601),\n window_days: 7,\n top_workflows: (\n [.runs[]\n | select(.status == \"completed\")\n | {\n workflow_name: .workflow_name,\n tokens: (.token_usage // 0),\n cost: (.estimated_cost // 0),\n turns: (.turns // 0),\n action_minutes: (.action_minutes // 0)\n }\n ]\n | group_by(.workflow_name)\n | map({\n workflow_name: .[0].workflow_name,\n run_count: length,\n total_tokens: (map(.tokens) | add),\n avg_tokens: ((map(.tokens) | add) / length),\n total_cost: (map(.cost) | add),\n total_turns: (map(.turns) | add),\n total_action_minutes: (map(.action_minutes) | add)\n })\n | sort_by(.total_tokens)\n | reverse\n | .[:10]\n )\n}' /tmp/gh-aw/token-audit/all-runs.json > /tmp/gh-aw/token-audit/top-workflows.json\n\necho \"✅ Generated top workflow summary at /tmp/gh-aw/token-audit/top-workflows.json\"\njq '.top_workflows' /tmp/gh-aw/token-audit/top-workflows.json\n" - name: Load optimization history @@ -464,15 +464,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_aa3b2bd0bfb870d0_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 + cat > "${RUNNER_TEMP}/gh-aw/safeoutputs/config.json" << 'GH_AW_SAFE_OUTPUTS_CONFIG_375a635b6d55f43f_EOF' + {"create_issue":{"close_older_issues":true,"expires":168,"max":1,"title_prefix":"[agentic-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_375a635b6d55f43f_EOF - name: Generate Safe Outputs Tools env: GH_AW_TOOLS_META_JSON: | { "description_suffixes": { - "create_issue": " CONSTRAINTS: Maximum 1 issue(s) can be created. Title will be prefixed with \"[copilot-token-optimizer] \"." + "create_issue": " CONSTRAINTS: Maximum 1 issue(s) can be created. Title will be prefixed with \"[agentic-token-optimizer] \"." }, "repo_params": {}, "dynamic_tools": [] @@ -663,7 +663,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_7497ae1d8022a838_EOF | "$GH_AW_NODE" "${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.cjs" { "mcpServers": { "safeoutputs": { @@ -688,7 +688,7 @@ jobs: "payloadDir": "${MCP_GATEWAY_PAYLOAD_DIR}" } } - GH_AW_MCP_CONFIG_8e694f5e06409a5c_EOF + GH_AW_MCP_CONFIG_7497ae1d8022a838_EOF - name: Mount MCP servers as CLIs id: mount-mcp-clis continue-on-error: true @@ -948,7 +948,7 @@ jobs: contents: read issues: write concurrency: - group: "gh-aw-conclusion-copilot-token-optimizer" + group: "gh-aw-conclusion-agentic-token-optimizer" cancel-in-progress: false outputs: incomplete_count: ${{ steps.report_incomplete.outputs.incomplete_count }} @@ -964,8 +964,8 @@ jobs: job-name: ${{ github.job }} trace-id: ${{ needs.activation.outputs.setup-trace-id }} env: - GH_AW_SETUP_WORKFLOW_NAME: "Copilot Token Usage Optimizer" - GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/copilot-token-optimizer.lock.yml@${{ github.ref }} + GH_AW_SETUP_WORKFLOW_NAME: "Agentic Workflow Token Usage Optimizer" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/agentic-token-optimizer.lock.yml@${{ github.ref }} GH_AW_INFO_VERSION: "1.0.40" - name: Download agent output artifact id: download-agent-output @@ -987,8 +987,8 @@ jobs: env: 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_TRACKER_ID: "copilot-token-optimizer" + GH_AW_WORKFLOW_NAME: "Agentic Workflow Token Usage Optimizer" + GH_AW_TRACKER_ID: "agentic-token-optimizer" GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} GH_AW_AGENT_CONCLUSION: ${{ needs.agent.result }} GH_AW_NOOP_REPORT_AS_ISSUE: "true" @@ -1005,8 +1005,8 @@ jobs: env: 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_TRACKER_ID: "copilot-token-optimizer" + GH_AW_WORKFLOW_NAME: "Agentic Workflow Token Usage Optimizer" + GH_AW_TRACKER_ID: "agentic-token-optimizer" with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | @@ -1020,8 +1020,8 @@ jobs: env: 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_TRACKER_ID: "copilot-token-optimizer" + GH_AW_WORKFLOW_NAME: "Agentic Workflow Token Usage Optimizer" + GH_AW_TRACKER_ID: "agentic-token-optimizer" with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | @@ -1035,11 +1035,11 @@ jobs: uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 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_TRACKER_ID: "copilot-token-optimizer" + GH_AW_WORKFLOW_NAME: "Agentic Workflow Token Usage Optimizer" + GH_AW_TRACKER_ID: "agentic-token-optimizer" GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} GH_AW_AGENT_CONCLUSION: ${{ needs.agent.result }} - GH_AW_WORKFLOW_ID: "copilot-token-optimizer" + GH_AW_WORKFLOW_ID: "agentic-token-optimizer" GH_AW_ACTION_FAILURE_ISSUE_EXPIRES_HOURS: "168" GH_AW_ENGINE_ID: "copilot" GH_AW_SECRET_VERIFICATION_RESULT: ${{ needs.activation.outputs.secret_verification_result }} @@ -1092,8 +1092,8 @@ jobs: job-name: ${{ github.job }} trace-id: ${{ needs.activation.outputs.setup-trace-id }} env: - GH_AW_SETUP_WORKFLOW_NAME: "Copilot Token Usage Optimizer" - GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/copilot-token-optimizer.lock.yml@${{ github.ref }} + GH_AW_SETUP_WORKFLOW_NAME: "Agentic Workflow Token Usage Optimizer" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/agentic-token-optimizer.lock.yml@${{ github.ref }} GH_AW_INFO_VERSION: "1.0.40" - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -1154,14 +1154,14 @@ jobs: issues: write timeout-minutes: 15 env: - GH_AW_CALLER_WORKFLOW_ID: "${{ github.repository }}/copilot-token-optimizer" + GH_AW_CALLER_WORKFLOW_ID: "${{ github.repository }}/agentic-token-optimizer" GH_AW_EFFECTIVE_TOKENS: ${{ needs.agent.outputs.effective_tokens }} GH_AW_ENGINE_ID: "copilot" GH_AW_ENGINE_MODEL: ${{ needs.agent.outputs.model }} GH_AW_ENGINE_VERSION: "1.0.40" - GH_AW_TRACKER_ID: "copilot-token-optimizer" - GH_AW_WORKFLOW_ID: "copilot-token-optimizer" - GH_AW_WORKFLOW_NAME: "Copilot Token Usage Optimizer" + GH_AW_TRACKER_ID: "agentic-token-optimizer" + GH_AW_WORKFLOW_ID: "agentic-token-optimizer" + GH_AW_WORKFLOW_NAME: "Agentic Workflow Token Usage Optimizer" 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 }} @@ -1180,8 +1180,8 @@ jobs: job-name: ${{ github.job }} trace-id: ${{ needs.activation.outputs.setup-trace-id }} env: - GH_AW_SETUP_WORKFLOW_NAME: "Copilot Token Usage Optimizer" - GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/copilot-token-optimizer.lock.yml@${{ github.ref }} + GH_AW_SETUP_WORKFLOW_NAME: "Agentic Workflow Token Usage Optimizer" + GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/agentic-token-optimizer.lock.yml@${{ github.ref }} GH_AW_INFO_VERSION: "1.0.40" - name: Download agent output artifact id: download-agent-output @@ -1214,7 +1214,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_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\"},\"report_incomplete\":{}}" + GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG: "{\"create_issue\":{\"close_older_issues\":true,\"expires\":168,\"max\":1,\"title_prefix\":\"[agentic-token-optimizer] \"},\"create_report_incomplete_issue\":{},\"missing_data\":{},\"missing_tool\":{},\"noop\":{\"max\":1,\"report-as-issue\":\"true\"},\"report_incomplete\":{}}" with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | diff --git a/.github/workflows/copilot-token-optimizer.md b/workflows/agentic-token-optimizer.md similarity index 93% rename from .github/workflows/copilot-token-optimizer.md rename to workflows/agentic-token-optimizer.md index 7b3e0dc..92dfea4 100644 --- a/.github/workflows/copilot-token-optimizer.md +++ b/workflows/agentic-token-optimizer.md @@ -1,5 +1,5 @@ --- -description: Daily optimizer that identifies a high-token-usage Copilot workflow, audits its runs, and recommends efficiency improvements +description: Daily optimizer that identifies a high-token-usage agentic workflow, audits its runs, and recommends efficiency improvements on: schedule: - cron: "daily around 14:00 on weekdays" @@ -9,8 +9,7 @@ permissions: actions: read issues: read pull-requests: read -tracker-id: copilot-token-optimizer -engine: copilot +tracker-id: agentic-token-optimizer tools: github: mode: gh-proxy @@ -19,31 +18,30 @@ tools: - "*" repo-memory: branch-name: "memory/token-audit" - description: "Historical daily Copilot token usage snapshots (shared with copilot-token-audit)" + description: "Historical daily workflow token usage snapshots (shared with agentic-token-audit)" file-glob: ["*.json", "*.jsonl", "*.csv", "*.md"] max-file-size: 102400 max-patch-size: 51200 safe-outputs: create-issue: expires: 7d - title-prefix: "[copilot-token-optimizer] " + title-prefix: "[agentic-token-optimizer] " close-older-issues: true max: 1 threat-detection: false timeout-minutes: 30 steps: - - name: Download recent Copilot workflow logs + - name: Download recent agentic workflow logs env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | set -euo pipefail mkdir -p /tmp/gh-aw/token-audit - echo "📥 Downloading Copilot workflow logs (last 7 days)..." + echo "📥 Downloading agentic workflow logs (last 7 days)..." LOGS_EXIT=0 gh aw logs \ - --engine copilot \ --start-date -7d \ --json \ -c 50 \ @@ -51,7 +49,7 @@ steps: if [ -s /tmp/gh-aw/token-audit/all-runs.json ]; then TOTAL=$(jq '.runs | length' /tmp/gh-aw/token-audit/all-runs.json) - echo "✅ Downloaded $TOTAL Copilot workflow runs (last 7 days)" + echo "✅ Downloaded $TOTAL agentic workflow runs (last 7 days)" if [ "$LOGS_EXIT" -ne 0 ]; then echo "⚠️ gh aw logs exited with code $LOGS_EXIT (partial results — likely API rate limit)" fi @@ -111,9 +109,9 @@ steps: fi --- -# Copilot Token Usage Optimizer +# Agentic Workflow Token Usage Optimizer -You are the Copilot Token Optimizer. Pick one high-cost workflow, audit recent runs, and create a conservative optimization issue with measurable savings. +You are the Agentic Workflow Token Optimizer. Pick one high-cost workflow, audit recent runs, and create a conservative optimization issue with measurable savings. ## Objectives