Skip to content

bugfix: fix duplicate Telegram message sending#105

Merged
yinwm merged 2 commits intosipeed:mainfrom
Zhaoyikaiii:bugfix/fix-duplicate-telegram-messages
Feb 13, 2026
Merged

bugfix: fix duplicate Telegram message sending#105
yinwm merged 2 commits intosipeed:mainfrom
Zhaoyikaiii:bugfix/fix-duplicate-telegram-messages

Conversation

@Zhaoyikaiii
Copy link
Collaborator

Summary

  • Fix system messages (from subagent) being sent twice: processSystemMessage set SendResponse: true causing runAgentLoop to publish outbound, then Run() also published outbound using the returned response string
  • Fix message tool double-send: when LLM called the "message" tool during processing, it published outbound immediately, then Run() published the final response again
  • Add sentInRound tracking to MessageTool so Run() can skip duplicate publishing

Test plan

  • go build ./... passes
  • go test ./... passes (existing integration test failures are unrelated — Claude CLI root restriction)
  • Send a message via Telegram and verify only one response is received
  • Trigger a subagent (spawn tool) task and verify the completion message is sent only once
  • Verify the message tool still works correctly when called by LLM

Two issues caused duplicate messages to be sent to users:

1. System messages (from subagent): processSystemMessage set SendResponse:true,
   causing runAgentLoop to publish outbound. Then Run() also published outbound
   using the returned response string, resulting in two identical messages.
   Fix: processSystemMessage now returns empty string since runAgentLoop already
   handles the send.

2. Message tool double-send: When LLM called the "message" tool during
   processing, it published outbound immediately. Then Run() published the
   final response again. Fix: Track whether MessageTool sent a message in the
   current round (sentInRound flag, reset on each SetContext call). Run()
   checks HasSentInRound() before publishing to avoid duplicates.
@yinwm
Copy link
Collaborator

yinwm commented Feb 13, 2026

please fix conflicts

Merge upstream/main into bugfix/fix-duplicate-telegram-messages.

Conflict resolutions:
- pkg/agent/loop.go: Adopt upstream's processSystemMessage which removes
  runAgentLoop call entirely (subagents now communicate via message tool
  directly). Keep PR's HasSentInRound() check in Run() for normal
  message processing path.
- pkg/tools/message.go: Merge both changes - keep sentInRound tracking
  from PR and adopt upstream's *ToolResult return type with Silent: true.
@Zhaoyikaiii
Copy link
Collaborator Author

done

@yinwm
Copy link
Collaborator

yinwm commented Feb 13, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

@yinwm yinwm merged commit 5339389 into sipeed:main Feb 13, 2026
@Zepan
Copy link
Contributor

Zepan commented Feb 13, 2026

Thanks for your contribution! We are forming the PicoClaw Dev Group to accelerate the evolution of the project. Any developer with more than one merged PR is invited to join.

Would you like to join the PicoClaw Dev Group? If so, please send an email to support@sipeed.com with the subject line: [Join PicoClaw Dev Group] + Your GitHub account. We will send the Discord invite link to your inbox.

emadomedher pushed a commit to emadomedher/picoclaw that referenced this pull request Feb 17, 2026
…elegram-messages

bugfix: fix duplicate Telegram message sending
@alexhoshina
Copy link
Collaborator

I want to understand the scenario in which you discovered this bug. In some cases, deduplication based solely on whether a tool has been called can lead to message loss.

StarWindv referenced this pull request in StarWindv/PicoClaw-shou Feb 19, 2026
…m-messages

bugfix: fix duplicate Telegram message sending
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.

4 participants