{"record":{"id":"3d861163a55ce73b","repo":"langgenius/dify","slug":"agent-app-has-no-bound-agent","errorCode":null,"errorMessage":"Agent App has no bound Agent","messagePattern":"Agent App has no bound Agent","errorType":"http","errorClass":"AgentAppGeneratorError","httpStatus":null,"severity":"error","filePath":"api/controllers/common/agent_app_parameters.py","lineNumber":25,"sourceCode":"from core.app.apps.agent_app.app_feature_projection import merge_agent_app_features\nfrom core.app.apps.agent_app.app_variable_projection import agent_app_variables_to_user_input_form\nfrom core.app.apps.agent_app.errors import AgentAppGeneratorError, AgentAppNotPublishedError\nfrom models.agent import Agent, AgentConfigSnapshot, AgentStatus\nfrom models.agent_config_entities import AgentSoulConfig\nfrom models.model import App, load_annotation_reply_config\n\n\ndef get_published_agent_app_feature_dict_and_user_input_form(\n    app_model: App,\n    *,\n    session: Session,\n) -> tuple[dict[str, Any], list[dict[str, Any]]]:\n    \"\"\"Return public Agent App parameters backed by the published Agent Soul.\"\"\"\n    app_model_config = app_model.app_model_config_with_session(session=session)\n\n    agent_id = app_model.bound_agent_id\n    if not agent_id:\n        raise AgentAppGeneratorError(\"Agent App has no bound Agent\")\n\n    agent = session.scalar(\n        select(Agent)\n        .where(\n            Agent.tenant_id == app_model.tenant_id,\n            Agent.id == agent_id,\n            Agent.status == AgentStatus.ACTIVE,\n        )\n        .limit(1)\n    )\n    if agent is None:\n        raise AgentAppGeneratorError(\"Agent App has no bound Agent\")\n    if not agent_has_workflow_callable_active_snapshot(session=session, agent=agent):\n        raise AgentAppNotPublishedError(\"Agent has not been published\")\n\n    snapshot = session.scalar(\n        select(AgentConfigSnapshot)\n        .where(","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/common/agent_app_parameters.py#L7-L43","documentation":"Raised by get_published_agent_app_feature_dict_and_user_input_form when app_model.bound_agent_id is falsy. The Agent App model is backed by a published Agent Soul; without a bound agent there is nothing to project into app features and user input form, so generation is refused early.","triggerScenarios":"Requesting the published parameters of an App whose mode is agent-app but whose bound_agent_id column is null/empty — e.g. an app created before the agent binding was set, or a stale app record.","commonSituations":"Migrating legacy apps that predate Agent Soul, deleting the bound agent without clearing the app, or a race where the app was created but the binding transaction did not commit.","solutions":["Bind an Agent to the App (set bound_agent_id) via the agent app management API.","If the agent was deleted, re-create it and rebind, or convert the app mode.","Check the apps table row for the app_id to confirm bound_agent_id is populated."],"exampleFix":"// before\n// app.bound_agent_id is NULL\n// after\n// bind an agent (via the management endpoint or ORM):\napp.bound_agent_id = agent.id\nsession.commit()","handlingStrategy":"type-guard","validationCode":"def app_has_bound_agent(app_model) -> bool:\n    return bool(getattr(app_model, 'bound_agent_id', None))","typeGuard":"def app_has_bound_agent(app_model) -> bool:\n    return bool(getattr(app_model, 'bound_agent_id', None))","tryCatchPattern":"from controllers.common.agent_app_parameters import get_published_agent_app_feature_dict_and_user_input_form\nfrom core.app.apps.agent_app.errors import AgentAppGeneratorError\n\ntry:\n    features, form = get_published_agent_app_feature_dict_and_user_input_form(app_model, session=session)\nexcept AgentAppGeneratorError:\n    # surface a user-facing 'app not configured' message\n    raise","preventionTips":["Always bind an Agent before publishing an agent-app.","Clear bound_agent_id when an agent is deleted to keep state consistent.","Add a DB constraint / app-layer invariant that agent-app mode requires a binding."],"tags":["agent-app","controller","data-integrity","runtime"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}