Skip to content

fix(discord): honor configured line limits in durable sends - #137969

Merged
Patrick-Erichsen merged 1 commit into
openclaw:mainfrom
anyech:fix/91860-current-main
Sep 11, 2026
Merged

Patrick-Erichsen merged 1 commit into
openclaw:mainfrom
anyech:fix/91860-current-main

Conversation

@anyech

@anyech anyech commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Closes #91860
Related: #120249

What Problem This Solves

Durable Discord replies were split at the adapter's implicit 17-line limit before the selected account's configuration reached the sender. Bound-thread webhook sends also need to preserve the default, configured, and explicit line-limit behavior when planning defers that decision.

Why This Change Was Made

Keep line-limit resolution with the Discord senders. The adapter defers only an implicit limit; explicit per-send formatting still takes precedence. The webhook sender reuses its already-resolved account instead of introducing another configuration resolver. Calls that omit chunk options retain their existing character-only chunking contract.

Reuse the existing reply-reference helpers across physical webhook chunks: implicit first-mode replies attach once, while explicit replies and all-mode retain their existing scope. Preserve already-accepted partial deliveries.

Production changes are limited to two Discord files (+26/-6, net +20 lines). The shared chunker/SDK and configuration schema are unchanged. Existing text preparation, character caps, retry behavior, and timeout ownership are preserved.

User Impact

Bot and bound-thread webhook delivery honor default, root, selected-account, and per-send limits. No configured override still means 17 lines. Structured fallback text receives the same account-aware handling; thread and persona behavior remain intact.

Evidence

  • Candidate: 0ab3bcd238d2df022afb25a574e9cd5ddb5965b3
  • Frozen main used for the repair and negative control: 0d25c9b48f68f0bf2a69002184281a6427be69dd
  • A fresh merge check against 1029e3870f23315812565cc02d0504a208173697 was clean.
  • Restoring the two production files to the frozen main made five new durable HTTP-boundary regressions fail. Restoring the repair passed 132 tests across seven Discord suites.
  • All changed-file validation passed, including extension/extension-test typechecks, lint, dead-export scans, dependency guards, and runtime import-cycle checks. The committed source was verified byte-identical to that tested candidate.
  • Independent P0–P2 review found no actionable issue.
  • pnpm build passed on the exact committed candidate; package build metadata matched its SHA.

Real behavior proof

Behavior addressed: Premature durable-reply splitting and loss of the webhook default/configured line-limit owner.

Real setup tested: The exact freshly built candidate ran as three isolated ephemeral Gateways using a mock OpenAI-compatible provider and a loopback Discord REST endpoint. This exercises Gateway final delivery through the packaged Discord adapter and bot/webhook senders to actual HTTP POSTs. Dependencies are deliberately mocked; this is not a live Discord test.

Exact steps or command run after this patch: After pnpm build, ran a temporary QA harness with OPENCLAW_E2E_SKIP_BUILD=1 node scripts/run-vitest.mjs test/e2e/qa-lab/plugins/discord-durable-line-limit.mock-gateway.e2e.test.ts. Each scenario submitted an exact 20-line final reply through the Gateway agent API, waited for terminal delivery, and inspected HTTP bodies. The harness was archived and removed from the checkout afterward; it is not a shipped test in this PR.

  1. Bot: root limit 10, selected-account limit 50.
  2. Bound-thread webhook: no root or account override.
  3. Bound-thread webhook: root limit 5, selected-account limit 50.

Evidence after fix:

{
  "verdict": "PASS",
  "candidateHead": "0ab3bcd238d2df022afb25a574e9cd5ddb5965b3",
  "inputLineCount": 20,
  "scenarios": [
    {
      "scenario": "bot-account",
      "observedLineCounts": [
        20
      ],
      "payloadPreservedExactly": true,
      "terminalDelivery": {
        "status": "sent",
        "resultCount": 1
      }
    },
    {
      "scenario": "webhook-default",
      "observedLineCounts": [
        17,
        3
      ],
      "payloadPreservedExactly": true,
      "terminalDelivery": {
        "status": "sent",
        "resultCount": 1
      }
    },
    {
      "scenario": "webhook-account",
      "observedLineCounts": [
        20
      ],
      "payloadPreservedExactly": true,
      "terminalDelivery": {
        "status": "sent",
        "resultCount": 1
      }
    }
  ]
}

Observed result after fix: The three scenarios produced [20], [17, 3], and [20] lines respectively. All preserved the exact text and reported terminal delivery sent. Both webhook scenarios verified the thread query and configured persona. Loaded adapter/sender hashes were unchanged before and after the runs, and all test listeners were stopped.

