From 99d11edb1c978b1eff9b0b17fcf34c01c28a2a22 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 15 Oct 2025 06:06:01 +0000
Subject: [PATCH 1/4] Initial plan


From 92253bbce221b16eeb9a83fdd63f10961fbb802a Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 15 Oct 2025 06:23:00 +0000
Subject: [PATCH 2/4] Add triggering issue/PR/discussion reference to safe
 output footers

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
---
 pkg/workflow/js/add_comment.cjs              | 40 ++++++++++++++-
 pkg/workflow/js/create_issue.cjs             | 51 +++++++++++++++++++-
 pkg/workflow/js/create_pr_review_comment.cjs | 28 ++++++++++-
 pkg/workflow/js/create_pull_request.cjs      | 24 ++++++++-
 4 files changed, 136 insertions(+), 7 deletions(-)

diff --git a/pkg/workflow/js/add_comment.cjs b/pkg/workflow/js/add_comment.cjs
index 5a88640c4b3..fe26588b4c3 100644
--- a/pkg/workflow/js/add_comment.cjs
+++ b/pkg/workflow/js/add_comment.cjs
@@ -4,11 +4,26 @@
  * @param {string} runUrl - URL of the workflow run
  * @param {string} workflowSource - Source of the workflow (owner/repo/path@ref)
  * @param {string} workflowSourceURL - GitHub URL for the workflow source
+ * @param {object} [triggeringContext] - Context about what triggered the workflow (optional, can be null)
+ * @param {string} triggeringContext.type - Type of trigger: 'issue', 'pull_request', or 'discussion'
+ * @param {number} triggeringContext.number - Number of the triggering item
+ * @param {string} [triggeringContext.url] - URL for discussions (optional)
  * @returns {string} Footer text
  */
-function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL) {
+function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
   let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
 
+  // Add triggering reference if available
+  if (triggeringContext && triggeringContext.number) {
+    if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+      footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
+    } else if (triggeringContext.type === 'pull_request') {
+      footer += ` for #${triggeringContext.number}`;
+    } else if (triggeringContext.type === 'issue') {
+      footer += ` for #${triggeringContext.number}`;
+    }
+  }
+
   if (workflowSource && workflowSourceURL) {
     footer += `\n>\n> To add this workflow in your repository, run \`gh aw add ${workflowSource}\`. See [usage guide](https://githubnext.github.io/gh-aw/tools/cli/).`;
   }
@@ -188,6 +203,27 @@ async function main() {
     context.eventName === "pull_request_review_comment";
   const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
 
+  // Determine triggering context for footer
+  let triggeringContext = undefined;
+  if (isIssueContext && context.payload.issue) {
+    triggeringContext = {
+      type: 'issue',
+      number: context.payload.issue.number
+    };
+  } else if (isPRContext && context.payload.pull_request) {
+    triggeringContext = {
+      type: 'pull_request',
+      number: context.payload.pull_request.number
+    };
+  } else if (isDiscussionContext && context.payload.discussion) {
+    const repoUrl = getRepositoryUrl();
+    triggeringContext = {
+      type: 'discussion',
+      number: context.payload.discussion.number,
+      url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+    };
+  }
+
   // Validate context based on target configuration
   if (commentTarget === "triggering" && !isIssueContext && !isPRContext && !isDiscussionContext) {
     core.info('Target is "triggering" but not running in issue, pull request, or discussion context, skipping comment creation');
@@ -272,7 +308,7 @@ async function main() {
     const runUrl = context.payload.repository
       ? `${context.payload.repository.html_url}/actions/runs/${runId}`
       : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-    body += generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL);
+    body += generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext);
 
     try {
       let comment;
diff --git a/pkg/workflow/js/create_issue.cjs b/pkg/workflow/js/create_issue.cjs
index 4519e92f372..9e74d22d1bb 100644
--- a/pkg/workflow/js/create_issue.cjs
+++ b/pkg/workflow/js/create_issue.cjs
@@ -19,11 +19,26 @@ function sanitizeLabelContent(content) {
  * @param {string} runUrl - URL of the workflow run
  * @param {string} workflowSource - Source of the workflow (owner/repo/path@ref)
  * @param {string} workflowSourceURL - GitHub URL for the workflow source
+ * @param {object} [triggeringContext] - Context about what triggered the workflow (optional, can be null)
+ * @param {string} triggeringContext.type - Type of trigger: 'issue', 'pull_request', or 'discussion'
+ * @param {number} triggeringContext.number - Number of the triggering item
+ * @param {string} [triggeringContext.url] - URL for discussions (optional)
  * @returns {string} Footer text
  */
-function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL) {
+function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
   let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
 
+  // Add triggering reference if available
+  if (triggeringContext && triggeringContext.number) {
+    if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+      footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
+    } else if (triggeringContext.type === 'pull_request') {
+      footer += ` for #${triggeringContext.number}`;
+    } else if (triggeringContext.type === 'issue') {
+      footer += ` for #${triggeringContext.number}`;
+    }
+  }
+
   if (workflowSource && workflowSourceURL) {
     footer += `\n>\n> To add this workflow in your repository, run \`gh aw add ${workflowSource}\`. See [usage guide](https://githubnext.github.io/gh-aw/tools/cli/).`;
   }
@@ -81,6 +96,38 @@ async function main() {
     return;
   }
   const parentIssueNumber = context.payload?.issue?.number;
+
+  // Determine triggering context for footer
+  const isIssueContext = context.eventName === "issues" || context.eventName === "issue_comment";
+  const isPRContext =
+    context.eventName === "pull_request" ||
+    context.eventName === "pull_request_review" ||
+    context.eventName === "pull_request_review_comment";
+  const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
+
+  let triggeringContext = undefined;
+  if (isIssueContext && context.payload.issue) {
+    triggeringContext = {
+      type: 'issue',
+      number: context.payload.issue.number
+    };
+  } else if (isPRContext && context.payload.pull_request) {
+    triggeringContext = {
+      type: 'pull_request',
+      number: context.payload.pull_request.number
+    };
+  } else if (isDiscussionContext && context.payload.discussion) {
+    const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
+    const repoUrl = context.payload.repository
+      ? context.payload.repository.html_url
+      : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
+    triggeringContext = {
+      type: 'discussion',
+      number: context.payload.discussion.number,
+      url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+    };
+  }
+
   const labelsEnv = process.env.GITHUB_AW_ISSUE_LABELS;
   let envLabels = labelsEnv
     ? labelsEnv
@@ -132,7 +179,7 @@ async function main() {
     const runUrl = context.payload.repository
       ? `${context.payload.repository.html_url}/actions/runs/${runId}`
       : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-    bodyLines.push(``, ``, generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL).trimEnd(), "");
+    bodyLines.push(``, ``, generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext).trimEnd(), "");
     const body = bodyLines.join("\n").trim();
     core.info(`Creating issue with title: ${title}`);
     core.info(`Labels: ${labels}`);
diff --git a/pkg/workflow/js/create_pr_review_comment.cjs b/pkg/workflow/js/create_pr_review_comment.cjs
index c114daa50e0..decb0a090c4 100644
--- a/pkg/workflow/js/create_pr_review_comment.cjs
+++ b/pkg/workflow/js/create_pr_review_comment.cjs
@@ -4,11 +4,26 @@
  * @param {string} runUrl - URL of the workflow run
  * @param {string} workflowSource - Source of the workflow (owner/repo/path@ref)
  * @param {string} workflowSourceURL - GitHub URL for the workflow source
+ * @param {object} [triggeringContext] - Context about what triggered the workflow (optional, can be null)
+ * @param {string} triggeringContext.type - Type of trigger: 'issue', 'pull_request', or 'discussion'
+ * @param {number} triggeringContext.number - Number of the triggering item
+ * @param {string} [triggeringContext.url] - URL for discussions (optional)
  * @returns {string} Footer text
  */
-function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL) {
+function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
   let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
 
+  // Add triggering reference if available
+  if (triggeringContext && triggeringContext.number) {
+    if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+      footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
+    } else if (triggeringContext.type === 'pull_request') {
+      footer += ` for #${triggeringContext.number}`;
+    } else if (triggeringContext.type === 'issue') {
+      footer += ` for #${triggeringContext.number}`;
+    }
+  }
+
   if (workflowSource && workflowSourceURL) {
     footer += `\n>\n> To add this workflow in your repository, run \`gh aw add ${workflowSource}\`. See [usage guide](https://githubnext.github.io/gh-aw/tools/cli/).`;
   }
@@ -125,6 +140,15 @@ async function main() {
     context.eventName === "pull_request_review_comment" ||
     (context.eventName === "issue_comment" && context.payload.issue && context.payload.issue.pull_request);
 
+  // Determine triggering context for footer
+  let triggeringContext = undefined;
+  if (isPRContext && context.payload.pull_request) {
+    triggeringContext = {
+      type: 'pull_request',
+      number: context.payload.pull_request.number
+    };
+  }
+
   // Validate context based on target configuration
   if (commentTarget === "triggering" && !isPRContext) {
     core.info('Target is "triggering" but not running in pull request context, skipping review comment creation');
@@ -258,7 +282,7 @@ async function main() {
     const runUrl = context.payload.repository
       ? `${context.payload.repository.html_url}/actions/runs/${runId}`
       : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-    body += generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL);
+    body += generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext);
 
     core.info(
       `Creating review comment on PR #${pullRequestNumber} at ${commentItem.path}:${line}${startLine ? ` (lines ${startLine}-${line})` : ""} [${side}]`
diff --git a/pkg/workflow/js/create_pull_request.cjs b/pkg/workflow/js/create_pull_request.cjs
index 24bd2caff6b..d476a35c34e 100644
--- a/pkg/workflow/js/create_pull_request.cjs
+++ b/pkg/workflow/js/create_pull_request.cjs
@@ -241,6 +241,28 @@ async function main() {
     title = titlePrefix + title;
   }
 
+  // Determine triggering context for footer
+  const isIssueContext = context.eventName === "issues" || context.eventName === "issue_comment";
+  const isPRContext =
+    context.eventName === "pull_request" ||
+    context.eventName === "pull_request_review" ||
+    context.eventName === "pull_request_review_comment";
+  const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
+
+  let triggeringReference = "";
+  if (isIssueContext && context.payload.issue) {
+    triggeringReference = ` for #${context.payload.issue.number}`;
+  } else if (isPRContext && context.payload.pull_request) {
+    triggeringReference = ` for #${context.payload.pull_request.number}`;
+  } else if (isDiscussionContext && context.payload.discussion) {
+    const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
+    const repoUrl = context.payload.repository
+      ? context.payload.repository.html_url
+      : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
+    const discussionUrl = `${repoUrl}/discussions/${context.payload.discussion.number}`;
+    triggeringReference = ` for [discussion #${context.payload.discussion.number}](${discussionUrl})`;
+  }
+
   // Add AI disclaimer with workflow name and run url
   const workflowName = process.env.GITHUB_AW_WORKFLOW_NAME || "Workflow";
   const runId = context.runId;
@@ -248,7 +270,7 @@ async function main() {
   const runUrl = context.payload.repository
     ? `${context.payload.repository.html_url}/actions/runs/${runId}`
     : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-  bodyLines.push(``, ``, `> AI generated by [${workflowName}](${runUrl})`, "");
+  bodyLines.push(``, ``, `> AI generated by [${workflowName}](${runUrl})${triggeringReference}`, "");
 
   // Prepare the body content
   const body = bodyLines.join("\n").trim();

From 39c91e89117705e7b4d28dea43e7c4c19f143c06 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 15 Oct 2025 06:31:17 +0000
Subject: [PATCH 3/4] Add tests for triggering reference in footer

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
---
 .github/workflows/brave.lock.yml              |  32 ++++-
 .github/workflows/ci-doctor.lock.yml          |  73 ++++++++++-
 .../workflows/cli-version-checker.lock.yml    |  21 +++-
 .github/workflows/dev.lock.yml                |  41 ++++++-
 .../duplicate-code-detector.lock.yml          |  41 ++++++-
 .../example-workflow-analyzer.lock.yml        |  41 ++++++-
 .../workflows/go-pattern-detector.lock.yml    |  41 ++++++-
 .github/workflows/pdf-summary.lock.yml        |  32 ++++-
 .github/workflows/plan.lock.yml               |  41 ++++++-
 .github/workflows/poem-bot.lock.yml           | 114 ++++++++++++++++--
 .github/workflows/q.lock.yml                  |  21 +++-
 .github/workflows/scout.lock.yml              |  32 ++++-
 .github/workflows/security-fix-pr.lock.yml    |  21 +++-
 .github/workflows/smoke-claude.lock.yml       |  41 ++++++-
 .github/workflows/smoke-codex.lock.yml        |  41 ++++++-
 .github/workflows/smoke-copilot.lock.yml      |  41 ++++++-
 .github/workflows/smoke-genaiscript.lock.yml  |  41 ++++++-
 .github/workflows/smoke-opencode.lock.yml     |  41 ++++++-
 .../workflows/technical-doc-writer.lock.yml   |  53 +++++++-
 .github/workflows/tidy.lock.yml               |  21 +++-
 .github/workflows/unbloat-docs.lock.yml       |  53 +++++++-
 pkg/workflow/js/add_comment.cjs               |  18 +--
 pkg/workflow/js/create_issue.cjs              |  18 +--
 pkg/workflow/js/create_issue.test.cjs         | 114 ++++++++++++++++++
 pkg/workflow/js/create_pr_review_comment.cjs  |  10 +-
 25 files changed, 973 insertions(+), 70 deletions(-)

diff --git a/.github/workflows/brave.lock.yml b/.github/workflows/brave.lock.yml
index e7a666b451b..ac504ac00e5 100644
--- a/.github/workflows/brave.lock.yml
+++ b/.github/workflows/brave.lock.yml
@@ -4117,8 +4117,17 @@ jobs:
           GITHUB_AW_WORKFLOW_NAME: "Brave Web Search Agent"
         with:
           script: |
-            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL) {
+            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
+              if (triggeringContext && triggeringContext.number) {
+                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                  footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
+                } else if (triggeringContext.type === 'pull_request') {
+                  footer += ` for #${triggeringContext.number}`;
+                } else if (triggeringContext.type === 'issue') {
+                  footer += ` for #${triggeringContext.number}`;
+                }
+              }
               if (workflowSource && workflowSourceURL) {
                 footer += `\n>\n> To add this workflow in your repository, run \`gh aw add ${workflowSource}\`. See [usage guide](https://githubnext.github.io/gh-aw/tools/cli/).`;
               }
@@ -4248,6 +4257,25 @@ jobs:
                 context.eventName === "pull_request_review" ||
                 context.eventName === "pull_request_review_comment";
               const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
+              let triggeringContext = undefined;
+              if (isIssueContext && context.payload.issue) {
+                triggeringContext = {
+                  type: 'issue',
+                  number: context.payload.issue.number
+                };
+              } else if (isPRContext && context.payload.pull_request) {
+                triggeringContext = {
+                  type: 'pull_request',
+                  number: context.payload.pull_request.number
+                };
+              } else if (isDiscussionContext && context.payload.discussion) {
+                const repoUrl = getRepositoryUrl();
+                triggeringContext = {
+                  type: 'discussion',
+                  number: context.payload.discussion.number,
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                };
+              }
               if (commentTarget === "triggering" && !isIssueContext && !isPRContext && !isDiscussionContext) {
                 core.info('Target is "triggering" but not running in issue, pull request, or discussion context, skipping comment creation');
                 return;
@@ -4318,7 +4346,7 @@ jobs:
                 const runUrl = context.payload.repository
                   ? `${context.payload.repository.html_url}/actions/runs/${runId}`
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-                body += generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL);
+                body += generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext);
                 try {
                   let comment;
                   if (isDiscussion) {
diff --git a/.github/workflows/ci-doctor.lock.yml b/.github/workflows/ci-doctor.lock.yml
index 622ea278f7b..7c4458b69d9 100644
--- a/.github/workflows/ci-doctor.lock.yml
+++ b/.github/workflows/ci-doctor.lock.yml
@@ -3518,8 +3518,17 @@ jobs:
               sanitized = sanitized.replace(/[<>&'"]/g, "");
               return sanitized.trim();
             }
-            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL) {
+            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
+              if (triggeringContext && triggeringContext.number) {
+                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                  footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
+                } else if (triggeringContext.type === 'pull_request') {
+                  footer += ` for #${triggeringContext.number}`;
+                } else if (triggeringContext.type === 'issue') {
+                  footer += ` for #${triggeringContext.number}`;
+                }
+              }
               if (workflowSource && workflowSourceURL) {
                 footer += `\n>\n> To add this workflow in your repository, run \`gh aw add ${workflowSource}\`. See [usage guide](https://githubnext.github.io/gh-aw/tools/cli/).`;
               }
@@ -3575,6 +3584,34 @@ jobs:
                 return;
               }
               const parentIssueNumber = context.payload?.issue?.number;
+              const isIssueContext = context.eventName === "issues" || context.eventName === "issue_comment";
+              const isPRContext =
+                context.eventName === "pull_request" ||
+                context.eventName === "pull_request_review" ||
+                context.eventName === "pull_request_review_comment";
+              const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
+              let triggeringContext = undefined;
+              if (isIssueContext && context.payload.issue) {
+                triggeringContext = {
+                  type: 'issue',
+                  number: context.payload.issue.number
+                };
+              } else if (isPRContext && context.payload.pull_request) {
+                triggeringContext = {
+                  type: 'pull_request',
+                  number: context.payload.pull_request.number
+                };
+              } else if (isDiscussionContext && context.payload.discussion) {
+                const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
+                const repoUrl = context.payload.repository
+                  ? context.payload.repository.html_url
+                  : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
+                triggeringContext = {
+                  type: 'discussion',
+                  number: context.payload.discussion.number,
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                };
+              }
               const labelsEnv = process.env.GITHUB_AW_ISSUE_LABELS;
               let envLabels = labelsEnv
                 ? labelsEnv
@@ -3625,7 +3662,7 @@ jobs:
                 const runUrl = context.payload.repository
                   ? `${context.payload.repository.html_url}/actions/runs/${runId}`
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-                bodyLines.push(``, ``, generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL).trimEnd(), "");
+                bodyLines.push(``, ``, generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext).trimEnd(), "");
                 const body = bodyLines.join("\n").trim();
                 core.info(`Creating issue with title: ${title}`);
                 core.info(`Labels: ${labels}`);
