Replace degenerate agent output with a notice in Slack - #1691
Draft
knechtionscoding wants to merge 1 commit into
Draft
Replace degenerate agent output with a notice in Slack#1691knechtionscoding wants to merge 1 commit into
knechtionscoding wants to merge 1 commit into
Conversation
When capture flags a run's final message as degenerate, Slack now renders a short notice in place of the unusable fragments rather than pasting them into the thread. The PR link, the task context block, and the error line on the failed phase are all preserved, and the raw response is left untouched in the Task's results. The substitution happens before both the response blocks and the fallback text are built, so the fragments stay out of notifications and accessibility surfaces as well. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
knechtionscoding
requested a deployment
to
ok-to-test
August 25, 2026 17:20 — with
GitHub Actions
Waiting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
/kind bug
What this PR does / why we need it:
When an agent's final message is unusable, Kelos currently pastes it into the
Slack thread verbatim. On 2026-08-21 that put this into a live customer-issue
thread:
FormatSlackTransitionMessagenow reads thedegeneratemarker thatkelos-capturesets in the Task's results and renders a short notice in placeof the response:
The notice is phase-aware — the
failedphase says the run was attempted twice(
backoffLimitis 1, so a Failed Task has exhausted both attempts); otherphases get the shorter form without the count claim.
Everything else in the message is left alone: the PR link block still renders
(the agent may well have opened a real PR before its final message degenerated,
and that link is the most useful thing in the reply), the task-name context
block still renders, and the
:warning: *Error:*line still renders on thefailedphase.The substitution happens on the decoded response before both
responseToBlocksand
buildFallbackTextrun, so the fragments stay out of the messageTexttoo— otherwise they would still ship in notifications and accessibility surfaces
even with the blocks replaced.
The raw
responsekey is left untouched intask.Status.Results. It is theonly evidence available for calibrating the detection thresholds, and nothing
here clears it.
Which issue(s) this PR is related to:
N/A
Special notes for your reviewer:
Depends on
fix/detect-degenerate-claude-output, which introduces thedegenerateresult key. Until that lands this branch is inert: with the markerunset, every existing code path is unchanged. Two of the new tests assert
exactly that (marker absent, and marker present but not
"true").Deliberately narrow:
TaskReporter(GitHub comments and check runs) is a differentsurface with different readers and is untouched.
FormatProgressMessagerenders in-flightsnapshots from pod logs, not the final result, and has no results map.
backoffLimitstays at 1.reportingpackage does not havenum_turnsanyway, and a second copy of thepredicate would drift from the first.
New tests in
internal/reporting/slack_test.gouse the real 2026-08-21 garbledoutput as the fixture and assert the fragments appear in neither the rendered
blocks nor the fallback text: substitution on
succeeded, PR link survival,notice plus error line together on
failed, a degenerate attempt that producedno response at all, a long garbled response staying a single message (the
multi-message split path is not entered and the block count stays far under
SlackBlockLimit), and the two no-op cases above.make testandmake verifyboth pass.Does this PR introduce a user-facing change?