mirror of
https://github.com/PR0M3TH3AN/TORCH.git
synced 2026-11-13 00:01:29 +00:00
TASK-pilot-executor-outcomes retain bounded runtime diagnostics
This commit is contained in:
1 parent
12e1e33cc8
commit
f4594e9a37
2 files changed
+55
-8
No files matched your search
+19
-2
@@ -111,7 +111,11 @@ function startupFailureEvent(record) {
|
||||
if (record.type === 'error' || record.type === 'turn.failed' || record.type === 'turn.error') {
|
||||
const error = record.error && typeof record.error === 'object' && !Array.isArray(record.error)
|
||||
? record.error : record;
|
||||
return { code: error.code ?? record.code, message: error.message ?? record.message };
|
||||
return {
|
||||
code: error.code ?? record.code,
|
||||
category: error.category ?? record.category,
|
||||
message: error.message ?? record.message,
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -120,6 +124,18 @@ function safeDiagnosticCode(value) {
|
||||
return typeof value === 'string' && /^[A-Z][A-Z0-9_.-]{0,79}$/.test(value) ? value : null;
|
||||
}
|
||||
|
||||
function safeDiagnosticCategory(value) {
|
||||
return ['model-rejection', 'authentication', 'quota'].includes(value) ? value : null;
|
||||
}
|
||||
|
||||
function categoryFromDiagnosticCode(code) {
|
||||
if (!code) return null;
|
||||
if (/(?:MODEL|UNSUPPORTED|UNAVAILABLE|NOT_FOUND)/.test(code)) return 'model-rejection';
|
||||
if (/(?:AUTH|UNAUTHORIZED|FORBIDDEN|CREDENTIAL)/.test(code)) return 'authentication';
|
||||
if (/(?:QUOTA|RATE_LIMIT|RATE-LIMIT|LIMIT_EXCEEDED)/.test(code)) return 'quota';
|
||||
return null;
|
||||
}
|
||||
|
||||
export function diagnoseCodexStartupFailure({ stdout, stderr } = {}) {
|
||||
const parsed = boundedStartupOutput(stdout);
|
||||
const safeStderr = redactDiagnosticText(stderr);
|
||||
@@ -138,11 +154,12 @@ export function diagnoseCodexStartupFailure({ stdout, stderr } = {}) {
|
||||
}
|
||||
const message = redactDiagnosticText(failure.message);
|
||||
const code = safeDiagnosticCode(failure.code);
|
||||
const category = safeDiagnosticCategory(failure.category);
|
||||
const modelRejection = /\b(model|unsupported|not supported|unavailable|not available|does not exist)\b/i.test(message ?? '')
|
||||
|| /MODEL|UNSUPPORTED/i.test(code ?? '');
|
||||
return {
|
||||
schema: 'torch.dev/runtime-startup-diagnostic/v1alpha1', outcome: 'known',
|
||||
category: modelRejection ? 'model-rejection' : 'runtime-error',
|
||||
category: category ?? categoryFromDiagnosticCode(code) ?? (modelRejection ? 'model-rejection' : 'runtime-error'),
|
||||
...(code ? { code } : {}),
|
||||
...(message ? { message } : {}),
|
||||
stderr: safeStderr,
|
||||
|
||||
Reference in new issue
Block a user