@@ -3761,8 +3798,17 @@ jobs:
           GITHUB_AW_WORKFLOW_SOURCE_URL: "${{ github.server_url }}/githubnext/agentics/tree/main/workflows/ci-doctor.md"
         with:
           script: |
-            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL) {
+            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
+              if (triggeringContext && triggeringContext.number) {
+                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                  footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
+                } else if (triggeringContext.type === 'pull_request') {
+                  footer += ` for #${triggeringContext.number}`;
+                } else if (triggeringContext.type === 'issue') {
+                  footer += ` for #${triggeringContext.number}`;
+                }
+              }
               if (workflowSource && workflowSourceURL) {
                 footer += `\n>\n> To add this workflow in your repository, run \`gh aw add ${workflowSource}\`. See [usage guide](https://githubnext.github.io/gh-aw/tools/cli/).`;
               }
@@ -3892,6 +3938,25 @@ jobs:
                 context.eventName === "pull_request_review" ||
                 context.eventName === "pull_request_review_comment";
               const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
+              let triggeringContext = undefined;
+              if (isIssueContext && context.payload.issue) {
+                triggeringContext = {
+                  type: 'issue',
+                  number: context.payload.issue.number
+                };
+              } else if (isPRContext && context.payload.pull_request) {
+                triggeringContext = {
+                  type: 'pull_request',
+                  number: context.payload.pull_request.number
+                };
+              } else if (isDiscussionContext && context.payload.discussion) {
+                const repoUrl = getRepositoryUrl();
+                triggeringContext = {
+                  type: 'discussion',
+                  number: context.payload.discussion.number,
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                };
+              }
               if (commentTarget === "triggering" && !isIssueContext && !isPRContext && !isDiscussionContext) {
                 core.info('Target is "triggering" but not running in issue, pull request, or discussion context, skipping comment creation');
                 return;
@@ -3962,7 +4027,7 @@ jobs:
                 const runUrl = context.payload.repository
                   ? `${context.payload.repository.html_url}/actions/runs/${runId}`
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-                body += generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL);
+                body += generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext);
                 try {
                   let comment;
                   if (isDiscussion) {
diff --git a/.github/workflows/cli-version-checker.lock.yml b/.github/workflows/cli-version-checker.lock.yml
index 1080c6b2125..c422e4dfeb2 100644
--- a/.github/workflows/cli-version-checker.lock.yml
+++ b/.github/workflows/cli-version-checker.lock.yml
@@ -3339,13 +3339,32 @@ jobs:
               if (titlePrefix && !title.startsWith(titlePrefix)) {
                 title = titlePrefix + title;
               }
+              const isIssueContext = context.eventName === "issues" || context.eventName === "issue_comment";
+              const isPRContext =
+                context.eventName === "pull_request" ||
+                context.eventName === "pull_request_review" ||
+                context.eventName === "pull_request_review_comment";
+              const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
+              let triggeringReference = "";
+              if (isIssueContext && context.payload.issue) {
+                triggeringReference = ` for #${context.payload.issue.number}`;
+              } else if (isPRContext && context.payload.pull_request) {
+                triggeringReference = ` for #${context.payload.pull_request.number}`;
+              } else if (isDiscussionContext && context.payload.discussion) {
+                const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
+                const repoUrl = context.payload.repository
+                  ? context.payload.repository.html_url
+                  : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
+                const discussionUrl = `${repoUrl}/discussions/${context.payload.discussion.number}`;
+                triggeringReference = ` for [discussion #${context.payload.discussion.number}](${discussionUrl})`;
+              }
               const workflowName = process.env.GITHUB_AW_WORKFLOW_NAME || "Workflow";
               const runId = context.runId;
               const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
               const runUrl = context.payload.repository
                 ? `${context.payload.repository.html_url}/actions/runs/${runId}`
                 : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-              bodyLines.push(``, ``, `> AI generated by [${workflowName}](${runUrl})`, "");
+              bodyLines.push(``, ``, `> AI generated by [${workflowName}](${runUrl})${triggeringReference}`, "");
               const body = bodyLines.join("\n").trim();
               const labelsEnv = process.env.GITHUB_AW_PR_LABELS;
               const labels = labelsEnv
diff --git a/.github/workflows/dev.lock.yml b/.github/workflows/dev.lock.yml
index 04fdbff9f38..d3c445423fc 100644
--- a/.github/workflows/dev.lock.yml
+++ b/.github/workflows/dev.lock.yml
@@ -3352,8 +3352,17 @@ jobs:
               sanitized = sanitized.replace(/[<>&'"]/g, "");
               return sanitized.trim();
             }
-            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL) {
+            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
+              if (triggeringContext && triggeringContext.number) {
+                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                  footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
+                } else if (triggeringContext.type === 'pull_request') {
+                  footer += ` for #${triggeringContext.number}`;
+                } else if (triggeringContext.type === 'issue') {
+                  footer += ` for #${triggeringContext.number}`;
+                }
+              }
               if (workflowSource && workflowSourceURL) {
                 footer += `\n>\n> To add this workflow in your repository, run \`gh aw add ${workflowSource}\`. See [usage guide](https://githubnext.github.io/gh-aw/tools/cli/).`;
               }
@@ -3409,6 +3418,34 @@ jobs:
                 return;
               }
               const parentIssueNumber = context.payload?.issue?.number;
+              const isIssueContext = context.eventName === "issues" || context.eventName === "issue_comment";
+              const isPRContext =
+                context.eventName === "pull_request" ||
+                context.eventName === "pull_request_review" ||
+                context.eventName === "pull_request_review_comment";
+              const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
+              let triggeringContext = undefined;
+              if (isIssueContext && context.payload.issue) {
+                triggeringContext = {
+                  type: 'issue',
+                  number: context.payload.issue.number
+                };
+              } else if (isPRContext && context.payload.pull_request) {
+                triggeringContext = {
+                  type: 'pull_request',
+                  number: context.payload.pull_request.number
+                };
+              } else if (isDiscussionContext && context.payload.discussion) {
+                const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
+                const repoUrl = context.payload.repository
+                  ? context.payload.repository.html_url
+                  : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
+                triggeringContext = {
+                  type: 'discussion',
+                  number: context.payload.discussion.number,
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                };
+              }
               const labelsEnv = process.env.GITHUB_AW_ISSUE_LABELS;
               let envLabels = labelsEnv
                 ? labelsEnv
@@ -3459,7 +3496,7 @@ jobs:
                 const runUrl = context.payload.repository
                   ? `${context.payload.repository.html_url}/actions/runs/${runId}`
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-                bodyLines.push(``, ``, generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL).trimEnd(), "");
+                bodyLines.push(``, ``, generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext).trimEnd(), "");
                 const body = bodyLines.join("\n").trim();
                 core.info(`Creating issue with title: ${title}`);
                 core.info(`Labels: ${labels}`);
diff --git a/.github/workflows/duplicate-code-detector.lock.yml b/.github/workflows/duplicate-code-detector.lock.yml
index 590911b7523..6be91c3f07e 100644
--- a/.github/workflows/duplicate-code-detector.lock.yml
+++ b/.github/workflows/duplicate-code-detector.lock.yml
@@ -3036,8 +3036,17 @@ jobs:
               sanitized = sanitized.replace(/[<>&'"]/g, "");
               return sanitized.trim();
             }
-            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL) {
+            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
+              if (triggeringContext && triggeringContext.number) {
+                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                  footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
+                } else if (triggeringContext.type === 'pull_request') {
+                  footer += ` for #${triggeringContext.number}`;
+                } else if (triggeringContext.type === 'issue') {
+                  footer += ` for #${triggeringContext.number}`;
+                }
+              }
               if (workflowSource && workflowSourceURL) {
                 footer += `\n>\n> To add this workflow in your repository, run \`gh aw add ${workflowSource}\`. See [usage guide](https://githubnext.github.io/gh-aw/tools/cli/).`;
               }
@@ -3093,6 +3102,34 @@ jobs:
                 return;
               }
               const parentIssueNumber = context.payload?.issue?.number;
+              const isIssueContext = context.eventName === "issues" || context.eventName === "issue_comment";
+              const isPRContext =
+                context.eventName === "pull_request" ||
+                context.eventName === "pull_request_review" ||
+                context.eventName === "pull_request_review_comment";
+              const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
+              let triggeringContext = undefined;
+              if (isIssueContext && context.payload.issue) {
+                triggeringContext = {
+                  type: 'issue',
+                  number: context.payload.issue.number
+                };
+              } else if (isPRContext && context.payload.pull_request) {
+                triggeringContext = {
+                  type: 'pull_request',
+                  number: context.payload.pull_request.number
+                };
+              } else if (isDiscussionContext && context.payload.discussion) {
+                const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
+                const repoUrl = context.payload.repository
+                  ? context.payload.repository.html_url
+                  : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
+                triggeringContext = {
+                  type: 'discussion',
+                  number: context.payload.discussion.number,
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                };
+              }
               const labelsEnv = process.env.GITHUB_AW_ISSUE_LABELS;
               let envLabels = labelsEnv
                 ? labelsEnv
@@ -3143,7 +3180,7 @@ jobs:
                 const runUrl = context.payload.repository
                   ? `${context.payload.repository.html_url}/actions/runs/${runId}`
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-                bodyLines.push(``, ``, generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL).trimEnd(), "");
+                bodyLines.push(``, ``, generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext).trimEnd(), "");
                 const body = bodyLines.join("\n").trim();
                 core.info(`Creating issue with title: ${title}`);
                 core.info(`Labels: ${labels}`);
diff --git a/.github/workflows/example-workflow-analyzer.lock.yml b/.github/workflows/example-workflow-analyzer.lock.yml
index e9eb954ae4b..8d9f63e3ac3 100644
--- a/.github/workflows/example-workflow-analyzer.lock.yml
+++ b/.github/workflows/example-workflow-analyzer.lock.yml
@@ -3006,8 +3006,17 @@ jobs:
               sanitized = sanitized.replace(/[<>&'"]/g, "");
               return sanitized.trim();
             }
-            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL) {
+            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
+              if (triggeringContext && triggeringContext.number) {
+                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                  footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
+                } else if (triggeringContext.type === 'pull_request') {
+                  footer += ` for #${triggeringContext.number}`;
+                } else if (triggeringContext.type === 'issue') {
+                  footer += ` for #${triggeringContext.number}`;
+                }
+              }
               if (workflowSource && workflowSourceURL) {
                 footer += `\n>\n> To add this workflow in your repository, run \`gh aw add ${workflowSource}\`. See [usage guide](https://githubnext.github.io/gh-aw/tools/cli/).`;
               }
@@ -3063,6 +3072,34 @@ jobs:
                 return;
               }
               const parentIssueNumber = context.payload?.issue?.number;
+              const isIssueContext = context.eventName === "issues" || context.eventName === "issue_comment";
+              const isPRContext =
+                context.eventName === "pull_request" ||
+                context.eventName === "pull_request_review" ||
+                context.eventName === "pull_request_review_comment";
+              const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
+              let triggeringContext = undefined;
+              if (isIssueContext && context.payload.issue) {
+                triggeringContext = {
+                  type: 'issue',
+                  number: context.payload.issue.number
+                };
+              } else if (isPRContext && context.payload.pull_request) {
+                triggeringContext = {
+                  type: 'pull_request',
+                  number: context.payload.pull_request.number
+                };
+              } else if (isDiscussionContext && context.payload.discussion) {
+                const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
+                const repoUrl = context.payload.repository
+                  ? context.payload.repository.html_url
+                  : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
+                triggeringContext = {
+                  type: 'discussion',
+                  number: context.payload.discussion.number,
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                };
+              }
               const labelsEnv = process.env.GITHUB_AW_ISSUE_LABELS;
               let envLabels = labelsEnv
                 ? labelsEnv