What was not tested: No production Gateway, real credentials, or live Discord account was used. Media, forum creation, and actual Discord-service acceptance were not tested. Physical reply-reference scope, explicit formatting, code fences, and failure/retry cases are covered by focused regression tests rather than these three packaged-Gateway scenarios.

Reproducible regression coverage

node scripts/run-vitest.mjs run extensions/discord/src/durable-line-limit.test.ts extensions/discord/src/durable-delivery.test.ts extensions/discord/src/outbound-adapter.test.ts extensions/discord/src/send.webhook.chunk-limit.test.ts extensions/discord/src/send.webhook.proxy.test.ts extensions/discord/src/send.webhook.timeout.test.ts extensions/discord/src/monitor/reply-delivery.test.ts

Result: 132 tests across seven files passed. Coverage includes default/root/account/explicit limits, structured fallback text, first/all reply scope, fenced text and the 2000-character cap, already-planned webhook callers, retries/timeouts, and partial outcomes.

Relationship to #120249

The open alternative addresses the same report by expanding shared chunker context. This PR keeps the repair within Discord's senders without expanding the SDK. It updates the existing contribution rather than opening another competing PR.

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord size: S labels Sep 4, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 10, 2026, 8:16 PM ET / September 11, 2026, 00:16 UTC (Revision 8).

ClawSweeper review

What this changes

Discord durable sends defer implicit line limits to the account-aware senders while preserving explicit overrides, legacy webhook calls, and reply-reference scope.

Merge readiness

✅ Ready for maintainer review

This remains a useful, bounded repair: current main and the latest release retain the premature split. Earlier findings are addressed, compatibility is explicitly discussed, and the supplied packaged-Gateway proof supports the changed behavior.

Priority: P2
Reviewed head: 0ab3bcd238d2df022afb25a574e9cd5ddb5965b3

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused owner-boundary repair with explicit compatibility analysis, meaningful negative controls, and packaged-Gateway behavior proof.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied exact-candidate packaged-Gateway runs exercise the changed Discord adapter and bot/webhook senders through actual HTTP POSTs, demonstrating the expected [20], [17,3], and [20] splits with preserved text and sent outcomes. This satisfies the repository’s channel boundary-proof policy; live Discord acceptance and native webhook reply display were not demonstrated.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The supplied exact-candidate packaged-Gateway runs exercise the changed Discord adapter and bot/webhook senders through actual HTTP POSTs, demonstrating the expected [20], [17,3], and [20] splits with preserved text and sent outcomes. This satisfies the repository’s channel boundary-proof policy; live Discord acceptance and native webhook reply display were not demonstrated.
Evidence reviewed 8 items Verified introduced repair: The pinned merge-base-to-head production diff defers only implicit adapter line limits and adds opt-in webhook limit resolution using the already-resolved account.
Current-main necessity: Fetched main still passes an absent formatting limit into the adapter chunker, whose default is 17; the downstream bot sender already resolves explicit versus selected-account limits.
Latest-release check: The latest supplied release also retains the configuration-blind adapter prechunking; this repair is not already shipped there.
Findings None None.
Security None None.

How this fits together

OpenClaw’s outbound planner passes replies to the Discord plugin, which turns them into bot or bound-thread webhook messages. Line-limit resolution determines how that text becomes physical Discord messages.

flowchart TD
 A[Reply text and formatting] --> B[Outbound planner]
 B --> C[Discord adapter]
 C --> D[Bot sender]
 C --> E[Bound-thread webhook sender]
 F[Selected account settings] --> D
 F --> E
 D --> G[Bounded Discord messages]
 E --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +20, Tests +277. Total +297 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 26 6 +20
Tests 3 281 4 +277
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 307 10 +297

Review metrics

Metric Value Why it matters
Compatibility surface 1 optional webhook chunking field; existing string reply input retained Durable callers opt into account-aware limits without changing omitted-option behavior for existing callers.
Production versus test growth Production +20 net lines; tests +277 net lines The stated production growth preserves legacy webhook semantics and physical reply scope, with boundary regressions carrying most of the added code.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #91860
Summary: This PR is a candidate repair for the canonical durable-send report; another unmerged implementation targets the same defect.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep account-aware line-limit resolution in Discord’s senders, with explicit formatting taking precedence and legacy webhook omission semantics preserved.

Do we have a high-confidence way to reproduce the issue?

