Skip to content

Commit 2f6c660

Browse files
AlinaVarkkiDevtools-frontend LUCI CQ
authored andcommitted
[AI] Ensure the Accessibility Agent correctly understands n/a report results
Previously, if some report result was n/a, the agent assumed that the report passed. Let's make sure that it knows that n/a indicates mossing data or a failure. Result: https://screenshot.googleplex.com/3gUHWBvEiysUh7E Bug: 498942928 Change-Id: I9c755e4b324b744036b781ea7a0f51d7ad62cb9a Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7734960 Reviewed-by: Jack Franklin <jacktfranklin@chromium.org> Commit-Queue: Jack Franklin <jacktfranklin@chromium.org> Auto-Submit: Alina Varkki <alinavarkki@chromium.org> Commit-Queue: Alina Varkki <alinavarkki@chromium.org>
1 parent 255f4ff commit 2f6c660

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

front_end/models/ai_assistance/agents/AccessibilityAgent.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Your role is to help users understand and fix accessibility issues found in Ligh
6262
# Constraints
6363
* **CRITICAL**: ALWAYS call a tool before providing an answer if an element path is available.
6464
* **CRITICAL**: You are an accessibility agent. NEVER provide answers to questions of unrelated topics such as legal advice, financial advice, personal opinions, medical advice, or any other non web-development topics.
65+
* **CRITICAL**: If the Lighthouse report shows scores as "n/a" or indicates a failure, it means the data is missing or the run failed. Do NOT assume that the page passed or has no issues.
6566
6667
## Response Structure
6768
@@ -462,7 +463,13 @@ export class AccessibilityAgent extends AiAgent<LHModel.ReporterTypes.ReportJSON
462463
#getInitialPayload(context: ConversationContext<LHModel.ReporterTypes.ReportJSON>): string {
463464
const report = context.getItem();
464465
const formatter = new LighthouseFormatter();
465-
return `# Lighthouse Report:\n${formatter.summary(report)}\n${formatter.audits(report, 'accessibility')}\n`;
466+
const summary = formatter.summary(report);
467+
const audits = formatter.audits(report, 'accessibility');
468+
const allFailed = Object.values(report.categories).every(category => category.score === null);
469+
if (allFailed) {
470+
return '**CRITICAL**: The Lighthouse report failed to record or all category scores are error/unavailable (n/a). This indicates a failed run or missing data.';
471+
}
472+
return `# Lighthouse Report:\n${summary}\n${audits}`;
466473
}
467474

468475
override async enhanceQuery(query: string, lhr: ConversationContext<LHModel.ReporterTypes.ReportJSON>|null):

0 commit comments

Comments
 (0)