Skip to content

fix(dingtalk): fire-and-forget message processing & session_webhook fallback#11518

Closed
kagura-agent wants to merge 1 commit into
NousResearch:mainfrom
kagura-agent:fix/dingtalk-session-webhook
Closed

fix(dingtalk): fire-and-forget message processing & session_webhook fallback#11518
kagura-agent wants to merge 1 commit into
NousResearch:mainfrom
kagura-agent:fix/dingtalk-session-webhook

Conversation

@kagura-agent

Copy link
Copy Markdown
Contributor

Summary

Fixes #11463: DingTalk channel receives messages but fails to reply with No session_webhook available.

Changes

1. Fire-and-forget message processing

_IncomingHandler.process() now dispatches _on_message as a background task via asyncio.create_task() instead of awaiting it directly. This ensures the SDK ACK is returned immediately, preventing heartbeat timeouts and WebSocket disconnections when message processing takes longer than the SDK's ACK deadline.

2. session_webhook extraction fallback

If ChatbotMessage.from_dict() fails to map the sessionWebhook field (possible across SDK versions where the camelCase key name differs), the handler now falls back to extracting it directly from the raw callback data dict using both sessionWebhook and session_webhook key variants.

Testing

Added 3 new tests:

  • test_process_extracts_session_webhook — verifies webhook is populated from callback data
  • test_process_fallback_session_webhook_when_from_dict_misses_it — verifies fallback extraction
  • test_process_returns_ack_immediately — verifies ACK returns before message processing completes

All 31 DingTalk tests pass.

…allback

Fixes NousResearch#11463: DingTalk channel receives messages but fails to reply
with 'No session_webhook available'.

Two changes:

1. **Fire-and-forget message processing**: process() now dispatches
   _on_message as a background task via asyncio.create_task instead of
   awaiting it. This ensures the SDK ACK is returned immediately,
   preventing heartbeat timeouts and disconnections when message
   processing takes longer than the SDK's ACK deadline.

2. **session_webhook extraction fallback**: If ChatbotMessage.from_dict()
   fails to map the sessionWebhook field (possible across SDK versions),
   the handler now falls back to extracting it directly from the raw
   callback data dict using both 'sessionWebhook' and 'session_webhook'
   key variants.

Added 3 tests covering webhook extraction, fallback behavior, and
fire-and-forget ACK timing.
@teknium1

Copy link
Copy Markdown
Contributor

Merged via #11605 (#11605). Your commit was cherry-picked with authorship preserved (47a0dd1). Thanks for the fire-and-forget fix + session_webhook fallback + 3 new tests — this is a real scalability issue for longer-running agents that would silently drop the WebSocket when the SDK heartbeat timed out.

Conflict resolution note: your branch predated #11564 (the group-gating tests we merged earlier today), so tests/gateway/test_dingtalk.py had a conflict at EOF where both sides appended new test classes. Kept both.

This should also resolve @sgjeff's report in #11463 — their symptom ("No session_webhook available") matches exactly what your fallback handles. We'll ping them to retest.

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]: dingtalk channle callback error

2 participants