Yes. Current source shows that a short 20-line durable send with an account limit of 50 is split by the adapter’s implicit 17-line default before reaching the account-aware sender; supplied baseline HTTP traces corroborate this.

Is this the best way to solve the issue?

Yes. Deferring implicit limits to the existing Discord senders repairs the owning boundary without expanding generic chunker context, while the optional webhook argument preserves existing callers.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 46f1b8d5cce5.

Labels

Label justifications:

  • P2: This repairs unwanted Discord message splitting under an existing configuration option with limited blast radius.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The supplied exact-candidate packaged-Gateway runs exercise the changed Discord adapter and bot/webhook senders through actual HTTP POSTs, demonstrating the expected [20], [17,3], and [20] splits with preserved text and sent outcomes. This satisfies the repository’s channel boundary-proof policy; live Discord acceptance and native webhook reply display were not demonstrated.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied exact-candidate packaged-Gateway runs exercise the changed Discord adapter and bot/webhook senders through actual HTTP POSTs, demonstrating the expected [20], [17,3], and [20] splits with preserved text and sent outcomes. This satisfies the repository’s channel boundary-proof policy; live Discord acceptance and native webhook reply display were not demonstrated.

Evidence

What I checked:

  • Verified introduced repair: The pinned merge-base-to-head production diff defers only implicit adapter line limits and adds opt-in webhook limit resolution using the already-resolved account. (extensions/discord/src/outbound-adapter.ts:133, 0ab3bcd238d2)
  • Current-main necessity: Fetched main still passes an absent formatting limit into the adapter chunker, whose default is 17; the downstream bot sender already resolves explicit versus selected-account limits. (extensions/discord/src/outbound-adapter.ts:130, 46f1b8d5cce5)
  • Latest-release check: The latest supplied release also retains the configuration-blind adapter prechunking; this repair is not already shipped there. (extensions/discord/src/outbound-adapter.ts:130, 1391f7cd2d40)
  • Compatibility and prior-review disposition: The webhook sender preserves character-only chunking when chunking options are omitted and preserves reusable string reply references. The supplied discussion explicitly evaluates this additive contract and accepts the bounded repair: fix(discord): honor configured line limits in durable sends #137969 (comment) . Current coverage addresses both earlier findings: structured fallback account limits and bound-thread webhook limits. (extensions/discord/src/send.webhook.ts:156, 0ab3bcd238d2)
  • Packaged production-boundary proof: The complete supplied PR body records three isolated Gateways running the built candidate through the packaged adapter and actual HTTP POSTs to a loopback Discord endpoint. Twenty input lines produced bot/account [20], webhook/default [17,3], and webhook/account [20], with exact text, thread/persona fields, and terminal sent outcomes preserved. The provider and Discord service were simulated; this is boundary proof, not authenticated Discord proof. Root policy expressly accepts isolated mock-Gateway proof for channel changes. (0ab3bcd238d2)
  • Regression evidence: Read the new durable HTTP-boundary suite and webhook compatibility coverage. The supplied validation comment reports five intended failures when only the production files were restored to baseline, 19 passing candidate cases, and 132 passing tests across seven suites. No tests or contributor code were executed during this read-only review. (extensions/discord/src/durable-line-limit.test.ts:154, 0ab3bcd238d2)

Likely related people:

  • Patrick-Erichsen: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • rbutera: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (7 earlier review cycles)
  • reviewed 2026-09-04T06:17:52.435Z sha 9f517cb5b9a92839e156224c208164ba23599ce7 :: needs real behavior proof before merge. :: [P2] Propagate chunker context through structured payload fallbacks
  • reviewed 2026-09-04T10:02:33.248Z sha d97b25aaae12e410a74a9d5f8f3a15308ee04ad0 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-04T10:14:21.146Z sha d97b25aaae12e410a74a9d5f8f3a15308ee04ad0 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-05T04:54:28.005Z sha eace22a8f121cb11bd644be44ad162beb75800cb :: blocked before merge. :: [P2] Preserve line limits for bound-thread webhook sends
  • reviewed 2026-09-08T07:14:54.563Z sha 0ab3bcd :: blocked before merge. :: none
  • reviewed 2026-09-08T13:53:36.642Z sha 0ab3bcd :: blocked before merge. :: none
  • reviewed 2026-09-11T00:05:17.805Z sha 0ab3bcd :: needs maintainer review before merge. :: none

