Agent V2 Configure Interface#
The Agent V2 Configure editor lives under web/features/agent-v2/agent-editor/ and is the primary surface for editing, testing, and publishing an Agent V2 app. At wider viewports, it renders a split-pane layout :
- Left pane (Orchestrate) โ the agent configuration editor: prompt, tools, skills, knowledge, model, environment variables, feature flags, etc.
- Right pane (Preview surface) โ an interactive chat panel for testing the agent, toggling between Build and Preview modes.
At narrower viewports (below 1280px), the workspace, preview controls, publish bar, and version history reflow and stack vertically to satisfy WCAG reflow requirements for responsive design.
The right panel mode is tracked via URL query parameter ?mode=build|preview using nuqs with history: 'replace', defaulting to build .
Component Hierarchy#
The root component hierarchy for the page is:
agent-editor/roster-page.tsx
โโโ AgentRosterComposerSession (composer/build-draft init)
โโโ AgentRosterEditorSession (conversation IDs, refresh mutations)
โโโ AgentRosterEditorContent (layout + all panel logic)
โโโ AgentConfigurationPanel (left pane)
โโโ AgentConfigurePreviewSurface (right pane)
The central orchestration component initialises AgentComposerProvider with the active soul config, scopes conversation ID atoms with ScopeProvider, and wires up all refresh, publish, and build-draft lifecycle callbacks.
Tools: Call Limits#
In Orchestrate โ Tools, expand a provider and hover over or focus an operation to reveal Set limit. Open it, turn on Call limit per run, and enter a positive whole number in Maximum calls. The switch starts at 3 if no previous limit is saved. Invalid input leaves the last saved limit unchanged. Turning the switch off makes the operation unlimited, but turning it back on restores the last enabled value, even after a reload. An enabled limit appears beside the operation as N calls / run, including in read-only views. The call-limit control updates the composer draft, which saves the operation's max_calls_per_run and retains the last enabled value in last_max_calls_per_run without changing its credentials or runtime parameters.
Build Mode vs. Preview Mode#
The right panel header AgentPreviewHeader exposes a SegmentedControl with Build and Preview tabs .
| Mode | Purpose | Draft type used |
|---|---|---|
| Build | Conversationally refine config via a build chat session | debug_build |
| Preview | Test the published/saved config as an end-user would | draft |
Preview mode is feature-gated. The page reads deployment_edition from the system-features API and computes previewEnabled = deploymentEdition !== 'COMMUNITY' . When disabled, the Preview tab renders as a tooltip-wrapped disabled button, and any ?mode=preview URL param is silently overridden to build . ENTERPRISE always has preview enabled regardless of license validity.
Build mode renders AgentBuildChat with draftType="debug_build" and a decorative empty state until the first message is sent .
Preview mode renders AgentPreviewChat which wires sendPreviewChatMessage to AgentChatRuntime and shows the agent's avatar and name in the empty state. The empty state fetches fresh agent data via consoleQuery.agent.byAgentId.get and resolves the icon URL based on type: for image icons it uses the signed icon_url field, for link icons it uses the raw icon value, and for emoji icons it passes the emoji character directly. This ensures uploaded image avatars render correctly via their signed URLs instead of resulting in 404 errors when the browser attempts to fetch /agents/<agent-id>/<file-id>.
In Preview, a backend quota rejection appears as Not executed. The usage and limit (for example, 3 of 3 calls used) appear inline when the tool activity container is at least 400px wide and are hidden at narrower widths. The expanded tool card shows Reason, without a separate call-limit row. Ordinary calls do not show counts, and a rejected call does not prevent the agent from producing its final answer. After Stop, the chat hook retries the history refresh within a bounded window so the tool cards can reflect persisted outcomes rather than rely on the last streamed update.
Mode switching when a build draft is active triggers a confirmation dialog ("clear session?") before discarding the draft and switching to Preview .
Chat Features: Show Thinking#
The Chat features panel offers a per-app Show thinking toggle, stored as app_features.show_thoughts.enabled. It defaults to off; a missing or null show_thoughts value also means off. The panel writes the setting to the agent config, and Build and Preview chat config reads the current draft setting. The published web app uses the published value.
When enabled, AgentRosterResponseContent displays non-empty agent_thought.thought content as trimmed plain text before tool calls, with the activity panel initially expanded. With the toggle off, thought text stays hidden and the existing activity rendering is unchanged. This controls display only: message APIs still return thoughts regardless of the toggle. App parameters expose show_thoughts: { enabled: boolean }, defaulting to { enabled: false }. This setting does not apply to the Workflow Agent V2 node.
The Build Draft System#
The build draft is a server-side isolated snapshot of the agent's soul config, created and mutated conversationally during a Build mode chat session, completely separate from the normal editable composer draft.
Lifecycle (useAgentConfigureBuildDraftData)#
The useAgentConfigureBuildDraftData hook manages existence detection and state :
- Detection โ calls
GET /agents/{agent_id}/build-draftwithmeta: { errorToast: false }to skip cache-level error toasts. A 404 means no active draft; the hook shows a toast for non-404 errors. - Active state โ when a build draft exists,
soulSourceresolves to'build-draft'and the orchestrate pane reflects the build draft config (read-only). - Change summary โ a diff is computed across skills, files, and env variables and surfaced as
AgentBuildDraftChangeSummary, powering the change-count indicator shown inAgentBuildDraftBar.
Terminal Actions (useAgentConfigureBuildDraftActions)#
The useAgentConfigureBuildDraftActions hook :
| Action | API calls | Effect |
|---|---|---|
| Apply | POST .../build-chat/finalize โ POST .../build-draft/apply | Invalidates caches, rebases composer to updated config, exits build-draft mode |
| Discard | DELETE .../build-draft | Exits build-draft mode without rebasing |
| Refresh after chat | refetch build draft (debounced 1 s after last message) | Rebases composer to latest build draft |
| Start fresh session | resets chat conversation | Forces checkout of current draft before next run |
While a build draft is active: the orchestrate pane is read-only, autosave is suspended, and the publish bar is hidden .
Soul Source: Config Source Abstraction#
AgentConfigureSoulSource is a union type controlling which agent config is rendered in the orchestrate pane :
| Value | Meaning |
|---|---|
'draft' | Normal editable composer draft |
'build-draft' | Active build draft (transient, conversationally modified) |
'view-version' | A specific published version opened read-only |
Resolution order: 'view-version' โ explicit soulSourceOverride โ build-draft existence โ 'draft' . If the user switches to Preview mode while a build draft is active, the source is forced back to 'draft' โ you cannot preview an uncommitted build draft.
The composerSessionKey is computed as {agentId}:{activeVersionId|selectedVersionId|'draft'}:{composerHydrationState}:{composerRebaseRevision} โ changing this key remounts AgentComposerProvider with a fresh initial draft .
Draft Autosave and Version Restore#
Autosave is handled by useAgentConfigureSync :
- 5-second debounce after any composer change.
- Deduplication via
lastAutosavedDraftKeyRef,explicitlySavingDraftKeysRef, and asaveSequencecounter. - Page-close persistence via
visibilitychange/beforeunloadkeepalive requests. - Suspended when a build draft is active or a version is being viewed .
Version restore is available from the versions panel kebab menu and the publish bar. Before restoring, any pending draft saves are flushed. AgentVersionRestore provides both a confirmation and a plan-upgrade dialog stage :
| Deployment | Behavior |
|---|---|
| Cloud Free/Sandbox | Shows PlanUpgradeModal |
| Paid Cloud / Self-hosted | Calls POST /agents/{id}/versions/{version_id}/restore, rebases composer, exits version view |
Restore is disabled when a build draft is active, when publishing, or when the user lacks release/version permissions .
Agent Icon Rendering#
Agent icons appear in the build/preview empty states, the configure sidebar, the roster list, and the web app access card. There are three icon types: emoji, image, and link .
Before PR #40449, image icons were rendered using the raw upload_files.id as <img src>, causing 404s. The fix introduced getAgentAppIconImageUrl(agent) โ a helper that returns the signed icon_url for image type icons and falls back appropriately for other types .
The AgentPreviewChatEmptyState component fetches agent data and passes it to AppIcon through a single narrow icon prop carrying the business icon fields (icon_type, icon, icon_background, icon_url). AppIcon resolves the rendering in one place:
imageโ uploaded images are resolved from the signedicon_urllinkโ external links are resolved from the rawiconemojiโ persisted emoji IDs are resolved fromicon
AppIcon uses Dify UI Avatar to handle image loading and shows a fallback if the image fails to load. Where compact Agent responses use different field meanings, explicit adapters map them into the icon shape.
The web app access card icon is resolved via getSettingsIcon(agent) which prefers the site's own icon if set, then falls back to the agent's icon, and includes icon_url only for image and link types .
Key Source Files#
| File | Role |
|---|---|
agent-editor/roster-page.tsx | Root page: mode routing, layout, previewEnabled gate |
agent-editor/state.ts | Jotai atoms: soul source override, version selection, conversation IDs, rebase revision |
agent-editor/roster-session.tsx | Central orchestration: composer provider, refresh mutations, layout wiring |
agent-editor/use-agent-configure-build-draft.ts | Build draft lifecycle: detection, change diffing, apply/discard/refresh actions |
agent-editor/use-agent-configure-sync.ts | Normal draft autosave, publish, and page-close persistence |
agent-editor/preview/header.tsx | AgentPreviewHeader: Build/Preview tab, disabled state for Community edition |
agent-editor/preview/build-chat.tsx | AgentBuildChat: build mode chat with debug_build draft type |
agent-editor/preview/preview-chat.tsx | AgentPreviewChat: preview mode chat with icon resolution |
agent-editor/version-restore/index.tsx | AgentVersionRestore: confirmation/upgrade dialog for version restoration |
utils/agent-icon.ts | getAgentAppIconImageUrl(): canonical icon URL resolution helper |