hermes - 💡(How to fix) Fix fix(dingtalk): four AI Card delivery gaps (webhook gate blocks cards, env template id, DM robot_code, wide-screen layout)

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

While bundling hermes-agent into a desktop distribution (real-world DingTalk usage with AI Cards enabled), I hit four small but impactful gaps in gateway/platforms/dingtalk.py. I've been carrying them as local patches and would rather upstream them. All four are isolated to AI Card delivery and are individually low-risk.

A PR implementing all four follows this issue.

Error Message

return SendResult(success=False, error="No valid session_webhook available. ...") But the AI Card path below is delivered through the Card SDK (_create_and_stream_card) and does not use the webhook at all. So when there's no valid webhook (e.g. a proactive/out-of-band reply, or the webhook expired) the adapter returns an error even though it could have delivered an AI Card successfully. The webhook is only actually needed for the markdown-webhook fallback path.

Root Cause

While bundling hermes-agent into a desktop distribution (real-world DingTalk usage with AI Cards enabled), I hit four small but impactful gaps in gateway/platforms/dingtalk.py. I've been carrying them as local patches and would rather upstream them. All four are isolated to AI Card delivery and are individually low-risk.

A PR implementing all four follows this issue.

Fix Action

Fix / Workaround

While bundling hermes-agent into a desktop distribution (real-world DingTalk usage with AI Cards enabled), I hit four small but impactful gaps in gateway/platforms/dingtalk.py. I've been carrying them as local patches and would rather upstream them. All four are isolated to AI Card delivery and are individually low-risk.

Code Example

session_webhook = metadata.get("session_webhook")
if not session_webhook:
    webhook_info = self._get_valid_webhook(chat_id)
    if not webhook_info:
        return SendResult(success=False, error="No valid session_webhook available. ...")
    session_webhook, _ = webhook_info

---

self._card_template_id: Optional[str] = extra.get("card_template_id")

---

im_group_open_deliver_model=DeliverCardRequestImGroupOpenDeliverModel(
    robot_code=self._robot_code,
)

---

im_robot_open_deliver_model=DeliverCardRequestImRobotOpenDeliverModel(
    space_type="IM_ROBOT",
)
RAW_BUFFERClick to expand / collapse

Summary

While bundling hermes-agent into a desktop distribution (real-world DingTalk usage with AI Cards enabled), I hit four small but impactful gaps in gateway/platforms/dingtalk.py. I've been carrying them as local patches and would rather upstream them. All four are isolated to AI Card delivery and are individually low-risk.

A PR implementing all four follows this issue.

1. A missing session_webhook blocks AI Card delivery (AI Cards don't need a webhook)

In DingTalkAdapter.send() the very first thing the method does is resolve and gate on session_webhook, returning early if none is available:

session_webhook = metadata.get("session_webhook")
if not session_webhook:
    webhook_info = self._get_valid_webhook(chat_id)
    if not webhook_info:
        return SendResult(success=False, error="No valid session_webhook available. ...")
    session_webhook, _ = webhook_info

But the AI Card path below is delivered through the Card SDK (_create_and_stream_card) and does not use the webhook at all. So when there's no valid webhook (e.g. a proactive/out-of-band reply, or the webhook expired) the adapter returns an error even though it could have delivered an AI Card successfully. The webhook is only actually needed for the markdown-webhook fallback path.

Fix: defer the webhook lookup/gate until after the AI Card attempt, right before the webhook fallback runs.

2. No env-var fallback for the AI Card template id

self._card_template_id: Optional[str] = extra.get("card_template_id")

The template id can only come from per-adapter extra config. In a packaged/headless deployment it's much more convenient to set it via environment. Fix: fall back to DINGTALK_CARD_TEMPLATE_ID when extra doesn't provide one. Default behavior is unchanged when extra has the value.

3. DM AI Card delivery omits robot_code

The group path passes robot_code:

im_group_open_deliver_model=DeliverCardRequestImGroupOpenDeliverModel(
    robot_code=self._robot_code,
)

…but the 1:1 / DM path does not:

im_robot_open_deliver_model=DeliverCardRequestImRobotOpenDeliverModel(
    space_type="IM_ROBOT",
)

For internal apps this can surface as the card failing to deliver to DMs. Fix: pass robot_code=self._robot_code in the DM deliver model too, mirroring the group path.

4. AI Cards render in a narrow column (no wide-screen layout)

CreateCardRequestCardData is created with only {"content": ""}. Without sys_full_json_obj{"config": {"autoLayout": True}}, wide tables and code blocks wrap badly in the card. Fix: add the autoLayout config to the card param map.

Environment

  • hermes-agent 0.15.1 (also present on current main)
  • DingTalk Stream mode with AI Cards (alibabacloud_dingtalk.card_1_0) enabled

Happy to split the PR into four commits / separate PRs if maintainers prefer atomic review.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix fix(dingtalk): four AI Card delivery gaps (webhook gate blocks cards, env template id, DM robot_code, wide-screen layout)