Skip to content

fix(auto-reply): allow message tool for attachments in group-chat sessions#465

Open
BingqingLyu wants to merge 5 commits into
mainfrom
fork-pr-43276-fix-group-chat-allow-message-tool-attachments
Open

fix(auto-reply): allow message tool for attachments in group-chat sessions#465
BingqingLyu wants to merge 5 commits into
mainfrom
fork-pr-43276-fix-group-chat-allow-message-tool-attachments

Conversation

@BingqingLyu

@BingqingLyu BingqingLyu commented Apr 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • Problem: BuildGroupChatContext injected a prompt rule that unconditionally forbid the agent from using the message tool to send to the same group (Do not use the message tool to send to this same group just reply normally), blocking file/image/attachment delivery in Telegram group/forum-topic sessions.
  • Why it matters: The routing infrastructure already supports same-chat message tool sends for Telegram (via
    esolveTelegramAutoThreadId) and Slack (via
    esolveSlackAutoThreadId). The injected instruction contradicted that capability, causing 100% repro failure for attachment workflows in group sessions.
  • What changed: Rewrote the injected instruction to distinguish text replies (direct reply) from attachments/files/images (may use message tool targeting same group).
  • What did NOT change: No routing logic, no config, no other prompt template was modified.

Change Type (select all)

  • Bug fix

Scope (select all touched areas)

  • Integrations

Linked Issue/PR

User-visible / Behavior Changes

Agents in Telegram (and other) group-chat sessions can now send files, images, and attachments back into the same group using the message tool, instead of being silently blocked by the system prompt.

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No

Repro + Verification

Environment

  • Integration/channel: Telegram group / forum topic

Steps

  1. Add bot to a Telegram group with forum topics.
  2. Ask agent to generate and send a file/image back to the same topic.
  3. Before: agent refuses, citing group policy.
  4. After: agent uses message tool to send attachment to the same group/topic.

Tests

Added src/auto-reply/reply/groups.test.ts with 6 unit tests covering:

  • Correct group intro (with/without subject)
  • Participant list included when present
  • Text replies still guided to reply directly
  • Message tool no longer blanket-forbidden
  • Attachment guidance explicitly present

之前 buildGroupChatContext 生成的提示词完全禁止 AI 在群组中
使用 message 工具('Do not use the message tool to send to this
same group'),导致无法向 Telegram 群组/话题发送文件、图片等
附件,即便路由基础设施已支持同聊天室 message 工具的自动 threadId
注入(resolveTelegramAutoThreadId / resolveSlackAutoThreadId)。

修改提示词,区分两种场景:
- 文本回复:直接回复即可,无需 message 工具
- 附件/文件/图片:允许,并指引使用 message 工具发送到同一群组

新增 buildGroupChatContext 单元测试覆盖以上两条路径。

Closes openclaw#43146
type import must come before value import per oxfmt rules.
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.

[Bug]: Telegram group/topic sessions forbid same-chat message tool sends, blocking attachments/media despite same-chat thread routing support

2 participants