Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions gateway/platforms/weixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,20 +758,13 @@ def _pack_markdown_blocks_for_weixin(content: str, max_length: int) -> List[str]
def _split_text_for_weixin_delivery(content: str, max_length: int) -> List[str]:
"""Split content into sequential Weixin messages.

Prefer one message per top-level line/markdown unit when the author used
explicit line breaks. Oversized units fall back to block-aware packing so
long code fences still split safely.
A single response = a single Weixin message. Only split when the content
genuinely exceeds the API limit. Oversized content is truncated (not
broken into multiple messages) to preserve readability.
"""
if len(content) <= max_length and "\n" not in content:
if len(content) <= max_length:
return [content]

chunks: List[str] = []
for unit in _split_delivery_units_for_weixin(content):
if len(unit) <= max_length:
chunks.append(unit)
continue
chunks.extend(_pack_markdown_blocks_for_weixin(unit, max_length))
return chunks or [content]
return [BasePlatformAdapter.truncate_message(content, max_length)]


def _extract_text(item_list: List[Dict[str, Any]]) -> str:
Expand Down
2 changes: 1 addition & 1 deletion run_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -5519,7 +5519,7 @@ def _build_api_kwargs(self, api_messages: list) -> dict:
preserve_dots=self._anthropic_preserve_dots(),
context_length=ctx_len,
base_url=getattr(self, "_anthropic_base_url", None),
fast_mode=self.request_overrides.get("speed") == "fast",
fast_mode=(self.request_overrides or {}).get("speed") == "fast",
)

if self.api_mode == "codex_responses":
Expand Down