From eeee22601965088e84645766a44d222bd8ffa0f1 Mon Sep 17 00:00:00 2001 From: masami-agent Date: Thu, 16 Jul 2026 09:38:47 +0800 Subject: [PATCH] fix(teams): set message_limit to 20000 for standalone Teams gateway MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Scope narrowed to standalone gateway mode only (where platform isolation is guaranteed). Unified Mode stays at 4096 to protect LINE (5000 char limit) and other embedded platforms that share the same adapter. Changes: - Standalone GatewayAdapter: returns 20000 for platform "teams", 4096 otherwise - UnifiedGatewayAdapter: remains at 4096 (conservative, shared across platforms) - docs/platforms/schema/teams.toml: updated message_split entry with PR ref Why Unified Mode is not changed here: The UnifiedGatewayAdapter serves Teams, LINE, Telegram, Feishu, Google Chat, and WeCom through one shared message_limit(). LINE does not re-chunk at the adapter layer and has a 5000-char API limit — raising the shared limit would regress LINE delivery. A proper Unified Mode fix requires a channel-aware message_limit_for(&ChannelRef) API (tracked separately). The standalone gateway mode (used by Docker Compose / legacy deployments) is safe because each standalone gateway instance serves exactly one platform. Fixes #1409 (standalone mode only; Unified Mode tracked separately) --- crates/openab-core/src/gateway.rs | 5 ++++- docs/platforms/schema/teams.toml | 3 ++- src/unified_adapter.rs | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/crates/openab-core/src/gateway.rs b/crates/openab-core/src/gateway.rs index caac2441e..1b7575317 100644 --- a/crates/openab-core/src/gateway.rs +++ b/crates/openab-core/src/gateway.rs @@ -499,7 +499,10 @@ impl ChatAdapter for GatewayAdapter { } fn message_limit(&self) -> usize { - 4096 // Telegram limit + match self.platform_name { + "teams" => 20000, // Teams ~80 KB UTF-16; 20000 BMP chars ≈ 40 KB (safe margin) + _ => 4096, // Telegram / generic limit + } } async fn send_message(&self, channel: &ChannelRef, content: &str) -> Result { diff --git a/docs/platforms/schema/teams.toml b/docs/platforms/schema/teams.toml index 42a325e85..364c4398c 100644 --- a/docs/platforms/schema/teams.toml +++ b/docs/platforms/schema/teams.toml @@ -126,7 +126,8 @@ pr = "" [[openab_features]] feature = "message_split" status = "partial" -note = "Core splits via `split_delivery`; `GatewayAdapter::message_limit()` returns 4096 (hardcoded 'Telegram limit', not Teams' ~100 KB / UTF-16 budget) — chunking works but the bound is generic, not Teams-tuned." +pr = "#1410" +note = "Core splits via `split_delivery`; standalone `GatewayAdapter` returns 20000 for Teams (BMP-char budget ≈ 40 KB UTF-16). Unified Mode remains at 4096 (shared with LINE/Telegram) pending a channel-aware `message_limit_for()` API." source = ["crates/openab-core/src/adapter.rs#message_limit", "crates/openab-core/src/gateway.rs"] pr = "" diff --git a/src/unified_adapter.rs b/src/unified_adapter.rs index d04d1ba7a..5e7f6c157 100644 --- a/src/unified_adapter.rs +++ b/src/unified_adapter.rs @@ -130,7 +130,11 @@ impl ChatAdapter for UnifiedGatewayAdapter { } fn message_limit(&self) -> usize { - 4096 // conservative limit across platforms + // Unified Mode serves multiple platforms (Teams, LINE, Telegram, etc.) + // with different limits. Use the most conservative (LINE = 5000, + // Telegram = 4096). Platform-specific budgets require a future + // channel-aware message_limit_for() API. + 4096 } async fn send_message(&self, channel: &ChannelRef, content: &str) -> Result {