From 30259159ded384d30f73429e0b82625fb4853435 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Feb 2026 07:08:35 +0000 Subject: [PATCH 1/5] Initial plan From a3ed64bfce82e2ade6464fd795c4cd34165625aa Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Feb 2026 07:10:24 +0000 Subject: [PATCH 2/5] Add upper bound validation for AI response length Co-authored-by: DimaBir <28827735+DimaBir@users.noreply.github.com> --- .github/workflows/issue-assistant.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/issue-assistant.yml b/.github/workflows/issue-assistant.yml index 0e2e6920..bd0e402a 100644 --- a/.github/workflows/issue-assistant.yml +++ b/.github/workflows/issue-assistant.yml @@ -457,6 +457,15 @@ Keep responses concise (50-150 words). No signatures.`; return; } + // Check maximum length (50-150 words guidance ≈ 1000 chars with formatting) + if (aiResponse.trim().length > 1000) { + console.log(`::warning::AI response too long (${aiResponse.trim().length} chars, max 1000)`); + core.setOutput('response', ''); + core.setOutput('is_valid', 'false'); + core.setOutput('outcome', 'error'); + return; + } + // === RESPONSE VALIDATION === let isValid = true; const issues = []; From 916cf0289b11614e18ebaf2a3ec31a04169665f6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Feb 2026 07:11:16 +0000 Subject: [PATCH 3/5] Refactor response length validation to use named constants Co-authored-by: DimaBir <28827735+DimaBir@users.noreply.github.com> --- .github/workflows/issue-assistant.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/issue-assistant.yml b/.github/workflows/issue-assistant.yml index bd0e402a..633d0b70 100644 --- a/.github/workflows/issue-assistant.yml +++ b/.github/workflows/issue-assistant.yml @@ -330,6 +330,10 @@ jobs: with: script: | const fs = require('fs'); + + // Response validation constants + const MIN_AI_RESPONSE_LENGTH = 20; + const MAX_AI_RESPONSE_LENGTH = 1000; // ~150 words with formatting let wikiContext = ''; if (process.env.HAS_WIKI === 'true') { @@ -449,7 +453,7 @@ Keep responses concise (50-150 words). No signatures.`; return; } - if (!aiResponse || aiResponse.trim().length < 20) { + if (!aiResponse || aiResponse.trim().length < MIN_AI_RESPONSE_LENGTH) { console.log('::warning::AI response too short'); core.setOutput('response', ''); core.setOutput('is_valid', 'false'); @@ -458,8 +462,8 @@ Keep responses concise (50-150 words). No signatures.`; } // Check maximum length (50-150 words guidance ≈ 1000 chars with formatting) - if (aiResponse.trim().length > 1000) { - console.log(`::warning::AI response too long (${aiResponse.trim().length} chars, max 1000)`); + if (aiResponse.trim().length > MAX_AI_RESPONSE_LENGTH) { + console.log(`::warning::AI response too long (${aiResponse.trim().length} chars, max ${MAX_AI_RESPONSE_LENGTH})`); core.setOutput('response', ''); core.setOutput('is_valid', 'false'); core.setOutput('outcome', 'error'); From c07bf6c14f2bdcd81f0d967432472a2263a15b8e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Feb 2026 07:12:24 +0000 Subject: [PATCH 4/5] Optimize response validation and improve comment clarity Co-authored-by: DimaBir <28827735+DimaBir@users.noreply.github.com> --- .github/workflows/issue-assistant.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/issue-assistant.yml b/.github/workflows/issue-assistant.yml index 633d0b70..53dc38d2 100644 --- a/.github/workflows/issue-assistant.yml +++ b/.github/workflows/issue-assistant.yml @@ -333,7 +333,7 @@ jobs: // Response validation constants const MIN_AI_RESPONSE_LENGTH = 20; - const MAX_AI_RESPONSE_LENGTH = 1000; // ~150 words with formatting + const MAX_AI_RESPONSE_LENGTH = 1000; // ~150 words (~750 chars) + buffer for formatting let wikiContext = ''; if (process.env.HAS_WIKI === 'true') { @@ -453,7 +453,10 @@ Keep responses concise (50-150 words). No signatures.`; return; } - if (!aiResponse || aiResponse.trim().length < MIN_AI_RESPONSE_LENGTH) { + // Trim response once for validation + const trimmedResponse = aiResponse ? aiResponse.trim() : ''; + + if (!trimmedResponse || trimmedResponse.length < MIN_AI_RESPONSE_LENGTH) { console.log('::warning::AI response too short'); core.setOutput('response', ''); core.setOutput('is_valid', 'false'); @@ -462,8 +465,8 @@ Keep responses concise (50-150 words). No signatures.`; } // Check maximum length (50-150 words guidance ≈ 1000 chars with formatting) - if (aiResponse.trim().length > MAX_AI_RESPONSE_LENGTH) { - console.log(`::warning::AI response too long (${aiResponse.trim().length} chars, max ${MAX_AI_RESPONSE_LENGTH})`); + if (trimmedResponse.length > MAX_AI_RESPONSE_LENGTH) { + console.log(`::warning::AI response too long (${trimmedResponse.length} chars, max ${MAX_AI_RESPONSE_LENGTH})`); core.setOutput('response', ''); core.setOutput('is_valid', 'false'); core.setOutput('outcome', 'error'); From 356b939201e7cfac11e20e6041e67f20fd3bbb64 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Feb 2026 07:13:12 +0000 Subject: [PATCH 5/5] Improve consistency in validation messages and comment clarity Co-authored-by: DimaBir <28827735+DimaBir@users.noreply.github.com> --- .github/workflows/issue-assistant.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/issue-assistant.yml b/.github/workflows/issue-assistant.yml index 53dc38d2..5f3906e5 100644 --- a/.github/workflows/issue-assistant.yml +++ b/.github/workflows/issue-assistant.yml @@ -333,7 +333,7 @@ jobs: // Response validation constants const MIN_AI_RESPONSE_LENGTH = 20; - const MAX_AI_RESPONSE_LENGTH = 1000; // ~150 words (~750 chars) + buffer for formatting + const MAX_AI_RESPONSE_LENGTH = 1000; // ~150 words (~750 chars) + 250 char buffer for markdown let wikiContext = ''; if (process.env.HAS_WIKI === 'true') { @@ -457,7 +457,7 @@ Keep responses concise (50-150 words). No signatures.`; const trimmedResponse = aiResponse ? aiResponse.trim() : ''; if (!trimmedResponse || trimmedResponse.length < MIN_AI_RESPONSE_LENGTH) { - console.log('::warning::AI response too short'); + console.log(`::warning::AI response too short (${trimmedResponse.length} chars, min ${MIN_AI_RESPONSE_LENGTH})`); core.setOutput('response', ''); core.setOutput('is_valid', 'false'); core.setOutput('outcome', 'error');