fix(dingtalk): adapter reliability — websockets proxy, card QPS throttle, inbound queue (rebased)#40929
Open
meng93 wants to merge 1 commit into
Open
Conversation
…tle, inbound queue serialization - Capture websockets proxy env vars before dingtalk-stream SDK can clobber them; restore after import (_install_dingtalk_websockets_proxy). - Add _CardTokenBucket (token-bucket, 20 QPS) and per-message 800 ms edit_message() throttle to stay under DingTalk AI-Card rate limits. 403 responses trigger an automatic 2 s exponential backoff. - Inbound message queue (_enqueue_inbound / _sweep_session_queues) serialises same-chat messages so long-running agent turns are not duplicated; a random 'busy' acknowledgement is sent for queued msgs. - Hydrate *_HOME_CHANNEL yaml keys into os.environ on gateway boot so /sethome survives process restarts (gateway/config.py). - Fix REGISTRATION_SOURCE default (openClaw → DING_DWS_CLAW) in hermes_cli/dingtalk_auth.py. - Platform display-name overrides for /sethome prompt (DingTalk, WeCom, etc.) in gateway/run.py. - Add scripts/gateway_guard.sh — auto-restart supervisor for the gateway process with caffeinate support on macOS. - Add .claude to .gitignore.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stabilise the DingTalk Stream-Mode adapter with three reliability improvements that prevent message loss and API-side rate-limit errors during sustained usage.
Rebased onto current
main— resolves all CI failures from #14333 (which were main-breakage, not DingTalk-related) and the two merge conflicts flagged in review.Motivation
dingtalk-streamSDK clobbersHTTPS_PROXY/HTTP_PROXYat import time, breaking corporate proxy setups.PUTAPI enforces a ~20 QPS limit; exceeding it returns 403 and drops the card update.Changes
gateway/platforms/dingtalk.py_install_dingtalk_websockets_proxy()— snapshot + restore proxy env vars around SDK importgateway/platforms/dingtalk.py_CardTokenBucket— token-bucket (20 QPS) + per-message 800 ms throttle onedit_message()gateway/platforms/dingtalk.py_enqueue_inbound/_sweep_session_queues— promise-chain queue per chat; busy-ack with random phrasegateway/config.py*_HOME_CHANNELyaml keys →os.environon gateway boot (survives restart)hermes_cli/dingtalk_auth.pyREGISTRATION_SOURCEdefault (openClaw→DING_DWS_CLAW)gateway/run.py/sethomeprompt (DingTalk,WeCom, etc.)scripts/gateway_guard.shcaffeinatesupport on macOS.gitignore.claude/Conflicts resolved (vs original #14333)
.gitignore.claude/into the existing editor-tooling block (.codex/,.cursor/,.gemini/,.zed/) added on maingateway/run.py_display_overridesdict but routed through main's newer_home_target_env_var(platform_name)helper and_deliver_platform_notice(source, notice)wrapperTest Plan
tests/gateway/test_dingtalk.pysuite passesRisk Assessment
Low. Changes are additive (new classes / functions) and the queue serialisation is opt-in per chat. The proxy capture only activates when env vars are pre-set.
Supersedes #14333. Credit to @jackjin1997 for the rebase conflict resolution guidance.
🤖 Generated with Claude Code