@@ -3113,7 +3150,7 @@ jobs:
                 const runUrl = context.payload.repository
                   ? `${context.payload.repository.html_url}/actions/runs/${runId}`
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-                bodyLines.push(``, ``, generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL).trimEnd(), "");
+                bodyLines.push(``, ``, generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext).trimEnd(), "");
                 const body = bodyLines.join("\n").trim();
                 core.info(`Creating issue with title: ${title}`);
                 core.info(`Labels: ${labels}`);
diff --git a/.github/workflows/go-pattern-detector.lock.yml b/.github/workflows/go-pattern-detector.lock.yml
index 7f715beda2e..28c6f77c429 100644
--- a/.github/workflows/go-pattern-detector.lock.yml
+++ b/.github/workflows/go-pattern-detector.lock.yml
@@ -3122,8 +3122,17 @@ jobs:
               sanitized = sanitized.replace(/[<>&'"]/g, "");
               return sanitized.trim();
             }
-            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL) {
+            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
+              if (triggeringContext && triggeringContext.number) {
+                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                  footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
+                } else if (triggeringContext.type === 'pull_request') {
+                  footer += ` for #${triggeringContext.number}`;
+                } else if (triggeringContext.type === 'issue') {
+                  footer += ` for #${triggeringContext.number}`;
+                }
+              }
               if (workflowSource && workflowSourceURL) {
                 footer += `\n>\n> To add this workflow in your repository, run \`gh aw add ${workflowSource}\`. See [usage guide](https://githubnext.github.io/gh-aw/tools/cli/).`;
               }
@@ -3179,6 +3188,34 @@ jobs:
                 return;
               }
               const parentIssueNumber = context.payload?.issue?.number;
+              const isIssueContext = context.eventName === "issues" || context.eventName === "issue_comment";
+              const isPRContext =
+                context.eventName === "pull_request" ||
+                context.eventName === "pull_request_review" ||
+                context.eventName === "pull_request_review_comment";
+              const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
+              let triggeringContext = undefined;
+              if (isIssueContext && context.payload.issue) {
+                triggeringContext = {
+                  type: 'issue',
+                  number: context.payload.issue.number
+                };
+              } else if (isPRContext && context.payload.pull_request) {
+                triggeringContext = {
+                  type: 'pull_request',
+                  number: context.payload.pull_request.number
+                };
+              } else if (isDiscussionContext && context.payload.discussion) {
+                const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
+                const repoUrl = context.payload.repository
+                  ? context.payload.repository.html_url
+                  : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
+                triggeringContext = {
+                  type: 'discussion',
+                  number: context.payload.discussion.number,
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                };
+              }
               const labelsEnv = process.env.GITHUB_AW_ISSUE_LABELS;
               let envLabels = labelsEnv
                 ? labelsEnv
@@ -3229,7 +3266,7 @@ jobs:
                 const runUrl = context.payload.repository
                   ? `${context.payload.repository.html_url}/actions/runs/${runId}`
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-                bodyLines.push(``, ``, generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL).trimEnd(), "");
+                bodyLines.push(``, ``, generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext).trimEnd(), "");
                 const body = bodyLines.join("\n").trim();
                 core.info(`Creating issue with title: ${title}`);
                 core.info(`Labels: ${labels}`);
diff --git a/.github/workflows/pdf-summary.lock.yml b/.github/workflows/pdf-summary.lock.yml
index 8dabdf63447..ba3ea4cd421 100644
--- a/.github/workflows/pdf-summary.lock.yml
+++ b/.github/workflows/pdf-summary.lock.yml
@@ -4071,8 +4071,17 @@ jobs:
           GITHUB_AW_WORKFLOW_NAME: "Resource Summarizer Agent"
         with:
           script: |
-            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL) {
+            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
+              if (triggeringContext && triggeringContext.number) {
+                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                  footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
+                } else if (triggeringContext.type === 'pull_request') {
+                  footer += ` for #${triggeringContext.number}`;
+                } else if (triggeringContext.type === 'issue') {
+                  footer += ` for #${triggeringContext.number}`;
+                }
+              }
               if (workflowSource && workflowSourceURL) {
                 footer += `\n>\n> To add this workflow in your repository, run \`gh aw add ${workflowSource}\`. See [usage guide](https://githubnext.github.io/gh-aw/tools/cli/).`;
               }
@@ -4202,6 +4211,25 @@ jobs:
                 context.eventName === "pull_request_review" ||
                 context.eventName === "pull_request_review_comment";
               const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
+              let triggeringContext = undefined;
+              if (isIssueContext && context.payload.issue) {
+                triggeringContext = {
+                  type: 'issue',
+                  number: context.payload.issue.number
+                };
+              } else if (isPRContext && context.payload.pull_request) {
+                triggeringContext = {
+                  type: 'pull_request',
+                  number: context.payload.pull_request.number
+                };
+              } else if (isDiscussionContext && context.payload.discussion) {
+                const repoUrl = getRepositoryUrl();
+                triggeringContext = {
+                  type: 'discussion',
+                  number: context.payload.discussion.number,
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                };
+              }
               if (commentTarget === "triggering" && !isIssueContext && !isPRContext && !isDiscussionContext) {
                 core.info('Target is "triggering" but not running in issue, pull request, or discussion context, skipping comment creation');
                 return;
@@ -4272,7 +4300,7 @@ jobs:
                 const runUrl = context.payload.repository
                   ? `${context.payload.repository.html_url}/actions/runs/${runId}`
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-                body += generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL);
+                body += generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext);
                 try {
                   let comment;
                   if (isDiscussion) {
diff --git a/.github/workflows/plan.lock.yml b/.github/workflows/plan.lock.yml
index 1bc51e0fc01..e4d0b8afd2b 100644
--- a/.github/workflows/plan.lock.yml
+++ b/.github/workflows/plan.lock.yml
@@ -3958,8 +3958,17 @@ jobs:
               sanitized = sanitized.replace(/[<>&'"]/g, "");
               return sanitized.trim();
             }
-            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL) {
+            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
+              if (triggeringContext && triggeringContext.number) {
+                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                  footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
+                } else if (triggeringContext.type === 'pull_request') {
+                  footer += ` for #${triggeringContext.number}`;
+                } else if (triggeringContext.type === 'issue') {
+                  footer += ` for #${triggeringContext.number}`;
+                }
+              }
               if (workflowSource && workflowSourceURL) {
                 footer += `\n>\n> To add this workflow in your repository, run \`gh aw add ${workflowSource}\`. See [usage guide](https://githubnext.github.io/gh-aw/tools/cli/).`;
               }
@@ -4015,6 +4024,34 @@ jobs:
                 return;
               }
               const parentIssueNumber = context.payload?.issue?.number;
+              const isIssueContext = context.eventName === "issues" || context.eventName === "issue_comment";
+              const isPRContext =
+                context.eventName === "pull_request" ||
+                context.eventName === "pull_request_review" ||
+                context.eventName === "pull_request_review_comment";
+              const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
+              let triggeringContext = undefined;
+              if (isIssueContext && context.payload.issue) {
+                triggeringContext = {
+                  type: 'issue',
+                  number: context.payload.issue.number
+                };
+              } else if (isPRContext && context.payload.pull_request) {
+                triggeringContext = {
+                  type: 'pull_request',
+                  number: context.payload.pull_request.number
+                };
+              } else if (isDiscussionContext && context.payload.discussion) {
+                const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
+                const repoUrl = context.payload.repository
+                  ? context.payload.repository.html_url
+                  : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
+                triggeringContext = {
+                  type: 'discussion',
+                  number: context.payload.discussion.number,
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                };
+              }
               const labelsEnv = process.env.GITHUB_AW_ISSUE_LABELS;
               let envLabels = labelsEnv
                 ? labelsEnv
@@ -4065,7 +4102,7 @@ jobs:
                 const runUrl = context.payload.repository
                   ? `${context.payload.repository.html_url}/actions/runs/${runId}`
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-                bodyLines.push(``, ``, generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL).trimEnd(), "");
+                bodyLines.push(``, ``, generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext).trimEnd(), "");
                 const body = bodyLines.join("\n").trim();
                 core.info(`Creating issue with title: ${title}`);
                 core.info(`Labels: ${labels}`);
diff --git a/.github/workflows/poem-bot.lock.yml b/.github/workflows/poem-bot.lock.yml
index 14acfb09dda..65a3a074fb9 100644
--- a/.github/workflows/poem-bot.lock.yml
+++ b/.github/workflows/poem-bot.lock.yml
@@ -4110,8 +4110,17 @@ jobs:
               sanitized = sanitized.replace(/[<>&'"]/g, "");
               return sanitized.trim();
             }
-            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL) {
+            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
+              if (triggeringContext && triggeringContext.number) {
+                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                  footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
+                } else if (triggeringContext.type === 'pull_request') {
+                  footer += ` for #${triggeringContext.number}`;
+                } else if (triggeringContext.type === 'issue') {
+                  footer += ` for #${triggeringContext.number}`;
+                }
+              }
               if (workflowSource && workflowSourceURL) {
                 footer += `\n>\n> To add this workflow in your repository, run \`gh aw add ${workflowSource}\`. See [usage guide](https://githubnext.github.io/gh-aw/tools/cli/).`;
               }
@@ -4167,6 +4176,34 @@ jobs:
                 return;
               }
               const parentIssueNumber = context.payload?.issue?.number;
+              const isIssueContext = context.eventName === "issues" || context.eventName === "issue_comment";
+              const isPRContext =
+                context.eventName === "pull_request" ||
+                context.eventName === "pull_request_review" ||
+                context.eventName === "pull_request_review_comment";
+              const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
+              let triggeringContext = undefined;
+              if (isIssueContext && context.payload.issue) {
+                triggeringContext = {
+                  type: 'issue',
+                  number: context.payload.issue.number
+                };
+              } else if (isPRContext && context.payload.pull_request) {
+                triggeringContext = {
+                  type: 'pull_request',
+                  number: context.payload.pull_request.number
+                };
+              } else if (isDiscussionContext && context.payload.discussion) {
+                const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
+                const repoUrl = context.payload.repository
+                  ? context.payload.repository.html_url
+                  : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
+                triggeringContext = {
+                  type: 'discussion',
+                  number: context.payload.discussion.number,
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                };
+              }
               const labelsEnv = process.env.GITHUB_AW_ISSUE_LABELS;
               let envLabels = labelsEnv
                 ? labelsEnv
@@ -4217,7 +4254,7 @@ jobs:
                 const runUrl = context.payload.repository
                   ? `${context.payload.repository.html_url}/actions/runs/${runId}`
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-                bodyLines.push(``, ``, generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL).trimEnd(), "");
+                bodyLines.push(``, ``, generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext).trimEnd(), "");
                 const body = bodyLines.join("\n").trim();
                 core.info(`Creating issue with title: ${title}`);
                 core.info(`Labels: ${labels}`);
@@ -4351,8 +4388,17 @@ jobs:
           GITHUB_AW_SAFE_OUTPUTS_STAGED: "true"
         with:
           script: |
-            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL) {
+            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
+              if (triggeringContext && triggeringContext.number) {
+                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                  footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
+                } else if (triggeringContext.type === 'pull_request') {
+                  footer += ` for #${triggeringContext.number}`;
+                } else if (triggeringContext.type === 'issue') {
+                  footer += ` for #${triggeringContext.number}`;
+                }
+              }
               if (workflowSource && workflowSourceURL) {
                 footer += `\n>\n> To add this workflow in your repository, run \`gh aw add ${workflowSource}\`. See [usage guide](https://githubnext.github.io/gh-aw/tools/cli/).`;
               }
@@ -4482,6 +4528,25 @@ jobs:
                 context.eventName === "pull_request_review" ||
                 context.eventName === "pull_request_review_comment";
               const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
+              let triggeringContext = undefined;
+              if (isIssueContext && context.payload.issue) {
+                triggeringContext = {
+                  type: 'issue',
+                  number: context.payload.issue.number
+                };
+              } else if (isPRContext && context.payload.pull_request) {
+                triggeringContext = {
+                  type: 'pull_request',
+                  number: context.payload.pull_request.number
+                };
+              } else if (isDiscussionContext && context.payload.discussion) {
+                const repoUrl = getRepositoryUrl();
+                triggeringContext = {
+                  type: 'discussion',
+                  number: context.payload.discussion.number,
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                };
+              }
               if (commentTarget === "triggering" && !isIssueContext && !isPRContext && !isDiscussionContext) {
                 core.info('Target is "triggering" but not running in issue, pull request, or discussion context, skipping comment creation');
                 return;
@@ -4552,7 +4617,7 @@ jobs:
                 const runUrl = context.payload.repository
                   ? `${context.payload.repository.html_url}/actions/runs/${runId}`
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-                body += generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL);
+                body += generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext);
                 try {
                   let comment;
                   if (isDiscussion) {
@@ -4621,8 +4686,17 @@ jobs:
           GITHUB_AW_SAFE_OUTPUTS_STAGED: "true"
         with:
           script: |
-            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL) {
+            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
+              if (triggeringContext && triggeringContext.number) {
+                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                  footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
+                } else if (triggeringContext.type === 'pull_request') {
+                  footer += ` for #${triggeringContext.number}`;
+                } else if (triggeringContext.type === 'issue') {
+                  footer += ` for #${triggeringContext.number}`;
+                }
+              }
               if (workflowSource && workflowSourceURL) {
                 footer += `\n>\n> To add this workflow in your repository, run \`gh aw add ${workflowSource}\`. See [usage guide](https://githubnext.github.io/gh-aw/tools/cli/).`;
               }
@@ -4707,6 +4781,13 @@ jobs:
                 context.eventName === "pull_request_review" ||
                 context.eventName === "pull_request_review_comment" ||
                 (context.eventName === "issue_comment" && context.payload.issue && context.payload.issue.pull_request);
+              let triggeringContext = undefined;
+              if (isPRContext && context.payload.pull_request) {
+                triggeringContext = {
+                  type: 'pull_request',
+                  number: context.payload.pull_request.number
+                };
+              }
               if (commentTarget === "triggering" && !isPRContext) {
                 core.info('Target is "triggering" but not running in pull request context, skipping review comment creation');
                 return;
@@ -4811,7 +4892,7 @@ jobs:
                 const runUrl = context.payload.repository
                   ? `${context.payload.repository.html_url}/actions/runs/${runId}`
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-                body += generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL);
+                body += generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext);
                 core.info(
                   `Creating review comment on PR #${pullRequestNumber} at ${commentItem.path}:${line}${startLine ? ` (lines ${startLine}-${line})` : ""} [${side}]`
                 );
@@ -5075,13 +5156,32 @@ jobs:
               if (titlePrefix && !title.startsWith(titlePrefix)) {
                 title = titlePrefix + title;
               }
