Skip to content

fix(weixin): avoid double-splitting when delivering messages - #8069

Closed
xiaobitaozi wants to merge 1 commit into
NousResearch:mainfrom
xiaobitaozi:fix-weixin-split
Closed

fix(weixin): avoid double-splitting when delivering messages#8069
xiaobitaozi wants to merge 1 commit into
NousResearch:mainfrom
xiaobitaozi:fix-weixin-split

Conversation

@xiaobitaozi

@xiaobitaozi xiaobitaozi commented Apr 12, 2026

Copy link
Copy Markdown
  • Add send_chunks() to BasePlatformAdapter as a hook for platforms

    • WeixinAdapter.send_chunks() bypasses internal _split_text to prevent double-splitting
    • StreamConsumer uses send_chunks() for pre-chunked content instead of send()
    • Fixes Weixin messages arriving as multiple fragments

    What does this PR do?

    WeixinAdapter internally calls _split_text to split messages, but StreamConsumer already does streaming
    chunking. Both layers split independently, causing a single message to arrive as multiple fragments to users.

    The fix adds a send_chunks() hook to BasePlatformAdapter. StreamConsumer now passes pre-chunked content
    directly through this hook, bypassing _split_text in WeixinAdapter to eliminate the double-splitting issue.

    Related Issue

    Fixes #

    Type of Change

    • 🐛 Bug fix (non-breaking change that fixes an issue)
    • ✨ New feature (non-breaking change that adds functionality)
    • 🔒 Security fix
    • 📝 Documentation update
    • ✅ Tests (adding or improving test coverage)
    • ♻️ Refactor (no behavior change)
    • 🎯 New skill (bundled or hub)

    Changes Made

    • gateway/platforms/base.py: Add send_chunks() hook to BasePlatformAdapter
    • gateway/platforms/weixin.py: Implement send_chunks() to bypass _split_text
    • gateway/delivery.py: StreamConsumer uses send_chunks() for pre-chunked content

    How to Test

    1. Connect Weixin platform with streaming enabled
    2. Send a long message that would normally be split
    3. Verify message arrives as a single complete message, not multiple fragments

    Checklist

    Code

    • I've read the Contributing Guide
    • My commit messages follow Conventional Commits (fix(scope):,
      feat(scope):, etc.)
    • I searched for existing PRs to make sure this isn't a
      duplicate
    • My PR contains only changes related to this fix/feature (no unrelated commits)
    • I've run pytest tests/ -q and all tests pass
    • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
    • I've tested on my platform:

    Documentation & Housekeeping

    • I've updated relevant documentation (README, docs/, docstrings) — or N/A
    • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
    • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
    • I've considered cross-platform impact (Windows, macOS) per the compatibility
      guide
      — or
      N/A
    • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

    For New Skills

    • This skill is broadly useful to most users (if bundled) — see Contributing
      Guide
    • SKILL.md follows the standard
      format
      (frontmatter,
      trigger conditions, steps, pitfalls)
    • No external dependencies that aren't already available (prefer stdlib, curl, existing Hermes tools)
    • I've tested the skill end-to-end: hermes --toolsets skills -q "Use the X skill to do Y"

    Screenshots / Logs

- Add send_chunks() to BasePlatformAdapter as a hook for platforms
- WeixinAdapter.send_chunks() bypasses internal _split_text to prevent double-splitting
- StreamConsumer uses send_chunks() for pre-chunked content instead of send()
- Fixes Weixin messages arriving as multiple fragments
@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #8665 which synthesizes the best fixes from ~25 community PRs into a single consolidated change. Your contribution (double-splitting prevention) was reviewed and informed the final implementation. Thank you @xiaobitaozi for your work on this!

@teknium1 teknium1 closed this Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants