Repository navigation
Description
Delivery status — 2026-11-02
Implementation is completed through merged #390; this issue remains closed as completed.
SDK 0.11.0 publication for Dify 1.19.0 is tracked separately in #413.
Blocking LLM invocation drops the opaque_body returned by model plugins, although the SDK assistant message already declares the field.
The streaming branch preserves that payload, so changing stream=True to False loses provider replay state.
The blocking aggregation also ignores content arrays: a string chunk followed by a content block and another string returns only the concatenated strings.
Ordinary and structured-output blocking invocations have the same problem.
Required behavior
- Preserve the last non-
Nonemessage snapshot, including{},[],"",0, andfalse. - Retain mixed strings and content blocks in order, including block-level opaque metadata and boundaries between unannotated text blocks.
- Treat an assistant containing opaque state or tool calls as nonempty.
- Start each invocation with fresh state and retain a captured snapshot across trailing empty chunks.
- Keep string-only responses as strings and preserve the existing invocation signatures and message fields.
Block boundaries matter even without opaque metadata: the current Gemini provider processes a thinking prefix separately on each text block.
Text consumers should extract text at their output boundary rather than changing replay data in the SDK.
Implementation and validation
PR #390 implements the SDK fix and regression tests.
Its final scope preserves the existing Agent token-counting and output-budget behavior.
Generic GPT-2 estimates do not provide a sufficient basis for introducing a new rejection policy across providers, so reasoning-budget policy is separate work.
The regression coverage uses the real Session and invocation paths with an HTTP transport fixture, ordinary and structured-output APIs, both stream settings, consecutive calls, nested state, falsy snapshots, and text-block boundaries.
Current local validation: just check, just test (333 passed, 1 skipped), just build, and git diff --check passed.
The skipped test requires the Dify CLI.
Related integration requirements
- langgenius/graphon#261 is merged, but Dify's pinned Graphon
0.7.0drops the replay fields.
The host must adopt a compatible containing release or the reviewed backport. - langgenius/dify-plugin-daemon#828 is the related opaque request-transport fix and remains a draft.
- langgenius/dify#41095 was closed without merging; its host replay changes need a restored or replacement implementation.
- Official plugins #4034 and issue #4032 track the Anthropic and Agent caller work.
The SDK pin and tests need alignment with the final scope of fix(llm)!: preserve complete messages and final usage #390.
The official OAIcompat endpoint and Dify's structured-output blocking parser also need to handle content arrays in their respective repositories.
The SDK cannot repair content already discarded or rejected before it receives a response.
General JSON numeric precision outside opaque replay data, Agent v2, and cross-session history restoration are separate work.
This issue tracks the SDK data-preservation defect.
A complete deployment still requires coordinated provider, Agent, host, and daemon validation; live provider APIs and that deployed combination have not been tested.
Activity