|
| 1 | +# Monitors anomalyco/opencode#21960 ("SessionRetry.policy() retries |
| 2 | +# forever with no max attempt count") and its known related PRs, since |
| 3 | +# this bug causes `opencode run` to hang indefinitely on a retryable error |
| 4 | +# (e.g. a 429 from an exhausted OpenCode Go quota) with no config |
| 5 | +# override available. See ~/.config/ralph-tui/config.toml's opencode-go |
| 6 | +# entry for where this blocks real usage. |
| 7 | +# |
| 8 | +# Setup: TELEGRAM_BOT_TOKEN must be set as a repository secret (shared |
| 9 | +# with monitor-herdr-extension-releases.yml). |
| 10 | + |
| 11 | +--- |
| 12 | +name: Monitor opencode retry-cap bug |
| 13 | + |
| 14 | +"on": |
| 15 | + schedule: |
| 16 | + - cron: "23 7 * * *" |
| 17 | + workflow_dispatch: |
| 18 | + inputs: |
| 19 | + send_test_notification: |
| 20 | + description: >- |
| 21 | + Send a test notification to the standing Hermes Telegram topic |
| 22 | + type: boolean |
| 23 | + default: false |
| 24 | + |
| 25 | +concurrency: |
| 26 | + group: monitor-opencode-retry-bug |
| 27 | + cancel-in-progress: false |
| 28 | + |
| 29 | +env: |
| 30 | + GH_TOKEN: ${{ github.token }} |
| 31 | + |
| 32 | +jobs: |
| 33 | + check-issue: |
| 34 | + name: Check opencode#21960 and related PRs |
| 35 | + runs-on: ubuntu-latest |
| 36 | + permissions: |
| 37 | + contents: read |
| 38 | + issues: write |
| 39 | + steps: |
| 40 | + - name: Read current upstream state |
| 41 | + id: state |
| 42 | + run: | |
| 43 | + issue_state=$(gh issue view 21960 --repo anomalyco/opencode \ |
| 44 | + --json state --jq .state) |
| 45 | + echo "issue_state=$issue_state" >> "$GITHUB_OUTPUT" |
| 46 | +
|
| 47 | + # Known related PRs proposing a maxAttempts/retry-cap config, as |
| 48 | + # of the last check. A new PR merging OR any of these merging is |
| 49 | + # the real "fixed" signal — the issue closing alone isn't |
| 50 | + # trustworthy (a near-identical earlier issue, #25733, auto-closed |
| 51 | + # as stale without ever being fixed). |
| 52 | + merged_any="false" |
| 53 | + for pr in 25805 26676 38958; do |
| 54 | + merged_at=$(gh pr view "$pr" --repo anomalyco/opencode \ |
| 55 | + --json mergedAt --jq .mergedAt 2>/dev/null || echo "null") |
| 56 | + if [ "$merged_at" != "null" ] && [ -n "$merged_at" ]; then |
| 57 | + merged_any="true" |
| 58 | + echo "PR #$pr merged at $merged_at" |
| 59 | + fi |
| 60 | + done |
| 61 | + echo "merged_any=$merged_any" >> "$GITHUB_OUTPUT" |
| 62 | +
|
| 63 | + if [ "$issue_state" = "CLOSED" ] || [ "$merged_any" = "true" ]; then |
| 64 | + echo "resolved=true" >> "$GITHUB_OUTPUT" |
| 65 | + else |
| 66 | + echo "resolved=false" >> "$GITHUB_OUTPUT" |
| 67 | + fi |
| 68 | +
|
| 69 | + - name: Check whether this resolution was already reported |
| 70 | + id: dedupe |
| 71 | + if: steps.state.outputs.resolved == 'true' |
| 72 | + run: | |
| 73 | + title="opencode retry-cap bug (anomalyco/opencode#21960) resolved" |
| 74 | + count=$(gh issue list \ |
| 75 | + --repo "$GITHUB_REPOSITORY" \ |
| 76 | + --state all \ |
| 77 | + --search "${title} in:title" \ |
| 78 | + --limit 100 \ |
| 79 | + --json title \ |
| 80 | + --jq "[.[] | select(.title == \"$title\")] | length") |
| 81 | +
|
| 82 | + if [ "$count" -eq 0 ]; then |
| 83 | + echo "new_resolution=true" >> "$GITHUB_OUTPUT" |
| 84 | + else |
| 85 | + echo "new_resolution=false" >> "$GITHUB_OUTPUT" |
| 86 | + echo "Resolution was already reported: $title" |
| 87 | + fi |
| 88 | +
|
| 89 | + - name: Notify via Hermes Telegram topic |
| 90 | + if: steps.dedupe.outputs.new_resolution == 'true' |
| 91 | + env: |
| 92 | + TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} |
| 93 | + ISSUE_STATE: ${{ steps.state.outputs.issue_state }} |
| 94 | + MERGED_ANY: ${{ steps.state.outputs.merged_any }} |
| 95 | + run: | |
| 96 | + run_url="https://github.com/${GITHUB_REPOSITORY}/actions/runs/" |
| 97 | + run_url="${run_url}${GITHUB_RUN_ID}" |
| 98 | + issue_url="https://github.com/anomalyco/opencode/issues/21960" |
| 99 | + printf -v text '%s\n%s\n%s\n%s / %s\n%s' \ |
| 100 | + "🔧 opencode retry-cap bug may be resolved" \ |
| 101 | + "issue state: ${ISSUE_STATE}, fix PR merged: ${MERGED_ANY}" \ |
| 102 | + "$issue_url" "$GITHUB_REPOSITORY" "$GITHUB_WORKFLOW" "$run_url" |
| 103 | + response=$(mktemp) |
| 104 | + telegram_url="https://api.telegram.org/bot" |
| 105 | + telegram_url="${telegram_url}${TELEGRAM_BOT_TOKEN}/sendMessage" |
| 106 | +
|
| 107 | + curl --fail-with-body --silent --show-error \ |
| 108 | + -X POST "$telegram_url" \ |
| 109 | + -d chat_id=838808636 \ |
| 110 | + -d message_thread_id=22082 \ |
| 111 | + --data-urlencode "text=${text}" \ |
| 112 | + --output "$response" |
| 113 | +
|
| 114 | + jq_filter='if .ok == true then true else error(.description) end' |
| 115 | + jq -e "$jq_filter" "$response" >/dev/null |
| 116 | + echo "Telegram accepted the notification." |
| 117 | +
|
| 118 | + - name: Record resolution as a GitHub issue |
| 119 | + if: steps.dedupe.outputs.new_resolution == 'true' |
| 120 | + env: |
| 121 | + ISSUE_STATE: ${{ steps.state.outputs.issue_state }} |
| 122 | + MERGED_ANY: ${{ steps.state.outputs.merged_any }} |
| 123 | + run: | |
| 124 | + title="opencode retry-cap bug (anomalyco/opencode#21960) resolved" |
| 125 | + body=$(cat <<EOF |
| 126 | + Upstream state changed: issue state is now ${ISSUE_STATE}, a |
| 127 | + known related fix PR merged: ${MERGED_ANY}. |
| 128 | +
|
| 129 | + - Issue: https://github.com/anomalyco/opencode/issues/21960 |
| 130 | + - We confirmed this bug live 2026-08-02 (opencode-go quota |
| 131 | + exhaustion triggers an uncapped retry loop, hanging \`opencode |
| 132 | + run\` indefinitely) and posted a confirming comment: |
| 133 | + https://github.com/anomalyco/opencode/issues/21960#issuecomment-5158778654 |
| 134 | + - Detection run: |
| 135 | + https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID} |
| 136 | +
|
| 137 | + Re-verify the fix actually shipped in a released opencode version |
| 138 | + (not just merged to a dev branch) before re-enabling the |
| 139 | + opencode-go entry in ~/.config/ralph-tui/config.toml — see that |
| 140 | + file's own comment for the exact re-enable conditions. This issue |
| 141 | + also prevents duplicate Telegram notifications for this |
| 142 | + resolution. |
| 143 | + EOF |
| 144 | + ) |
| 145 | + gh issue create \ |
| 146 | + --repo "$GITHUB_REPOSITORY" \ |
| 147 | + --title "$title" \ |
| 148 | + --body "$body" |
| 149 | +
|
| 150 | + test-notification: |
| 151 | + name: Test Telegram delivery |
| 152 | + if: >- |
| 153 | + github.event_name == 'workflow_dispatch' && |
| 154 | + inputs.send_test_notification == true |
| 155 | + runs-on: ubuntu-latest |
| 156 | + permissions: |
| 157 | + contents: read |
| 158 | + steps: |
| 159 | + - name: Send test notification to Hermes Telegram topic |
| 160 | + env: |
| 161 | + TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} |
| 162 | + run: | |
| 163 | + run_url="https://github.com/${GITHUB_REPOSITORY}/actions/runs/" |
| 164 | + run_url="${run_url}${GITHUB_RUN_ID}" |
| 165 | + printf -v text '✅ opencode retry-cap bug monitor test\n%s / %s\n%s' \ |
| 166 | + "$GITHUB_REPOSITORY" "$GITHUB_WORKFLOW" "$run_url" |
| 167 | + response=$(mktemp) |
| 168 | + telegram_url="https://api.telegram.org/bot" |
| 169 | + telegram_url="${telegram_url}${TELEGRAM_BOT_TOKEN}/sendMessage" |
| 170 | +
|
| 171 | + curl --fail-with-body --silent --show-error \ |
| 172 | + -X POST "$telegram_url" \ |
| 173 | + -d chat_id=838808636 \ |
| 174 | + -d message_thread_id=22082 \ |
| 175 | + --data-urlencode "text=${text}" \ |
| 176 | + --output "$response" |
| 177 | +
|
| 178 | + jq_filter='if .ok == true then true else error(.description) end' |
| 179 | + jq -e "$jq_filter" "$response" >/dev/null |
| 180 | + echo "Telegram accepted the test notification." |
0 commit comments