-
Notifications
You must be signed in to change notification settings - Fork 494
[WIP] Fix failing GitHub Actions job 'js-typecheck' #38397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6455a1d
f822602
e6ad809
3b7d906
991b388
4d256f9
03ca5ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1967,7 +1967,10 @@ async function sendJobConclusionSpan(spanName, options = {}) { | |
| const detectionReason = process.env.GH_AW_DETECTION_REASON || ""; | ||
| const runtimeMetrics = readAgentRuntimeMetrics(); | ||
| // Read once and reuse for both gh-aw.aic and gen_ai.usage.* attributes. | ||
| const agentUsage = normalizeRuntimeTokenUsage(readJSONIfExists("/tmp/gh-aw/agent_usage.json")) || runtimeMetrics.tokenUsage || {}; | ||
| const agentUsageFilePath = "/tmp/gh-aw/agent_usage.json"; | ||
| const agentUsageRaw = readJSONIfExists(agentUsageFilePath); | ||
| const agentUsageNormalized = normalizeRuntimeTokenUsage(agentUsageRaw); | ||
| const agentUsage = agentUsageNormalized || runtimeMetrics.tokenUsage || {}; | ||
| // Mark the span as an error when the agent job failed, timed out, or was cancelled. | ||
| const isAgentTimedOut = agentConclusion === "timed_out"; | ||
| const isAgentFailure = agentConclusion === "failure" || isAgentTimedOut; | ||
|
|
@@ -2072,7 +2075,7 @@ async function sendJobConclusionSpan(spanName, options = {}) { | |
| const aiCreditsFromEnv = normalizeNonNegativeNumber(process.env.GH_AW_AIC); | ||
| const aiCreditsFromFile = agentUsage.ai_credits; | ||
|
pelikhan marked this conversation as resolved.
|
||
| const aiCreditsFromMetrics = runtimeMetrics.tokenUsage?.ai_credits; | ||
| const aiCredits = jobEmitsOwnTokenUsage ? (aiCreditsFromEnv ?? (aiCreditsFromFile > 0 ? aiCreditsFromFile : (aiCreditsFromMetrics ?? aiCreditsFromFile))) : undefined; | ||
|
pelikhan marked this conversation as resolved.
|
||
| const aiCredits = jobEmitsOwnTokenUsage ? (aiCreditsFromEnv ?? ((aiCreditsFromFile ?? 0) > 0 ? aiCreditsFromFile : (aiCreditsFromMetrics ?? aiCreditsFromFile))) : undefined; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [/tdd] The null-safety fix is correct for TypeScript strict checks, but there is no regression test covering the case where 💡 Suggested test patternit("aiCredits falls back to metrics when aiCreditsFromFile is undefined", () => {
// Arrange: agentUsage has no ai_credits field
const agentUsage = {}; // ai_credits is undefined
const runtimeMetrics = { tokenUsage: { ai_credits: 42 } };
// Act
const aiCreditsFromFile = agentUsage.ai_credits; // undefined
const aiCreditsFromMetrics = runtimeMetrics.tokenUsage?.ai_credits;
const aiCredits = (aiCreditsFromFile ?? 0) > 0
? aiCreditsFromFile
: (aiCreditsFromMetrics ?? aiCreditsFromFile);
// Assert
expect(aiCredits).toBe(42);
});Also note: the runtime behaviour of |
||
| if (typeof aiCredits === "number") { | ||
| attributes.push(buildAttr("gh-aw.aic", aiCredits)); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.