Skip to content

fix(feishu): keep msg_type=post consistent across chunks of long markdown replies - #68122

Merged
teknium1 merged 1 commit into
mainfrom
fix/feishu-chunk-msgtype
Jul 20, 2026
Merged

fix(feishu): keep msg_type=post consistent across chunks of long markdown replies#68122
teknium1 merged 1 commit into
mainfrom
fix/feishu-chunk-msgtype

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Every chunk of a long Feishu markdown reply now goes out with a consistent msg_type — the markdown/post decision is made once for the whole message instead of per chunk.

Root cause (#26841, #29471): send() splits replies at MAX_MESSAGE_LENGTH (8000 chars) and classified each chunk independently. Chunk 1 of a long markdown reply is often plain prose, so it went out as msg_type=text (raw **bold** / ## heading markers) while later chunks rendered as post.

Salvage of PR #26848 (@xxxigm) — transplanted onto the current plugin adapter path (plugins/platforms/feishu/adapter.py; the original targeted the since-removed gateway/platforms/feishu.py), exactly as the sweeper review on that PR recommended.

Stacked on #68121 (table→post fix). One deliberate divergence from the original PR: its per-chunk table exemption (tables stay text even under prefer_post) is dropped, because with #68121 tables route through post and the exemption would reintroduce the raw-table downgrade.

Changes

  • plugins/platforms/feishu/adapter.py: send() computes prefer_post = bool(_MARKDOWN_HINT_RE.search(formatted)) once before chunking; _build_outbound_payload() gains a keyword-only prefer_post flag
  • tests/gateway/test_feishu.py: 2 regression tests — multi-chunk markdown sends every chunk as post (was ["text", "post"]); plain-text messages are not upgraded by prefer_post

Validation

Scenario Before After
Long markdown reply, prose-only chunk 1 chunk 1 text, chunk 2 post both post
Plain-text message text text (unchanged)
  • scripts/run_tests.sh tests/gateway/test_feishu.py tests/gateway/test_feishu_table_markdown.py → 217 passed, 0 failed

Resolves #26841 and #29471.

Infographic

feishu-chunk-consistency

Base automatically changed from fix/feishu-table-post to main July 20, 2026 16:19
…ng markdown reply (#26841)

Transplant of PR #26848 onto the plugin adapter path
(plugins/platforms/feishu/adapter.py — the original PR targeted the
since-removed gateway/platforms/feishu.py).

``send`` classifies each chunk independently, so chunk 1 of a long
markdown reply (often plain prose) went out as msg_type=text while
later chunks rendered as post — literal **bold**/## heading markers
in the Feishu client. Lock the decision at the whole-message level:
compute prefer_post once from the full formatted message and pass it
to _build_outbound_payload per chunk.

The original PR's per-chunk table exemption is intentionally dropped:
tables now route through post/md (issue #52786 cluster fix), so the
exemption would reintroduce the raw-table downgrade.

Co-authored-by: Hermes Agent <hermes@nousresearch.com>
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.

[Feishu] First chunk of long messages sent as msg_type=text instead of post, breaking Markdown rendering

2 participants