@anyech
anyech force-pushed the fix/91860-current-main branch from 9f517cb to d97b25a Compare September 4, 2026 09:50
@openclaw-barnacle openclaw-barnacle Bot added triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Sep 4, 2026
@anyech
anyech force-pushed the fix/91860-current-main branch from d97b25a to eace22a Compare September 5, 2026 04:46
@openclaw-barnacle openclaw-barnacle Bot removed the docs Improvements or additions to documentation label Sep 5, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 5, 2026
@anyech
anyech force-pushed the fix/91860-current-main branch from eace22a to 0ab3bcd Compare September 8, 2026 06:58
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 8, 2026
@roboclaw-bot roboclaw-bot added the clawtributor-review Clawtributor pull request awaiting prioritized maintainer review label Sep 8, 2026
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 8, 2026
@Patrick-Erichsen

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

Maintainer landing requested for this reviewed revision. Refreshing the older review while the native landing checks run.

@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@Patrick-Erichsen

Patrick-Erichsen commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Maintainer landing validation for 0ab3bcd238d2df022afb25a574e9cd5ddb5965b3: no blocking correctness or compatibility findings. Accepting the bounded additive webhook API repair under the maintainer's explicit landing request.

Existing replyTo strings and omitted chunking options keep their shipped behavior. The optional chunking field opts durable callers into explicit/account/default line-limit resolution at the existing Discord sender. Return type, shared SDK and configuration schema are unchanged. Explicit formatting still takes priority. Production +26/-6 (net +20); tests +281/-4 (net +277). This growth preserves the legacy contract and per-physical-chunk reply scope without moving account configuration into generic planning.

Fresh paired HTTP-boundary proof, changing only the two production files between frozen baseline 0d25c9b48f68f0bf2a69002184281a6427be69dd and the exact candidate:

Scenario, 20 lines Baseline physical chunks Candidate physical chunks
Structured fallback, account limit 50 17 + 3 20
Bot, root limit 10 10 + 7 + 3 10 + 10
Bot, account limit 50 17 + 3 20
Webhook, root limit 10 17 + 3 10 + 10
Webhook, account limit 50 17 + 3 20

Baseline: 5 failed, 14 passed, all intended split assertions. Restored candidate: 19 passed. Original source bytes and clean working tree verified after restoration. Broader focused run: 132 tests across seven files passed, including legacy webhook calls, default 17, explicit formatting, first/all references, code fences/character cap, partial receipts, retries and timeouts.

node scripts/run-vitest.mjs run extensions/discord/src/durable-line-limit.test.ts
node scripts/run-vitest.mjs run extensions/discord/src/durable-line-limit.test.ts extensions/discord/src/durable-delivery.test.ts extensions/discord/src/outbound-adapter.test.ts extensions/discord/src/send.webhook.chunk-limit.test.ts extensions/discord/src/send.webhook.proxy.test.ts extensions/discord/src/send.webhook.timeout.test.ts extensions/discord/src/monitor/reply-delivery.test.ts

Fresh autoreview: scoped-clean at default P0. Independent compatibility review inspected current main, stable v2026.9.2, legacy callers, bot/media/forum siblings, shared planning, SDK exports and Discord API contract. Main and stable retain the premature adapter split. Source-change evidence: direct commit 5e640b93dae6, April 25, author/committer @steipete, replaced chunker: null with the configuration-blind chunker; no associated PR inferred.

No unresolved non-outdated review threads. The latest ClawSweeper review has no Rank-up moves list; the required age-based refresh is requested. Exact-head hosted CI freshness rerun: https://github.com/openclaw/openclaw/actions/runs/34545340704 . Native prepare/merge will wait for green gates.

Real-behavior proof reuses the PR's exact-candidate packaged mock-Gateway runs: bot/account [20], webhook/default [17,3], webhook/account [20], exact text and terminal sent status preserved. This is not a fresh authenticated Discord test. Third-party consumer packages were not run. Existing webhook message_reference serialization is not proof of native Discord reply display; the official execute-webhook contract does not document that field. Follow-up: establish supported native webhook reply behavior. This preexisting limitation does not change the line-limit compatibility verdict.

CI recovery: the old rerun remained queued without jobs; closing/reopening the PR triggered this fresh run on the unchanged tested commit.

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 11, 2026
@Patrick-Erichsen
Patrick-Erichsen merged commit d6be581 into openclaw:main Sep 11, 2026
205 checks passed
@Patrick-Erichsen

Copy link
Copy Markdown
Contributor

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord clawtributor-review Clawtributor pull request awaiting prioritized maintainer review P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Discord message send ignores maxLinesPerMessage and splits CLI sends at 17 lines

3 participants