dify/api/services
Yansong Zhang 7052257c8d fix(api): use lazy workflow persistence for transparent upgrade of old apps
VirtualWorkflowSynthesizer.ensure_workflow() creates a real draft
workflow on first call for a legacy app, persisting it to the database.
On subsequent calls, returns the existing draft.

This is needed because AdvancedChatAppGenerator's worker thread looks
up workflows from the database by ID. Instead of hacking the generator
to skip DB lookups, we treat this as a lazy one-time upgrade: the old
app gets a real workflow that can also be edited in the workflow editor.

Verified: old chat app created on main branch ("What is 2+2?" -> "Four")
and old agent-chat app ("Say hello" -> "Hello!") both successfully
execute through the Agent V2 engine with AGENT_V2_TRANSPARENT_UPGRADE=true.

Made-with: Cursor
2026-04-09 11:28:16 +08:00
..
auth chore(api): align Python support with 3.12 (#34419) 2026-04-02 05:07:32 +00:00
document_indexing_proxy feat: enable tenant isolation on duplicate document indexing tasks (#29080) 2025-12-08 17:54:57 +08:00
enterprise refactor(api): tighten types for Tenant.custom_config_dict and MCPToolProvider.headers (#34698) 2026-04-08 01:36:42 +00:00
entities refactor(api): remove duplicated RAG entities from services layer (#34689) 2026-04-07 23:36:59 +00:00
errors feat(api): enable all sandbox/skill controller routes and resolve dependencies (P0) 2026-04-09 09:36:16 +08:00
plugin refactor: migrate session.query to select API in sync task and services (#34619) 2026-04-07 04:23:14 +00:00
rag_pipeline refactor: select in rag_pipeline (#34495) 2026-04-03 03:42:01 +00:00
recommend_app refactor: select in 13 small service files (#34371) 2026-04-01 04:00:05 +00:00
retention refactor(api): type workflow run related counts with RelatedCountsDict TypedDict (#34530) 2026-04-06 13:17:01 +00:00
sandbox feat(api): port Sandbox + VirtualEnvironment + Skill system from feat/support-agent-sandbox (Phase 5-6) 2026-04-08 17:39:02 +08:00
tools refactor(api): replace json.loads with Pydantic validation in security and tools layers (#34380) 2026-04-07 12:11:51 +00:00
trigger refactor(api): type webhook validation result and workflow inputs with TypedDict (#34645) 2026-04-07 05:57:02 +00:00
workflow fix(api): use lazy workflow persistence for transparent upgrade of old apps 2026-04-09 11:28:16 +08:00
__init__.py chore(api/services): apply ruff reformatting (#7599) 2024-08-26 13:43:57 +08:00
account_service.py refactor(api): type invitation detail with InvitationDetailDict TypedDict (#34613) 2026-04-07 01:03:31 +00:00
advanced_prompt_template_service.py refactor: convert AppMode if/elif to match/case in service files (#30001) (#34562) 2026-04-05 10:22:11 +00:00
agent_service.py refactor: select in 10 service files (#34373) 2026-04-01 08:03:49 +00:00
annotation_service.py refactor: select in annotation_service (#34503) 2026-04-03 22:47:22 +00:00
api_based_extension_service.py refactor: select in 10 service files (#34373) 2026-04-01 08:03:49 +00:00
api_token_service.py fix: redis for api token (#31861) 2026-02-06 16:25:27 +08:00
app_asset_package_service.py feat(api): enable all sandbox/skill controller routes and resolve dependencies (P0) 2026-04-09 09:36:16 +08:00
app_asset_service.py feat(api): port Sandbox + VirtualEnvironment + Skill system from feat/support-agent-sandbox (Phase 5-6) 2026-04-08 17:39:02 +08:00
app_bundle_service.py feat(api): port Sandbox + VirtualEnvironment + Skill system from feat/support-agent-sandbox (Phase 5-6) 2026-04-08 17:39:02 +08:00
app_dsl_service.py feat(api): add Agent V2 node and new Agent app type (Phase 1-3) 2026-04-08 12:31:23 +08:00
app_generate_service.py fix(api): use lazy workflow persistence for transparent upgrade of old apps 2026-04-09 11:28:16 +08:00
app_model_config_service.py refactor: convert AppMode if/elif to match/case in service files (#30001) (#34562) 2026-04-05 10:22:11 +00:00
app_runtime_upgrade_service.py feat(api): enable all sandbox/skill controller routes and resolve dependencies (P0) 2026-04-09 09:36:16 +08:00
app_service.py fix(api): add AGENT mode to app list filtering 2026-04-09 10:54:05 +08:00
app_task_service.py refactor(api): use standalone graphon package (#34209) 2026-03-27 21:05:32 +00:00
asset_content_service.py feat(api): enable all sandbox/skill controller routes and resolve dependencies (P0) 2026-04-09 09:36:16 +08:00
async_workflow_service.py refactor(api): replace dict/Mapping with TypedDict in trigger.py and workflow.py (#33562) 2026-03-17 13:14:42 +09:00
attachment_service.py refactor: migrate session.query to select API in sync task and services (#34619) 2026-04-07 04:23:14 +00:00
audio_service.py refactor: select in 13 small service files (#34371) 2026-04-01 04:00:05 +00:00
billing_service.py refactor(api): migrate dict returns to TypedDicts in billing service (#34649) 2026-04-07 05:56:02 +00:00
clear_free_plan_tenant_expired_logs.py refactor(api): use standalone graphon package (#34209) 2026-03-27 21:05:32 +00:00
code_based_extension_service.py remove bare list, dict, Sequence, None, Any (#25058) 2025-09-06 03:32:23 +08:00
conversation_service.py chore(api): align Python support with 3.12 (#34419) 2026-04-02 05:07:32 +00:00
conversation_variable_updater.py refactor(api): use standalone graphon package (#34209) 2026-03-27 21:05:32 +00:00
credit_pool_service.py refactor: select in 13 small service files (#34371) 2026-04-01 04:00:05 +00:00
dataset_service.py refactor(api): type dataset service dicts with TypedDict (#34625) 2026-04-07 02:10:52 +00:00
datasource_provider_service.py refactor: select in datasource_provider_service (#34548) 2026-04-05 00:12:15 +00:00
end_user_service.py refactor: migrate session.query to select API in end_user_service and small tasks (#34620) 2026-04-07 04:25:55 +00:00
external_knowledge_service.py refactor(api): migrate consumers to shared RAG domain entities from core/rag/entities/ (#34692) 2026-04-07 23:22:56 +00:00
feature_service.py fix: enterprise API error handling and license enforcement (#33044) 2026-03-15 20:59:41 -07:00
feedback_service.py refactor: select in 10 service files (#34373) 2026-04-01 08:03:49 +00:00
file_service.py refactor(api): use standalone graphon package (#34209) 2026-03-27 21:05:32 +00:00
hit_testing_service.py refactor(api): remove duplicated RAG entities from services layer (#34689) 2026-04-07 23:36:59 +00:00
human_input_delivery_test_service.py refactor(api): use standalone graphon package (#34209) 2026-03-27 21:05:32 +00:00
human_input_service.py refactor(api): use standalone graphon package (#34209) 2026-03-27 21:05:32 +00:00
knowledge_service.py refactor: replace dict with BedrockRetrievalSetting BaseModel in knowledge_service (#34080) 2026-03-25 21:33:24 +09:00
llm_generation_service.py feat(api): enable all sandbox/skill controller routes and resolve dependencies (P0) 2026-04-09 09:36:16 +08:00
message_service.py chore(api): align Python support with 3.12 (#34419) 2026-04-02 05:07:32 +00:00
metadata_service.py refactor: select in metadata_service (#34479) 2026-04-02 12:34:38 +00:00
model_load_balancing_service.py refactor(api): type load balancing config dicts with TypedDict (#34639) 2026-04-07 05:58:10 +00:00
model_provider_service.py refactor(api): use standalone graphon package (#34209) 2026-03-27 21:05:32 +00:00
oauth_server.py use deco to avoid current_user (#26077) 2025-10-16 15:45:51 +09:00
operation_service.py more httpx (#25651) 2025-09-22 23:07:09 +08:00
ops_service.py refactor(api): type OpsTraceProviderConfigMap with TracingProviderCon… (#34424) 2026-04-02 01:47:08 +00:00
recommended_app_service.py refactor: select in 10 service files (#34373) 2026-04-01 08:03:49 +00:00
saved_message_service.py chore(api): align Python support with 3.12 (#34419) 2026-04-02 05:07:32 +00:00
skill_service.py feat(api): enable all sandbox/skill controller routes and resolve dependencies (P0) 2026-04-09 09:36:16 +08:00
storage_ticket_service.py feat(api): enable all sandbox/skill controller routes and resolve dependencies (P0) 2026-04-09 09:36:16 +08:00
summary_index_service.py refactor(api): type document summary status detail with TypedDict (#34610) 2026-04-07 01:00:39 +00:00
tag_service.py refactor: replace dict params with BaseModel payloads in TagService (#34422) 2026-04-07 04:20:02 +00:00
variable_truncator.py test: add unit tests for services and tasks part-4 (#33223) 2026-04-02 08:35:46 +00:00
vector_service.py refactor(api): remove duplicated RAG entities from services layer (#34689) 2026-04-07 23:36:59 +00:00
web_conversation_service.py chore(api): align Python support with 3.12 (#34419) 2026-04-02 05:07:32 +00:00
webapp_auth_service.py refactor: select in 13 small service files (#34371) 2026-04-01 04:00:05 +00:00
website_service.py refactor(api): type crawl status dicts with CrawlStatusDict TypedDict (#34611) 2026-04-07 01:01:04 +00:00
workflow_app_service.py chore(api): align Python support with 3.12 (#34419) 2026-04-02 05:07:32 +00:00
workflow_collaboration_service.py feat(api): enable all sandbox/skill controller routes and resolve dependencies (P0) 2026-04-09 09:36:16 +08:00
workflow_comment_service.py feat(api): enable all sandbox/skill controller routes and resolve dependencies (P0) 2026-04-09 09:36:16 +08:00
workflow_draft_variable_service.py chore: normalize frozenset literals and myscale typing (#34327) 2026-03-31 08:21:22 +00:00
workflow_event_snapshot_service.py refactor(api): use standalone graphon package (#34209) 2026-03-27 21:05:32 +00:00
workflow_restore.py fix: adding a restore API for version control on workflow draft (#33582) 2026-03-20 14:54:23 +08:00
workflow_run_service.py feat(api): Introduce workflow pause state management (#27298) 2025-10-30 14:41:09 +08:00
workflow_service.py fix(api): allow AGENT mode in workflow features validation 2026-04-08 13:19:59 +08:00
workspace_service.py refactor: select in 13 small service files (#34371) 2026-04-01 04:00:05 +00:00