You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a reasonable refactoring pattern. Making db.session an explicit parameter instead of relying on the implicit global db.session has some clear benefits:
Explicitness — callers and readers can immediately see which functions touch the database, improving readability and traceability.
Testability — passing session as a parameter makes it straightforward to inject a mock or test session without monkeypatching globals.
Safety — as you noted, it's a safe, non-behavioral change since db.session is still the same object being passed; the difference is only in how it's threaded through.
A few considerations worth noting:
Incremental adoption — since the codebase is large, doing this incrementally (as in your example PR) is practical, but it may create inconsistency in the interim where some functions accept session and others still use the global. A linting rule or type annotation convention could help track progress.
Type errors — your example PR already surfaced some type-checking issues (e.g., missing session arguments in ParagraphIndexProcessor methods), which validates the point that the refactor makes implicit dependencies visible and catches missing plumbing at compile time.
API surface — for deeply nested call chains, threading session through many layers can get verbose. Some projects address this with a context-local pattern or a unit-of-work abstraction, but explicit parameter passing is the simplest and most transparent approach.
Overall, it's a solid incremental improvement to code quality. The main trade-off is verbosity vs. explicitness, and for a production codebase like Dify, explicitness generally wins.
Hi, I opened #37417 to handle RecommendedAppService for this issue. It adds an explicit session: scoped_session parameter to the three classmethods (get_recommended_apps_and_categories, get_recommend_app_detail, and add_trial_app_record) and passes db.session in from the explore controllers, following the same approach as #37402.
@asukaminato0721 I have implemented the db.session parameter for one of the services. The documents specifically suggests creating an issue and talk about the changes which needs to be implemented, before creating a pr, but i am not sure under which criteria should the issue be opened, can you please help here. Or should i directly create a pr.
@asukaminato0721 I have implemented the db.session parameter for one of the services. The documents specifically suggests creating an issue and talk about the changes which needs to be implemented, before creating a pr, but i am not sure under which criteria should the issue be opened, can you please help here. Or should i directly create a pr.
api/providers/ (18 files): trace providers (13) and vector DB providers (5)
Total: ~153+ files. The heaviest areas are api/core/ (68), api/controllers/ (62), api/services/ (51), and api/tasks/ (42). A natural approach would be to tackle services first (since controllers call into them), then core/tasks, doing it incrementally per-module as contributors are already doing with PRs like #37402 and #37417.
Note: this list was generated via deep search and may not be 100% exhaustive — there could be a handful of additional files, especially in test code or newer additions. Running grep -rl "db.session" api/ locally would give you the definitive count.
I'd like to work on this issue. I see that PR #37402 has been merged for paragraph_index_processor.py. Are there other functions that need to be refactored to pass db.session as a parameter? I can continue the work.
@asukaminato0721 I have implemented the db.session parameter for one of the services. The documents specifically suggests creating an issue and talk about the changes which needs to be implemented, before creating a pr, but i am not sure under which criteria should the issue be opened, can you please help here. Or should i directly create a pr.
create a pr
Sorry for the delayed reply, Created a pr please check :- #37763
_resolve_model and _resolve_tool in api/controllers/inner_api/runtime_credentials.py each open their own Session(db.engine) for a single read. Moving both to core.db.session_factory matches what inner_api/wraps.py and web/wraps.py already do. Both blocks are pure reads and neither commits, so no commit boundary moves.
Opened as #42400 — a slice, not a fix for the whole issue.
Taking the workflow-run repository slice. service_api/app/workflow.py, service_api/app/workflow_events.py, web/workflow_events.py and console/human_input_form.py each build sessionmaker(db.engine) only to pass it to DifyAPIRepositoryFactory.create_api_workflow_run_repository(...). Moving them to session_factory.get_session_maker(), as controllers/openapi/workflow_events.py already does. The repository calls are single reads that never commit, so no commit boundary moves.
Opened as #42927 — a slice, not a fix for the whole issue.
Taking the conversation endpoints: service_api/app/conversation.py and web/conversation.py (conversation list) and console/app/conversation_variables.py each open sessionmaker(db.engine…).begin() per request. Moving them to session_factory.get_session_maker().begin(), the form console/snippets/snippet_workflow.py already uses. The .begin() block and its commit stay where they are.
Opened as #42954 — a slice, not a fix for the whole issue.
Hi @asukaminato0721 , I'd like to take a narrow, non-overlapping slice of this refactor: the audio controllers.
Scope (4 call sites, 2 files):
api/controllers/web/audio.py — AudioApi.post (ASR) and TextApi.post (TTS)
api/controllers/service_api/app/audio.py — AudioApi.post (ASR) and TextApi.post (TTS)
On current main all four handlers call AudioService.transcript_asr(...) / AudioService.transcript_tts(...) with session=db.session(), i.e. they hand the global scoped session to the service instead of owning a request-scoped one.
Plan:
Adopt @with_session from controllers.common.session on the four handlers, following the pattern already used in service_api/app/completion.py and the merged refactor(controllers): adopt with_session in web saved_message #41859. The decorator injects a request-scoped session: Session which I'll pass straight through to AudioService.
Both handlers only read through the session (ASR feature / app config lookups and the TTS message lookup), so I intend to use @with_session(write=False); I'll double-check the service path during implementation and switch to the default write mode if anything commits.
Drop the now-unused from extensions.ext_database import db import from both controllers.
No change to AudioService: transcript_asr / transcript_tts already accept an explicit session: Session.
Update tests/unit_tests/controllers/web/test_audio.py and tests/unit_tests/controllers/service_api/app/test_audio.py so they assert the session kwarg comes from the injected session rather than db.session.
Non-overlapping with the open slices I can see (#42954, #42927, #42400 by @ShousenZHANG, and #43288). Will run make lint, make type-check and the targeted unit tests, and link the PR here once it's up.
As planned, the four handlers in controllers/web/audio.py and controllers/service_api/app/audio.py now use @with_session(write=False) and forward the injected session to AudioService; the unused db import is gone. Verified AudioService and the helpers it calls only read through the session, so write=False holds. ruff, pyrefly, response-contract lint, import linter and the two audio test files (41 passed) are clean locally.
Activity
asukaminato0721 commentedon Jun 13, 2026
@dosu how is this change
dosubot commentedon Jun 13, 2026
This is a reasonable refactoring pattern. Making
db.sessionan explicit parameter instead of relying on the implicit globaldb.sessionhas some clear benefits:db.sessionis still the same object being passed; the difference is only in how it's threaded through.A few considerations worth noting:
sessionand others still use the global. A linting rule or type annotation convention could help track progress.sessionarguments inParagraphIndexProcessormethods), which validates the point that the refactor makes implicit dependencies visible and catches missing plumbing at compile time.sessionthrough many layers can get verbose. Some projects address this with a context-local pattern or a unit-of-work abstraction, but explicit parameter passing is the simplest and most transparent approach.Overall, it's a solid incremental improvement to code quality. The main trade-off is verbosity vs. explicitness, and for a production codebase like Dify, explicitness generally wins.
To reply, just mention @dosu.
Docs are dead. Just use Dosu.
nexiouscaliver commentedon Jun 14, 2026
Hi, I opened #37417 to handle RecommendedAppService for this issue. It adds an explicit session: scoped_session parameter to the three classmethods (get_recommended_apps_and_categories, get_recommend_app_detail, and add_trial_app_record) and passes db.session in from the explore controllers, following the same approach as #37402.
Uttamxalpha commentedon Jun 15, 2026
Hi! I'm interested in working on this issue and would like to submit a fix. Could you please assign it to me?
Thanks for maintaining the project!
Kunal152000 commentedon Jun 15, 2026
@asukaminato0721 I have implemented the db.session parameter for one of the services. The documents specifically suggests creating an issue and talk about the changes which needs to be implemented, before creating a pr, but i am not sure under which criteria should the issue be opened, can you please help here. Or should i directly create a pr.
asukaminato0721 commentedon Jun 15, 2026
create a pr
test: example of make db.session pass from parameter. langgenius#37403 (
asukaminato0721 commentedon Jun 17, 2026
@dosu give me a full file list that patch db.session.
dosubot commentedon Jun 17, 2026
Here's the full file list of files that use
db.sessionin the codebase (~153+ files):api/controllers/ (62 files)
Inner API:
api/controllers/inner_api/wraps.pyapi/controllers/inner_api/workspace/workspace.pyapi/controllers/inner_api/app/dsl.pyapi/controllers/inner_api/plugin/plugin.pyapi/controllers/inner_api/plugin/wraps.pyConsole:
api/controllers/console/datasets/datasets_segments.pyapi/controllers/console/datasets/datasets_document.pyapi/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.pyapi/controllers/console/datasets/rag_pipeline/rag_pipeline_draft_variable.pyapi/controllers/console/datasets/wraps.pyapi/controllers/console/datasets/datasets.pyapi/controllers/console/datasets/data_source.pyapi/controllers/console/auth/oauth.pyapi/controllers/console/auth/forgot_password.pyapi/controllers/console/auth/activate.pyapi/controllers/console/setup.pyapi/controllers/console/wraps.pyapi/controllers/console/apikey.pyapi/controllers/console/agent/roster.pyapi/controllers/console/agent/app_helpers.pyapi/controllers/console/workspace/account.pyapi/controllers/console/workspace/workspace.pyapi/controllers/console/workspace/tool_providers.pyapi/controllers/console/workspace/members.pyapi/controllers/console/snippets/snippet_workflow_draft_variable.pyapi/controllers/console/app/workflow_draft_variable.pyapi/controllers/console/app/site.pyapi/controllers/console/app/workflow_run.pyapi/controllers/console/app/agent.pyapi/controllers/console/app/agent_app_access.pyapi/controllers/console/app/wraps.pyapi/controllers/console/app/conversation.pyapi/controllers/console/app/workflow.pyapi/controllers/console/app/model_config.pyapi/controllers/console/app/message.pyapi/controllers/console/app/mcp_server.pyapi/controllers/console/tag/tags.pyapi/controllers/console/explore/banner.pyapi/controllers/console/explore/wraps.pyapi/controllers/console/explore/installed_app.pyapi/controllers/console/explore/completion.pyapi/controllers/console/explore/recommended_app.pyapi/controllers/console/explore/trial.pyWeb:
api/controllers/web/site.pyapi/controllers/web/human_input_form.pyapi/controllers/web/forgot_password.pyapi/controllers/web/passport.pyService API:
api/controllers/service_api/wraps.pyapi/controllers/service_api/dataset/segment.pyapi/controllers/service_api/dataset/rag_pipeline/rag_pipeline_workflow.pyapi/controllers/service_api/dataset/document.pyapi/controllers/service_api/dataset/dataset.pyapi/controllers/service_api/app/site.pyapi/controllers/service_api/app/file_preview.pyOpenAPI:
api/controllers/openapi/auth/verify.pyapi/controllers/openapi/auth/prepare.pyapi/controllers/openapi/account.pyapi/controllers/openapi/oauth_device_sso.pyapi/controllers/openapi/apps_permitted_external.pyapi/controllers/openapi/apps.pyapi/controllers/openapi/workspaces.pyapi/controllers/openapi/oauth_device.pyapi/services/ (51 files)
api/services/agent_drive_service.pyapi/services/workflow/node_output_inspector_service.pyapi/services/data_migration/import_service.pyapi/services/data_migration/export_service.pyapi/services/workflow/workflow_converter.pyapi/services/conversation_service.pyapi/services/file_service.pyapi/services/tools/builtin_tools_manage_service.pyapi/services/credential_permission_service.pyapi/services/feedback_service.pyapi/services/tag_service.pyapi/services/ops_service.pyapi/services/agent_app_sandbox_service.pyapi/services/webapp_auth_service.pyapi/services/workflow_collaboration_service.pyapi/services/async_workflow_service.pyapi/services/plugin/plugin_auto_upgrade_service.pyapi/services/plugin/plugin_permission_service.pyapi/services/auth/api_key_auth_service.pyapi/services/datasource_provider_service.pyapi/services/app_service.pyapi/services/web_conversation_service.pyapi/services/model_load_balancing_service.pyapi/services/workspace_service.pyapi/services/agent_service.pyapi/services/dataset_service.pyapi/services/workflow_service.pyapi/services/rag_pipeline/pipeline_generate_service.pyapi/services/enterprise/account_deletion_sync.pyapi/services/rag_pipeline/pipeline_template/database/database_retrieval.pyapi/services/external_knowledge_service.pyapi/services/annotation_service.pyapi/services/rag_pipeline/pipeline_template/customized/customized_retrieval.pyapi/services/vector_service.pyapi/services/audio_service.pyapi/services/metadata_service.pyapi/services/hit_testing_service.pyapi/services/account_service.pyapi/services/message_service.pyapi/services/saved_message_service.pyapi/services/credit_pool_service.pyapi/services/rag_pipeline/rag_pipeline_transform_service.pyapi/services/rag_pipeline/rag_pipeline.pyapi/services/agent/composer_service.pyapi/services/billing_service.pyapi/services/agent/skill_tool_inference_service.pyapi/services/api_based_extension_service.pyapi/services/clear_free_plan_tenant_expired_logs.pyapi/services/summary_index_service.pyapi/services/recommend_app/database/database_retrieval.pyapi/core/ (68 files)
api/core/repositories/human_input_repository.pyapi/core/workflow/nodes/agent_v2/binding_resolver.pyapi/core/workflow/nodes/agent_v2/session_store.pyapi/core/workflow/nodes/agent_v2/output_file_rebacker.pyapi/core/workflow/nodes/agent_v2/file_tenant_validator.pyapi/core/workflow/nodes/agent_v2/ask_human_resume.pyapi/core/workflow/node_factory.pyapi/core/moderation/api/api.pyapi/core/helper/encrypter.pyapi/core/callback_handler/index_tool_callback_handler.pyapi/core/tools/workflow_as_tool/tool.pyapi/core/tools/workflow_as_tool/provider.pyapi/core/tools/tool_engine.pyapi/core/tools/custom_tool/provider.pyapi/core/tools/tool_file_manager.pyapi/core/tools/tool_manager.pyapi/core/tools/utils/dataset_retriever/dataset_multi_retriever_tool.pyapi/core/tools/utils/dataset_retriever/dataset_retriever_tool.pyapi/core/tools/utils/model_invocation_utils.pyapi/core/plugin/backwards_invocation/app.pyapi/core/rag/rerank/rerank_model.pyapi/core/rag/docstore/dataset_docstore.pyapi/core/rag/datasource/keyword/jieba/jieba.pyapi/core/rag/datasource/vdb/vector_factory.pyapi/core/rag/datasource/retrieval_service.pyapi/core/rag/extractor/excel_extractor.pyapi/core/rag/extractor/notion_extractor.pyapi/core/rag/extractor/pdf_extractor.pyapi/core/rag/extractor/word_extractor.pyapi/core/rag/retrieval/dataset_retrieval.pyapi/core/rag/summary_index/summary_index.pyapi/core/rag/embedding/cached_embedding.pyapi/core/rag/index_processor/index_processor_base.pyapi/core/rag/index_processor/index_processor.pyapi/core/rag/index_processor/processor/parent_child_index_processor.pyapi/core/rag/index_processor/processor/qa_index_processor.pyapi/core/rag/index_processor/processor/paragraph_index_processor.pyapi/core/llm_generator/llm_generator.pyapi/core/external_data_tool/api/api.pyapi/core/provider_manager.pyapi/core/agent/base_agent_runner.pyapi/core/datasource/datasource_file_manager.pyapi/core/datasource/datasource_manager.pyapi/core/file/remote_fetcher.pyapi/core/prompt/utils/get_thread_messages_length.pyapi/core/app/workflow/file_runtime.pyapi/core/app/layers/trigger_post_layer.pyapi/core/app/features/annotation_reply/annotation_reply.pyapi/core/app/apps/workflow/app_generator.pyapi/core/app/apps/advanced_chat/app_runner.pyapi/core/app/apps/advanced_chat/app_generator.pyapi/core/app/apps/base_app_runner.pyapi/core/app/apps/agent_app/app_generator.pyapi/core/app/apps/agent_app/session_store.pyapi/core/app/apps/agent_chat/app_runner.pyapi/core/app/apps/agent_chat/app_generator.pyapi/core/app/apps/message_based_app_generator.pyapi/core/app/apps/chat/app_runner.pyapi/core/app/apps/chat/app_generator.pyapi/core/app/apps/completion/app_runner.pyapi/core/app/apps/completion/app_generator.pyapi/core/app/apps/pipeline/pipeline_runner.pyapi/core/app/apps/pipeline/pipeline_generator.pyapi/core/app/task_pipeline/message_cycle_manager.pyapi/core/memory/token_buffer_memory.pyapi/core/ops/ops_trace_manager.pyapi/core/ops/utils.pyapi/core/indexing_runner.pyapi/tasks/ (42 files)
api/tasks/disable_segment_from_index_task.pyapi/tasks/duplicate_document_indexing_task.pyapi/tasks/disable_segments_from_index_task.pyapi/tasks/clean_notion_document_task.pyapi/tasks/workflow_execution_tasks.pyapi/tasks/deal_dataset_index_update_task.pyapi/tasks/async_workflow_tasks.pyapi/tasks/document_indexing_sync_task.pyapi/tasks/delete_segment_from_index_task.pyapi/tasks/deal_dataset_vector_index_task.pyapi/tasks/retry_document_indexing_task.pyapi/tasks/batch_create_segment_to_index_task.pyapi/tasks/regenerate_summary_index_task.pyapi/tasks/batch_clean_document_task.pyapi/tasks/app_generate/resume_agent_app_task.pyapi/tasks/clean_dataset_task.pyapi/tasks/trigger_processing_tasks.pyapi/tasks/workflow_node_execution_tasks.pyapi/tasks/rag_pipeline/rag_pipeline_run_task.pyapi/tasks/rag_pipeline/priority_rag_pipeline_run_task.pyapi/tasks/add_document_to_index_task.pyapi/tasks/annotation/batch_import_annotations_task.pyapi/tasks/remove_document_from_index_task.pyapi/tasks/document_indexing_task.pyapi/tasks/recover_document_indexing_task.pyapi/tasks/annotation/disable_annotation_reply_task.pyapi/tasks/annotation/enable_annotation_reply_task.pyapi/tasks/workflow_schedule_tasks.pyapi/tasks/delete_conversation_task.pyapi/tasks/enable_segment_to_index_task.pyapi/tasks/remove_app_and_related_data_task.pyapi/tasks/clean_document_task.pyapi/tasks/sync_website_document_indexing_task.pyapi/tasks/enable_segments_to_index_task.pyapi/tasks/delete_account_task.pyapi/tasks/trigger_subscription_refresh_tasks.pyapi/tasks/document_indexing_update_task.pyapi/tasks/workflow_draft_var_tasks.pyapi/tasks/create_segment_to_index_task.pyapi/tasks/generate_summary_index_task.pyOther directories
api/models/ (10 files):
model.py,comment.py,dataset.py,account.py,trigger.py,snippet.py,provider.py,workflow.py,web.py,tools.pyapi/commands/ (5 files):
storage.py,plugin.py,system.py,data_migration.py,vector.pyapi/schedule/ (8 files):
queue_monitor_task.py,create_tidb_serverless_task.py,mail_clean_document_notify_task.py,clean_unused_datasets_task.py,clean_embedding_cache_task.py,clean_oauth_access_tokens_task.py,update_tidb_serverless_status_task.py,check_upgradable_plugin_task.pyapi/extensions/ (3 files):
ext_session_factory.py,ext_oauth_bearer.py,ext_login.pyapi/events/ (5 files):
create_document_index.py,update_app_dataset_join_when_app_model_config_updated.py,create_installed_app_when_app_created.py,create_site_record_when_app_created.py,update_app_dataset_join_when_app_published_workflow_updated.pyapi/libs/ (2 files):
oauth_bearer.py,oauth_data_source.pyapi/factories/ (1 file):
file_factory/builders.pyapi/providers/ (18 files): trace providers (13) and vector DB providers (5)
Total: ~153+ files. The heaviest areas are
api/core/(68),api/controllers/(62),api/services/(51), andapi/tasks/(42). A natural approach would be to tackle services first (since controllers call into them), then core/tasks, doing it incrementally per-module as contributors are already doing with PRs like #37402 and #37417.Note: this list was generated via deep search and may not be 100% exhaustive — there could be a handful of additional files, especially in test code or newer additions. Running
grep -rl "db.session" api/locally would give you the definitive count.To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.
refactor: accept db.session explicitly in SavedMessageService
EvanYao826 commentedon Jun 22, 2026
I'd like to work on this issue. I see that PR #37402 has been merged for
paragraph_index_processor.py. Are there other functions that need to be refactored to passdb.sessionas a parameter? I can continue the work.Kunal152000 commentedon Jun 22, 2026
Sorry for the delayed reply, Created a pr please check :- #37763
17 remaining items
refactor(api): pass session explicitly into RBACResourceService (lang…
ShousenZHANG commentedon Sep 17, 2026
Taking the runtime_credentials slice.
_resolve_modeland_resolve_toolinapi/controllers/inner_api/runtime_credentials.pyeach open their ownSession(db.engine)for a single read. Moving both tocore.db.session_factorymatches whatinner_api/wraps.pyandweb/wraps.pyalready do. Both blocks are pure reads and neither commits, so no commit boundary moves.Opened as #42400 — a slice, not a fix for the whole issue.
refactor: pass db.session explicitly to get_message_data (langgenius#…
ShousenZHANG commentedon Sep 24, 2026
Taking the workflow-run repository slice.
service_api/app/workflow.py,service_api/app/workflow_events.py,web/workflow_events.pyandconsole/human_input_form.pyeach buildsessionmaker(db.engine)only to pass it toDifyAPIRepositoryFactory.create_api_workflow_run_repository(...). Moving them tosession_factory.get_session_maker(), ascontrollers/openapi/workflow_events.pyalready does. The repository calls are single reads that never commit, so no commit boundary moves.Opened as #42927 — a slice, not a fix for the whole issue.
fix: inline the session instead of a helper method
ShousenZHANG commentedon Sep 25, 2026
Taking the conversation endpoints:
service_api/app/conversation.pyandweb/conversation.py(conversation list) andconsole/app/conversation_variables.pyeach opensessionmaker(db.engine…).begin()per request. Moving them tosession_factory.get_session_maker().begin(), the formconsole/snippets/snippet_workflow.pyalready uses. The.begin()block and its commit stay where they are.Opened as #42954 — a slice, not a fix for the whole issue.
refactor: pass db.session explicitly to instruction_modify_legacy (la…
Bear0117 commentedon Oct 1, 2026
Hi @asukaminato0721 , I'd like to take a narrow, non-overlapping slice of this refactor: the audio controllers.
Scope (4 call sites, 2 files):
api/controllers/web/audio.py—AudioApi.post(ASR) andTextApi.post(TTS)api/controllers/service_api/app/audio.py—AudioApi.post(ASR) andTextApi.post(TTS)On current
mainall four handlers callAudioService.transcript_asr(...)/AudioService.transcript_tts(...)withsession=db.session(), i.e. they hand the global scoped session to the service instead of owning a request-scoped one.Plan:
@with_sessionfromcontrollers.common.sessionon the four handlers, following the pattern already used inservice_api/app/completion.pyand the merged refactor(controllers): adopt with_session in web saved_message #41859. The decorator injects a request-scopedsession: Sessionwhich I'll pass straight through toAudioService.@with_session(write=False); I'll double-check the service path during implementation and switch to the default write mode if anything commits.from extensions.ext_database import dbimport from both controllers.AudioService:transcript_asr/transcript_ttsalready accept an explicitsession: Session.tests/unit_tests/controllers/web/test_audio.pyandtests/unit_tests/controllers/service_api/app/test_audio.pyso they assert thesessionkwarg comes from the injected session rather thandb.session.Non-overlapping with the open slices I can see (#42954, #42927, #42400 by @ShousenZHANG, and #43288). Will run
make lint,make type-checkand the targeted unit tests, and link the PR here once it's up.Bear0117 commentedon Oct 1, 2026
Opened #43322 for the audio controllers slice.
As planned, the four handlers in
controllers/web/audio.pyandcontrollers/service_api/app/audio.pynow use@with_session(write=False)and forward the injected session toAudioService; the unuseddbimport is gone. VerifiedAudioServiceand the helpers it calls only read through the session, sowrite=Falseholds.ruff,pyrefly, response-contract lint, import linter and the two audio test files (41 passed) are clean locally.41tair commentedon Oct 1, 2026
Now we have #39993 in progress, this issue could be closed.
refactor(api): adopt with_session in audio controllers (langgenius#37403
refactor: take the session as a parameter instead of hiding it behind…
refactor: pass db.session explicitly to ApiExternalDataTool (langgeni…
refactor: pass db.session explicitly to ApiExternalDataTool (langgeni…