Conversation
When `sendMessage` fails with a non-zero `ret` the server often returns an empty `errmsg` (commonly `ret=-2`), so the thrown error was `sendMessage ret=-2 errmsg=(none)` — impossible to act on. The most common cause on agent-initiated outbound delivery (cron reminders, scheduled digests) is an expired or missing `context_token`: it is only refreshed by a recent inbound message from the recipient, so after a long idle period the bot cannot send until the user messages it again. Add `describeSendMessageFailure`, which passes through a real server errmsg but, when it is empty, reports the likely cause and whether a `context_token` was included in the request. No behavior change on success or when the server provides an error detail. Refreshing the token automatically is not possible from the bot side (it depends on inbound user activity), so this focuses on diagnosability. Fixes Tencent#225
|
Thank you for this diagnostics improvement. The original patch commit has been carried into and released by the current community-maintained
A non-zero One-line in-place replacement/upgrade (requires OpenClaw openclaw plugins install npm:openclaw-weixin --forceThe plugin/channel ID and state paths are unchanged, so this normally preserves existing configuration and login state. For clarity: the linked repository/package is a community-maintained distribution, not the official Tencent/Weixin release. This upstream Tencent PR is still open; this comment only records that its patch has shipped in the community release. |
Summary
When
sendMessagefails with a non-zeroretthe server often returns an emptyerrmsg(commonlyret=-2), so the thrown error wassendMessage ret=-2 errmsg=(none)— impossible to act on. On agent-initiated outbound delivery (cron reminders, scheduled digests) the usual cause is an expired or missingcontext_token, which is only refreshed by a recent inbound message from the recipient; after a long idle period the bot cannot send until the user messages it again.Fix
Add
describeSendMessageFailure, which passes through a real servererrmsgbut, when it is empty, reports the likely cause and whether acontext_tokenwas included in the request. No behavior change on success or when the server provides an error detail. Refreshing the token automatically is not possible from the bot side (it depends on inbound user activity), so this focuses on diagnosability.Tests
Added end-to-end and unit tests in
src/api/api.test.ts; they fail before this change and pass after. Full suite is 402/402 green and typecheck is clean.Fixes #225