langgenius/dify · error · AgentAppNotPublishedError

Agent has not been published

Error message

Agent has not been published

What it means

Raised as AgentAppNotPublishedError when fetching a published Agent App's parameters: the App has a bound Agent in ACTIVE status, but that Agent has no workflow-callable active config snapshot (no published version). Dify refuses to expose app parameters until the Agent has been published so callers never read a half-configured app. It surfaces a state-machine violation, not a missing resource.

Solutions

  1. Open the Agent in the console and click Publish to create an active config snapshot, then retry the parameters call.
  2. Verify agent.active_config_snapshot_id is non-null and the referenced AgentConfigSnapshot row is workflow-callable via agent_has_workflow_callable_active_snapshot.
  3. If publishing repeatedly fails, inspect AgentComposerService.publish logs for snapshot creation errors and resolve the underlying DB/storage failure before retrying.
  4. In tests/fixtures, drive the full publish flow (or insert an AgentConfigSnapshot + set active_config_snapshot_id) instead of only creating the Agent row.
Defensive patterns

Strategy: validation

Validate before calling

from sqlalchemy import select
from models.agent import Agent, AgentStatus
from core.agent.publish_visibility import agent_has_workflow_callable_active_snapshot

def assert_agent_published(session, app_model) -> None:
    agent_id = getattr(app_model, 'bound_agent_id', None)
    if not agent_id:
        raise ValueError('App has no bound Agent')
    agent = session.scalar(
        select(Agent).where(
            Agent.tenant_id == app_model.tenant_id,
            Agent.id == agent_id,
            Agent.status == AgentStatus.ACTIVE,
        )
    )
    if agent is None or not agent_has_workflow_callable_active_snapshot(session=session, agent=agent):
        raise ValueError('Agent is not published; publish it before fetching parameters')

Prevention

When it happens

Trigger: Calling the Agent App parameters/feature endpoint (the shared agent_app_parameters resolver used by console parameters + chat bootstrap) for an App whose bound Agent was created in the composer but never published, or whose published snapshot was later deactivated. Reproducible: create an Agent App, save a draft, do not hit Publish, then GET /console/apps/<app_id>/parameters or open the chat page.

Common situations: New Agent App left in draft state before sharing or embedding; publishing failed silently upstream and active_config_snapshot_id remained null; a copy/import of an App that did not carry over the Agent snapshot; CI/tests that create the App+Agent fixtures but skip the publish step.

Related errors


AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12). Data as JSON: /api/errors/44e8474ffb0ee9ec. Report an issue: GitHub.

Appendix: source

Thrown at api/controllers/common/agent_app_parameters.py:39

    app_model_config = app_model.app_model_config_with_session(session=session)

    agent_id = app_model.bound_agent_id
    if not agent_id:
        raise AgentAppGeneratorError("Agent App has no bound Agent")

    agent = session.scalar(
        select(Agent)
        .where(
            Agent.tenant_id == app_model.tenant_id,
            Agent.id == agent_id,
            Agent.status == AgentStatus.ACTIVE,
        )
        .limit(1)
    )
    if agent is None:
        raise AgentAppGeneratorError("Agent App has no bound Agent")
    if not agent_has_workflow_callable_active_snapshot(session=session, agent=agent):
        raise AgentAppNotPublishedError("Agent has not been published")

    snapshot = session.scalar(
        select(AgentConfigSnapshot)
        .where(
            AgentConfigSnapshot.tenant_id == app_model.tenant_id,
            AgentConfigSnapshot.agent_id == agent.id,
            AgentConfigSnapshot.id == agent.active_config_snapshot_id,
        )
        .limit(1)
    )
    if snapshot is None:
        raise AgentAppGeneratorError("Agent published version not found")

    agent_soul = AgentSoulConfig.model_validate(snapshot.config_snapshot_dict)
    annotation_reply = load_annotation_reply_config(session, app_model.id) if app_model_config else None
    features_dict = merge_agent_app_features(
        agent_soul=agent_soul,
        app_model_config=app_model_config,

View on GitHub (pinned to ef8544b173)