From b3deee74125b632249a680d0040dafd36c85eb44 Mon Sep 17 00:00:00 2001 From: Felix Faerber Date: Sat, 4 Jul 2026 10:02:50 +0300 Subject: [PATCH] fix(agent): route issue-opened events (event_name is workflow_call in reusable wf) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The shared agent.yml is a reusable (workflow_call) workflow, so on Gitea github.event_name evaluates to 'workflow_call' — not the original 'issues'/ 'issue_comment'. route.sh branched on EVENT == "issues", so issue-opened runs scanned the empty comment body and skipped the @pm fallback, exiting 1 with "no known agent mentioned" (runs #393/#394). Comment runs were unaffected because the @mention lives in $BODY. Discriminate on the comment id (CID) instead, which IS reliably forwarded in the event payload: empty => issue-opened (scan issue body, default @pm), set => comment (scan comment body). Also add .gitignore for .env. Co-Authored-By: Claude Opus 4.8 (1M context) --- .gitea/workflows/agent.yml | 6 +++++- .gitea/workflows/scripts/route.sh | 8 +++++--- .gitignore | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 .gitignore diff --git a/.gitea/workflows/agent.yml b/.gitea/workflows/agent.yml index d395dbd..0d41bc1 100644 --- a/.gitea/workflows/agent.yml +++ b/.gitea/workflows/agent.yml @@ -56,7 +56,11 @@ jobs: SCRIPTS: ${{ github.workspace }}/.agents-workflow/.gitea/workflows/scripts BODY: ${{ github.event.comment.body }} # event text via env, never inline in shell IBODY: ${{ github.event.issue.body }} - EVENT: ${{ github.event_name }} + # Comment-vs-issue discriminator. Do NOT use github.event_name here: this is a REUSABLE + # (workflow_call) workflow, so on Gitea event_name is 'workflow_call', not the original + # 'issues'/'issue_comment'. The comment id, however, is reliably present in the forwarded + # payload — empty on an issue-opened event, set on a comment event. + CID: ${{ github.event.comment.id }} IS_PR: ${{ github.event.issue.pull_request }} NUM: ${{ github.event.issue.number }} GT: ${{ secrets.GITEA_TOKEN }} diff --git a/.gitea/workflows/scripts/route.sh b/.gitea/workflows/scripts/route.sh index 482620b..7237d46 100755 --- a/.gitea/workflows/scripts/route.sh +++ b/.gitea/workflows/scripts/route.sh @@ -4,7 +4,7 @@ # /tmp/agents.json, picks which agent to run, emits step outputs (name/model/vision/mode/branch/new) # to $GITHUB_OUTPUT, configures git identity, and prepares/publishes the working branch. # -# Required env (all provided by the workflow step): BODY IBODY EVENT IS_PR NUM GT +# Required env (all provided by the workflow step): BODY IBODY CID IS_PR NUM GT # TOKEN_PM TOKEN_SENIOR TOKEN_JUNIOR TOKEN_LEAD TOKEN_QA # GITHUB_SERVER_URL GITHUB_REPOSITORY GITHUB_OUTPUT set -eu @@ -26,13 +26,15 @@ cat > /tmp/agents.json <<'JSON' } JSON # On a new issue, @pm auto-assesses. On a comment, route by the @mention. -scan="$BODY"; [ "$EVENT" = "issues" ] && scan="$IBODY" +# A comment event has a comment id (CID); an issue-opened event does not. (event_name is unreliable +# here — see agent.yml: this reusable workflow sees it as 'workflow_call'.) +if [ -n "$CID" ]; then scan="$BODY"; else scan="$IBODY"; fi name="" for a in pm junior senior lead qa; do case "$scan" in *"@$a"*) name=$a; break;; esac done if [ -z "$name" ]; then - if [ "$EVENT" = "issues" ]; then name=pm; else echo "no known agent mentioned"; exit 1; fi + if [ -z "$CID" ]; then name=pm; else echo "no known agent mentioned"; exit 1; fi fi model=$(jq -r --arg a "$name" '.[$a].model' /tmp/agents.json) vision=$(jq -r --arg a "$name" '.[$a].vision' /tmp/agents.json) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c49bd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env