Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
refactor(models): remove the legacy db.session wrappers on App (#41942)
Eddy ZHANG970bbeca8d59
diff --git a/api/models/model.py b/api/models/model.pyindex b735268065f..a9e0acd1f40 100644--- a/api/models/model.py+++ b/api/models/model.py@@ -575,20 +575,12 @@ class App(Base):return Truereturn False- @property- def mode_compatible_with_agent(self) -> str:- return self.mode_compatible_with_agent_with_session(session=db.session())-def mode_compatible_with_agent_with_session(self, *, session: Session) -> str:if self.mode == AppMode.CHAT and self.is_agent_with_session(session=session):return AppMode.AGENT_CHATreturn str(self.mode)- @property- def deleted_tools(self) -> list[DeletedToolInfo]:- return self.deleted_tools_with_session(session=db.session())-def deleted_tools_with_session(self, *, session: Session) -> list[DeletedToolInfo]:from core.plugin.plugin_service import PluginServicefrom core.tools.tool_manager import ToolManager, ToolProviderTypediff --git a/api/tests/unit_tests/models/test_app_models.py b/api/tests/unit_tests/models/test_app_models.pyindex 7c7e2a8163d..9a48bf4a3d9 100644--- a/api/tests/unit_tests/models/test_app_models.py+++ b/api/tests/unit_tests/models/test_app_models.py@@ -241,6 +241,35 @@ class TestAppModelValidation:# Assertassert result == AppMode.CHAT+ @pytest.mark.parametrize("sqlite_session", [(App, AppModelConfig)], indirect=True)+ def test_app_mode_compatible_with_agent_reports_agent_chat(self, sqlite_session: Session):+ """A CHAT app whose own config enables agent mode reports AGENT_CHAT."""+ # Arrange+ app = App(+ tenant_id=str(uuid4()),+ name="Test App",+ mode=AppMode.CHAT,+ enable_site=True,+ enable_api=False,+ created_by=str(uuid4()),+ )+ sqlite_session.add(app)+ sqlite_session.flush()+ app.app_model_config_id = str(uuid4())+ config = AppModelConfig(+ app_id=app.id,+ agent_mode=json.dumps({"enabled": True, "strategy": "react"}),+ )+ config.id = app.app_model_config_id+ sqlite_session.add(config)+ sqlite_session.flush()++ # Act+ result = app.mode_compatible_with_agent_with_session(session=sqlite_session)++ # Assert+ assert result == AppMode.AGENT_CHAT+@pytest.mark.parametrize("sqlite_session", [(App, AppModelConfig)], indirect=True)def test_deleted_tools_checks_plugin_builtin_providers_through_core_plugin_service(self, sqlite_session: Session):"""Plugin-backed built-in tools are checked through core PluginService."""