Skip to content

fix(wechat): Service API text requests fail on streaming-only models, and image fallback should upload pic_url as local_file #37

Description

@AlexMultiAgent

Summary

When using bikeread/dify_wechat_plugin with Dify Service API and a streaming-only model such as qwen3.5-flash, the plugin may return AI did not give a reply for follow-up text messages.

Image handling also has a fallback gap: if WeChat media_id download fails because the server IP is not in the WeChat whitelist, the plugin should still process the image reliably by downloading pic_url itself and uploading it to Dify as local_file.

There is also a conversation recovery issue: if a cached conversation_id becomes stale, Dify returns Conversation Not Exists, and the plugin should clear the cached conversation and retry automatically.

Reproduction

  1. Install and configure the WeChat plugin with a Dify chat app.
  2. Configure the plugin to call Dify through Service API.
  3. Use a streaming-only model such as qwen3.5-flash.
  4. Send an image to the public account.
  5. Send a follow-up text such as 这是什么.

Actual Behavior

  • The image request may succeed, but the follow-up text can return AI did not give a reply.
  • If a cached conversation is stale, Dify returns Conversation Not Exists.
  • If WeChat media API access is blocked by IP whitelist, the plugin cannot fetch media_id directly.

Relevant errors observed locally:

This model only supports incremental_output set to True.
Conversation Not Exists
invalid ip xxx.xxx.xxx.xxx, not in whitelist

Expected Behavior

  • Text requests should work with streaming-only models.
  • If media_id fetch fails, image requests should still work by downloading pic_url and uploading it to Dify as local_file.
  • If a cached conversation becomes stale, the plugin should clear it and retry once automatically.

Root Cause

  • Service API text requests use response_mode=blocking, which breaks on models that require incremental output.
  • When media_id fetch fails, the current fallback is fragile.
  • Cached stale conversation_id is not always auto-recovered.

Suggested Fix

  • Always use response_mode=streaming for Service API chat requests.
  • Parse SSE responses for both text and image requests.
  • If Dify returns Conversation Not Exists, clear cached conversation and retry once.
  • If WeChat media_id fetch fails, download pic_url inside the plugin and upload it to Dify /files/upload, then send it as local_file.
  • Keep remote_url only as the last fallback.

Notes

I already verified this locally with qwen3.5-flash and Dify Service API. If needed, I can open a PR with the exact patch.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions