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 App.bound_agent_id and App.is_agent wrappers (#41998)
Eddy ZHANGdc9dd9c5591a
diff --git a/api/models/model.py b/api/models/model.pyindex daea53bdccb..93eb4e6f850 100644--- a/api/models/model.py+++ b/api/models/model.py@@ -492,10 +492,6 @@ class App(Base):return None- @property- def bound_agent_id(self) -> str | None:- return self.bound_agent_id_with_session(session=db.session())-def bound_agent_id_with_session(self, *, session: Session) -> str | None:"""For an Agent App (mode=agent), the roster Agent it is backed by.@@ -550,10 +546,6 @@ class App(Base):def tenant(self) -> Tenant | None:return db.session.scalar(select(Tenant).where(Tenant.id == self.tenant_id))- @property- def is_agent(self) -> bool:- return self.is_agent_with_session(session=db.session())-def is_agent_with_session(self, *, session: Session) -> bool:"""Detect legacy agent mode, committing the compatible app mode through the supplied session."""app_model_config = session.get(AppModelConfig, self.app_model_config_id) if self.app_model_config_id else Nonediff --git a/api/tests/unit_tests/controllers/console/app/test_model_config_api.py b/api/tests/unit_tests/controllers/console/app/test_model_config_api.pyindex 7201315c98f..43d4925e165 100644--- a/api/tests/unit_tests/controllers/console/app/test_model_config_api.py+++ b/api/tests/unit_tests/controllers/console/app/test_model_config_api.py@@ -25,8 +25,9 @@ def _poison_implicit_app_config_properties(monkeypatch: pytest.MonkeyPatch) -> Ndef fail(_app: App) -> Never:raise AssertionError("implicit App model-config property was accessed")+ # `App.is_agent` used to be poisoned here too. It no longer exists as an+ # implicit property, so its absence enforces the same thing outright.monkeypatch.setattr(App, "app_model_config", property(fail))- monkeypatch.setattr(App, "is_agent", property(fail))@pytest.mark.parametrize("app_mode", [AppMode.CHAT, AppMode.COMPLETION])diff --git a/api/tests/unit_tests/models/test_app_models.py b/api/tests/unit_tests/models/test_app_models.pyindex 9a48bf4a3d9..7485031575a 100644--- a/api/tests/unit_tests/models/test_app_models.py+++ b/api/tests/unit_tests/models/test_app_models.py@@ -16,9 +16,8 @@ from uuid import UUID, uuid4import pytestfrom sqlalchemy import select-from sqlalchemy.orm import Session, scoped_session+from sqlalchemy.orm import Session-from models import model as model_modulefrom models.dataset import DatasetCollectionBindingfrom models.enums import CollectionBindingType, ConversationFromSource, CustomizeTokenStrategyfrom models.model import (@@ -166,8 +165,8 @@ class TestAppModelValidation:assert result == ""@pytest.mark.parametrize("sqlite_session", [(App, AppModelConfig)], indirect=True)- def test_app_is_agent_property_false(self, sqlite_session: Session, monkeypatch: pytest.MonkeyPatch):- """Test is_agent property returns False when not configured as agent."""+ def test_app_is_agent_false_when_not_configured_as_agent(self, sqlite_session: Session):+ """`is_agent_with_session` returns False when the config has no agent mode."""# Arrangeapp = App(tenant_id=str(uuid4()),@@ -180,11 +179,9 @@ class TestAppModelValidation:)sqlite_session.add(app)sqlite_session.flush()- session_registry = scoped_session(lambda: sqlite_session)- monkeypatch.setattr(model_module.db, "session", session_registry)# Act- result = app.is_agent+ result = app.is_agent_with_session(session=sqlite_session)# Assertassert result is Falsediff --git a/api/tests/unit_tests/services/test_app_service.py b/api/tests/unit_tests/services/test_app_service.pyindex 796439acc72..1e6f79261f3 100644--- a/api/tests/unit_tests/services/test_app_service.py+++ b/api/tests/unit_tests/services/test_app_service.py@@ -639,13 +639,15 @@ class TestAgentAppType:assert searched_counts.drafts == 1def test_bound_agent_id_is_none_for_non_agent_app(self):- """Non-agent apps short-circuit without touching the DB."""+ """Non-agent apps short-circuit before the session is used."""from models.model import App, AppModeapp = App(mode=AppMode.CHAT,)- assert app.bound_agent_id is None+ # `agent_app_binding_with_session` returns before touching the session+ # for a non-agent app, so passing None still exercises that path.+ assert app.bound_agent_id_with_session(session=None) is None # type: ignore[arg-type]def test_update_agent_app_syncs_backing_agent_identity(self, sqlite_session: Session):app, backing_agent = _persist_agent_app(sqlite_session)