Skip to content

Commit e341b83

Browse files
Gkrumbach07Ambient Code Botclaude
authored
feat: improve Slack notification formatting + read issue comments (#1238)
<!-- acp:session_id=session-abe4e0df-bc2e-4258-be06-fb50d90d7d63 source=#1238 last_action=2026-04-10T14:58:30Z retry_count=0 --> ## Summary Improve Slack notification formatting across the Amber issue handler workflow: - Use `jq -nc` for JSON-safe payload construction in all Slack notification templates (prevents JSON injection from issue/PR titles containing quotes or newlines) - Include issue/PR title in all notification messages for better context - Add title resolution via `gh issue/pr view` before sending notifications - Use heredoc/delimiter syntax for GITHUB_OUTPUT to safely handle multiline or special-character titles ## Test plan - [ ] Verify YAML syntax is valid (`check-yaml` pre-commit hook) - [ ] Confirm all Slack notification templates use the `jq -nc` pattern consistently - [ ] Confirm PR title is included in all notification payloads - [ ] Test that titles with special characters (quotes, newlines) don't break notifications - [ ] Verify GITHUB_OUTPUT handles multiline titles correctly --- 🤖 [Ambient Session](https://ambient-code.apps.rosa.vteam-uat.0ksl.p3.openshiftapps.com/projects/ambient-platform-and-workflow-feedback-loop-running/sessions/session-abe4e0df-bc2e-4258-be06-fb50d90d7d63) --------- Co-authored-by: Ambient Code Bot <bot@ambient-code.local> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a1ebe4a commit e341b83

1 file changed

Lines changed: 86 additions & 28 deletions

File tree

.github/workflows/amber-issue-handler.yml

Lines changed: 86 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ jobs:
5757
NUMBER="${{ github.event.issue.number }}"
5858
TITLE=$(gh issue view "$NUMBER" --repo "${{ github.repository }}" --json title --jq '.title')
5959
echo "number=$NUMBER" >> $GITHUB_OUTPUT
60-
echo "title=$TITLE" >> $GITHUB_OUTPUT
60+
{
61+
echo "title<<EOF"
62+
echo "$TITLE"
63+
echo "EOF"
64+
} >> $GITHUB_OUTPUT
6165
6266
- name: Check for existing PR
6367
id: existing
@@ -103,11 +107,15 @@ jobs:
103107
unclear requirements, multiple valid approaches, missing context — you
104108
MUST ask for clarification. IMPORTANT: Before calling AskUserQuestion,
105109
ALWAYS send a Slack notification first (the session stops streaming when
106-
AskUserQuestion is called, so the notification must go out before):
110+
AskUserQuestion is called, so the notification must go out before).
111+
Use Slack mrkdwn link format: <URL|display text>. Example:
107112
```bash
108-
curl -X POST -H 'Content-type: application/json' \
109-
--data '{"text":"I have a question about #${{ steps.issue.outputs.number }}\n*Issue*: https://github.com/${{ github.repository }}/issues/${{ steps.issue.outputs.number }}\n*Session*: '"$PLATFORM_HOST/projects/$AGENTIC_SESSION_NAMESPACE/sessions/$AGENTIC_SESSION_NAME"'\n*Question*: <brief summary of what you need>"}' \
110-
"$SLACK_WEBHOOK_URL"
113+
TITLE=$(gh issue view ${{ steps.issue.outputs.number }} --repo ${{ github.repository }} --json title --jq '.title')
114+
PAYLOAD=$(jq -nc --arg text "❓ *Question about <https://github.com/${{ github.repository }}/issues/${{ steps.issue.outputs.number }}|#${{ steps.issue.outputs.number }} — $TITLE>*
115+
<your question here>
116+
117+
<$PLATFORM_HOST/projects/$AGENTIC_SESSION_NAMESPACE/sessions/$AGENTIC_SESSION_NAME|View Session>" '{text: $text}')
118+
curl -X POST -H 'Content-type: application/json' --data "$PAYLOAD" "$SLACK_WEBHOOK_URL"
111119
```
112120
Only send if SLACK_WEBHOOK_URL is set. Then call AskUserQuestion.
113121
4. Implement the fix. Write tests if the area has existing test coverage.
@@ -119,9 +127,20 @@ jobs:
119127
---
120128
🤖 [Ambient Session](<SESSION_URL>)
121129
6. Add the `ambient-code:managed` label to the PR.
122-
7. Ensure CI passes. If it fails, investigate and fix.
123-
8. Do not merge. Leave the PR open for human review.
124-
9. When you comment on the PR, include this footer at the end:
130+
7. After creating the PR, send a Slack notification with a brief summary
131+
of what you changed. Use Slack mrkdwn link format: <URL|display text>. Example:
132+
```bash
133+
TITLE=$(gh issue view ${{ steps.issue.outputs.number }} --repo ${{ github.repository }} --json title --jq '.title')
134+
PAYLOAD=$(jq -nc --arg text "🔧 *PR created for <https://github.com/${{ github.repository }}/issues/${{ steps.issue.outputs.number }}|#${{ steps.issue.outputs.number }} — $TITLE>*
135+
<PR_URL|View PR> · <SESSION_URL|View Session>
136+
137+
<1-2 sentence summary of what you changed>" '{text: $text}')
138+
curl -X POST -H 'Content-type: application/json' --data "$PAYLOAD" "$SLACK_WEBHOOK_URL"
139+
```
140+
Only send if SLACK_WEBHOOK_URL is set.
141+
8. Ensure CI passes. If it fails, investigate and fix.
142+
9. Do not merge. Leave the PR open for human review.
143+
10. When you comment on the PR, include this footer at the end:
125144
_🤖 [Session](<SESSION_URL>)_
126145
127146
## Session URL
@@ -140,7 +159,7 @@ jobs:
140159
wait: 'true'
141160
timeout: '0'
142161
environment-variables: >-
143-
{"SLACK_WEBHOOK_URL": "${{ secrets.SLACK_WEBHOOK_URL }}", "PLATFORM_HOST": "${{ secrets.PLATFORM_HOST }}"}
162+
{"SLACK_WEBHOOK_URL": "${{ secrets.SLACK_WEBHOOK_URL }}", "PLATFORM_HOST": "${{ secrets.PLATFORM_HOST }}", "GITHUB_TOKEN": "${{ secrets.GITHUB_TOKEN }}"}
144163
145164
- name: Post-session update comment
146165
if: steps.existing.outputs.skip != 'true'
@@ -228,6 +247,13 @@ jobs:
228247
echo "type=pr" >> $GITHUB_OUTPUT
229248
echo "url=https://github.com/${{ github.repository }}/pull/$NUMBER" >> $GITHUB_OUTPUT
230249
250+
TITLE=$(gh pr view "$NUMBER" --repo "${{ github.repository }}" --json title --jq '.title')
251+
{
252+
echo "title<<EOF"
253+
echo "$TITLE"
254+
echo "EOF"
255+
} >> $GITHUB_OUTPUT
256+
231257
IS_FORK=$(gh pr view "$NUMBER" --repo "${{ github.repository }}" --json isCrossRepository --jq '.isCrossRepository')
232258
echo "is_fork=$IS_FORK" >> $GITHUB_OUTPUT
233259
@@ -238,6 +264,14 @@ jobs:
238264
else
239265
echo "type=issue" >> $GITHUB_OUTPUT
240266
echo "url=https://github.com/${{ github.repository }}/issues/$NUMBER" >> $GITHUB_OUTPUT
267+
268+
TITLE=$(gh issue view "$NUMBER" --repo "${{ github.repository }}" --json title --jq '.title')
269+
{
270+
echo "title<<EOF"
271+
echo "$TITLE"
272+
echo "EOF"
273+
} >> $GITHUB_OUTPUT
274+
241275
echo "is_fork=false" >> $GITHUB_OUTPUT
242276
243277
# Check for existing ambient-code:managed PR for this issue and get its session ID
@@ -304,14 +338,18 @@ jobs:
304338
305339
## Slack Notifications
306340
307-
When you need human attention — whether you hit the circuit breaker (3 retries),
308-
you're stuck and can't proceed, or you use the AskUserQuestion tool — send a
309-
Slack notification:
341+
When you need human attention — circuit breaker, stuck, or before calling
342+
AskUserQuestion — send a Slack notification. IMPORTANT: Always send BEFORE
343+
calling AskUserQuestion (the session stops streaming on that call).
344+
Use Slack mrkdwn link format: <URL|display text>. Example:
310345
311346
```bash
312-
curl -X POST -H 'Content-type: application/json' \
313-
--data '{"text":"I need human attention\n*PR*: ${{ steps.context.outputs.url }}\n*Session*: '"$PLATFORM_HOST/projects/$AGENTIC_SESSION_NAMESPACE/sessions/$AGENTIC_SESSION_NAME"'\n*Reason*: <brief reason>"}' \
314-
"$SLACK_WEBHOOK_URL"
347+
TITLE=$(gh pr view ${{ steps.context.outputs.number }} --repo ${{ github.repository }} --json title --jq '.title')
348+
PAYLOAD=$(jq -nc --arg text "🚨 *Need help with <${{ steps.context.outputs.url }}|PR #${{ steps.context.outputs.number }} — $TITLE>*
349+
<reason — what you tried and why you're stuck>
350+
351+
<$PLATFORM_HOST/projects/$AGENTIC_SESSION_NAMESPACE/sessions/$AGENTIC_SESSION_NAME|View Session>" '{text: $text}')
352+
curl -X POST -H 'Content-type: application/json' --data "$PAYLOAD" "$SLACK_WEBHOOK_URL"
315353
```
316354
317355
The environment variables SLACK_WEBHOOK_URL, PLATFORM_HOST, AGENTIC_SESSION_NAMESPACE,
@@ -344,11 +382,15 @@ jobs:
344382
unclear requirements, multiple valid approaches, missing context — you
345383
MUST ask for clarification. IMPORTANT: Before calling AskUserQuestion,
346384
ALWAYS send a Slack notification first (the session stops streaming when
347-
AskUserQuestion is called, so the notification must go out before):
385+
AskUserQuestion is called, so the notification must go out before).
386+
Use Slack mrkdwn link format: <URL|display text>. Example:
348387
```bash
349-
curl -X POST -H 'Content-type: application/json' \
350-
--data '{"text":"I have a question about #${{ steps.context.outputs.number }}\n*Issue*: ${{ steps.context.outputs.url }}\n*Session*: '"$PLATFORM_HOST/projects/$AGENTIC_SESSION_NAMESPACE/sessions/$AGENTIC_SESSION_NAME"'\n*Question*: <brief summary of what you need>"}' \
351-
"$SLACK_WEBHOOK_URL"
388+
TITLE=$(gh issue view ${{ steps.context.outputs.number }} --repo ${{ github.repository }} --json title --jq '.title')
389+
PAYLOAD=$(jq -nc --arg text "❓ *Question about <${{ steps.context.outputs.url }}|#${{ steps.context.outputs.number }} — $TITLE>*
390+
<your question here>
391+
392+
<$PLATFORM_HOST/projects/$AGENTIC_SESSION_NAMESPACE/sessions/$AGENTIC_SESSION_NAME|View Session>" '{text: $text}')
393+
curl -X POST -H 'Content-type: application/json' --data "$PAYLOAD" "$SLACK_WEBHOOK_URL"
352394
```
353395
Only send if SLACK_WEBHOOK_URL is set. Then call AskUserQuestion.
354396
4. Implement the fix. Write tests if the area has existing test coverage.
@@ -360,9 +402,20 @@ jobs:
360402
---
361403
🤖 [Ambient Session](<SESSION_URL>)
362404
6. Add the `ambient-code:managed` label to the PR.
363-
7. Ensure CI passes. If it fails, investigate and fix.
364-
8. Do not merge. Leave the PR open for human review.
365-
9. When you comment on the PR, include this footer at the end:
405+
7. After creating the PR, send a Slack notification with a brief summary
406+
of what you changed. Use Slack mrkdwn link format: <URL|display text>. Example:
407+
```bash
408+
TITLE=$(gh issue view ${{ steps.context.outputs.number }} --repo ${{ github.repository }} --json title --jq '.title')
409+
PAYLOAD=$(jq -nc --arg text "🔧 *PR created for <${{ steps.context.outputs.url }}|#${{ steps.context.outputs.number }} — $TITLE>*
410+
<PR_URL|View PR> · <SESSION_URL|View Session>
411+
412+
<1-2 sentence summary of what you changed>" '{text: $text}')
413+
curl -X POST -H 'Content-type: application/json' --data "$PAYLOAD" "$SLACK_WEBHOOK_URL"
414+
```
415+
Only send if SLACK_WEBHOOK_URL is set.
416+
8. Ensure CI passes. If it fails, investigate and fix.
417+
9. Do not merge. Leave the PR open for human review.
418+
10. When you comment on the PR, include this footer at the end:
366419
_🤖 [Session](<SESSION_URL>)_
367420
368421
## Session URL
@@ -381,7 +434,7 @@ jobs:
381434
wait: 'true'
382435
timeout: '0'
383436
environment-variables: >-
384-
{"SLACK_WEBHOOK_URL": "${{ secrets.SLACK_WEBHOOK_URL }}", "PLATFORM_HOST": "${{ secrets.PLATFORM_HOST }}"}
437+
{"SLACK_WEBHOOK_URL": "${{ secrets.SLACK_WEBHOOK_URL }}", "PLATFORM_HOST": "${{ secrets.PLATFORM_HOST }}", "GITHUB_TOKEN": "${{ secrets.GITHUB_TOKEN }}"}
385438
386439
# Custom prompt: @ambient-code <instruction> — pass user's text
387440
- name: Run custom prompt
@@ -406,7 +459,7 @@ jobs:
406459
wait: 'true'
407460
timeout: '0'
408461
environment-variables: >-
409-
{"SLACK_WEBHOOK_URL": "${{ secrets.SLACK_WEBHOOK_URL }}", "PLATFORM_HOST": "${{ secrets.PLATFORM_HOST }}"}
462+
{"SLACK_WEBHOOK_URL": "${{ secrets.SLACK_WEBHOOK_URL }}", "PLATFORM_HOST": "${{ secrets.PLATFORM_HOST }}", "GITHUB_TOKEN": "${{ secrets.GITHUB_TOKEN }}"}
410463
411464
- name: Post check run on PR
412465
if: >-
@@ -835,11 +888,16 @@ jobs:
835888
836889
## Slack Notifications
837890
838-
When you need human attention — circuit breaker, stuck, or using AskUserQuestion — send:
891+
When you need human attention — circuit breaker, stuck, or before calling
892+
AskUserQuestion — send a Slack notification. IMPORTANT: Always send BEFORE
893+
calling AskUserQuestion. Use Slack mrkdwn link format: <URL|display text>.
894+
895+
TITLE=$(gh pr view {number} --repo {REPO} --json title --jq '.title')
896+
PAYLOAD=$(jq -nc --arg text "🚨 *Need help with <https://github.com/{REPO}/pull/{number}|PR #{number} — $TITLE>*
897+
<reason — what you tried and why you are stuck>
839898
840-
curl -X POST -H 'Content-type: application/json' \\
841-
--data '{{"text":"I need human attention\\n*PR*: https://github.com/{REPO}/pull/{number}\\n*Session*: '"$PLATFORM_HOST/projects/$AGENTIC_SESSION_NAMESPACE/sessions/$AGENTIC_SESSION_NAME"'\\n*Reason*: <brief reason>"}}' \\
842-
"$SLACK_WEBHOOK_URL"
899+
<$PLATFORM_HOST/projects/$AGENTIC_SESSION_NAMESPACE/sessions/$AGENTIC_SESSION_NAME|View Session>" '{{text: $text}}')
900+
curl -X POST -H 'Content-type: application/json' --data "$PAYLOAD" "$SLACK_WEBHOOK_URL"
843901
844902
Only send if SLACK_WEBHOOK_URL is set."""
845903

0 commit comments

Comments
 (0)