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
5 changes: 5 additions & 0 deletions .changeset/routing-run-observation.md

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

3 changes: 3 additions & 0 deletions actions/setup/js/collect_ndjson_output.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ async function main() {

core.info(`[INGESTION] Output file path: ${outputFile}`);
const collectionErrors = [];
let collectorInfrastructureCause;
if (!outputFile || !fs.existsSync(outputFile)) {
core.info(outputFile ? `Output file does not exist: ${outputFile}` : "GH_AW_SAFE_OUTPUTS not set, no output to collect");
const runnerTemp = process.env.RUNNER_TEMP || "/home/runner/work/_temp";
Expand All @@ -208,6 +209,7 @@ async function main() {
`This is a gateway infrastructure failure, not a normal no-op. ` +
`Check the MCP gateway startup logs for ECONNRESET errors or delayed backend registration and re-run the workflow.`;
collectionErrors.push(reason);
collectorInfrastructureCause = "safeoutputs_gateway_empty";
// eslint-disable-next-line gh-aw-custom/require-return-after-core-setfailed
core.setFailed(reason);
}
Expand Down Expand Up @@ -432,6 +434,7 @@ async function main() {
...(collectorDriverExitCode !== undefined ? { collectorDriverExitCode } : {}),
...(collectorRetryCount !== undefined ? { collectorRetryCount } : {}),
...(collectorEngineErrorType ? { collectorEngineErrorType } : {}),
...(collectorInfrastructureCause ? { collectorInfrastructureCause } : {}),
};
const path = require("path");
const agentOutputFile = path.join(TMP_GH_AW_PATH, AGENT_OUTPUT_FILENAME);
Expand Down
1 change: 1 addition & 0 deletions actions/setup/js/collect_ndjson_output.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ describe("collect_ndjson_output.cjs", () => {
const output = JSON.parse(mockCore.setOutput.mock.calls.find(call => call[0] === "output")[1]);
expect(output.items[0].type).toBe("report_incomplete");
expect(output.items[0].details).toContain("Safe-output tools: unavailable (gateway registered zero tools)");
expect(output.collectorInfrastructureCause).toBe("safeoutputs_gateway_empty");
expect(fs.existsSync(path.join(TMP_GH_AW_PATH, AGENT_OUTPUT_FILENAME))).toBe(true);
} finally {
if (originalRunnerTemp === undefined) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "items": [{ "type": "create_issue" }], "errors": [] }
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{"_schema":"model-routing/v0.28.62","timestamp":"2026-10-18T17:05:38.963Z","event":"model_routing","stage":"classification","purpose":"routing_classification","attempt":1,"classifier_model":"github-copilot/gpt-5.6-luna","classifier_effort":"high"}
{"_schema":"model-routing/v0.28.62","timestamp":"2026-10-18T17:05:45.104Z","event":"model_routing","stage":"selection","objective":{"goal":"cost","mode":"economy"},"provider":"copilot","selected_provider":"copilot","wire_model":"gpt-5.6-luna","endpoint":"/responses","labels":{"task_type":"chore","scope":"cross_system","task_complexity":"trivial"},"mode":"economy","classifier_model":"github-copilot/gpt-5.6-luna","classifier_effort":"high","router":{"name":"gh-aw-router","version":"0.1.3"},"ranked_choices":[{"model":"github-copilot/gpt-5.6-luna","effort":"max"},{"model":"github-copilot/gpt-5.6-luna","effort":"xhigh"},{"model":"github-copilot/gpt-5.6-luna","effort":"high"},{"model":"github-copilot/gpt-5.6-luna","effort":"medium"},{"model":"github-copilot/gpt-5.4-mini","effort":"xhigh"},{"model":"github-copilot/gpt-5.4-mini","effort":"high"},{"model":"github-copilot/gpt-5.4-mini","effort":"medium"},{"model":"github-copilot/gpt-5.6-luna","effort":"low"},{"model":"github-copilot/gpt-5.4-mini","effort":"low"},{"model":"github-copilot/claude-haiku-4.5","effort":null},{"model":"github-copilot/gpt-5.6-luna","effort":"none"},{"model":"github-copilot/gpt-5.4-mini","effort":"none"}],"conversation_sha256":"7af299df550a5bfe2ae9f80ccae3e5cb3a68c7d60b5b0c159f727ef364241498","selected_id":"choice-0009","selected_model":"github-copilot/gpt-5.6-luna","selected_effort":"max","degraded_classification":false,"degraded_reason":null,"classifier_attempts":1,"eligible_choices":12,"catalogue_overlap":12,"latency_ms":6156,"interaction_id":"39147795806-1","github_repository":"github/gh-aw","github_workflow_ref":"github/gh-aw/.github/workflows/smoke-copilot-routed.lock.yml@refs/heads/main"}
{"_schema":"model-routing/v0.28.62","timestamp":"2026-10-18T17:05:56.986Z","event":"model_routing","stage":"request","routed":"as_selected","deviations":[],"unavailable":[],"method":"POST","pathname":"/responses","provider":"copilot","requested_model":"gpt-5.6-luna","requested_effort":"max","selected_provider":"copilot","selected_model":"gpt-5.6-luna","selected_effort":"max","selected_endpoint":"/responses","requested_endpoint":"/responses","upstream_endpoint":"/responses","request_id":"350154af-d6ed-4d8c-b176-b93da7144bdd","outcome":"completed","status":200}
{"_schema":"model-routing/v0.28.62","timestamp":"2026-10-18T17:05:58.589Z","event":"model_routing","stage":"request","routed":"as_selected","deviations":[],"unavailable":[],"method":"POST","pathname":"/responses","provider":"copilot","requested_model":"gpt-5.6-luna","requested_effort":"max","selected_provider":"copilot","selected_model":"gpt-5.6-luna","selected_effort":"max","selected_endpoint":"/responses","requested_endpoint":"/responses","upstream_endpoint":"/responses","request_id":"79b45ef3-a365-4e5e-9e39-89c48698f37e","outcome":"completed","status":200}
{"_schema":"model-routing/v0.28.62","timestamp":"2026-10-18T17:06:01.270Z","event":"model_routing","stage":"request","routed":"as_selected","deviations":[],"unavailable":[],"method":"POST","pathname":"/responses","provider":"copilot","requested_model":"gpt-5.6-luna","requested_effort":"max","selected_provider":"copilot","selected_model":"gpt-5.6-luna","selected_effort":"max","selected_endpoint":"/responses","requested_endpoint":"/responses","upstream_endpoint":"/responses","request_id":"c2453852-d56d-4964-b514-3536a525afda","outcome":"completed","status":200}
{"_schema":"model-routing/v0.28.62","timestamp":"2026-10-18T17:06:05.354Z","event":"model_routing","stage":"request","routed":"as_selected","deviations":[],"unavailable":[],"method":"POST","pathname":"/responses","provider":"copilot","requested_model":"gpt-5.6-luna","requested_effort":"max","selected_provider":"copilot","selected_model":"gpt-5.6-luna","selected_effort":"max","selected_endpoint":"/responses","requested_endpoint":"/responses","upstream_endpoint":"/responses","request_id":"8fcd367d-53d6-48ac-b56f-620c1a1a6a80","outcome":"completed","status":200}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{"_schema":"token-usage/v0.28.62","timestamp":"2026-10-18T17:05:45.096Z","event":"token_usage","request_id":"78a3c387-fe05-4ad8-9e8a-ccd5806dc19c","provider":"copilot","model":"gpt-5.6-luna","path":"/responses","status":200,"streaming":false,"input_tokens":941,"output_tokens":549,"cache_read_tokens":0,"cache_write_tokens":0,"duration_ms":6129,"response_bytes":20133,"purpose":"routing_classification","x_initiator":"agent","ai_credits_this_response":0.0847,"ai_credits_total":0.0847,"ai_credits_pricing_source":"provider","ai_credits_pricing_tier":"default","ai_credits_accounting_policy":"concrete_model","ai_credits_fallback_pricing_used":false,"ai_credits_pricing_observed_at":"2026-10-18T17:05:38.926Z","ai_credits_pricing_api_version":"2026-07-01"}
{"_schema":"token-usage/v0.28.62","timestamp":"2026-10-18T17:05:56.985Z","event":"token_usage","request_id":"350154af-d6ed-4d8c-b176-b93da7144bdd","provider":"copilot","model":"gpt-5.6-luna","path":"/responses","status":200,"streaming":true,"input_tokens":23197,"output_tokens":400,"cache_read_tokens":0,"cache_write_tokens":0,"duration_ms":6725,"response_bytes":237349,"x_initiator":"user","ai_credits_this_response":0.51194,"ai_credits_total":0.59664,"ai_credits_pricing_source":"provider","ai_credits_pricing_tier":"default","ai_credits_accounting_policy":"concrete_model","ai_credits_fallback_pricing_used":false,"ai_credits_pricing_observed_at":"2026-10-18T17:05:38.926Z","ai_credits_pricing_api_version":"2026-07-01"}
{"_schema":"token-usage/v0.28.62","timestamp":"2026-10-18T17:05:58.589Z","event":"token_usage","request_id":"79b45ef3-a365-4e5e-9e39-89c48698f37e","provider":"copilot","model":"gpt-5.6-luna","path":"/responses","status":200,"streaming":true,"input_tokens":23799,"output_tokens":45,"cache_read_tokens":23194,"cache_write_tokens":0,"duration_ms":1536,"response_bytes":225482,"x_initiator":"agent","ai_credits_this_response":0.063888,"ai_credits_total":0.660528,"ai_credits_pricing_source":"provider","ai_credits_pricing_tier":"default","ai_credits_accounting_policy":"concrete_model","ai_credits_fallback_pricing_used":false,"ai_credits_pricing_observed_at":"2026-10-18T17:05:38.926Z","ai_credits_pricing_api_version":"2026-07-01"}
{"_schema":"token-usage/v0.28.62","timestamp":"2026-10-18T17:06:01.270Z","event":"token_usage","request_id":"c2453852-d56d-4964-b514-3536a525afda","provider":"copilot","model":"gpt-5.6-luna","path":"/responses","status":200,"streaming":true,"input_tokens":23870,"output_tokens":196,"cache_read_tokens":23796,"cache_write_tokens":0,"duration_ms":2614,"response_bytes":261689,"x_initiator":"agent","ai_credits_this_response":0.072592,"ai_credits_total":0.73312,"ai_credits_pricing_source":"provider","ai_credits_pricing_tier":"default","ai_credits_accounting_policy":"concrete_model","ai_credits_fallback_pricing_used":false,"ai_credits_pricing_observed_at":"2026-10-18T17:05:38.926Z","ai_credits_pricing_api_version":"2026-07-01"}
{"_schema":"token-usage/v0.28.62","timestamp":"2026-10-18T17:06:05.354Z","event":"token_usage","request_id":"8fcd367d-53d6-48ac-b56f-620c1a1a6a80","provider":"copilot","model":"gpt-5.6-luna","path":"/responses","status":200,"streaming":true,"input_tokens":24084,"output_tokens":109,"cache_read_tokens":23867,"cache_write_tokens":0,"duration_ms":3844,"response_bytes":298553,"x_initiator":"agent","ai_credits_this_response":0.065154,"ai_credits_total":0.798274,"ai_credits_pricing_source":"provider","ai_credits_pricing_tier":"default","ai_credits_accounting_policy":"concrete_model","ai_credits_fallback_pricing_used":false,"ai_credits_pricing_observed_at":"2026-10-18T17:05:38.926Z","ai_credits_pricing_api_version":"2026-07-01"}
5 changes: 5 additions & 0 deletions actions/setup/js/fixtures/routing_analytics_runs.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
* https://github.com/github/gh-aw/actions/runs/39499464895 (usage 12300520074,
* agent 12298393979). Selected claude-haiku-4.5, then failed closed:
* `mini-whoami` requested unavailable gpt-5.4-mini.
* - run-39147795806: Smoke Copilot Routed, AWF v0.28.62,
* https://github.com/github/gh-aw/actions/runs/39147795806/attempts/1. Selected
* gpt-5.6-luna at max; four main requests and one classifier request. It keeps
* only the api-proxy logs and `agent_output.json`, reduced to its item types:
* the agent created its required report, but a later check failed its job.
*
* `routing-analytics/awf-10211/` holds records produced by the gh-aw-firewall
* writers at b5c683e116470e0aa579ec9bf30a675fcdb66f76 (github/gh-aw-firewall#10211)
Expand Down
53 changes: 40 additions & 13 deletions actions/setup/js/routing_analytics.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,40 @@ function matchesDeclaredSubAgent(requested, provider, declarations) {
});
}

/**
* AWF's per-request routing records by request ID. Conflicting records for one
* request are ambiguous and map to null.
* @param {unknown[]} routing firewall.model_routing records
* @returns {Map<string, Record<string, any> | null>}
*/
function routedRequests(routing) {
/** @type {Map<string, Record<string, any> | null>} */
const requests = new Map();
for (const record of routing) {
if (!isObject(record) || record.stage !== "request" || typeof record.request_id !== "string" || !record.request_id) continue;
const previous = requests.get(record.request_id);
requests.set(record.request_id, previous === undefined || (previous && previous.routed === record.routed && previous.requested_model === record.requested_model) ? record : null);
}
return requests;
}

/**
* Attribute one proxy request from AWF's record of it and the runner-declared
* sub-agents: `main` ran as selected, `subagent` is a declared sub-agent's model
* that AWF recorded as deviated, `deviated` ran another model or effort, and
* anything else, including a missing or conflicting record, is `unattributed`.
* @param {Record<string, any> | null | undefined} route
* @param {unknown} provider
* @param {unknown} subAgentModels aw_info.sub_agent_models
* @returns {"main" | "subagent" | "deviated" | "unattributed"}
*/
function attributeRequest(route, provider, subAgentModels) {
const requested = route?.requested_model;
const declared = typeof requested === "string" && matchesDeclaredSubAgent(requested, route?.provider ?? provider, subAgentModels);
if (route?.routed === "deviated") return declared ? "subagent" : "deviated";
return route?.routed === "as_selected" && !declared ? "main" : "unattributed";
}

/** @param {unknown} value @returns {number | undefined} */
const tokenCount = value => (value === undefined || value === null ? 0 : typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : undefined);

Expand All @@ -270,14 +304,7 @@ const tokenCount = value => (value === undefined || value === null ? 0 : typeof
function estimateBaseline({ config, subAgentModels, tokenUsage, routing }) {
if (config?.routing?.enabled !== true) return undefined;
const baseline = config.baselineModel;
/** @type {Map<string, Record<string, any> | null>} */
const requests = new Map();
for (const record of routing) {
if (!isObject(record) || record.stage !== "request" || typeof record.request_id !== "string" || !record.request_id) continue;
// Conflicting proxy records for one request are ambiguous.
const previous = requests.get(record.request_id);
requests.set(record.request_id, previous === undefined || (previous && previous.routed === record.routed && previous.requested_model === record.requested_model) ? record : null);
}
const requests = routedRequests(routing);
const seen = new Set();
let mainRequests = 0;
let pricedRequests = 0;
Expand All @@ -295,11 +322,9 @@ function estimateBaseline({ config, subAgentModels, tokenUsage, routing }) {
if (seen.has(id)) continue;
seen.add(id);
if (record.purpose === "routing_classification") continue;
const route = requests.get(id);
const requested = route?.requested_model;
const declared = typeof requested === "string" && matchesDeclaredSubAgent(requested, route?.provider ?? record.provider, subAgentModels);
if (route?.routed === "deviated" && declared) continue;
if (route?.routed !== "as_selected" || declared) {
const role = attributeRequest(requests.get(id), record.provider, subAgentModels);
if (role === "subagent") continue;
if (role !== "main") {
unattributedRequests++;
continue;
}
Expand Down Expand Up @@ -353,5 +378,7 @@ module.exports = {
persistModelConfigBaseline,
projectModelConfig,
matchesDeclaredSubAgent,
routedRequests,
attributeRequest,
estimateBaseline,
};
Loading
Loading