Repository navigation
fix(discord): mark a reply part that could not be delivered - #19031
Conversation
A long Discord reply is split across messages. Each length rotation seals one part and drops its text, but both rotation sites in DiscordRenderer ignored _seal_current's result. A part whose every send and edit failed was gone, the later parts still went out, and nothing told the reader. delivery_failed stays False in that case, because it means that nothing of the reply landed. The rotation now seals through _seal_rotated_part. When a part was attempted and did not land, it logs a warning and sends "Part of this reply could not be delivered." in its place, then the later parts continue. A part with nothing to send and a part whose fallback send landed get no notice. The notice is not counted as a delivery, so delivery_failed keeps its documented meaning.
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Check one thing: What this change shipsInventory (5 items) — 5 justifiedIntent: when one part of a long Discord reply fails to send, the reader is told the reply has a gap, and the later parts still arrive. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 6aaabb3 Description read[DESCRIPTION-READ] 11991ade09f729331df52e11998733a2e18941940cf2d801fe83e115ad6bda50 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Not run against a live Discord bot. Check that an AutoMod-blocked part comes back as a failed send ( [DESIGN-REVIEWED] 6aaabb3 Description read[DESCRIPTION-READ] a0760049e384997c378ba71eee2c0767e0e3ae5189c17eb9a58fabe8359256db That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
iamwhatever
left a comment
There was a problem hiding this comment.
Both length-rotation loops in DiscordRenderer._rotate_on_length used to ignore _seal_current's result. A part whose sends and edits all failed vanished, and the parts around the gap read as one continuous answer. The new _seal_rotated_part (discord/renderer.py) reads that result and sends a fixed LOST_PART_NOTICE in the part's place, which fixes the root cause. I read _seal_current and _land_sealed at head 6aaabb3 to check the edge cases. A part with nothing to send returns False without incrementing _seals_attempted, so it gets no notice. A failed edit whose fallback send lands returns True, so it gets none either. A split part where only some chunks landed returns False and gets the notice, which the "may not have been" wording covers. The notice is a fixed literal, so it cannot rebuild a credential across the seam. It is recorded as the next part's predecessor and consumes a held reasoning note, consistent with every other send. A failed notice send is caught and logged. delivery_failed keeps its meaning, because the notice does not count as a landed seal. The new test is red on main and green here. It has controls for the all-landed and fallback-landed cases, and the credential-boundary inventory names the new send. All lanes PASS, checks are green, and no change request is open. — crew-pr-reviewer (deep re-check)
Problem / Motivation
Goal: when one part of a long Discord reply cannot be delivered, the reader is told, and the later parts still arrive.
DiscordRenderersplits a reply that outgrows Discord's message limit into several messages. Each length rotation seals one part with_seal_current(extract_uploads=False), drops that part's text, and opens the next message. Both rotation sites ignored the seal's result: the presentation branch (src/kiro_crew/discord/renderer.py, thefor chunk in chunks[:-1]loop) and the source branch (thefor ch in sealedloop). A part whose every send and edit failed was gone, the later parts went out below the part before it, and the reader read the two sides of the gap as one continuous answer.delivery_failedstayedFalse, because by its docstring it means that nothing of the reply landed.Why it matters
A reply can lose a middle paragraph, a list item or a code block with no sign that anything is missing. Discord can refuse one part while accepting the others, for example when an AutoMod rule blocks a word that only that part contains.
Not a goal
_render_fallbackinsrc/kiro_crew/slack/renderer.py) are skipped on failure as a documented best-effort, and are left alone here._land_sealed, and this change does not touch it.delivery_failedkeeps its meaning. A turn where some parts landed is still delivered, and the notice does not count as a delivery.What changed
DiscordRendererdiscarded_seal_current's return value. It now seals through the new_seal_rotated_part, which reads that value._seal_rotated_partlogs a warning and sendsLOST_PART_NOTICE, "Part of this reply may not have been delivered.", in the part's place, then the later parts continue._seals_attempteddoes not move), so it gets no notice. A part whose edit failed and whose fallback send landed is delivered (_seal_currentreturnsTrue), so it gets none either._record_sent), like every other send, and it consumes a held reasoning note (_pending_note_tail), as a fresh send does in_land_sealed.test/test_discord_lost_part_notice.py, three tests that drive the realDiscordRendererthroughtest_discord.FakeClient. The one seam is a refusal for any send or edit carrying a marker.test/test_split_credential_boundary.pylists every standalone send in the renderer, and the notice is added there as a fixed literal.Backwards compatibility
Compatible: a reply whose parts all land is unchanged, message for message.
Removes nothing: no setting, field or event is removed.
Reader: a part that cannot be delivered now shows "Part of this reply may not have been delivered." where it would have been.
Tests
Red on
origin/maind8185f1 (a throwaway detached worktree with only the new test file copied in),pytest test/test_discord_lost_part_notice.py -p no:cacheprovider -q -n 0, RC=1 in 3 of 3 runs:Green on the branch, rebased onto d8185f1, the same command, RC=0 in 3 of 3 runs:
The two controls pass on both sides: a reply whose parts all land shows A, B and C with no notice, and a part whose edits fail but whose fresh send lands shows B with no notice. Discord renderer neighbours, 24 files run serially (
test_discord.py,test_discord_empty_turn.py,test_discord_outbound_files.py,test_discord_render_config.py,test_discord_sessions.py,test_discord_approval_press_race_13539.py,test_channel_turns.py,test_channel_control_tag_strip.py,test_channel_table_rendering.py,test_split_credential_boundary.pyand the others that name the renderer): 3167 passed, 5 skipped, exit 0, including the existingdelivery_failedtests. mypy, flake8, isort, black,scripts/check_black_formatting.py,scripts/check_harness_parity.py,scripts/docs-lint.shand the comment-history check withCOMMENT_HISTORY_BASE_REF=origin/mainexit 0.Manual verification
Not run against a live Discord bot.
Related Issues
#19028 fixes the same gap in the Telegram renderer. It edits no file this change edits, and the two merge cleanly.
Open PRs that edit
src/kiro_crew/discord/renderer.py, each checked withgit merge-treeagainst this branch:test/test_split_credential_boundary.pymerge cleanly. Its conflicts are in other files.__call__, not in the rotation, so this change neither causes nor touches the conflict.Pattern harvest
Rule candidate: a loop that drops text after handing it to a send reads the send's result.
Checklist