Creating a new Agent toasts "Agent config version not found" for a missing build-draft
Self Checks
- [x] I have read the Contributing Guide and Language Policy.
- [x] This is only for bug report, if you would like to ask a question, please head to Discussions.
- [x] I have searched for existing issues search for existing issues, including closed ones.
- [x] I confirm that I am using English to submit this report, otherwise it will be closed.
- [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
- [x] Please do not modify this template :) and fill in all the required fields.
Dify version
1.16.1
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
- Create a new Agent.
- Open the Agent configure page (it defaults to Build mode).
- The page immediately GETs
/console/api/agent/{id}/build-draft.
Screenshot of the toast:
✔️ Expected Behavior
A missing build-draft after create is an empty state. Stay on the normal draft and do not toast.
❌ Actual Behavior
The API returns 404 Agent config version not found because the new agent has no DEBUG_BUILD row. The UI toasts that 404 as a version error (Flask-RESTX also appends "did you mean ...").
Hi @NovZhang! I'm Dosu and I'm helping the Dify team.
I can confirm this bug. Here's what's happening:
Root cause: The configure page defaults to 'build' mode [1], which immediately enables the build-draft query. The hook useAgentConfigureBuildDraftData uses a shouldSilenceBuildDraftCheckRef to make the first fetch with silent: true context, intending to suppress error toasts on the initial check [2]. However, when the API returns a 404 (because a brand-new agent has no build-draft row), the catch block calls setSoulSourceOverride('draft') and then rethrows the error [3]. This rethrow lets the global error handler pick it up and display the toast, even though the silent context was used for the fetch itself.
The fix should be in the queryFn catch block in use-agent-configure-build-draft.ts. When the error is a 404 on the initial silent check, the error should not be rethrown — a missing build-draft is an empty state, not a user-facing error. For example:
} catch (error) {
if (isNotFoundResponse(error)) {
setSoulSourceOverride('draft')
// Don't rethrow — treat a missing build-draft as an empty state
return null
}
throw error
}
This matches your expected outcome: a missing build-draft on a fresh agent should silently fall back to the normal draft without surfacing a toast.
Issue #38646 reported what appears to be the same symptom (404 toast on agent creation), though that issue was attributed to a different root cause at the time.
To reply, just mention @dosu.
Docs are dead. Just use Dosu.
@dosubot Thanks for confirming.
The toast is emitted in the fetch afterResponse hook (web/service/fetch.ts) before queryFn catch runs. It toasts whenever !silent. Not rethrowing a 404 (or returning null) does not prevent that toast.
The previous shouldSilenceBuildDraftCheckRef only silenced the first probe. A second fetch (React Strict Mode, remount) used silent: false and surfaced Agent config version not found.
#40734 always sends this GET with silent: true. A 404 still falls back to the normal draft via setSoulSourceOverride('draft') and the existing error/empty checks. I kept the rethrow so React Query still records the 404 as an empty-state error, which the configure page already treats as normal draft.
Happy to also swallow the 404 in queryFn if maintainers prefer that query state, but silent: true is what stops the toast.
Thanks for the detailed explanation and the fix in #40734 — your analysis is spot-on.
You're right that the toast fires in afterResponseErrorCode before the queryFn catch runs — !otherOptions.silent is what gates it [1], so not rethrowing in queryFn would have been too late to prevent the toast.
The shouldSilenceBuildDraftCheckRef approach was also fragile: React Strict Mode double-invokes effects, which flipped the ref to false before the second mount's fetch [2], causing the non-silent options to be used on what was effectively still the "first real" probe.
Always sending the GET with silent: true is the correct and minimal fix [3]. The existing 404 → setSoulSourceOverride('draft') path already handles the empty-state correctly [4], and keeping the rethrow so React Query records the error state is a reasonable call — the configure page already treats buildDraftNotFound as a normal-draft fallback [5]. Maintainers can decide if they also want to swallow the error in queryFn, but it's not required for correctness.
To reply, just mention @dosu.
Docs are dead. Just use Dosu.
This no longer reproduces on current main. In web/features/agent-v2/agent-detail/configure/use-agent-configure-build-draft.ts, the configure page fetches the build draft with a silent: true query context, and a 404 (AgentVersionNotFoundError, "Agent config version not found.") is handled by isNotFoundError(error) → setSoulSourceOverride('draft') with no toast; only non-404 failures surface an error. So a freshly created agent without a build draft silently falls back to the draft source, which is the expected state for a new agent.
Both attempts were closed (#40749 by its author after the empty-state regression, #40734 in the 2026-09-28 PR-queue cleanup). Could this be closed as completed? If it still reproduces on current main for anyone, please say so and keep it open.
From ZCode