fix(slack-bot): ensure PR/MR URLs surface in Slack replies#1711
Open
kilo-code-bot[bot] wants to merge 1 commit intomainfrom
Open
fix(slack-bot): ensure PR/MR URLs surface in Slack replies#1711kilo-code-bot[bot] wants to merge 1 commit intomainfrom
kilo-code-bot[bot] wants to merge 1 commit intomainfrom
Conversation
Three root causes prevented PR/MR URLs from reaching users: 1. Legacy bot did not append 'return the PR URL' instruction to the cloud agent prompt (System 2 already did this). 2. Neither bot system prompt nor tool description explicitly told the outer LLM to extract and relay the PR/MR URL from tool results. 3. Legacy webhook put the entire response in a single Slack section block, which silently truncates at 3000 chars — often cutting off the URL at the end. Fixes: - Append PR/MR URL instruction to legacy cloud agent prompt (code mode) - Add 'Sharing results' section to both system prompts - Add PR URL relay instruction to legacy tool description - Split long responses into multiple section blocks to stay within Slack's 3000-char section limit
| type: 'section', | ||
| text: { type: 'mrkdwn', text: remaining.slice(0, splitAt) }, | ||
| }); | ||
| remaining = remaining.slice(splitAt + 1); |
Contributor
Author
There was a problem hiding this comment.
WARNING: Hard-split path drops one character
When no newline exists within the limit, splitAt is set to charLimit, but this line still advances by + 1. That skips the character at the split boundary, so long single-line responses lose one character per block and can still break PR/MR URLs or code blocks.
Suggested change
| remaining = remaining.slice(splitAt + 1); | |
| remaining = remaining.slice(remaining[splitAt] === '\n' ? splitAt + 1 : splitAt); |
Contributor
Author
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Other Observations (not in diff)N/A Files Reviewed (3 files)
Reviewed by gpt-5.4-20260305 · 222,130 tokens |
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.
Summary
Users reported that PR/MR URLs created by the cloud agent never appear in Slack bot replies. Investigation found three independent root causes:
src/lib/slack-bot.ts) did not append "Open a pull request and return the PR URL" to the cloud agent prompt forcodemode sessions. The System 2 bot (Pound) already did this atsrc/lib/bot/tools/spawn-cloud-agent-session.ts:87-93, but the legacy bot only appended the PR signature — not the URL return instruction.src/app/slack/webhook/route.ts:219-232) placed the entire formatted response in a singlesectionblock. Slack's API silently truncatessection.textat 3000 characters. Cloud agent responses often exceed this, with the PR URL appearing near the end — exactly where it gets cut off.Fixes applied:
codemode (matching System 2 behavior)Verification
pnpm typecheck— passedpnpm format:check— passed (via pre-push hook)Visual Changes
N/A
Reviewer Notes
src/lib/bot/run.ts) was already better instrumented than the legacy bot — its tool description at line 152 already said "check the result for a PR/MR URL and share it with the user." The system prompt section added here reinforces this at a different layer.toSectionBlocksfunction in the webhook route splits on newline boundaries to avoid breaking URLs mid-character. Falls back to hard-split if no newline is found within the limit.sectionblock limit is a known Slack API constraint. Thetextfield outsideblocksis preserved as-is (40k char limit) and serves as fallback for clients that don't render blocks.