Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/agents/agentic-workflows.agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ This is a **dispatcher agent** that routes your request to the appropriate speci
- **Fixing Dependabot PRs**: Routes to `dependabot` prompt — use this when Dependabot opens PRs that modify generated manifest files (`.github/workflows/package.json`, `.github/workflows/requirements.txt`, `.github/workflows/go.mod`). Never merge those PRs directly; instead update the source `.md` files and rerun `gh aw compile --dependabot` to bundle all fixes
- **Analyzing test coverage**: Routes to `test-coverage` prompt — consult this whenever the workflow reads, analyzes, or reports on test coverage data from PRs or CI runs
- **CLI commands and triggering workflows**: Routes to `cli-commands` guide — consult this whenever the user asks how to run, compile, debug, or manage workflows from the command line, or when they need the MCP tool equivalent of a `gh aw` command
- **Reducing token consumption / cost optimization**: Routes to `token-optimization` guide — consult this whenever the user asks how to reduce token usage, lower costs, speed up workflows, or measure the impact of prompt changes with experiments

Workflows may optionally include:

Expand Down Expand Up @@ -141,6 +142,19 @@ When you interact with this agent, it will:
- "I'm in Copilot Cloud — how do I compile a workflow?"
- "Show me all available gh aw commands"

### Token Consumption Optimization
**Load when**: The user asks how to reduce token usage, lower workflow costs, make a workflow faster or cheaper, or measure the impact of prompt or configuration changes.

**Reference file**: https://github.com/github/gh-aw/blob/main/.github/aw/token-optimization.md

**Use cases**:
- "How do I reduce the token cost of this workflow?"
- "My workflow is too expensive — how do I optimize it?"
- "How do I compare token usage between two runs?"
- "Should I use gh-proxy or the MCP server?"
- "How do I use sub-agents to reduce costs?"
- "How do I measure the impact of a prompt change?"

## Instructions

When a user interacts with you:
Expand Down
33 changes: 20 additions & 13 deletions .github/workflows/aw-portfolio-yield.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

105 changes: 103 additions & 2 deletions .github/workflows/aw-portfolio-yield.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,113 @@ safe-outputs:
imports:
- shared/otel-queries.md
pre-agent-steps:
- name: Collect workflow telemetry snapshot
uses: actions/github-script@v9
env:
AW_YIELD_TELEMETRY_OUT: /tmp/aw-yield-telemetry-summary.json
with:
script: |
const fs = require("fs");
const owner = context.repo.owner;
const repo = context.repo.repo;
const now = Date.now();
const windowMs = 90 * 24 * 60 * 60 * 1000;
const workflowIdToSourcePath = new Map();
const workflows = await github.paginate(github.rest.actions.listRepoWorkflows, {
owner,
repo,
per_page: 100,
});
for (const workflow of workflows) {
const workflowPath = workflow.path || "";
if (!workflowPath.startsWith(".github/workflows/") || !workflowPath.endsWith(".lock.yml")) {
continue;
}
workflowIdToSourcePath.set(workflow.id, workflowPath.replace(/\.lock\.yml$/, ".md"));
}

const aggregates = new Map();
let pageCount = 0;
let reachedWindowLimit = false;
for await (const page of github.paginate.iterator(github.rest.actions.listWorkflowRunsForRepo, {
owner,
repo,
status: "completed",
per_page: 100,
})) {
pageCount += 1;
for (const run of page.data.workflow_runs || []) {
const sourcePath = workflowIdToSourcePath.get(run.workflow_id);
if (!sourcePath) {
continue;
}
const createdAt = run.created_at ? Date.parse(run.created_at) : Number.NaN;
if (!Number.isNaN(createdAt) && createdAt < now - windowMs) {
reachedWindowLimit = true;
break;
}
const startedAt = run.run_started_at ? Date.parse(run.run_started_at) : Number.NaN;
Comment thread
mnkiefer marked this conversation as resolved.
Resolved
const updatedAt = run.updated_at ? Date.parse(run.updated_at) : Number.NaN;
const durationSeconds =
!Number.isNaN(startedAt) && !Number.isNaN(updatedAt) && updatedAt >= startedAt
? (updatedAt - startedAt) / 1000
: 0;
const aggregate = aggregates.get(sourcePath) || {
runs: 0,
successfulRuns: 0,
runtimeSeconds: 0,
runtimeSamples: 0,
};
aggregate.runs += 1;
if (run.conclusion === "success") {
aggregate.successfulRuns += 1;
}
if (durationSeconds > 0) {
aggregate.runtimeSeconds += durationSeconds;
aggregate.runtimeSamples += 1;
}
aggregates.set(sourcePath, aggregate);
}
if (reachedWindowLimit || pageCount >= 10) {
break;
}
}

const workflow_metrics = {};
for (const [path, aggregate] of aggregates.entries()) {
workflow_metrics[path] = {
workflow_path: path,
workflow_invocation_count: aggregate.runs,
success_rate: aggregate.runs ? Number((aggregate.successfulRuns / aggregate.runs).toFixed(4)) : 0,
runtime_duration: aggregate.runtimeSamples
? Number((aggregate.runtimeSeconds / aggregate.runtimeSamples).toFixed(2))
: 0,
observed: aggregate.runs > 0,
validated: aggregate.runs > 0,
source: "github-actions-runs",
};
}

fs.writeFileSync(
process.env.AW_YIELD_TELEMETRY_OUT,
JSON.stringify(
{
generated_at: new Date().toISOString(),
source: "github-actions-runs",
window_days: 90,
workflow_metrics,
},
null,
2,
) + "\n",
);
- name: Precompute workflow portfolio data
uses: actions/github-script@v9
env:
AW_YIELD_WORKSPACE: ${{ github.workspace }}
AW_YIELD_WORKFLOWS: .github/workflows
AW_YIELD_OUT: /tmp/aw-yield-precompute.json
AWY_OTEL_SUMMARY_JSON: /tmp/aw-yield-telemetry-summary.json
with:
script: |
const path = require("path");
Expand Down Expand Up @@ -71,7 +172,7 @@ You are the semantic interpreter for the repository's agentic workflow portfolio
## Hard Rules

- Treat `/tmp/aw-yield-precompute.json` as the factual source of truth.
- OTel = facts. Deterministic precompute/postcompute = math. Agent = interpretation.
- Telemetry = facts. Deterministic precompute/postcompute = math. Agent = interpretation.
- Do **not** recompute raw scores, ranking, overlap values, fractions, or portfolio math from scratch.
- Do **not** invent telemetry, economics, confidence, or success evidence.
- Use the OTel queries skill only when the precompute file explicitly indicates that telemetry exists and needs brief interpretation.
Expand All @@ -94,7 +195,7 @@ Read and rely on:
- workflow recommendation seeds already computed there
- overlap clusters already computed there
- organizational health signals already computed there
- optional OTel summaries already folded into the precompute payload
- optional telemetry summaries already folded into the precompute payload

## Deliverables

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/issue-monster.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading