Skip to content

fix(dify): handle string query response#1922

Open
guslegend0510 wants to merge 1 commit into
agentscope-ai:mainfrom
guslegend0510:fix/issue-1917-dify-query-string
Open

fix(dify): handle string query response#1922
guslegend0510 wants to merge 1 commit into
agentscope-ai:mainfrom
guslegend0510:fix/issue-1917-dify-query-string

Conversation

@guslegend0510

@guslegend0510 guslegend0510 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.0.0-SNAPSHOT

Description

Background

The Dify RAG integration fails against real Dify Cloud (api.dify.ai) responses because the top-level query field is returned as a JSON string, while DifyResponse.Query only supported the object form. This caused DifyResponse deserialization to fail and made kb_search results/references empty.

Purpose

Make the Dify response model compatible with both query: "..." and query: { "content": "..." } payloads so retrieval works reliably with real Dify Cloud deployments.

Changes

  • Add a delegating Jackson creator to DifyResponse.Query so string payloads can be deserialized.
  • Keep the existing bean-style object mapping so both response shapes remain supported.
  • Add regression tests for both string and object query payloads.

How to test

  • mvn -pl agentscope-extensions/agentscope-extensions-rag/agentscope-extensions-rag-dify -am -Dtest=DifyRAGClientTest test

Related issue

@guslegend0510 guslegend0510 requested a review from a team June 25, 2026 15:30
@guslegend0510 guslegend0510 force-pushed the fix/issue-1917-dify-query-string branch from 7b69b7b to 9b0f781 Compare June 26, 2026 02:29
@itxaiohanglover

Copy link
Copy Markdown
Contributor

Clean fix — using @JsonCreator with DELEGATING mode is the right approach here, and I like that you kept the object form working too. Test coverage for both string and object query formats is great. Looks good to me.

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] Dify Cloud 检索接口 query 字段返回字符串,导致 DifyResponse 反序列化失败(kb_search 对 api.dify.ai 引用恒为空)

3 participants