Skip to content

fix(workflow): persist Agent caller before node execution - #39699

Open
zyz619963502zyz wants to merge 3 commits into
langgenius:mainfrom
zyz619963502zyz:fix/workflow-start-persistence-order
Open

fix(workflow): persist Agent caller before node execution#39699
zyz619963502zyz wants to merge 3 commits into
langgenius:mainfrom
zyz619963502zyz:fix/workflow-start-persistence-order

Conversation

@zyz619963502zyz

Copy link
Copy Markdown
Contributor

Summary

Fixes #39546.

Graphon 0.6.0 runs layer on_node_run_start hooks synchronously in the worker before node.run() can advance. This change uses that boundary for Agent v2 to commit its WorkflowNodeExecutionModel caller row before participant/session setup begins.

  • synchronously persist the Agent v2 caller in WorkflowPersistenceLayer.on_node_run_start
  • serialize concurrent Agent start writes so node sequence allocation remains consistent
  • enrich the already-persisted execution when the normal NodeRunStartedEvent reaches the dispatcher instead of inserting it again
  • propagate synchronous persistence failures back into DifyAgentNode, before binding resolution or participant allocation
  • remove the old 60-attempt / 3-second caller visibility polling loop

Non-Agent nodes retain the existing event-driven persistence path.

Tests

  • pytest api/tests/unit_tests/core/app/workflow/test_persistence_layer.py api/tests/unit_tests/core/workflow/nodes/agent_v2/test_agent_node.py api/tests/unit_tests/core/workflow/nodes/agent_v2/test_session_store.py -q66 passed
  • Ruff on all six changed files
  • py_compile on production modules
  • git diff --check

The new tests deterministically cover both the worker-first ordering and persistence failure before participant allocation; no sleeps or timing polls are used.

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactor/Chore] Order workflow node-start persistence before dependent node execution

1 participant