Skip to content

fix(runtime)!: resolve Dify 0.9 integration regressions - #383

Merged
41tair merged 6 commits into
mainfrom
fix/dify-0.9-integration
Nov 11, 2026
Merged

41tair merged 6 commits into
mainfrom
fix/dify-0.9-integration

Conversation

@WH-2099

@WH-2099 WH-2099 commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Important

  1. Make sure you have read our contribution guidelines
  2. Search existing issues and pull requests to confirm this change is not a duplicate
  3. Open or identify the issue this pull request resolves or advances
  4. Use a Conventional Commits title for this pull request, and mark breaking changes with !
  5. Remember that the pull request title will become the squash merge commit message
  6. If CLA Assistant prompts you, sign CLA.md in the pull request conversation

Related Issue

Refs #379 and langgenius/dify#45355.
This PR is based on main, including the release preparation merged in #382.

Summary

The 0.9.0 candidate interpreted ordinary JSON resembling files inside mixed arrays as File objects and could not serialize nested File values for Dify draft persistence.
Keep ordinary JSON intact and record actual File locations in complete typed snapshots, preserving file identity through variable pools, container tasks, and repeated pause/resume.
Derive file paths from Pydantic's serialized nested values, including models, dataclasses, root models, and collections, while honoring aliases, exclusions, caller context, and declared field visibility.
Keep snapshot encoding and restoration in one module; scoped file markers are cleared on both success and serialization errors.
Validate declared file paths and payloads, require string keys in dictionaries containing files, and preserve the discriminated union's JSON Schema.
Filtered exports and dumps_with_segments produce ordinary JSON without file restoration metadata.
Historical array[any] snapshots without that metadata retain dictionaries as data.

Render templates over object arrays containing nested File/Segment models as JSON, preserving Unicode and empty arrays.
Replace named tool argument snapshots by call ID, append unnamed fragments, and skip complete stream accumulation when no callback consumes it.
Breaking change: runtime adapters that emit argument fragments must omit the function name after the initial call; a named update carries the current argument snapshot.

Add Engine(..., emit_frame_events=False) so hosts can avoid constructing and copying unused frame observations while retaining execution, variable commits, and pause/resume.
Frame observations remain enabled by default.

Validation:

  • just test: 1,195 passed on Python 3.12.13, with two existing pandas warnings.
  • just check, wheel/source distribution builds, and 29 documentation checks passed.
  • Independent regression-test, knowledge, and final naming reviews completed.
  • After the final naming pass, just check and 105 focused serialization, file, segment, and container tests passed.
  • Regression coverage includes repeated restoration of nested files in both variable pools and queued container results, retained download behavior, declared File/Segment field visibility, serializer failure cleanup, filtered exports, sets, schema generation, invalid paths, and JSON dictionaries resembling files.
  • The installed Graphon commit in chore(deps): upgrade Graphon to 0.9.0 and adapt runtime contracts dify#45356 passed 1,138 API tests and 1,095 Agent tests, with 5 existing Agent skips; host type and lint checks also passed.

Live provider calls, database integration tests, and production concurrency were not run.

Checklist

  • This pull request links the issue it resolves or advances
  • This pull request title follows Conventional Commits, and any breaking change is marked with !
  • If CLA Assistant prompted me, I signed CLA.md in the pull request conversation

Serialize files nested in mixed arrays, replace named tool argument snapshots, avoid callback-free result accumulation, and allow hosts to disable frame observations before copying values.

BREAKING CHANGE: Named tool calls carry the current argument snapshot. Runtime adapters emitting argument fragments must omit the function name after the initial call.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the Dify integration and release-preparation changes.

No open issues 🎉

What changed in this PR

Addresses Dify integration regressions ahead of Graphon 0.9.0, supporting the release preparation tracked in #379 and #382.

Changes:

  • Preserves nested File types in complete mixed-array snapshots without converting ordinary JSON into files, and supports nested models in object-array templates.
  • Makes named tool-call updates replace argument snapshots while unnamed updates append fragments—a breaking adapter contract change—and skips stream accumulation without callbacks.
  • Adds optional frame-event suppression while preserving execution and pause/resume behavior, with regression tests and documentation.
File Description
uv.lock Updates the project version and locked dependencies.
tests/​variables/​test_template_resolution.py Tests object-array rendering with nested Files and segments.
tests/​utils/​test_variable_utils.py Tests snapshot fidelity, filtered exports, key validation, and schema compatibility.
tests/​nodes/​test_container_effects.py Tests File restoration through pools and container resume tasks.
tests/​model_runtime/​test_model_dispatch.py Tests tool-call replacement and callback-free content release.
tests/​engine/​test_frame_observations.py Tests disabling frame events without changing results or copying unused context.
tests/​engine/​test_frame_failures.py Tests failure propagation across pause/restore with frame events disabled.
src/​graphon/​variables/​utils.py Adds nested File serialization to plain-value JSON exports.
src/​graphon/​variables/​segments.py Records explicit File paths in snapshots and serializes nested models for templates.
src/​graphon/​model_runtime/​README.md Documents tool-call merging and callback-dependent accumulation.
src/​graphon/​model_runtime/​model_providers/​base/​large_language_model.py Implements snapshot replacement and optional stream accumulation.
src/​graphon/​model_runtime/​entities/​llm_entities.py Documents the tool-call update contract.
src/​graphon/​engine/​frame.py Avoids observation-only error tracking when frame events are disabled.
src/​graphon/​engine/​engine.py Adds the default-enabled emit_frame_events option.
pyproject.toml Sets the package version to 0.9.0.
ARCHITECTURE.md Documents snapshot semantics, template rendering, and optional frame observations.
.github/​workflows/​test.yml Updates the pinned setup-uv action.
.github/​workflows/​release.yml Updates setup-uv pins for release jobs.
.github/​workflows/​pr.yml Updates the pinned setup-uv action.

Review effort: Balanced

@WH-2099
WH-2099 force-pushed the fix/dify-0.9-integration branch from 454cd1c to b5407fa Compare November 11, 2026 05:46
Copilot AI balanced review requested due to automatic review settings November 11, 2026 05:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI balanced review requested due to automatic review settings November 11, 2026 07:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@41tair
41tair merged commit a71f16c into main Nov 11, 2026
15 of 17 checks passed
@41tair
41tair deleted the fix/dify-0.9-integration branch November 11, 2026 07:34
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.

3 participants