feat(api): Introduce WorkflowResumptionContext for pause state management#28122
Conversation
…gement Certain metadata (including but not limited to `InvokeFrom`, `call_depth`, and `streaming`) is required when resuming a paused workflow. However, these fields are not part of `GraphRuntimeState` and were not saved in the previous implementation of `PauseStatePersistenceLayer`. This commit addresses this limitation by introducing a `WorkflowResumptionContext` model that wraps both the `*GenerateEntity` and `GraphRuntimeState`. This approach provides: - A structured container for all necessary resumption data - Better separation of concerns between execution state and persistence - Enhanced extensibility for future metadata additions - Clearer naming that distinguishes from `GraphRuntimeState` The `WorkflowResumptionContext` model makes extending the pause state easier while maintaining backward compatibility and proper version management for the entire execution state ecosystem.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces WorkflowResumptionContext to properly manage and persist the state required for resuming paused workflows. The new model encapsulates both the GraphRuntimeState and the GenerateEntity, which is a great improvement for structuring resumption data and ensuring all necessary metadata is saved. The implementation is solid, and the changes are well-tested with both unit and integration tests. I've left a few minor comments to improve documentation and code clarity. Overall, this is a well-executed feature.
api/tests/unit_tests/core/app/layers/test_pause_state_persist_layer.py
Outdated
Show resolved
Hide resolved
api/tests/unit_tests/core/app/layers/test_pause_state_persist_layer.py
Outdated
Show resolved
Hide resolved
api/tests/unit_tests/core/app/layers/test_pause_state_persist_layer.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull Request Overview
This pull request introduces WorkflowResumptionContext to improve pause state management for workflows by capturing all necessary metadata (including InvokeFrom, call_depth, and streaming) that was previously not being saved. The implementation wraps both the generate entity and the graph runtime state in a versioned container for better extensibility and maintainability.
Key changes:
- Introduces
WorkflowResumptionContextmodel with version management and discriminated union support for different entity types - Updates
PauseStatePersistenceLayerto serialize/deserialize the new context instead of just the graph runtime state - Adds comprehensive test coverage for serialization roundtrips and persistence flows
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| api/core/app/layers/pause_state_persist_layer.py | Introduces WorkflowResumptionContext and wrapper classes for entity type discrimination; updates PauseStatePersistenceLayer.__init__ to require generate_entity parameter |
| api/core/app/entities/app_invoke_entities.py | Adds documentation comment clarifying that user_id corresponds to Account.id or EndUser.id |
| api/tests/unit_tests/core/app/layers/test_pause_state_persist_layer.py | Updates all test cases to pass generate_entity to layer constructor; adds parametrized roundtrip tests for serialization |
| api/tests/test_containers_integration_tests/core/app/layers/test_pause_state_persist_layer.py | Updates integration tests to create and pass generate_entity; verifies WorkflowResumptionContext in persisted state |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
* fix(api): Trace Hierarchy, Span Status, and Broken Workflow for Arize & Phoenix Integration (langgenius#27937) Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> * chore: add type-check to pre-commit (langgenius#28005) * fix document enable (langgenius#28081) * chore: not SaaS version can query long log time range (langgenius#28109) * When graph_engine worker run exception, keep the node_id for deep res… (langgenius#26205) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: -LAN- <laipz8200@outlook.com> * fix document index test (langgenius#28113) * chore: improve the user experience of not login into apps (langgenius#28120) * feat(api): Introduce `WorkflowResumptionContext` for pause state management (langgenius#28122) Certain metadata (including but not limited to `InvokeFrom`, `call_depth`, and `streaming`) is required when resuming a paused workflow. However, these fields are not part of `GraphRuntimeState` and were not saved in the previous implementation of `PauseStatePersistenceLayer`. This commit addresses this limitation by introducing a `WorkflowResumptionContext` model that wraps both the `*GenerateEntity` and `GraphRuntimeState`. This approach provides: - A structured container for all necessary resumption data - Better separation of concerns between execution state and persistence - Enhanced extensibility for future metadata additions - Clearer naming that distinguishes from `GraphRuntimeState` The `WorkflowResumptionContext` model makes extending the pause state easier while maintaining backward compatibility and proper version management for the entire execution state ecosystem. Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * add transform-datasource-credentials command online check (langgenius#28124) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Garfield Dai <dai.hai@foxmail.com> * feat: introduce trigger functionality (langgenius#27644) Signed-off-by: lyzno1 <yuanyouhuilyz@gmail.com> Co-authored-by: Stream <Stream_2@qq.com> Co-authored-by: lyzno1 <92089059+lyzno1@users.noreply.github.com> Co-authored-by: zhsama <torvalds@linux.do> Co-authored-by: Harry <xh001x@hotmail.com> Co-authored-by: lyzno1 <yuanyouhuilyz@gmail.com> Co-authored-by: yessenia <yessenia.contact@gmail.com> Co-authored-by: hjlarry <hjlarry@163.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: WTW0313 <twwu@dify.ai> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: determine cpu cores determination in baseedpyright-check script on macos (langgenius#28058) * fix: variable assigner can't assign float number (langgenius#28068) * Add file type validation to paste upload (langgenius#28017) * test: create some hooks and utils test script, modified clipboard test script (langgenius#27928) * convert to TypeBase (langgenius#27935) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: disable workflow logs auto-cleanup by default (langgenius#28136) This PR changes the default value of `WORKFLOW_LOG_CLEANUP_ENABLED` from `true` to `false` across all configuration files. ## Motivation Setting the default to `false` provides safer default behavior by: - Preventing unintended data loss for new installations - Giving users explicit control over when to enable log cleanup - Following the opt-in principle for data deletion features Users who need automatic cleanup can enable it by setting `WORKFLOW_LOG_CLEANUP_ENABLED=true` in their configuration. * fix: simplify graph structure validation in WorkflowService (langgenius#28146) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * fix: app's ai site text to speech api (langgenius#28091) * refactor(web): reuse the same edit-custom-collection-modal component, and fix the pop up error (langgenius#28003) * add doc (langgenius#28016) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * fix: inconsistent behaviour of zoom in button and shortcut (langgenius#27944) * consolve conficts * fix * fix --------- Signed-off-by: lyzno1 <yuanyouhuilyz@gmail.com> Co-authored-by: Ali Saleh <saleh.a@turing.com> Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> Co-authored-by: lyzno1 <92089059+lyzno1@users.noreply.github.com> Co-authored-by: Jyong <76649700+JohnJyong@users.noreply.github.com> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: 湛露先生 <zhanluxianshen@163.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: -LAN- <laipz8200@outlook.com> Co-authored-by: QuantumGhost <obelisk.reg+git@gmail.com> Co-authored-by: Garfield Dai <dai.hai@foxmail.com> Co-authored-by: Yeuoly <45712896+Yeuoly@users.noreply.github.com> Co-authored-by: Stream <Stream_2@qq.com> Co-authored-by: zhsama <torvalds@linux.do> Co-authored-by: Harry <xh001x@hotmail.com> Co-authored-by: lyzno1 <yuanyouhuilyz@gmail.com> Co-authored-by: yessenia <yessenia.contact@gmail.com> Co-authored-by: hjlarry <hjlarry@163.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Co-authored-by: WTW0313 <twwu@dify.ai> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Bowen Liang <liang.bowen.123@qq.com> Co-authored-by: Gen Sato <52241300+halogen22@users.noreply.github.com> Co-authored-by: Gritty_dev <101377478+codomposer@users.noreply.github.com> Co-authored-by: Asuka Minato <i@asukaminato.eu.org> Co-authored-by: mnasrautinno <m.nasr@dai.autinno.com> Co-authored-by: yangzheli <43645580+yangzheli@users.noreply.github.com>
…gement (langgenius#28122) Certain metadata (including but not limited to `InvokeFrom`, `call_depth`, and `streaming`) is required when resuming a paused workflow. However, these fields are not part of `GraphRuntimeState` and were not saved in the previous implementation of `PauseStatePersistenceLayer`. This commit addresses this limitation by introducing a `WorkflowResumptionContext` model that wraps both the `*GenerateEntity` and `GraphRuntimeState`. This approach provides: - A structured container for all necessary resumption data - Better separation of concerns between execution state and persistence - Enhanced extensibility for future metadata additions - Clearer naming that distinguishes from `GraphRuntimeState` The `WorkflowResumptionContext` model makes extending the pause state easier while maintaining backward compatibility and proper version management for the entire execution state ecosystem. Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
…gement (#28122) Certain metadata (including but not limited to `InvokeFrom`, `call_depth`, and `streaming`) is required when resuming a paused workflow. However, these fields are not part of `GraphRuntimeState` and were not saved in the previous implementation of `PauseStatePersistenceLayer`. This commit addresses this limitation by introducing a `WorkflowResumptionContext` model that wraps both the `*GenerateEntity` and `GraphRuntimeState`. This approach provides: - A structured container for all necessary resumption data - Better separation of concerns between execution state and persistence - Enhanced extensibility for future metadata additions - Clearer naming that distinguishes from `GraphRuntimeState` The `WorkflowResumptionContext` model makes extending the pause state easier while maintaining backward compatibility and proper version management for the entire execution state ecosystem. Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Summary
Certain metadata (including but not limited to
InvokeFrom,call_depth, andstreaming) is required when resuming a paused workflow. However, these fields are not part ofGraphRuntimeStateand were not saved in the previousimplementation of
PauseStatePersistenceLayer.This commit addresses this limitation by introducing a
WorkflowResumptionContextmodel that wraps both the*GenerateEntityandGraphRuntimeState. This approach provides:GraphRuntimeStateThe
WorkflowResumptionContextmodel makes extending the pause state easier while maintaining backward compatibility and proper version management for the entire execution state ecosystem.Resolves #28121.
Screenshots
N/A
Checklist
dev/reformat(backend) andcd web && npx lint-staged(frontend) to appease the lint gods