+              const isIssueContext = context.eventName === "issues" || context.eventName === "issue_comment";
+              const isPRContext =
+                context.eventName === "pull_request" ||
+                context.eventName === "pull_request_review" ||
+                context.eventName === "pull_request_review_comment";
+              const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
+              let triggeringReference = "";
+              if (isIssueContext && context.payload.issue) {
+                triggeringReference = ` for #${context.payload.issue.number}`;
+              } else if (isPRContext && context.payload.pull_request) {
+                triggeringReference = ` for #${context.payload.pull_request.number}`;
+              } else if (isDiscussionContext && context.payload.discussion) {
+                const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
+                const repoUrl = context.payload.repository
+                  ? context.payload.repository.html_url
+                  : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
+                const discussionUrl = `${repoUrl}/discussions/${context.payload.discussion.number}`;
+                triggeringReference = ` for [discussion #${context.payload.discussion.number}](${discussionUrl})`;
+              }
               const workflowName = process.env.GITHUB_AW_WORKFLOW_NAME || "Workflow";
               const runId = context.runId;
               const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
               const runUrl = context.payload.repository
                 ? `${context.payload.repository.html_url}/actions/runs/${runId}`
                 : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-              bodyLines.push(``, ``, `> AI generated by [${workflowName}](${runUrl})`, "");
+              bodyLines.push(``, ``, `> AI generated by [${workflowName}](${runUrl})${triggeringReference}`, "");
               const body = bodyLines.join("\n").trim();
               const labelsEnv = process.env.GITHUB_AW_PR_LABELS;
               const labels = labelsEnv
diff --git a/.github/workflows/q.lock.yml b/.github/workflows/q.lock.yml
index 8f34d64a8d3..8428338835c 100644
--- a/.github/workflows/q.lock.yml
+++ b/.github/workflows/q.lock.yml
@@ -4617,13 +4617,32 @@ jobs:
               if (titlePrefix && !title.startsWith(titlePrefix)) {
                 title = titlePrefix + title;
               }
+              const isIssueContext = context.eventName === "issues" || context.eventName === "issue_comment";
+              const isPRContext =
+                context.eventName === "pull_request" ||
+                context.eventName === "pull_request_review" ||
+                context.eventName === "pull_request_review_comment";
+              const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
+              let triggeringReference = "";
+              if (isIssueContext && context.payload.issue) {
+                triggeringReference = ` for #${context.payload.issue.number}`;
+              } else if (isPRContext && context.payload.pull_request) {
+                triggeringReference = ` for #${context.payload.pull_request.number}`;
+              } else if (isDiscussionContext && context.payload.discussion) {
+                const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
+                const repoUrl = context.payload.repository
+                  ? context.payload.repository.html_url
+                  : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
+                const discussionUrl = `${repoUrl}/discussions/${context.payload.discussion.number}`;
+                triggeringReference = ` for [discussion #${context.payload.discussion.number}](${discussionUrl})`;
+              }
               const workflowName = process.env.GITHUB_AW_WORKFLOW_NAME || "Workflow";
               const runId = context.runId;
               const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
               const runUrl = context.payload.repository
                 ? `${context.payload.repository.html_url}/actions/runs/${runId}`
                 : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-              bodyLines.push(``, ``, `> AI generated by [${workflowName}](${runUrl})`, "");
+              bodyLines.push(``, ``, `> AI generated by [${workflowName}](${runUrl})${triggeringReference}`, "");
               const body = bodyLines.join("\n").trim();
               const labelsEnv = process.env.GITHUB_AW_PR_LABELS;
               const labels = labelsEnv
diff --git a/.github/workflows/scout.lock.yml b/.github/workflows/scout.lock.yml
index fbe48af7d52..42588d8d35b 100644
--- a/.github/workflows/scout.lock.yml
+++ b/.github/workflows/scout.lock.yml
@@ -4439,8 +4439,17 @@ jobs:
           GITHUB_AW_WORKFLOW_NAME: "Scout"
         with:
           script: |
-            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL) {
+            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
+              if (triggeringContext && triggeringContext.number) {
+                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                  footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
+                } else if (triggeringContext.type === 'pull_request') {
+                  footer += ` for #${triggeringContext.number}`;
+                } else if (triggeringContext.type === 'issue') {
+                  footer += ` for #${triggeringContext.number}`;
+                }
+              }
               if (workflowSource && workflowSourceURL) {
                 footer += `\n>\n> To add this workflow in your repository, run \`gh aw add ${workflowSource}\`. See [usage guide](https://githubnext.github.io/gh-aw/tools/cli/).`;
               }
@@ -4570,6 +4579,25 @@ jobs:
                 context.eventName === "pull_request_review" ||
                 context.eventName === "pull_request_review_comment";
               const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
+              let triggeringContext = undefined;
+              if (isIssueContext && context.payload.issue) {
+                triggeringContext = {
+                  type: 'issue',
+                  number: context.payload.issue.number
+                };
+              } else if (isPRContext && context.payload.pull_request) {
+                triggeringContext = {
+                  type: 'pull_request',
+                  number: context.payload.pull_request.number
+                };
+              } else if (isDiscussionContext && context.payload.discussion) {
+                const repoUrl = getRepositoryUrl();
+                triggeringContext = {
+                  type: 'discussion',
+                  number: context.payload.discussion.number,
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                };
+              }
               if (commentTarget === "triggering" && !isIssueContext && !isPRContext && !isDiscussionContext) {
                 core.info('Target is "triggering" but not running in issue, pull request, or discussion context, skipping comment creation');
                 return;
@@ -4640,7 +4668,7 @@ jobs:
                 const runUrl = context.payload.repository
                   ? `${context.payload.repository.html_url}/actions/runs/${runId}`
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-                body += generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL);
+                body += generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext);
                 try {
                   let comment;
                   if (isDiscussion) {
diff --git a/.github/workflows/security-fix-pr.lock.yml b/.github/workflows/security-fix-pr.lock.yml
index 40e33e517fa..13955e353f0 100644
--- a/.github/workflows/security-fix-pr.lock.yml
+++ b/.github/workflows/security-fix-pr.lock.yml
@@ -3427,13 +3427,32 @@ jobs:
               if (titlePrefix && !title.startsWith(titlePrefix)) {
                 title = titlePrefix + title;
               }
+              const isIssueContext = context.eventName === "issues" || context.eventName === "issue_comment";
+              const isPRContext =
+                context.eventName === "pull_request" ||
+                context.eventName === "pull_request_review" ||
+                context.eventName === "pull_request_review_comment";
+              const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
+              let triggeringReference = "";
+              if (isIssueContext && context.payload.issue) {
+                triggeringReference = ` for #${context.payload.issue.number}`;
+              } else if (isPRContext && context.payload.pull_request) {
+                triggeringReference = ` for #${context.payload.pull_request.number}`;
+              } else if (isDiscussionContext && context.payload.discussion) {
+                const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
+                const repoUrl = context.payload.repository
+                  ? context.payload.repository.html_url
+                  : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
+                const discussionUrl = `${repoUrl}/discussions/${context.payload.discussion.number}`;
+                triggeringReference = ` for [discussion #${context.payload.discussion.number}](${discussionUrl})`;
+              }
               const workflowName = process.env.GITHUB_AW_WORKFLOW_NAME || "Workflow";
               const runId = context.runId;
               const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
               const runUrl = context.payload.repository
                 ? `${context.payload.repository.html_url}/actions/runs/${runId}`
                 : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-              bodyLines.push(``, ``, `> AI generated by [${workflowName}](${runUrl})`, "");
+              bodyLines.push(``, ``, `> AI generated by [${workflowName}](${runUrl})${triggeringReference}`, "");
               const body = bodyLines.join("\n").trim();
               const labelsEnv = process.env.GITHUB_AW_PR_LABELS;
               const labels = labelsEnv
diff --git a/.github/workflows/smoke-claude.lock.yml b/.github/workflows/smoke-claude.lock.yml
index 6980374674d..26cdcde16d7 100644
--- a/.github/workflows/smoke-claude.lock.yml
+++ b/.github/workflows/smoke-claude.lock.yml
@@ -2964,8 +2964,17 @@ jobs:
               sanitized = sanitized.replace(/[<>&'"]/g, "");
               return sanitized.trim();
             }
-            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL) {
+            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
+              if (triggeringContext && triggeringContext.number) {
+                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                  footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
+                } else if (triggeringContext.type === 'pull_request') {
+                  footer += ` for #${triggeringContext.number}`;
+                } else if (triggeringContext.type === 'issue') {
+                  footer += ` for #${triggeringContext.number}`;
+                }
+              }
               if (workflowSource && workflowSourceURL) {
                 footer += `\n>\n> To add this workflow in your repository, run \`gh aw add ${workflowSource}\`. See [usage guide](https://githubnext.github.io/gh-aw/tools/cli/).`;
               }
@@ -3021,6 +3030,34 @@ jobs:
                 return;
               }
               const parentIssueNumber = context.payload?.issue?.number;
+              const isIssueContext = context.eventName === "issues" || context.eventName === "issue_comment";
+              const isPRContext =
+                context.eventName === "pull_request" ||
+                context.eventName === "pull_request_review" ||
+                context.eventName === "pull_request_review_comment";
+              const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
+              let triggeringContext = undefined;
+              if (isIssueContext && context.payload.issue) {
+                triggeringContext = {
+                  type: 'issue',
+                  number: context.payload.issue.number
+                };
+              } else if (isPRContext && context.payload.pull_request) {
+                triggeringContext = {
+                  type: 'pull_request',
+                  number: context.payload.pull_request.number
+                };
+              } else if (isDiscussionContext && context.payload.discussion) {
+                const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
+                const repoUrl = context.payload.repository
+                  ? context.payload.repository.html_url
+                  : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
+                triggeringContext = {
+                  type: 'discussion',
+                  number: context.payload.discussion.number,
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                };
+              }
               const labelsEnv = process.env.GITHUB_AW_ISSUE_LABELS;
               let envLabels = labelsEnv
                 ? labelsEnv
@@ -3071,7 +3108,7 @@ jobs:
                 const runUrl = context.payload.repository
                   ? `${context.payload.repository.html_url}/actions/runs/${runId}`
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-                bodyLines.push(``, ``, generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL).trimEnd(), "");
+                bodyLines.push(``, ``, generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext).trimEnd(), "");
                 const body = bodyLines.join("\n").trim();
                 core.info(`Creating issue with title: ${title}`);
                 core.info(`Labels: ${labels}`);
diff --git a/.github/workflows/smoke-codex.lock.yml b/.github/workflows/smoke-codex.lock.yml
index 89c7505b541..f8c3a8b62a0 100644
--- a/.github/workflows/smoke-codex.lock.yml
+++ b/.github/workflows/smoke-codex.lock.yml
@@ -2782,8 +2782,17 @@ jobs:
               sanitized = sanitized.replace(/[<>&'"]/g, "");
               return sanitized.trim();
             }
-            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL) {
+            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
+              if (triggeringContext && triggeringContext.number) {
+                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                  footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
+                } else if (triggeringContext.type === 'pull_request') {
+                  footer += ` for #${triggeringContext.number}`;
+                } else if (triggeringContext.type === 'issue') {
+                  footer += ` for #${triggeringContext.number}`;
+                }
+              }
               if (workflowSource && workflowSourceURL) {
                 footer += `\n>\n> To add this workflow in your repository, run \`gh aw add ${workflowSource}\`. See [usage guide](https://githubnext.github.io/gh-aw/tools/cli/).`;
               }
@@ -2839,6 +2848,34 @@ jobs:
                 return;
               }
               const parentIssueNumber = context.payload?.issue?.number;
+              const isIssueContext = context.eventName === "issues" || context.eventName === "issue_comment";
+              const isPRContext =
+                context.eventName === "pull_request" ||
+                context.eventName === "pull_request_review" ||
+                context.eventName === "pull_request_review_comment";
+              const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
+              let triggeringContext = undefined;
+              if (isIssueContext && context.payload.issue) {
+                triggeringContext = {
+                  type: 'issue',
+                  number: context.payload.issue.number
+                };
+              } else if (isPRContext && context.payload.pull_request) {
+                triggeringContext = {
+                  type: 'pull_request',
+                  number: context.payload.pull_request.number
+                };
+              } else if (isDiscussionContext && context.payload.discussion) {
+                const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
+                const repoUrl = context.payload.repository
+                  ? context.payload.repository.html_url
+                  : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
+                triggeringContext = {
+                  type: 'discussion',
+                  number: context.payload.discussion.number,
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                };
+              }
               const labelsEnv = process.env.GITHUB_AW_ISSUE_LABELS;
               let envLabels = labelsEnv
                 ? labelsEnv
@@ -2889,7 +2926,7 @@ jobs:
                 const runUrl = context.payload.repository
                   ? `${context.payload.repository.html_url}/actions/runs/${runId}`
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-                bodyLines.push(``, ``, generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL).trimEnd(), "");
+                bodyLines.push(``, ``, generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext).trimEnd(), "");
                 const body = bodyLines.join("\n").trim();
                 core.info(`Creating issue with title: ${title}`);
                 core.info(`Labels: ${labels}`);
diff --git a/.github/workflows/smoke-copilot.lock.yml b/.github/workflows/smoke-copilot.lock.yml
index 5fd15eef25f..eb251276ee5 100644
--- a/.github/workflows/smoke-copilot.lock.yml
+++ b/.github/workflows/smoke-copilot.lock.yml
@@ -3350,8 +3350,17 @@ jobs:
               sanitized = sanitized.replace(/[<>&'"]/g, "");
               return sanitized.trim();
             }
-            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL) {
+            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
+              if (triggeringContext && triggeringContext.number) {
+                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                  footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
+                } else if (triggeringContext.type === 'pull_request') {
+                  footer += ` for #${triggeringContext.number}`;
+                } else if (triggeringContext.type === 'issue') {
+                  footer += ` for #${triggeringContext.number}`;
+                }
+              }
               if (workflowSource && workflowSourceURL) {
                 footer += `\n>\n> To add this workflow in your repository, run \`gh aw add ${workflowSource}\`. See [usage guide](https://githubnext.github.io/gh-aw/tools/cli/).`;
               }
@@ -3407,6 +3416,34 @@ jobs:
                 return;
               }
               const parentIssueNumber = context.payload?.issue?.number;
+              const isIssueContext = context.eventName === "issues" || context.eventName === "issue_comment";
+              const isPRContext =
+                context.eventName === "pull_request" ||
+                context.eventName === "pull_request_review" ||
+                context.eventName === "pull_request_review_comment";
+              const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
+              let triggeringContext = undefined;
+              if (isIssueContext && context.payload.issue) {
+                triggeringContext = {
+                  type: 'issue',
+                  number: context.payload.issue.number
+                };
+              } else if (isPRContext && context.payload.pull_request) {
+                triggeringContext = {
+                  type: 'pull_request',
+                  number: context.payload.pull_request.number
+                };
+              } else if (isDiscussionContext && context.payload.discussion) {
+                const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
+                const repoUrl = context.payload.repository
+                  ? context.payload.repository.html_url
+                  : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
+                triggeringContext = {
+                  type: 'discussion',
+                  number: context.payload.discussion.number,
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                };
+              }
               const labelsEnv = process.env.GITHUB_AW_ISSUE_LABELS;
               let envLabels = labelsEnv
                 ? labelsEnv
