mirror of
https://github.com/langgenius/dify-plugin-sdks.git
synced 2026-07-22 02:15:22 -04:00
feat: add optional reasoning_content to LLMResultChunkDelta #63
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ultramancode on GitHub (Oct 27, 2025).
Summary
Add optional
reasoning_contentfield toLLMResultChunkDeltato support structured streaming of LLM reasoning/thinking processes, separate from the final response text.This change is part of a three-repository update (
sdk,plugin, andmain),with a safe, phased rollout plan detailed below to ensure backward compatibility.
Follow-up to #23313
Motivation
Current inefficient flow (error-prone):
delta.thinking)message.contentusing<think>tags<think>tags via_split_reasoning()to separate them againProblems:
but currently relies on fragile parsing through _split_reasoning() because the SDK lacks this field and plugin support.
Proposed flow:
reasoning_contentfield (no merging)This aligns the SDK with how vendor APIs actually work.
Proposed Changes
Phase 1: SDK (this issue)
Compatibility: Backward-compatible (optional field, default
None)Phase 2: Plugins (defensive)
New plugin versions will enforce SDK versions that include this PR or later (via requirements.txt)
Add defensive pop() before Dify Main Backend sends the flag (Phase 3).
This prevents vendor API errors if an older plugin receives updated parameters from the Main backend.
Affected plugins: All LLM plugins
Phase 3: Dify Main Backend (read & capability signaling)
Main reads
reasoning_contentfrom plugin responses:delta.reasoning_contentdirectly if presentMain sends capability flag via
model_parameters:Phase 4: Plugins (opt-in implementation)
Provider-by-provider implementation for reasoning-capable models:
My Plan
Backward Compatibility
No breaking changes at any phase
Migration Safety
This phased approach ensures zero-risk migration despite independent release cycles:
no coordination required between repositories.
Why this is safe:
Version compatibility matrix: