fix(telegram): make reaction handling soft-fail and message-id resilient#20236
Conversation
97b4735 to
664e822
Compare
There was a problem hiding this comment.
Pull request overview
This PR improves Telegram reaction handling robustness by implementing soft-fail error handling to prevent LLM re-generation loops, adds snake_case parameter alias support for better API compatibility, and introduces message-id fallback capabilities for more resilient reaction targeting.
Changes:
- Converted Telegram reaction errors from hard throws to soft-fail JSON results to prevent Gemini Flash re-generation loops
- Added snake_case (
message_id) alias support alongside camelCase (messageId) for parameter parsing - Threaded
currentMessageIdthrough tool context to enable fallback reaction targeting when messageId is omitted
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/infra/shell-env.test.ts | Added Windows platform checks to skip shell environment tests (unrelated fix) |
| src/channels/plugins/types.core.ts | Added CurrentMessageId to threading context types |
| src/channels/plugins/actions/telegram.ts | Added currentMessageId fallback for reaction targeting |
| src/channels/dock.ts | Removed ReplyToId fallback for threadId; added currentMessageId extraction |
| src/auto-reply/reply/agent-runner-utils.ts | Threaded currentMessageId through tool context building |
| src/agents/tools/telegram-actions.ts | Converted reaction errors to soft-fail results instead of throwing |
| src/agents/tools/telegram-actions.e2e.test.ts | Updated tests to expect soft-fail results; added snake_case alias test |
| src/agents/tools/message-tool.ts | Added message_id schema field as snake_case alias |
| src/agents/tools/common.ts | Implemented snake_case parameter alias support via toSnakeCaseKey |
| src/agents/tools/common.e2e.test.ts | Added tests for snake_case alias support |
| src/agents/pi-tools.ts | Added currentMessageId parameter threading |
| src/agents/pi-embedded-runner/run/params.ts | Added currentMessageId to run parameters |
| src/agents/pi-embedded-runner/run/attempt.ts | Threaded currentMessageId to tool creation |
| src/agents/pi-embedded-runner/run.ts | Threaded currentMessageId through agent execution |
| src/agents/openclaw-tools.ts | Added currentMessageId to tool options |
| extensions/telegram/src/channel.ts | Added safeParseTelegramReplyToMessageId with fallback implementation |
5995554 to
a01377e
Compare
|
Addressed review feedback in
I resolved the outdated review threads after the push. |
|
Update: all review feedback has been addressed and all CI checks are green. This PR is ready for maintainer review/merge. |
a01377e to
14cb34b
Compare
|
Rebased to latest Current red CI is from upstream formatting drift in files outside this PR scope (same |
|
This looks like a strong candidate for the reaction-handling track. Before merge, please rebase and confirm DM-specific reaction behavior against the open DM reaction report lineage (for example #21001) so we can tie closure evidence directly. If you can add one explicit DM reaction regression test in the rebased branch, it will make merge/closure much easier. |
14cb34b to
705a38c
Compare
|
Rebased and refreshed this PR with a focused reaction-resilience patch set:
Validation run locally:
I also added the unreleased changelog fix entry with contributor credit. |
|
@greptile review |
|
Follow-up to review feedback:
Validation:
|
…ent (openclaw#20236) * Telegram: soft-fail reactions and fallback to inbound message id * Telegram: soft-fail missing reaction message id * Update CHANGELOG.md --------- Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
…ent (openclaw#20236) * Telegram: soft-fail reactions and fallback to inbound message id * Telegram: soft-fail missing reaction message id * Update CHANGELOG.md --------- Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
…ent (openclaw#20236) * Telegram: soft-fail reactions and fallback to inbound message id * Telegram: soft-fail missing reaction message id * Update CHANGELOG.md --------- Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
…ent (openclaw#20236) * Telegram: soft-fail reactions and fallback to inbound message id * Telegram: soft-fail missing reaction message id * Update CHANGELOG.md --------- Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
…ent (openclaw#20236) * Telegram: soft-fail reactions and fallback to inbound message id * Telegram: soft-fail missing reaction message id * Update CHANGELOG.md --------- Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
…ent (openclaw#20236) * Telegram: soft-fail reactions and fallback to inbound message id * Telegram: soft-fail missing reaction message id * Update CHANGELOG.md --------- Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
…ent (openclaw#20236) * Telegram: soft-fail reactions and fallback to inbound message id * Telegram: soft-fail missing reaction message id * Update CHANGELOG.md --------- Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
…ent (openclaw#20236) * Telegram: soft-fail reactions and fallback to inbound message id * Telegram: soft-fail missing reaction message id * Update CHANGELOG.md --------- Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
…ent (openclaw#20236) * Telegram: soft-fail reactions and fallback to inbound message id * Telegram: soft-fail missing reaction message id * Update CHANGELOG.md --------- Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
…ent (openclaw#20236) * Telegram: soft-fail reactions and fallback to inbound message id * Telegram: soft-fail missing reaction message id * Update CHANGELOG.md --------- Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
Summary
This PR hardens Telegram reaction handling to fail softly and improves message-id compatibility/fallback routing.
Problem
Hard errors in reaction paths can trigger provider re-generation loops and duplicate content. Also, real-world payloads may use message_id and reaction targets may be omitted.
Changes
Risk
Medium-low. User-facing behavior change is intentional and scoped to Telegram reaction/dispatch flow.
Validation
Greptile Summary
This PR hardens Telegram reaction handling by converting hard errors (exceptions) into soft failures (structured
ok:falseresponses), preventing agent re-generation loops that cause duplicate content. It also improves message-id compatibility by accepting snake_casemessage_idaliases and automatically falling back to the current inbound message ID whenmessageIdis omitted.Key changes:
jsonResult({ok: false, reason, hint})instead of throwing exceptionsreadParamRawincommon.ts:56-71) for LLM tool-call flexibilitycurrentMessageIdfrom inbound context through runtime → tools → action handlerscurrentMessageIdfromcontext.CurrentMessageIdand passes it to tool contextmessage_idfield as LLM-facing alias (see inline comment atmessage-tool.ts:249)rejects.toThrowassertions for reaction errors)Confidence Score: 4/5
Last reviewed commit: 8901940