@@ -3457,7 +3494,7 @@ jobs:
                 const runUrl = context.payload.repository
                   ? `${context.payload.repository.html_url}/actions/runs/${runId}`
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-                bodyLines.push(``, ``, generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL).trimEnd(), "");
+                bodyLines.push(``, ``, generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext).trimEnd(), "");
                 const body = bodyLines.join("\n").trim();
                 core.info(`Creating issue with title: ${title}`);
                 core.info(`Labels: ${labels}`);
diff --git a/.github/workflows/smoke-genaiscript.lock.yml b/.github/workflows/smoke-genaiscript.lock.yml
index fef8fa5e172..deed96eb3d2 100644
--- a/.github/workflows/smoke-genaiscript.lock.yml
+++ b/.github/workflows/smoke-genaiscript.lock.yml
@@ -2143,8 +2143,17 @@ jobs:
               sanitized = sanitized.replace(/[<>&'"]/g, "");
               return sanitized.trim();
             }
-            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL) {
+            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
+              if (triggeringContext && triggeringContext.number) {
+                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                  footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
+                } else if (triggeringContext.type === 'pull_request') {
+                  footer += ` for #${triggeringContext.number}`;
+                } else if (triggeringContext.type === 'issue') {
+                  footer += ` for #${triggeringContext.number}`;
+                }
+              }
               if (workflowSource && workflowSourceURL) {
                 footer += `\n>\n> To add this workflow in your repository, run \`gh aw add ${workflowSource}\`. See [usage guide](https://githubnext.github.io/gh-aw/tools/cli/).`;
               }
@@ -2200,6 +2209,34 @@ jobs:
                 return;
               }
               const parentIssueNumber = context.payload?.issue?.number;
+              const isIssueContext = context.eventName === "issues" || context.eventName === "issue_comment";
+              const isPRContext =
+                context.eventName === "pull_request" ||
+                context.eventName === "pull_request_review" ||
+                context.eventName === "pull_request_review_comment";
+              const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
+              let triggeringContext = undefined;
+              if (isIssueContext && context.payload.issue) {
+                triggeringContext = {
+                  type: 'issue',
+                  number: context.payload.issue.number
+                };
+              } else if (isPRContext && context.payload.pull_request) {
+                triggeringContext = {
+                  type: 'pull_request',
+                  number: context.payload.pull_request.number
+                };
+              } else if (isDiscussionContext && context.payload.discussion) {
+                const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
+                const repoUrl = context.payload.repository
+                  ? context.payload.repository.html_url
+                  : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
+                triggeringContext = {
+                  type: 'discussion',
+                  number: context.payload.discussion.number,
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                };
+              }
               const labelsEnv = process.env.GITHUB_AW_ISSUE_LABELS;
               let envLabels = labelsEnv
                 ? labelsEnv
@@ -2250,7 +2287,7 @@ jobs:
                 const runUrl = context.payload.repository
                   ? `${context.payload.repository.html_url}/actions/runs/${runId}`
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-                bodyLines.push(``, ``, generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL).trimEnd(), "");
+                bodyLines.push(``, ``, generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext).trimEnd(), "");
                 const body = bodyLines.join("\n").trim();
                 core.info(`Creating issue with title: ${title}`);
                 core.info(`Labels: ${labels}`);
diff --git a/.github/workflows/smoke-opencode.lock.yml b/.github/workflows/smoke-opencode.lock.yml
index fa6eec16c47..465dbeddbdf 100644
--- a/.github/workflows/smoke-opencode.lock.yml
+++ b/.github/workflows/smoke-opencode.lock.yml
@@ -2111,8 +2111,17 @@ jobs:
               sanitized = sanitized.replace(/[<>&'"]/g, "");
               return sanitized.trim();
             }
-            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL) {
+            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
+              if (triggeringContext && triggeringContext.number) {
+                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                  footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
+                } else if (triggeringContext.type === 'pull_request') {
+                  footer += ` for #${triggeringContext.number}`;
+                } else if (triggeringContext.type === 'issue') {
+                  footer += ` for #${triggeringContext.number}`;
+                }
+              }
               if (workflowSource && workflowSourceURL) {
                 footer += `\n>\n> To add this workflow in your repository, run \`gh aw add ${workflowSource}\`. See [usage guide](https://githubnext.github.io/gh-aw/tools/cli/).`;
               }
@@ -2168,6 +2177,34 @@ jobs:
                 return;
               }
               const parentIssueNumber = context.payload?.issue?.number;
+              const isIssueContext = context.eventName === "issues" || context.eventName === "issue_comment";
+              const isPRContext =
+                context.eventName === "pull_request" ||
+                context.eventName === "pull_request_review" ||
+                context.eventName === "pull_request_review_comment";
+              const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
+              let triggeringContext = undefined;
+              if (isIssueContext && context.payload.issue) {
+                triggeringContext = {
+                  type: 'issue',
+                  number: context.payload.issue.number
+                };
+              } else if (isPRContext && context.payload.pull_request) {
+                triggeringContext = {
+                  type: 'pull_request',
+                  number: context.payload.pull_request.number
+                };
+              } else if (isDiscussionContext && context.payload.discussion) {
+                const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
+                const repoUrl = context.payload.repository
+                  ? context.payload.repository.html_url
+                  : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
+                triggeringContext = {
+                  type: 'discussion',
+                  number: context.payload.discussion.number,
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                };
+              }
               const labelsEnv = process.env.GITHUB_AW_ISSUE_LABELS;
               let envLabels = labelsEnv
                 ? labelsEnv
@@ -2218,7 +2255,7 @@ jobs:
                 const runUrl = context.payload.repository
                   ? `${context.payload.repository.html_url}/actions/runs/${runId}`
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-                bodyLines.push(``, ``, generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL).trimEnd(), "");
+                bodyLines.push(``, ``, generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext).trimEnd(), "");
                 const body = bodyLines.join("\n").trim();
                 core.info(`Creating issue with title: ${title}`);
                 core.info(`Labels: ${labels}`);
diff --git a/.github/workflows/technical-doc-writer.lock.yml b/.github/workflows/technical-doc-writer.lock.yml
index 9924d8dd0ef..944a8afd998 100644
--- a/.github/workflows/technical-doc-writer.lock.yml
+++ b/.github/workflows/technical-doc-writer.lock.yml
@@ -3328,8 +3328,17 @@ jobs:
           GITHUB_AW_WORKFLOW_NAME: "Technical Documentation Writer for GitHub Actions"
         with:
           script: |
-            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL) {
+            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
+              if (triggeringContext && triggeringContext.number) {
+                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                  footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
+                } else if (triggeringContext.type === 'pull_request') {
+                  footer += ` for #${triggeringContext.number}`;
+                } else if (triggeringContext.type === 'issue') {
+                  footer += ` for #${triggeringContext.number}`;
+                }
+              }
               if (workflowSource && workflowSourceURL) {
                 footer += `\n>\n> To add this workflow in your repository, run \`gh aw add ${workflowSource}\`. See [usage guide](https://githubnext.github.io/gh-aw/tools/cli/).`;
               }
@@ -3459,6 +3468,25 @@ jobs:
                 context.eventName === "pull_request_review" ||
                 context.eventName === "pull_request_review_comment";
               const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
+              let triggeringContext = undefined;
+              if (isIssueContext && context.payload.issue) {
+                triggeringContext = {
+                  type: 'issue',
+                  number: context.payload.issue.number
+                };
+              } else if (isPRContext && context.payload.pull_request) {
+                triggeringContext = {
+                  type: 'pull_request',
+                  number: context.payload.pull_request.number
+                };
+              } else if (isDiscussionContext && context.payload.discussion) {
+                const repoUrl = getRepositoryUrl();
+                triggeringContext = {
+                  type: 'discussion',
+                  number: context.payload.discussion.number,
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                };
+              }
               if (commentTarget === "triggering" && !isIssueContext && !isPRContext && !isDiscussionContext) {
                 core.info('Target is "triggering" but not running in issue, pull request, or discussion context, skipping comment creation');
                 return;
@@ -3529,7 +3557,7 @@ jobs:
                 const runUrl = context.payload.repository
                   ? `${context.payload.repository.html_url}/actions/runs/${runId}`
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-                body += generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL);
+                body += generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext);
                 try {
                   let comment;
                   if (isDiscussion) {
@@ -3791,13 +3819,32 @@ jobs:
               if (titlePrefix && !title.startsWith(titlePrefix)) {
                 title = titlePrefix + title;
               }
+              const isIssueContext = context.eventName === "issues" || context.eventName === "issue_comment";
+              const isPRContext =
+                context.eventName === "pull_request" ||
+                context.eventName === "pull_request_review" ||
+                context.eventName === "pull_request_review_comment";
+              const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
+              let triggeringReference = "";
+              if (isIssueContext && context.payload.issue) {
+                triggeringReference = ` for #${context.payload.issue.number}`;
+              } else if (isPRContext && context.payload.pull_request) {
+                triggeringReference = ` for #${context.payload.pull_request.number}`;
+              } else if (isDiscussionContext && context.payload.discussion) {
+                const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
+                const repoUrl = context.payload.repository
+                  ? context.payload.repository.html_url
+                  : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
+                const discussionUrl = `${repoUrl}/discussions/${context.payload.discussion.number}`;
+                triggeringReference = ` for [discussion #${context.payload.discussion.number}](${discussionUrl})`;
+              }
               const workflowName = process.env.GITHUB_AW_WORKFLOW_NAME || "Workflow";
               const runId = context.runId;
               const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
               const runUrl = context.payload.repository
                 ? `${context.payload.repository.html_url}/actions/runs/${runId}`
                 : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-              bodyLines.push(``, ``, `> AI generated by [${workflowName}](${runUrl})`, "");
+              bodyLines.push(``, ``, `> AI generated by [${workflowName}](${runUrl})${triggeringReference}`, "");
               const body = bodyLines.join("\n").trim();
               const labelsEnv = process.env.GITHUB_AW_PR_LABELS;
               const labels = labelsEnv
diff --git a/.github/workflows/tidy.lock.yml b/.github/workflows/tidy.lock.yml
index 71fdbf0577c..9a71684ee41 100644
--- a/.github/workflows/tidy.lock.yml
+++ b/.github/workflows/tidy.lock.yml
@@ -4081,13 +4081,32 @@ jobs:
               if (titlePrefix && !title.startsWith(titlePrefix)) {
                 title = titlePrefix + title;
               }
+              const isIssueContext = context.eventName === "issues" || context.eventName === "issue_comment";
+              const isPRContext =
+                context.eventName === "pull_request" ||
+                context.eventName === "pull_request_review" ||
+                context.eventName === "pull_request_review_comment";
+              const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
+              let triggeringReference = "";
+              if (isIssueContext && context.payload.issue) {
+                triggeringReference = ` for #${context.payload.issue.number}`;
+              } else if (isPRContext && context.payload.pull_request) {
+                triggeringReference = ` for #${context.payload.pull_request.number}`;
+              } else if (isDiscussionContext && context.payload.discussion) {
+                const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
+                const repoUrl = context.payload.repository
+                  ? context.payload.repository.html_url
+                  : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
+                const discussionUrl = `${repoUrl}/discussions/${context.payload.discussion.number}`;
+                triggeringReference = ` for [discussion #${context.payload.discussion.number}](${discussionUrl})`;
+              }
               const workflowName = process.env.GITHUB_AW_WORKFLOW_NAME || "Workflow";
               const runId = context.runId;
               const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
               const runUrl = context.payload.repository
                 ? `${context.payload.repository.html_url}/actions/runs/${runId}`
                 : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-              bodyLines.push(``, ``, `> AI generated by [${workflowName}](${runUrl})`, "");
+              bodyLines.push(``, ``, `> AI generated by [${workflowName}](${runUrl})${triggeringReference}`, "");
               const body = bodyLines.join("\n").trim();
               const labelsEnv = process.env.GITHUB_AW_PR_LABELS;
               const labels = labelsEnv
diff --git a/.github/workflows/unbloat-docs.lock.yml b/.github/workflows/unbloat-docs.lock.yml
index c3fc33f0005..efd28bd82e6 100644
--- a/.github/workflows/unbloat-docs.lock.yml
+++ b/.github/workflows/unbloat-docs.lock.yml
@@ -3658,8 +3658,17 @@ jobs:
           GITHUB_AW_WORKFLOW_NAME: "Documentation Unbloat"
         with:
           script: |
-            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL) {
+            function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
+              if (triggeringContext && triggeringContext.number) {
+                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                  footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
+                } else if (triggeringContext.type === 'pull_request') {
+                  footer += ` for #${triggeringContext.number}`;
+                } else if (triggeringContext.type === 'issue') {
+                  footer += ` for #${triggeringContext.number}`;
+                }
+              }
               if (workflowSource && workflowSourceURL) {
                 footer += `\n>\n> To add this workflow in your repository, run \`gh aw add ${workflowSource}\`. See [usage guide](https://githubnext.github.io/gh-aw/tools/cli/).`;
               }
@@ -3789,6 +3798,25 @@ jobs:
                 context.eventName === "pull_request_review" ||
                 context.eventName === "pull_request_review_comment";
               const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
+              let triggeringContext = undefined;
+              if (isIssueContext && context.payload.issue) {
+                triggeringContext = {
+                  type: 'issue',
+                  number: context.payload.issue.number
+                };
+              } else if (isPRContext && context.payload.pull_request) {
+                triggeringContext = {
+                  type: 'pull_request',
+                  number: context.payload.pull_request.number
+                };
+              } else if (isDiscussionContext && context.payload.discussion) {
+                const repoUrl = getRepositoryUrl();
+                triggeringContext = {
+                  type: 'discussion',
+                  number: context.payload.discussion.number,
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                };
+              }
               if (commentTarget === "triggering" && !isIssueContext && !isPRContext && !isDiscussionContext) {
                 core.info('Target is "triggering" but not running in issue, pull request, or discussion context, skipping comment creation');
                 return;
@@ -3859,7 +3887,7 @@ jobs:
                 const runUrl = context.payload.repository
                   ? `${context.payload.repository.html_url}/actions/runs/${runId}`
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-                body += generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL);
+                body += generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext);
                 try {
                   let comment;
                   if (isDiscussion) {
@@ -4121,13 +4149,32 @@ jobs:
               if (titlePrefix && !title.startsWith(titlePrefix)) {
                 title = titlePrefix + title;
               }
+              const isIssueContext = context.eventName === "issues" || context.eventName === "issue_comment";
+              const isPRContext =
+                context.eventName === "pull_request" ||
+                context.eventName === "pull_request_review" ||
+                context.eventName === "pull_request_review_comment";
+              const isDiscussionContext = context.eventName === "discussion" || context.eventName === "discussion_comment";
+              let triggeringReference = "";
+              if (isIssueContext && context.payload.issue) {
+                triggeringReference = ` for #${context.payload.issue.number}`;
+              } else if (isPRContext && context.payload.pull_request) {
+                triggeringReference = ` for #${context.payload.pull_request.number}`;
+              } else if (isDiscussionContext && context.payload.discussion) {
+                const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
+                const repoUrl = context.payload.repository
+                  ? context.payload.repository.html_url
+                  : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
+                const discussionUrl = `${repoUrl}/discussions/${context.payload.discussion.number}`;
+                triggeringReference = ` for [discussion #${context.payload.discussion.number}](${discussionUrl})`;
+              }
               const workflowName = process.env.GITHUB_AW_WORKFLOW_NAME || "Workflow";
               const runId = context.runId;
               const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
               const runUrl = context.payload.repository
                 ? `${context.payload.repository.html_url}/actions/runs/${runId}`
                 : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
-              bodyLines.push(``, ``, `> AI generated by [${workflowName}](${runUrl})`, "");
+              bodyLines.push(``, ``, `> AI generated by [${workflowName}](${runUrl})${triggeringReference}`, "");
               const body = bodyLines.join("\n").trim();
               const labelsEnv = process.env.GITHUB_AW_PR_LABELS;
               const labels = labelsEnv
diff --git a/pkg/workflow/js/add_comment.cjs b/pkg/workflow/js/add_comment.cjs
index fe26588b4c3..a04a28bac25 100644
--- a/pkg/workflow/js/add_comment.cjs
+++ b/pkg/workflow/js/add_comment.cjs
@@ -15,11 +15,11 @@ function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL,
 
   // Add triggering reference if available
   if (triggeringContext && triggeringContext.number) {
-    if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+    if (triggeringContext.type === "discussion" && triggeringContext.url) {
       footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
-    } else if (triggeringContext.type === 'pull_request') {
+    } else if (triggeringContext.type === "pull_request") {
       footer += ` for #${triggeringContext.number}`;
-    } else if (triggeringContext.type === 'issue') {
+    } else if (triggeringContext.type === "issue") {
       footer += ` for #${triggeringContext.number}`;
     }
   }
@@ -207,20 +207,20 @@ async function main() {
   let triggeringContext = undefined;
   if (isIssueContext && context.payload.issue) {
     triggeringContext = {
-      type: 'issue',
-      number: context.payload.issue.number
+      type: "issue",
+      number: context.payload.issue.number,
     };
   } else if (isPRContext && context.payload.pull_request) {
     triggeringContext = {
-      type: 'pull_request',
-      number: context.payload.pull_request.number
+      type: "pull_request",
+      number: context.payload.pull_request.number,
     };
   } else if (isDiscussionContext && context.payload.discussion) {
     const repoUrl = getRepositoryUrl();
     triggeringContext = {
-      type: 'discussion',
+      type: "discussion",
       number: context.payload.discussion.number,
-      url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+      url: `${repoUrl}/discussions/${context.payload.discussion.number}`,
     };
   }
 
diff --git a/pkg/workflow/js/create_issue.cjs b/pkg/workflow/js/create_issue.cjs
index 9e74d22d1bb..e802ce15c53 100644
--- a/pkg/workflow/js/create_issue.cjs
+++ b/pkg/workflow/js/create_issue.cjs
@@ -30,11 +30,11 @@ function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL,
 
   // Add triggering reference if available
   if (triggeringContext && triggeringContext.number) {
-    if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+    if (triggeringContext.type === "discussion" && triggeringContext.url) {
       footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
-    } else if (triggeringContext.type === 'pull_request') {
+    } else if (triggeringContext.type === "pull_request") {
       footer += ` for #${triggeringContext.number}`;
-    } else if (triggeringContext.type === 'issue') {
+    } else if (triggeringContext.type === "issue") {
       footer += ` for #${triggeringContext.number}`;
     }
   }
@@ -108,13 +108,13 @@ async function main() {
   let triggeringContext = undefined;
   if (isIssueContext && context.payload.issue) {
     triggeringContext = {
-      type: 'issue',
-      number: context.payload.issue.number
+      type: "issue",
+      number: context.payload.issue.number,
     };
   } else if (isPRContext && context.payload.pull_request) {
     triggeringContext = {
-      type: 'pull_request',
-      number: context.payload.pull_request.number
+      type: "pull_request",
+      number: context.payload.pull_request.number,
     };
   } else if (isDiscussionContext && context.payload.discussion) {
     const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
@@ -122,9 +122,9 @@ async function main() {
       ? context.payload.repository.html_url
       : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
     triggeringContext = {
-      type: 'discussion',
+      type: "discussion",
       number: context.payload.discussion.number,
-      url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+      url: `${repoUrl}/discussions/${context.payload.discussion.number}`,
     };
   }
 
diff --git a/pkg/workflow/js/create_issue.test.cjs b/pkg/workflow/js/create_issue.test.cjs
index 974331c2aaa..f9cdce3600b 100644
--- a/pkg/workflow/js/create_issue.test.cjs
+++ b/pkg/workflow/js/create_issue.test.cjs
@@ -603,4 +603,118 @@ describe("create_issue.cjs", () => {
     expect(callArgs.body).not.toContain("gh aw add");
     expect(callArgs.body).not.toContain("usage guide");
   });
+
+  it("should include triggering issue reference in footer when triggered by issue", async () => {
+    // Set up issue context
+    global.context.eventName = "issues";
+    global.context.payload = {
+      repository: {
+        html_url: "https://github.com/testowner/testrepo",
+      },
+      issue: {
+        number: 42,
+      },
+    };
+
+    process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({
+      items: [
+        {
+          type: "create_issue",
+          title: "Related Issue",
+          body: "This issue is related to the triggering issue",
+        },
+      ],
+    });
+
+    const mockIssue = {
+      number: 100,
+      html_url: "https://github.com/testowner/testrepo/issues/100",
+    };
+
+    mockGithub.rest.issues.create.mockResolvedValue({ data: mockIssue });
+
+    // Execute the script
+    await eval(`(async () => { ${createIssueScript} })()`);
+
+    const callArgs = mockGithub.rest.issues.create.mock.calls[0][0];
+
+    // Check that the footer includes the triggering issue reference
+    expect(callArgs.body).toContain("AI generated by");
+    expect(callArgs.body).toContain("for #42");
+  });
+
+  it("should include triggering PR reference in footer when triggered by pull request", async () => {
+    // Set up PR context
+    global.context.eventName = "pull_request";
+    global.context.payload = {
+      repository: {
+        html_url: "https://github.com/testowner/testrepo",
+      },
+      pull_request: {
+        number: 123,
+      },
+    };
+
+    process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({
+      items: [
+        {
+          type: "create_issue",
+          title: "PR Related Issue",
+          body: "This issue is related to the triggering PR",
+        },
+      ],
+    });
+
+    const mockIssue = {
+      number: 200,
+      html_url: "https://github.com/testowner/testrepo/issues/200",
+    };
+
+    mockGithub.rest.issues.create.mockResolvedValue({ data: mockIssue });
+
+    // Execute the script
+    await eval(`(async () => { ${createIssueScript} })()`);
+
+    const callArgs = mockGithub.rest.issues.create.mock.calls[0][0];
+
+    // Check that the footer includes the triggering PR reference
+    expect(callArgs.body).toContain("AI generated by");
+    expect(callArgs.body).toContain("for #123");
+  });
+
+  it("should not include triggering reference when not triggered by issue/PR/discussion", async () => {
+    // Set up non-triggering context (e.g., push event)
+    global.context.eventName = "push";
+    global.context.payload = {
+      repository: {
+        html_url: "https://github.com/testowner/testrepo",
+      },
+    };
+
+    process.env.GITHUB_AW_AGENT_OUTPUT = JSON.stringify({
+      items: [
+        {
+          type: "create_issue",
+          title: "Scheduled Issue",
+          body: "This issue is not triggered by an issue/PR",
+        },
+      ],
+    });
+
+    const mockIssue = {
+      number: 300,
+      html_url: "https://github.com/testowner/testrepo/issues/300",
+    };
+
+    mockGithub.rest.issues.create.mockResolvedValue({ data: mockIssue });
+
+    // Execute the script
+    await eval(`(async () => { ${createIssueScript} })()`);
+
+    const callArgs = mockGithub.rest.issues.create.mock.calls[0][0];
+
+    // Check that the footer does NOT include triggering reference
+    expect(callArgs.body).toContain("AI generated by");
+    expect(callArgs.body).not.toMatch(/for #\d+/);
+  });
 });
diff --git a/pkg/workflow/js/create_pr_review_comment.cjs b/pkg/workflow/js/create_pr_review_comment.cjs
index decb0a090c4..4d9fdf1f5de 100644
--- a/pkg/workflow/js/create_pr_review_comment.cjs
+++ b/pkg/workflow/js/create_pr_review_comment.cjs
@@ -15,11 +15,11 @@ function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL,
 
   // Add triggering reference if available
   if (triggeringContext && triggeringContext.number) {
-    if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+    if (triggeringContext.type === "discussion" && triggeringContext.url) {
       footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
-    } else if (triggeringContext.type === 'pull_request') {
+    } else if (triggeringContext.type === "pull_request") {
       footer += ` for #${triggeringContext.number}`;
-    } else if (triggeringContext.type === 'issue') {
+    } else if (triggeringContext.type === "issue") {
       footer += ` for #${triggeringContext.number}`;
     }
   }
@@ -144,8 +144,8 @@ async function main() {
   let triggeringContext = undefined;
   if (isPRContext && context.payload.pull_request) {
     triggeringContext = {
-      type: 'pull_request',
-      number: context.payload.pull_request.number
+      type: "pull_request",
+      number: context.payload.pull_request.number,
     };
   }
 

From 2155da6d516e8b5663068ca8c8310a05b631459b Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 15 Oct 2025 06:33:56 +0000
Subject: [PATCH 4/4] Final implementation complete

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
---
 .github/workflows/brave.lock.yml              | 18 ++++----
 .github/workflows/ci-doctor.lock.yml          | 36 +++++++--------
 .github/workflows/dev.lock.yml                | 18 ++++----
 .../duplicate-code-detector.lock.yml          | 18 ++++----
 .../example-workflow-analyzer.lock.yml        | 18 ++++----
 .../workflows/go-pattern-detector.lock.yml    | 18 ++++----
 .github/workflows/pdf-summary.lock.yml        | 18 ++++----
 .github/workflows/plan.lock.yml               | 18 ++++----
 .github/workflows/poem-bot.lock.yml           | 46 +++++++++----------
 .github/workflows/scout.lock.yml              | 18 ++++----
 .github/workflows/smoke-claude.lock.yml       | 18 ++++----
 .github/workflows/smoke-codex.lock.yml        | 18 ++++----
 .github/workflows/smoke-copilot.lock.yml      | 18 ++++----
 .github/workflows/smoke-genaiscript.lock.yml  | 18 ++++----
 .github/workflows/smoke-opencode.lock.yml     | 18 ++++----
 .../workflows/technical-doc-writer.lock.yml   | 18 ++++----
 .github/workflows/unbloat-docs.lock.yml       | 18 ++++----
 17 files changed, 176 insertions(+), 176 deletions(-)

diff --git a/.github/workflows/brave.lock.yml b/.github/workflows/brave.lock.yml
index ac504ac00e5..a711976012e 100644
--- a/.github/workflows/brave.lock.yml
+++ b/.github/workflows/brave.lock.yml
@@ -4120,11 +4120,11 @@ jobs:
             function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
               if (triggeringContext && triggeringContext.number) {
-                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                if (triggeringContext.type === "discussion" && triggeringContext.url) {
                   footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
-                } else if (triggeringContext.type === 'pull_request') {
+                } else if (triggeringContext.type === "pull_request") {
                   footer += ` for #${triggeringContext.number}`;
-                } else if (triggeringContext.type === 'issue') {
+                } else if (triggeringContext.type === "issue") {
                   footer += ` for #${triggeringContext.number}`;
                 }
               }
@@ -4260,20 +4260,20 @@ jobs:
               let triggeringContext = undefined;
               if (isIssueContext && context.payload.issue) {
                 triggeringContext = {
-                  type: 'issue',
-                  number: context.payload.issue.number
+                  type: "issue",
+                  number: context.payload.issue.number,
                 };
               } else if (isPRContext && context.payload.pull_request) {
                 triggeringContext = {
-                  type: 'pull_request',
-                  number: context.payload.pull_request.number
+                  type: "pull_request",
+                  number: context.payload.pull_request.number,
                 };
               } else if (isDiscussionContext && context.payload.discussion) {
                 const repoUrl = getRepositoryUrl();
                 triggeringContext = {
-                  type: 'discussion',
+                  type: "discussion",
                   number: context.payload.discussion.number,
-                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`,
                 };
               }
               if (commentTarget === "triggering" && !isIssueContext && !isPRContext && !isDiscussionContext) {
diff --git a/.github/workflows/ci-doctor.lock.yml b/.github/workflows/ci-doctor.lock.yml
index 7c4458b69d9..838be78049a 100644
--- a/.github/workflows/ci-doctor.lock.yml
+++ b/.github/workflows/ci-doctor.lock.yml
@@ -3521,11 +3521,11 @@ jobs:
             function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
               if (triggeringContext && triggeringContext.number) {
-                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                if (triggeringContext.type === "discussion" && triggeringContext.url) {
                   footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
-                } else if (triggeringContext.type === 'pull_request') {
+                } else if (triggeringContext.type === "pull_request") {
                   footer += ` for #${triggeringContext.number}`;
-                } else if (triggeringContext.type === 'issue') {
+                } else if (triggeringContext.type === "issue") {
                   footer += ` for #${triggeringContext.number}`;
                 }
               }
@@ -3593,13 +3593,13 @@ jobs:
               let triggeringContext = undefined;
               if (isIssueContext && context.payload.issue) {
                 triggeringContext = {
-                  type: 'issue',
-                  number: context.payload.issue.number
+                  type: "issue",
+                  number: context.payload.issue.number,
                 };
               } else if (isPRContext && context.payload.pull_request) {
                 triggeringContext = {
-                  type: 'pull_request',
-                  number: context.payload.pull_request.number
+                  type: "pull_request",
+                  number: context.payload.pull_request.number,
                 };
               } else if (isDiscussionContext && context.payload.discussion) {
                 const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
@@ -3607,9 +3607,9 @@ jobs:
                   ? context.payload.repository.html_url
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
                 triggeringContext = {
-                  type: 'discussion',
+                  type: "discussion",
                   number: context.payload.discussion.number,
-                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`,
                 };
               }
               const labelsEnv = process.env.GITHUB_AW_ISSUE_LABELS;
@@ -3801,11 +3801,11 @@ jobs:
             function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
               if (triggeringContext && triggeringContext.number) {
-                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                if (triggeringContext.type === "discussion" && triggeringContext.url) {
                   footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
-                } else if (triggeringContext.type === 'pull_request') {
+                } else if (triggeringContext.type === "pull_request") {
                   footer += ` for #${triggeringContext.number}`;
-                } else if (triggeringContext.type === 'issue') {
+                } else if (triggeringContext.type === "issue") {
                   footer += ` for #${triggeringContext.number}`;
                 }
               }
@@ -3941,20 +3941,20 @@ jobs:
               let triggeringContext = undefined;
               if (isIssueContext && context.payload.issue) {
                 triggeringContext = {
-                  type: 'issue',
-                  number: context.payload.issue.number
+                  type: "issue",
+                  number: context.payload.issue.number,
                 };
               } else if (isPRContext && context.payload.pull_request) {
                 triggeringContext = {
-                  type: 'pull_request',
-                  number: context.payload.pull_request.number
+                  type: "pull_request",
+                  number: context.payload.pull_request.number,
                 };
               } else if (isDiscussionContext && context.payload.discussion) {
                 const repoUrl = getRepositoryUrl();
                 triggeringContext = {
-                  type: 'discussion',
+                  type: "discussion",
                   number: context.payload.discussion.number,
-                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`,
                 };
               }
               if (commentTarget === "triggering" && !isIssueContext && !isPRContext && !isDiscussionContext) {
diff --git a/.github/workflows/dev.lock.yml b/.github/workflows/dev.lock.yml
index d3c445423fc..e85b5a33cb9 100644
--- a/.github/workflows/dev.lock.yml
+++ b/.github/workflows/dev.lock.yml
@@ -3355,11 +3355,11 @@ jobs:
             function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
               if (triggeringContext && triggeringContext.number) {
-                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                if (triggeringContext.type === "discussion" && triggeringContext.url) {
                   footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
-                } else if (triggeringContext.type === 'pull_request') {
+                } else if (triggeringContext.type === "pull_request") {
                   footer += ` for #${triggeringContext.number}`;
-                } else if (triggeringContext.type === 'issue') {
+                } else if (triggeringContext.type === "issue") {
                   footer += ` for #${triggeringContext.number}`;
                 }
               }
@@ -3427,13 +3427,13 @@ jobs:
               let triggeringContext = undefined;
               if (isIssueContext && context.payload.issue) {
                 triggeringContext = {
-                  type: 'issue',
-                  number: context.payload.issue.number
+                  type: "issue",
+                  number: context.payload.issue.number,
                 };
               } else if (isPRContext && context.payload.pull_request) {
                 triggeringContext = {
-                  type: 'pull_request',
-                  number: context.payload.pull_request.number
+                  type: "pull_request",
+                  number: context.payload.pull_request.number,
                 };
               } else if (isDiscussionContext && context.payload.discussion) {
                 const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
@@ -3441,9 +3441,9 @@ jobs:
                   ? context.payload.repository.html_url
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
                 triggeringContext = {
-                  type: 'discussion',
+                  type: "discussion",
                   number: context.payload.discussion.number,
-                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`,
                 };
               }
               const labelsEnv = process.env.GITHUB_AW_ISSUE_LABELS;
diff --git a/.github/workflows/duplicate-code-detector.lock.yml b/.github/workflows/duplicate-code-detector.lock.yml
index 6be91c3f07e..f38baed5f34 100644
--- a/.github/workflows/duplicate-code-detector.lock.yml
+++ b/.github/workflows/duplicate-code-detector.lock.yml
@@ -3039,11 +3039,11 @@ jobs:
             function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
               if (triggeringContext && triggeringContext.number) {
-                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                if (triggeringContext.type === "discussion" && triggeringContext.url) {
                   footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
-                } else if (triggeringContext.type === 'pull_request') {
+                } else if (triggeringContext.type === "pull_request") {
                   footer += ` for #${triggeringContext.number}`;
-                } else if (triggeringContext.type === 'issue') {
+                } else if (triggeringContext.type === "issue") {
                   footer += ` for #${triggeringContext.number}`;
                 }
               }
@@ -3111,13 +3111,13 @@ jobs:
               let triggeringContext = undefined;
               if (isIssueContext && context.payload.issue) {
                 triggeringContext = {
-                  type: 'issue',
-                  number: context.payload.issue.number
+                  type: "issue",
+                  number: context.payload.issue.number,
                 };
               } else if (isPRContext && context.payload.pull_request) {
                 triggeringContext = {
-                  type: 'pull_request',
-                  number: context.payload.pull_request.number
+                  type: "pull_request",
+                  number: context.payload.pull_request.number,
                 };
               } else if (isDiscussionContext && context.payload.discussion) {
                 const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
@@ -3125,9 +3125,9 @@ jobs:
                   ? context.payload.repository.html_url
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
                 triggeringContext = {
-                  type: 'discussion',
+                  type: "discussion",
                   number: context.payload.discussion.number,
-                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`,
                 };
               }
               const labelsEnv = process.env.GITHUB_AW_ISSUE_LABELS;
diff --git a/.github/workflows/example-workflow-analyzer.lock.yml b/.github/workflows/example-workflow-analyzer.lock.yml
index 8d9f63e3ac3..f260d808ad8 100644
--- a/.github/workflows/example-workflow-analyzer.lock.yml
+++ b/.github/workflows/example-workflow-analyzer.lock.yml
@@ -3009,11 +3009,11 @@ jobs:
             function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
               if (triggeringContext && triggeringContext.number) {
-                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                if (triggeringContext.type === "discussion" && triggeringContext.url) {
                   footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
-                } else if (triggeringContext.type === 'pull_request') {
+                } else if (triggeringContext.type === "pull_request") {
                   footer += ` for #${triggeringContext.number}`;
-                } else if (triggeringContext.type === 'issue') {
+                } else if (triggeringContext.type === "issue") {
                   footer += ` for #${triggeringContext.number}`;
                 }
               }
@@ -3081,13 +3081,13 @@ jobs:
               let triggeringContext = undefined;
               if (isIssueContext && context.payload.issue) {
                 triggeringContext = {
-                  type: 'issue',
-                  number: context.payload.issue.number
+                  type: "issue",
+                  number: context.payload.issue.number,
                 };
               } else if (isPRContext && context.payload.pull_request) {
                 triggeringContext = {
-                  type: 'pull_request',
-                  number: context.payload.pull_request.number
+                  type: "pull_request",
+                  number: context.payload.pull_request.number,
                 };
               } else if (isDiscussionContext && context.payload.discussion) {
                 const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
@@ -3095,9 +3095,9 @@ jobs:
                   ? context.payload.repository.html_url
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
                 triggeringContext = {
-                  type: 'discussion',
+                  type: "discussion",
                   number: context.payload.discussion.number,
-                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`,
                 };
               }
               const labelsEnv = process.env.GITHUB_AW_ISSUE_LABELS;
diff --git a/.github/workflows/go-pattern-detector.lock.yml b/.github/workflows/go-pattern-detector.lock.yml
index 28c6f77c429..6932492d7a9 100644
--- a/.github/workflows/go-pattern-detector.lock.yml
+++ b/.github/workflows/go-pattern-detector.lock.yml
@@ -3125,11 +3125,11 @@ jobs:
             function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
               if (triggeringContext && triggeringContext.number) {
-                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                if (triggeringContext.type === "discussion" && triggeringContext.url) {
                   footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
-                } else if (triggeringContext.type === 'pull_request') {
+                } else if (triggeringContext.type === "pull_request") {
                   footer += ` for #${triggeringContext.number}`;
-                } else if (triggeringContext.type === 'issue') {
+                } else if (triggeringContext.type === "issue") {
                   footer += ` for #${triggeringContext.number}`;
                 }
               }
@@ -3197,13 +3197,13 @@ jobs:
               let triggeringContext = undefined;
               if (isIssueContext && context.payload.issue) {
                 triggeringContext = {
-                  type: 'issue',
-                  number: context.payload.issue.number
+                  type: "issue",
+                  number: context.payload.issue.number,
                 };
               } else if (isPRContext && context.payload.pull_request) {
                 triggeringContext = {
-                  type: 'pull_request',
-                  number: context.payload.pull_request.number
+                  type: "pull_request",
+                  number: context.payload.pull_request.number,
                 };
               } else if (isDiscussionContext && context.payload.discussion) {
                 const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
@@ -3211,9 +3211,9 @@ jobs:
                   ? context.payload.repository.html_url
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
                 triggeringContext = {
-                  type: 'discussion',
+                  type: "discussion",
                   number: context.payload.discussion.number,
-                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`,
                 };
               }
               const labelsEnv = process.env.GITHUB_AW_ISSUE_LABELS;
diff --git a/.github/workflows/pdf-summary.lock.yml b/.github/workflows/pdf-summary.lock.yml
index ba3ea4cd421..1f209c120fc 100644
--- a/.github/workflows/pdf-summary.lock.yml
+++ b/.github/workflows/pdf-summary.lock.yml
@@ -4074,11 +4074,11 @@ jobs:
             function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
               if (triggeringContext && triggeringContext.number) {
-                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                if (triggeringContext.type === "discussion" && triggeringContext.url) {
                   footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
-                } else if (triggeringContext.type === 'pull_request') {
+                } else if (triggeringContext.type === "pull_request") {
                   footer += ` for #${triggeringContext.number}`;
-                } else if (triggeringContext.type === 'issue') {
+                } else if (triggeringContext.type === "issue") {
                   footer += ` for #${triggeringContext.number}`;
                 }
               }
@@ -4214,20 +4214,20 @@ jobs:
               let triggeringContext = undefined;
               if (isIssueContext && context.payload.issue) {
                 triggeringContext = {
-                  type: 'issue',
-                  number: context.payload.issue.number
+                  type: "issue",
+                  number: context.payload.issue.number,
                 };
               } else if (isPRContext && context.payload.pull_request) {
                 triggeringContext = {
-                  type: 'pull_request',
-                  number: context.payload.pull_request.number
+                  type: "pull_request",
+                  number: context.payload.pull_request.number,
                 };
               } else if (isDiscussionContext && context.payload.discussion) {
                 const repoUrl = getRepositoryUrl();
                 triggeringContext = {
-                  type: 'discussion',
+                  type: "discussion",
                   number: context.payload.discussion.number,
-                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`,
                 };
               }
               if (commentTarget === "triggering" && !isIssueContext && !isPRContext && !isDiscussionContext) {
diff --git a/.github/workflows/plan.lock.yml b/.github/workflows/plan.lock.yml
index e4d0b8afd2b..007d9441b6a 100644
--- a/.github/workflows/plan.lock.yml
+++ b/.github/workflows/plan.lock.yml
@@ -3961,11 +3961,11 @@ jobs:
             function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
               if (triggeringContext && triggeringContext.number) {
-                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                if (triggeringContext.type === "discussion" && triggeringContext.url) {
                   footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
-                } else if (triggeringContext.type === 'pull_request') {
+                } else if (triggeringContext.type === "pull_request") {
                   footer += ` for #${triggeringContext.number}`;
-                } else if (triggeringContext.type === 'issue') {
+                } else if (triggeringContext.type === "issue") {
                   footer += ` for #${triggeringContext.number}`;
                 }
               }
@@ -4033,13 +4033,13 @@ jobs:
               let triggeringContext = undefined;
               if (isIssueContext && context.payload.issue) {
                 triggeringContext = {
-                  type: 'issue',
-                  number: context.payload.issue.number
+                  type: "issue",
+                  number: context.payload.issue.number,
                 };
               } else if (isPRContext && context.payload.pull_request) {
                 triggeringContext = {
-                  type: 'pull_request',
-                  number: context.payload.pull_request.number
+                  type: "pull_request",
+                  number: context.payload.pull_request.number,
                 };
               } else if (isDiscussionContext && context.payload.discussion) {
                 const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
@@ -4047,9 +4047,9 @@ jobs:
                   ? context.payload.repository.html_url
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
                 triggeringContext = {
-                  type: 'discussion',
+                  type: "discussion",
                   number: context.payload.discussion.number,
-                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`,
                 };
               }
               const labelsEnv = process.env.GITHUB_AW_ISSUE_LABELS;
diff --git a/.github/workflows/poem-bot.lock.yml b/.github/workflows/poem-bot.lock.yml
index 65a3a074fb9..8651c31ab07 100644
--- a/.github/workflows/poem-bot.lock.yml
+++ b/.github/workflows/poem-bot.lock.yml
@@ -4113,11 +4113,11 @@ jobs:
             function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
               if (triggeringContext && triggeringContext.number) {
-                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                if (triggeringContext.type === "discussion" && triggeringContext.url) {
                   footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
-                } else if (triggeringContext.type === 'pull_request') {
+                } else if (triggeringContext.type === "pull_request") {
                   footer += ` for #${triggeringContext.number}`;
-                } else if (triggeringContext.type === 'issue') {
+                } else if (triggeringContext.type === "issue") {
                   footer += ` for #${triggeringContext.number}`;
                 }
               }
@@ -4185,13 +4185,13 @@ jobs:
               let triggeringContext = undefined;
               if (isIssueContext && context.payload.issue) {
                 triggeringContext = {
-                  type: 'issue',
-                  number: context.payload.issue.number
+                  type: "issue",
+                  number: context.payload.issue.number,
                 };
               } else if (isPRContext && context.payload.pull_request) {
                 triggeringContext = {
-                  type: 'pull_request',
-                  number: context.payload.pull_request.number
+                  type: "pull_request",
+                  number: context.payload.pull_request.number,
                 };
               } else if (isDiscussionContext && context.payload.discussion) {
                 const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
@@ -4199,9 +4199,9 @@ jobs:
                   ? context.payload.repository.html_url
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
                 triggeringContext = {
-                  type: 'discussion',
+                  type: "discussion",
                   number: context.payload.discussion.number,
-                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`,
                 };
               }
               const labelsEnv = process.env.GITHUB_AW_ISSUE_LABELS;
@@ -4391,11 +4391,11 @@ jobs:
             function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
               if (triggeringContext && triggeringContext.number) {
-                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                if (triggeringContext.type === "discussion" && triggeringContext.url) {
                   footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
-                } else if (triggeringContext.type === 'pull_request') {
+                } else if (triggeringContext.type === "pull_request") {
                   footer += ` for #${triggeringContext.number}`;
-                } else if (triggeringContext.type === 'issue') {
+                } else if (triggeringContext.type === "issue") {
                   footer += ` for #${triggeringContext.number}`;
                 }
               }
@@ -4531,20 +4531,20 @@ jobs:
               let triggeringContext = undefined;
               if (isIssueContext && context.payload.issue) {
                 triggeringContext = {
-                  type: 'issue',
-                  number: context.payload.issue.number
+                  type: "issue",
+                  number: context.payload.issue.number,
                 };
               } else if (isPRContext && context.payload.pull_request) {
                 triggeringContext = {
-                  type: 'pull_request',
-                  number: context.payload.pull_request.number
+                  type: "pull_request",
+                  number: context.payload.pull_request.number,
                 };
               } else if (isDiscussionContext && context.payload.discussion) {
                 const repoUrl = getRepositoryUrl();
                 triggeringContext = {
-                  type: 'discussion',
+                  type: "discussion",
                   number: context.payload.discussion.number,
-                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`,
                 };
               }
               if (commentTarget === "triggering" && !isIssueContext && !isPRContext && !isDiscussionContext) {
@@ -4689,11 +4689,11 @@ jobs:
             function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
               if (triggeringContext && triggeringContext.number) {
-                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                if (triggeringContext.type === "discussion" && triggeringContext.url) {
                   footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
-                } else if (triggeringContext.type === 'pull_request') {
+                } else if (triggeringContext.type === "pull_request") {
                   footer += ` for #${triggeringContext.number}`;
-                } else if (triggeringContext.type === 'issue') {
+                } else if (triggeringContext.type === "issue") {
                   footer += ` for #${triggeringContext.number}`;
                 }
               }
@@ -4784,8 +4784,8 @@ jobs:
               let triggeringContext = undefined;
               if (isPRContext && context.payload.pull_request) {
                 triggeringContext = {
-                  type: 'pull_request',
-                  number: context.payload.pull_request.number
+                  type: "pull_request",
+                  number: context.payload.pull_request.number,
                 };
               }
               if (commentTarget === "triggering" && !isPRContext) {
diff --git a/.github/workflows/scout.lock.yml b/.github/workflows/scout.lock.yml
index 42588d8d35b..c209bce1ddd 100644
--- a/.github/workflows/scout.lock.yml
+++ b/.github/workflows/scout.lock.yml
@@ -4442,11 +4442,11 @@ jobs:
             function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
               if (triggeringContext && triggeringContext.number) {
-                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                if (triggeringContext.type === "discussion" && triggeringContext.url) {
                   footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
-                } else if (triggeringContext.type === 'pull_request') {
+                } else if (triggeringContext.type === "pull_request") {
                   footer += ` for #${triggeringContext.number}`;
-                } else if (triggeringContext.type === 'issue') {
+                } else if (triggeringContext.type === "issue") {
                   footer += ` for #${triggeringContext.number}`;
                 }
               }
@@ -4582,20 +4582,20 @@ jobs:
               let triggeringContext = undefined;
               if (isIssueContext && context.payload.issue) {
                 triggeringContext = {
-                  type: 'issue',
-                  number: context.payload.issue.number
+                  type: "issue",
+                  number: context.payload.issue.number,
                 };
               } else if (isPRContext && context.payload.pull_request) {
                 triggeringContext = {
-                  type: 'pull_request',
-                  number: context.payload.pull_request.number
+                  type: "pull_request",
+                  number: context.payload.pull_request.number,
                 };
               } else if (isDiscussionContext && context.payload.discussion) {
                 const repoUrl = getRepositoryUrl();
                 triggeringContext = {
-                  type: 'discussion',
+                  type: "discussion",
                   number: context.payload.discussion.number,
-                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`,
                 };
               }
               if (commentTarget === "triggering" && !isIssueContext && !isPRContext && !isDiscussionContext) {
diff --git a/.github/workflows/smoke-claude.lock.yml b/.github/workflows/smoke-claude.lock.yml
index 26cdcde16d7..5170e34e38e 100644
--- a/.github/workflows/smoke-claude.lock.yml
+++ b/.github/workflows/smoke-claude.lock.yml
@@ -2967,11 +2967,11 @@ jobs:
             function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
               if (triggeringContext && triggeringContext.number) {
-                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                if (triggeringContext.type === "discussion" && triggeringContext.url) {
                   footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
-                } else if (triggeringContext.type === 'pull_request') {
+                } else if (triggeringContext.type === "pull_request") {
                   footer += ` for #${triggeringContext.number}`;
-                } else if (triggeringContext.type === 'issue') {
+                } else if (triggeringContext.type === "issue") {
                   footer += ` for #${triggeringContext.number}`;
                 }
               }
@@ -3039,13 +3039,13 @@ jobs:
               let triggeringContext = undefined;
               if (isIssueContext && context.payload.issue) {
                 triggeringContext = {
-                  type: 'issue',
-                  number: context.payload.issue.number
+                  type: "issue",
+                  number: context.payload.issue.number,
                 };
               } else if (isPRContext && context.payload.pull_request) {
                 triggeringContext = {
-                  type: 'pull_request',
-                  number: context.payload.pull_request.number
+                  type: "pull_request",
+                  number: context.payload.pull_request.number,
                 };
               } else if (isDiscussionContext && context.payload.discussion) {
                 const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
@@ -3053,9 +3053,9 @@ jobs:
                   ? context.payload.repository.html_url
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
                 triggeringContext = {
-                  type: 'discussion',
+                  type: "discussion",
                   number: context.payload.discussion.number,
-                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`,
                 };
               }
               const labelsEnv = process.env.GITHUB_AW_ISSUE_LABELS;
diff --git a/.github/workflows/smoke-codex.lock.yml b/.github/workflows/smoke-codex.lock.yml
index f8c3a8b62a0..8d85469073c 100644
--- a/.github/workflows/smoke-codex.lock.yml
+++ b/.github/workflows/smoke-codex.lock.yml
@@ -2785,11 +2785,11 @@ jobs:
             function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
               if (triggeringContext && triggeringContext.number) {
-                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                if (triggeringContext.type === "discussion" && triggeringContext.url) {
                   footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
-                } else if (triggeringContext.type === 'pull_request') {
+                } else if (triggeringContext.type === "pull_request") {
                   footer += ` for #${triggeringContext.number}`;
-                } else if (triggeringContext.type === 'issue') {
+                } else if (triggeringContext.type === "issue") {
                   footer += ` for #${triggeringContext.number}`;
                 }
               }
@@ -2857,13 +2857,13 @@ jobs:
               let triggeringContext = undefined;
               if (isIssueContext && context.payload.issue) {
                 triggeringContext = {
-                  type: 'issue',
-                  number: context.payload.issue.number
+                  type: "issue",
+                  number: context.payload.issue.number,
                 };
               } else if (isPRContext && context.payload.pull_request) {
                 triggeringContext = {
-                  type: 'pull_request',
-                  number: context.payload.pull_request.number
+                  type: "pull_request",
+                  number: context.payload.pull_request.number,
                 };
               } else if (isDiscussionContext && context.payload.discussion) {
                 const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
@@ -2871,9 +2871,9 @@ jobs:
                   ? context.payload.repository.html_url
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
                 triggeringContext = {
-                  type: 'discussion',
+                  type: "discussion",
                   number: context.payload.discussion.number,
-                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`,
                 };
               }
               const labelsEnv = process.env.GITHUB_AW_ISSUE_LABELS;
diff --git a/.github/workflows/smoke-copilot.lock.yml b/.github/workflows/smoke-copilot.lock.yml
index eb251276ee5..99c4f0f1835 100644
--- a/.github/workflows/smoke-copilot.lock.yml
+++ b/.github/workflows/smoke-copilot.lock.yml
@@ -3353,11 +3353,11 @@ jobs:
             function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
               if (triggeringContext && triggeringContext.number) {
-                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                if (triggeringContext.type === "discussion" && triggeringContext.url) {
                   footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
-                } else if (triggeringContext.type === 'pull_request') {
+                } else if (triggeringContext.type === "pull_request") {
                   footer += ` for #${triggeringContext.number}`;
-                } else if (triggeringContext.type === 'issue') {
+                } else if (triggeringContext.type === "issue") {
                   footer += ` for #${triggeringContext.number}`;
                 }
               }
@@ -3425,13 +3425,13 @@ jobs:
               let triggeringContext = undefined;
               if (isIssueContext && context.payload.issue) {
                 triggeringContext = {
-                  type: 'issue',
-                  number: context.payload.issue.number
+                  type: "issue",
+                  number: context.payload.issue.number,
                 };
               } else if (isPRContext && context.payload.pull_request) {
                 triggeringContext = {
-                  type: 'pull_request',
-                  number: context.payload.pull_request.number
+                  type: "pull_request",
+                  number: context.payload.pull_request.number,
                 };
               } else if (isDiscussionContext && context.payload.discussion) {
                 const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
@@ -3439,9 +3439,9 @@ jobs:
                   ? context.payload.repository.html_url
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
                 triggeringContext = {
-                  type: 'discussion',
+                  type: "discussion",
                   number: context.payload.discussion.number,
-                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`,
                 };
               }
               const labelsEnv = process.env.GITHUB_AW_ISSUE_LABELS;
diff --git a/.github/workflows/smoke-genaiscript.lock.yml b/.github/workflows/smoke-genaiscript.lock.yml
index deed96eb3d2..dac162cb7f4 100644
--- a/.github/workflows/smoke-genaiscript.lock.yml
+++ b/.github/workflows/smoke-genaiscript.lock.yml
@@ -2146,11 +2146,11 @@ jobs:
             function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
               if (triggeringContext && triggeringContext.number) {
-                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                if (triggeringContext.type === "discussion" && triggeringContext.url) {
                   footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
-                } else if (triggeringContext.type === 'pull_request') {
+                } else if (triggeringContext.type === "pull_request") {
                   footer += ` for #${triggeringContext.number}`;
-                } else if (triggeringContext.type === 'issue') {
+                } else if (triggeringContext.type === "issue") {
                   footer += ` for #${triggeringContext.number}`;
                 }
               }
@@ -2218,13 +2218,13 @@ jobs:
               let triggeringContext = undefined;
               if (isIssueContext && context.payload.issue) {
                 triggeringContext = {
-                  type: 'issue',
-                  number: context.payload.issue.number
+                  type: "issue",
+                  number: context.payload.issue.number,
                 };
               } else if (isPRContext && context.payload.pull_request) {
                 triggeringContext = {
-                  type: 'pull_request',
-                  number: context.payload.pull_request.number
+                  type: "pull_request",
+                  number: context.payload.pull_request.number,
                 };
               } else if (isDiscussionContext && context.payload.discussion) {
                 const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
@@ -2232,9 +2232,9 @@ jobs:
                   ? context.payload.repository.html_url
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
                 triggeringContext = {
-                  type: 'discussion',
+                  type: "discussion",
                   number: context.payload.discussion.number,
-                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`,
                 };
               }
               const labelsEnv = process.env.GITHUB_AW_ISSUE_LABELS;
diff --git a/.github/workflows/smoke-opencode.lock.yml b/.github/workflows/smoke-opencode.lock.yml
index 465dbeddbdf..e9ee37a387b 100644
--- a/.github/workflows/smoke-opencode.lock.yml
+++ b/.github/workflows/smoke-opencode.lock.yml
@@ -2114,11 +2114,11 @@ jobs:
             function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
               if (triggeringContext && triggeringContext.number) {
-                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                if (triggeringContext.type === "discussion" && triggeringContext.url) {
                   footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
-                } else if (triggeringContext.type === 'pull_request') {
+                } else if (triggeringContext.type === "pull_request") {
                   footer += ` for #${triggeringContext.number}`;
-                } else if (triggeringContext.type === 'issue') {
+                } else if (triggeringContext.type === "issue") {
                   footer += ` for #${triggeringContext.number}`;
                 }
               }
@@ -2186,13 +2186,13 @@ jobs:
               let triggeringContext = undefined;
               if (isIssueContext && context.payload.issue) {
                 triggeringContext = {
-                  type: 'issue',
-                  number: context.payload.issue.number
+                  type: "issue",
+                  number: context.payload.issue.number,
                 };
               } else if (isPRContext && context.payload.pull_request) {
                 triggeringContext = {
-                  type: 'pull_request',
-                  number: context.payload.pull_request.number
+                  type: "pull_request",
+                  number: context.payload.pull_request.number,
                 };
               } else if (isDiscussionContext && context.payload.discussion) {
                 const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com";
@@ -2200,9 +2200,9 @@ jobs:
                   ? context.payload.repository.html_url
                   : `${githubServer}/${context.repo.owner}/${context.repo.repo}`;
                 triggeringContext = {
-                  type: 'discussion',
+                  type: "discussion",
                   number: context.payload.discussion.number,
-                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`,
                 };
               }
               const labelsEnv = process.env.GITHUB_AW_ISSUE_LABELS;
diff --git a/.github/workflows/technical-doc-writer.lock.yml b/.github/workflows/technical-doc-writer.lock.yml
index 944a8afd998..e47cba7dc68 100644
--- a/.github/workflows/technical-doc-writer.lock.yml
+++ b/.github/workflows/technical-doc-writer.lock.yml
@@ -3331,11 +3331,11 @@ jobs:
             function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
               if (triggeringContext && triggeringContext.number) {
-                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                if (triggeringContext.type === "discussion" && triggeringContext.url) {
                   footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
-                } else if (triggeringContext.type === 'pull_request') {
+                } else if (triggeringContext.type === "pull_request") {
                   footer += ` for #${triggeringContext.number}`;
-                } else if (triggeringContext.type === 'issue') {
+                } else if (triggeringContext.type === "issue") {
                   footer += ` for #${triggeringContext.number}`;
                 }
               }
@@ -3471,20 +3471,20 @@ jobs:
               let triggeringContext = undefined;
               if (isIssueContext && context.payload.issue) {
                 triggeringContext = {
-                  type: 'issue',
-                  number: context.payload.issue.number
+                  type: "issue",
+                  number: context.payload.issue.number,
                 };
               } else if (isPRContext && context.payload.pull_request) {
                 triggeringContext = {
-                  type: 'pull_request',
-                  number: context.payload.pull_request.number
+                  type: "pull_request",
+                  number: context.payload.pull_request.number,
                 };
               } else if (isDiscussionContext && context.payload.discussion) {
                 const repoUrl = getRepositoryUrl();
                 triggeringContext = {
-                  type: 'discussion',
+                  type: "discussion",
                   number: context.payload.discussion.number,
-                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`,
                 };
               }
               if (commentTarget === "triggering" && !isIssueContext && !isPRContext && !isDiscussionContext) {
diff --git a/.github/workflows/unbloat-docs.lock.yml b/.github/workflows/unbloat-docs.lock.yml
index efd28bd82e6..2525756d252 100644
--- a/.github/workflows/unbloat-docs.lock.yml
+++ b/.github/workflows/unbloat-docs.lock.yml
@@ -3661,11 +3661,11 @@ jobs:
             function generateFooter(workflowName, runUrl, workflowSource, workflowSourceURL, triggeringContext) {
               let footer = `\n\n> AI generated by [${workflowName}](${runUrl})`;
               if (triggeringContext && triggeringContext.number) {
-                if (triggeringContext.type === 'discussion' && triggeringContext.url) {
+                if (triggeringContext.type === "discussion" && triggeringContext.url) {
                   footer += ` for [discussion #${triggeringContext.number}](${triggeringContext.url})`;
-                } else if (triggeringContext.type === 'pull_request') {
+                } else if (triggeringContext.type === "pull_request") {
                   footer += ` for #${triggeringContext.number}`;
-                } else if (triggeringContext.type === 'issue') {
+                } else if (triggeringContext.type === "issue") {
                   footer += ` for #${triggeringContext.number}`;
                 }
               }
@@ -3801,20 +3801,20 @@ jobs:
               let triggeringContext = undefined;
               if (isIssueContext && context.payload.issue) {
                 triggeringContext = {
-                  type: 'issue',
-                  number: context.payload.issue.number
+                  type: "issue",
+                  number: context.payload.issue.number,
                 };
               } else if (isPRContext && context.payload.pull_request) {
                 triggeringContext = {
-                  type: 'pull_request',
-                  number: context.payload.pull_request.number
+                  type: "pull_request",
+                  number: context.payload.pull_request.number,
                 };
               } else if (isDiscussionContext && context.payload.discussion) {
                 const repoUrl = getRepositoryUrl();
                 triggeringContext = {
-                  type: 'discussion',
+                  type: "discussion",
                   number: context.payload.discussion.number,
-                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`
+                  url: `${repoUrl}/discussions/${context.payload.discussion.number}`,
                 };
               }
               if (commentTarget === "triggering" && !isIssueContext && !isPRContext && !isDiscussionContext) {
