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
chore(agent-v2): sync changes (#38513)
yyh98d9b11f7b3a
diff --git a/api/clients/agent_backend/__init__.py b/api/clients/agent_backend/__init__.pyindex 172d63858a5..67175c4795c 100644--- a/api/clients/agent_backend/__init__.py+++ b/api/clients/agent_backend/__init__.py@@ -18,6 +18,7 @@ from clients.agent_backend.errors import (AgentBackendValidationError,)from clients.agent_backend.event_adapter import (+ AgentBackendAgentMessageDeltaInternalEvent,AgentBackendDeferredToolCallInternalEvent,AgentBackendInternalEvent,AgentBackendInternalEventType,@@ -46,6 +47,11 @@ from clients.agent_backend.request_builder import (AgentBackendWorkflowNodeRunInput,redact_for_agent_backend_log,)+from clients.agent_backend.session_cleanup import (+ AgentBackendSessionCleanupPayload,+ AgentBackendSessionCleanupResult,+ cleanup_agent_backend_session,+)__all__ = ["AGENT_SOUL_PROMPT_LAYER_ID",@@ -57,6 +63,7 @@ __all__ = ["WORKFLOW_NODE_JOB_PROMPT_LAYER_ID","WORKFLOW_USER_PROMPT_LAYER_ID","AgentBackendAgentAppRunInput",+ "AgentBackendAgentMessageDeltaInternalEvent","AgentBackendDeferredToolCallInternalEvent","AgentBackendError","AgentBackendHTTPError",@@ -73,6 +80,8 @@ __all__ = ["AgentBackendRunRequestBuilder","AgentBackendRunStartedInternalEvent","AgentBackendRunSucceededInternalEvent",+ "AgentBackendSessionCleanupPayload",+ "AgentBackendSessionCleanupResult","AgentBackendStreamError","AgentBackendStreamInternalEvent","AgentBackendTransportError",@@ -82,6 +91,7 @@ __all__ = ["FakeAgentBackendRunClient","FakeAgentBackendScenario","RuntimeLayerSpec",+ "cleanup_agent_backend_session","create_agent_backend_run_client","extract_runtime_layer_specs","redact_for_agent_backend_log",diff --git a/api/clients/agent_backend/event_adapter.py b/api/clients/agent_backend/event_adapter.pyindex 54c63f15e46..8fdc165ab3c 100644--- a/api/clients/agent_backend/event_adapter.py+++ b/api/clients/agent_backend/event_adapter.py@@ -5,6 +5,9 @@ The adapter does not define a new cross-service event contract. It consumesworkflow Agent Node maps to Graphon/AppQueue events. Deferred external tool callsremain Dify Agent ``run_succeeded`` payloads on the wire; API code turns theminto an internal event so workflow pause/session handling stays local to API.+Agent-message deltas are exposed as annotations on ``PydanticAIStreamRunEvent``+so API code does not have to parse Pydantic AI stream-event internals to+preserve streaming. The terminal answer remains the ``run_succeeded`` output."""from __future__ import annotations@@ -32,6 +35,7 @@ class AgentBackendInternalEventType(StrEnum):RUN_STARTED = "run_started"STREAM_EVENT = "stream_event"+ AGENT_MESSAGE_DELTA = "agent_message_delta"DEFERRED_TOOL_CALL = "deferred_tool_call"RUN_SUCCEEDED = "run_succeeded"RUN_FAILED = "run_failed"@@ -61,6 +65,13 @@ class AgentBackendStreamInternalEvent(AgentBackendInternalEventBase):data: JsonValue+class AgentBackendAgentMessageDeltaInternalEvent(AgentBackendInternalEventBase):+ """API-internal agent-message delta emitted independently from raw stream events."""++ type: Literal[AgentBackendInternalEventType.AGENT_MESSAGE_DELTA] = AgentBackendInternalEventType.AGENT_MESSAGE_DELTA+ delta: str++class AgentBackendRunSucceededInternalEvent(AgentBackendInternalEventBase):"""API-internal terminal success event carrying final output and session state."""@@ -99,6 +110,7 @@ class AgentBackendRunCancelledInternalEvent(AgentBackendInternalEventBase):type AgentBackendInternalEvent = Annotated[AgentBackendRunStartedInternalEvent| AgentBackendStreamInternalEvent+ | AgentBackendAgentMessageDeltaInternalEvent| AgentBackendDeferredToolCallInternalEvent| AgentBackendRunSucceededInternalEvent| AgentBackendRunFailedInternalEvent@@ -121,6 +133,14 @@ class AgentBackendRunEventAdapter:)]case PydanticAIStreamRunEvent():+ if event.agent_message_delta:+ return [+ AgentBackendAgentMessageDeltaInternalEvent(+ run_id=event.run_id,+ source_event_id=event.id,+ delta=event.agent_message_delta,+ )+ ]data = cast(JsonValue, _EVENT_DATA_ADAPTER.dump_python(event.data, mode="json"))event_kind = data.get("event_kind") if isinstance(data, dict) else Nonereturn [diff --git a/api/clients/agent_backend/request_builder.py b/api/clients/agent_backend/request_builder.pyindex 3b7b78f299b..1fd7b2cd990 100644--- a/api/clients/agent_backend/request_builder.py+++ b/api/clients/agent_backend/request_builder.py@@ -11,8 +11,9 @@ composition-driven.from __future__ import annotations+import refrom collections.abc import Mapping-from typing import ClassVar+from typing import ClassVar, Literalfrom agenton.compositor import CompositorSessionSnapshotfrom agenton.compositor.schemas import LayerSessionSnapshot@@ -46,7 +47,6 @@ from dify_agent.protocol import (LayerExitSignals,RunComposition,RunLayerSpec,- RunPurpose,RuntimeLayerSpec,)from pydantic import BaseModel, ConfigDict, Field, JsonValue, field_validator@@ -63,6 +63,7 @@ DIFY_CORE_TOOLS_LAYER_ID = "core_tools"DIFY_KNOWLEDGE_BASE_LAYER_ID = "knowledge"DIFY_ASK_HUMAN_LAYER_ID = "ask_human"DIFY_SHELL_LAYER_ID = "shell"+type AgentConfigVersionKind = Literal["snapshot", "draft", "build_draft"]def _filter_snapshot_to_specs(@@ -104,6 +105,59 @@ def _shell_config_with_drive_ref(return config.model_copy(update={"agent_stub_drive_ref": drive_config.drive_ref})+def _markdown_backtick_fence(text: str) -> str:+ """Choose a fence that will not terminate inside the prompt body."""+ longest_backtick_run = max((len(match.group(0)) for match in re.finditer(r"`+", text)), default=0)+ return "`" * max(3, longest_backtick_run + 1)+++_BUILD_DRAFT_AGENT_SOUL_PROMPT = """You are running in build mode.++Objective:+- Improve this agent's working environment, configuration, tools, files, notes,+ and context so it can handle the intended task well.++Guidance:+- Treat the intended task as context for setup work, validation, and configuration decisions.+- Perform concrete investigative or setup steps when they help improve or verify the agent configuration.+- Use the installed `dify-agent` CLI when you need to inspect or persist Agent configuration."""+++def _wrap_build_draft_agent_soul_prompt(prompt: str | None) -> str:+ """Reframe build-draft Agent Soul prompts as preparation work for a future run."""+ prompt_body = (prompt or "").strip()+ if not prompt_body:+ return _BUILD_DRAFT_AGENT_SOUL_PROMPT + "\n\nIntended task for later normal runs:\nNo task prompt was provided."+ fence = _markdown_backtick_fence(prompt_body)+ return (+ _BUILD_DRAFT_AGENT_SOUL_PROMPT+ + f"\n\nIntended task for later normal runs:\n{fence}text\n{prompt_body}\n{fence}"+ )+++def _agent_soul_prompt_for_layer(+ prompt: str | None,+ *,+ config_version_kind: AgentConfigVersionKind,+) -> str | None:+ """Preserve normal snapshot/draft prompts and only wrap build-draft prompts.++ The API-side layer adapter is the product boundary where Agent Soul text+ becomes the model-facing system-prompt layer. ``snapshot`` and normal+ ``draft`` runs pass through the original effective prompt unchanged, while+ ``build_draft`` always emits a setup prompt. When an original prompt is+ present, it is reframed as future-run context and embedded in a fenced+ block; when it is blank, the setup instruction is still kept.+ """+ if config_version_kind != "build_draft":+ if prompt is None:+ return None+ if not prompt.strip():+ return None+ return prompt+ return _wrap_build_draft_agent_soul_prompt(prompt)++class AgentBackendModelConfig(BaseModel):"""API-side model/plugin selection before it is converted to Dify Agent layers."""@@ -163,7 +217,7 @@ class AgentBackendWorkflowNodeRunInput(BaseModel):workflow_node_job_prompt: struser_prompt: stragent_soul_prompt: str | None = None- purpose: RunPurpose = "workflow_node"+ agent_config_version_kind: AgentConfigVersionKind = "snapshot"idempotency_key: str | None = Noneoutput: AgentBackendOutputConfig | None = Nonetools: DifyPluginToolsLayerConfig | None = None@@ -212,7 +266,7 @@ class AgentBackendAgentAppRunInput(BaseModel):execution_context: DifyExecutionContextLayerConfiguser_prompt: stragent_soul_prompt: str | None = None- purpose: RunPurpose = "agent_app"+ agent_config_version_kind: AgentConfigVersionKind = "snapshot"idempotency_key: str | None = Noneoutput: AgentBackendOutputConfig | None = Nonetools: DifyPluginToolsLayerConfig | None = None@@ -261,13 +315,17 @@ class AgentBackendRunRequestBuilder:prompt."""layers: list[RunLayerSpec] = []- if run_input.agent_soul_prompt:+ agent_soul_prompt = _agent_soul_prompt_for_layer(+ run_input.agent_soul_prompt,+ config_version_kind=run_input.agent_config_version_kind,+ )+ if agent_soul_prompt:layers.append(RunLayerSpec(name=AGENT_SOUL_PROMPT_LAYER_ID,type=PLAIN_PROMPT_LAYER_TYPE_ID,metadata={**run_input.metadata, "origin": "agent_soul"},- config=PromptLayerConfig(prefix=run_input.agent_soul_prompt),+ config=PromptLayerConfig(prefix=agent_soul_prompt),))@@ -419,7 +477,6 @@ class AgentBackendRunRequestBuilder:return CreateRunRequest(composition=RunComposition(layers=layers),- purpose=run_input.purpose,idempotency_key=run_input.idempotency_key,metadata=run_input.metadata,session_snapshot=run_input.session_snapshot,@@ -467,7 +524,6 @@ class AgentBackendRunRequestBuilder:filtered_snapshot = _filter_snapshot_to_specs(session_snapshot, runtime_layer_specs)return CreateRunRequest(composition=RunComposition(layers=layers),- purpose="workflow_node",idempotency_key=idempotency_key,metadata=request_metadata,session_snapshot=filtered_snapshot,@@ -483,13 +539,17 @@ class AgentBackendRunRequestBuilder:ask_human / structured output."""layers: list[RunLayerSpec] = []- if run_input.agent_soul_prompt:+ agent_soul_prompt = _agent_soul_prompt_for_layer(+ run_input.agent_soul_prompt,+ config_version_kind=run_input.agent_config_version_kind,+ )+ if agent_soul_prompt:layers.append(RunLayerSpec(name=AGENT_SOUL_PROMPT_LAYER_ID,type=PLAIN_PROMPT_LAYER_TYPE_ID,metadata={**run_input.metadata, "origin": "agent_soul"},- config=PromptLayerConfig(prefix=run_input.agent_soul_prompt),+ config=PromptLayerConfig(prefix=agent_soul_prompt),))@@ -649,7 +709,6 @@ class AgentBackendRunRequestBuilder:return CreateRunRequest(composition=RunComposition(layers=layers),- purpose=run_input.purpose,idempotency_key=run_input.idempotency_key,metadata=run_input.metadata,session_snapshot=run_input.session_snapshot,diff --git a/api/clients/agent_backend/session_cleanup.py b/api/clients/agent_backend/session_cleanup.pynew file mode 100644index 00000000000..370ff544e68--- /dev/null+++ b/api/clients/agent_backend/session_cleanup.py@@ -0,0 +1,100 @@+"""Shared API-side helper for Agent backend lifecycle-only session cleanup.++Product code owns local row retirement and background-task dispatch. This module+only adapts persisted cleanup inputs into the public ``dify-agent`` run+protocol, performs the synchronous ``create_run + wait_run`` loop used by Celery+workers, and reports whether the backend cleanup succeeded, was skipped, or+failed.+"""++from __future__ import annotations++from dataclasses import dataclass+from typing import ClassVar, Literal++from agenton.compositor import CompositorSessionSnapshot+from dify_agent.protocol import RuntimeLayerSpec+from pydantic import BaseModel, ConfigDict, Field, JsonValue++from clients.agent_backend.client import AgentBackendRunClient+from clients.agent_backend.errors import AgentBackendError+from clients.agent_backend.request_builder import AgentBackendRunRequestBuilder+++class AgentBackendSessionCleanupPayload(BaseModel):+ """Serialized cleanup inputs preserved across API and Celery boundaries."""++ session_snapshot: CompositorSessionSnapshot | None = None+ runtime_layer_specs: list[RuntimeLayerSpec] = Field(default_factory=list)+ idempotency_key: str | None = None+ metadata: dict[str, JsonValue] = Field(default_factory=dict)+ timeout_seconds: float = 30.0++ model_config: ClassVar[ConfigDict] = ConfigDict(extra="forbid")+++@dataclass(frozen=True, slots=True)+class AgentBackendSessionCleanupResult:+ """Terminal outcome of one backend cleanup attempt."""++ status: Literal["succeeded", "skipped", "failed"]+ reason: str | None = None+ cleanup_run_id: str | None = None++ @classmethod+ def succeeded(cls, cleanup_run_id: str) -> AgentBackendSessionCleanupResult:+ return cls(status="succeeded", cleanup_run_id=cleanup_run_id)++ @classmethod+ def skipped(cls, reason: str) -> AgentBackendSessionCleanupResult:+ return cls(status="skipped", reason=reason)++ @classmethod+ def failed(cls, reason: str, cleanup_run_id: str | None = None) -> AgentBackendSessionCleanupResult:+ return cls(status="failed", reason=reason, cleanup_run_id=cleanup_run_id)+++def cleanup_agent_backend_session(+ *,+ payload: AgentBackendSessionCleanupPayload,+ client: AgentBackendRunClient | None,+ request_builder: AgentBackendRunRequestBuilder | None = None,+) -> AgentBackendSessionCleanupResult:+ """Run lifecycle-only cleanup against the Agent backend and report status."""+ if client is None:+ return AgentBackendSessionCleanupResult.skipped("no_agent_backend_client")+ if payload.session_snapshot is None:+ return AgentBackendSessionCleanupResult.skipped("missing_session_snapshot")+ if not payload.runtime_layer_specs:+ return AgentBackendSessionCleanupResult.skipped("missing_runtime_layer_specs")++ builder = request_builder or AgentBackendRunRequestBuilder()+ request = builder.build_cleanup_request(+ session_snapshot=payload.session_snapshot,+ runtime_layer_specs=payload.runtime_layer_specs,+ idempotency_key=payload.idempotency_key,+ metadata=payload.metadata,+ )++ try:+ response = client.create_run(request)+ except AgentBackendError as exc:+ return AgentBackendSessionCleanupResult.failed(str(exc))++ try:+ status_response = client.wait_run(response.run_id, timeout_seconds=payload.timeout_seconds)+ except AgentBackendError as exc:+ return AgentBackendSessionCleanupResult.failed(str(exc), cleanup_run_id=response.run_id)++ if status_response.status != "succeeded":+ reason = status_response.error or f"cleanup run ended with status {status_response.status}"+ return AgentBackendSessionCleanupResult.failed(reason, cleanup_run_id=response.run_id)++ return AgentBackendSessionCleanupResult.succeeded(response.run_id)+++__all__ = [+ "AgentBackendSessionCleanupPayload",+ "AgentBackendSessionCleanupResult",+ "cleanup_agent_backend_session",+]diff --git a/api/controllers/console/app/completion.py b/api/controllers/console/app/completion.pyindex 4a8caff9c40..62cf38b86d8 100644--- a/api/controllers/console/app/completion.py+++ b/api/controllers/console/app/completion.py@@ -36,7 +36,7 @@ from controllers.console.wraps import (with_current_user_id,)from controllers.web.error import InvokeRateLimitError as InvokeRateLimitHttpError-from core.app.entities.app_invoke_entities import InvokeFrom+from core.app.entities.app_invoke_entities import AGENT_RUNTIME_EXIT_INTENT_ARG, InvokeFromfrom core.app.features.rate_limiting.rate_limit import RateLimitGeneratorfrom core.errors.error import (ModelCurrentlyNotSupportError,@@ -416,6 +416,7 @@ def _create_build_chat_finalization_message("draft_type": "debug_build","conversation_id": debug_conversation_id,"auto_generate_name": False,+ AGENT_RUNTIME_EXIT_INTENT_ARG: "delete",}external_trace_id = get_external_trace_id(request)if external_trace_id:diff --git a/api/core/app/apps/agent_app/app_generator.py b/api/core/app/apps/agent_app/app_generator.pyindex f2f62496883..4c10004fc7e 100644--- a/api/core/app/apps/agent_app/app_generator.py+++ b/api/core/app/apps/agent_app/app_generator.py@@ -1,14 +1,11 @@"""Agent App generator: orchestrate Agent App chat and finalize executions.-The primary mode mirrors the agent_chat generator (conversation + message ++Agent App turns mirror the agent_chat generator (conversation + message +queue + streamed response over the EasyUI chat pipeline), but the backingconfig comes from the bound Agent Soul and the answer is produced by``AgentAppRunner`` calling the dify-agent backend rather than an in-process-LLM/ReAct loop.--It also exposes a stateless build-finalize mode that reuses existing runtime-context from the bound debug conversation, triggers the Agent backend side-effect synchronously, and skips Dify-side chat/message persistence.+LLM/ReAct loop. Build-chat finalization uses this same streamed path and only+changes the runtime exit policy carried to the backend."""from __future__ import annotations@@ -41,13 +38,16 @@ from core.app.apps.exc import GenerateTaskStoppedErrorfrom core.app.apps.message_based_app_generator import MessageBasedAppGeneratorfrom core.app.apps.message_based_app_queue_manager import MessageBasedAppQueueManagerfrom core.app.entities.app_invoke_entities import (+ AGENT_RUNTIME_EXIT_INTENT_ARG,AgentAppGenerateEntity,+ AgentRuntimeExitIntent,DifyRunContext,InvokeFrom,UserFrom,)from core.app.llm.model_access import build_dify_model_accessfrom core.ops.ops_trace_manager import TraceQueueManager+from core.workflow.file_reference import build_file_reference, is_canonical_file_referencefrom extensions.ext_database import dbfrom models import Account, App, EndUser, Messagefrom models.agent import (@@ -64,12 +64,68 @@ from services.conversation_service import ConversationServicelogger = logging.getLogger(__name__)+_REFERENCE_FILE_TRANSFER_METHODS = {"local_file", "tool_file", "datasource_file"}+def _append_prompt_file_mappings(query: str, prompt_file_mappings: Sequence[JsonValue]) -> str:- """Append raw request file references to the backend user prompt."""- if not prompt_file_mappings:+ """Append labeled, prompt-safe file locators to the backend user prompt."""+ prompt_files = _prompt_file_locators(prompt_file_mappings)+ if not prompt_files:return query- return f"{query}\n{json.dumps(list(prompt_file_mappings), ensure_ascii=False)}"+ payload = json.dumps(prompt_files, ensure_ascii=False, separators=(",", ":"))+ return (+ f"{query}\n"+ "User provided files: use dify-agent file download with the listed transfer_method and reference/url "+ "to get the files and investigate them\n"+ f"{payload}"+ )+++def _prompt_file_locators(prompt_file_mappings: Sequence[JsonValue]) -> list[dict[str, str]]:+ locators: list[dict[str, str]] = []+ for file_mapping in prompt_file_mappings:+ if not isinstance(file_mapping, Mapping):+ continue+ locator = _prompt_file_locator(file_mapping)+ if locator is not None:+ locators.append(locator)+ return locators+++def _prompt_file_locator(file_mapping: Mapping[str, object]) -> dict[str, str] | None:+ transfer_method = _string_value(file_mapping, "transfer_method")+ if transfer_method == "remote_url":+ url = _string_value(file_mapping, "url") or _string_value(file_mapping, "remote_url")+ if url is None:+ return None+ return {"transfer_method": "remote_url", "url": url}+ elif transfer_method in _REFERENCE_FILE_TRANSFER_METHODS:+ if transfer_method is None:+ return None+ reference = _canonical_file_reference(+ _string_value(file_mapping, "reference")+ or _string_value(file_mapping, "upload_file_id")+ or _string_value(file_mapping, "file_id")+ or _string_value(file_mapping, "id")+ )+ if reference is None:+ return None+ return {"transfer_method": transfer_method, "reference": reference}+ else:+ return None+++def _canonical_file_reference(reference: str | None) -> str | None:+ if reference is None:+ return None+ if reference.startswith("dify-file-ref:"):+ return reference if is_canonical_file_reference(reference) else None+ return build_file_reference(record_id=reference)+++def _string_value(mapping: Mapping[str, object], key: str) -> str | None:+ value = mapping.get(key)+ return value if isinstance(value, str) and value else Noneclass AgentAppGenerator(MessageBasedAppGenerator):@@ -120,6 +176,7 @@ class AgentAppGenerator(MessageBasedAppGenerator):model_conf = ModelConfigConverter.convert(app_config)trace_manager = TraceQueueManager(app_model.id, user.id if isinstance(user, Account) else user.session_id)+ agent_runtime_exit_intent = self._resolve_agent_runtime_exit_intent(args)application_generate_entity = AgentAppGenerateEntity(task_id=str(uuid.uuid4()),@@ -149,6 +206,7 @@ class AgentAppGenerator(MessageBasedAppGenerator):agent_config_snapshot_id=agent_config_id,agent_config_version_kind=agent_config_version_kind,agent_runtime_session_snapshot_id=runtime_session_snapshot_id,+ agent_runtime_exit_intent=agent_runtime_exit_intent,)conversation, message = self._init_generate_records(application_generate_entity, conversation)@@ -187,86 +245,6 @@ class AgentAppGenerator(MessageBasedAppGenerator):)return AgentAppGenerateResponseConverter.convert(response=response, invoke_from=invoke_from)- def generate_stateless(- self,- *,- app_model: App,- user: Account | EndUser,- args: Mapping[str, Any],- invoke_from: InvokeFrom,- ) -> Mapping[str, Any]:- """Run one Agent App turn without persisting Dify conversation messages."""- query = self._require_query(args)- conversation_id = args.get("conversation_id")- if not isinstance(conversation_id, str) or not conversation_id:- raise AgentAppGeneratorError("conversation_id is required")-- agent, agent_config_id, agent_config_version_kind, agent_soul = self._resolve_agent(- app_model,- invoke_from=invoke_from,- draft_type=args.get("draft_type"),- user=user,- )- runtime_session_snapshot_id = self._runtime_session_snapshot_id(- invoke_from=invoke_from,- snapshot_id=agent_config_id,- )-- return self._run_stateless(- app_model=app_model,- user=user,- invoke_from=invoke_from,- query=query,- conversation_id=conversation_id,- agent=agent,- agent_config_id=agent_config_id,- agent_config_version_kind=agent_config_version_kind,- agent_soul=agent_soul,- runtime_session_snapshot_id=runtime_session_snapshot_id,- )-- def _run_stateless(- self,- *,- app_model: App,- user: Account | EndUser,- invoke_from: InvokeFrom,- query: str,- conversation_id: str,- agent: Agent,- agent_config_id: str,- agent_config_version_kind: Literal["snapshot", "draft", "build_draft"],- agent_soul: AgentSoulConfig,- runtime_session_snapshot_id: str | None,- ) -> Mapping[str, Any]:- """Run the Agent backend without creating or updating Dify chat records.-- Build-chat finalization is an action against the Agent backend (for- example, ``dify-agent config push``). It may reuse the active build-chat- runtime snapshot for shell/config context, but the API side must not add- a synthetic user/assistant turn to the debug conversation.- """-- dify_context = DifyRunContext(- tenant_id=app_model.tenant_id,- app_id=app_model.id,- user_id=user.id,- user_from=UserFrom.ACCOUNT if isinstance(user, Account) else UserFrom.END_USER,- invoke_from=invoke_from,- )- self._build_runner(dify_context).run_stateless(- dify_context=dify_context,- agent_id=agent.id,- agent_config_snapshot_id=agent_config_id,- agent_config_version_kind=agent_config_version_kind,- agent_soul=agent_soul,- conversation_id=conversation_id,- query=query,- idempotency_key=str(uuid.uuid4()),- session_scope_snapshot_id=runtime_session_snapshot_id,- )- return {"result": "success"}-def resume_after_form_submission(self,*,@@ -476,6 +454,7 @@ class AgentAppGenerator(MessageBasedAppGenerator):model_name=application_generate_entity.model_conf.model,queue_manager=queue_manager,session_scope_snapshot_id=application_generate_entity.agent_runtime_session_snapshot_id,+ agent_runtime_exit_intent=application_generate_entity.agent_runtime_exit_intent,)except GenerateTaskStoppedError:pass@@ -492,6 +471,18 @@ class AgentAppGenerator(MessageBasedAppGenerator):raise AgentAppGeneratorError("query is required")return query.replace("\x00", "")+ @staticmethod+ def _resolve_agent_runtime_exit_intent(args: Mapping[str, Any]) -> AgentRuntimeExitIntent:+ """Resolve API-internal runtime exit policy from controller-owned args.++ Only the private controller-injected "delete" value changes behavior.+ Normal chat and resume flows default/fallback to "suspend" so public+ payloads and invalid internal values preserve existing semantics.+ """+ if args.get(AGENT_RUNTIME_EXIT_INTENT_ARG) == "delete":+ return "delete"+ return "suspend"+@staticmethoddef _build_runner(dify_context: DifyRunContext) -> AgentAppRunner:credentials_provider, _ = build_dify_model_access(dify_context)diff --git a/api/core/app/apps/agent_app/app_runner.py b/api/core/app/apps/agent_app/app_runner.pyindex 8451ccebd4d..c6546cac569 100644--- a/api/core/app/apps/agent_app/app_runner.py+++ b/api/core/app/apps/agent_app/app_runner.py@@ -1,15 +1,10 @@-"""Agent App runner: drive Agent backend turns for both chat and finalize flows.+"""Agent App runner: drive Agent backend turns for chat and finalization flows.Unlike the legacy ``AgentChatAppRunner`` (which runs an in-process ReAct loop),-this runner delegates to the Agent backend and supports two execution modes.--- Normal chat turns build the run request from the Agent Soul + conversation,- consume backend stream events, republish the assistant answer through the- existing EasyUI chat task pipeline, and save the conversation- ``session_snapshot`` on success for multi-turn continuity (S3).-- Stateless build-finalize turns reuse any prior conversation snapshot only to- construct the backend request, wait synchronously for backend completion, and- intentionally do not persist Dify-side chat records or runtime-session state.+this runner delegates to the Agent backend, consumes the streamed event flow,+republishes the assistant answer through the existing EasyUI chat task+pipeline, and then either saves or retires the conversation-owned runtime+session depending on the turn's exit policy."""from __future__ import annotations@@ -26,6 +21,7 @@ from dify_agent.protocol import DeferredToolResultsPayloadfrom pydantic import JsonValuefrom clients.agent_backend import (+ AgentBackendAgentMessageDeltaInternalEvent,AgentBackendDeferredToolCallInternalEvent,AgentBackendError,AgentBackendInternalEventType,@@ -35,7 +31,7 @@ from clients.agent_backend import (AgentBackendStreamInternalEvent,extract_runtime_layer_specs,)-from configs import dify_config+from clients.agent_backend.session_cleanup import AgentBackendSessionCleanupPayloadfrom core.app.apps.agent_app.runtime_request_builder import (AgentAppRuntimeBuildContext,AgentAppRuntimeRequest,@@ -48,8 +44,13 @@ from core.app.apps.agent_app.session_store import ()from core.app.apps.base_app_queue_manager import AppQueueManager, PublishFromfrom core.app.apps.exc import GenerateTaskStoppedError-from core.app.entities.app_invoke_entities import DifyRunContext-from core.app.entities.queue_entities import QueueAgentThoughtEvent, QueueLLMChunkEvent, QueueMessageEndEvent+from core.app.entities.app_invoke_entities import AgentRuntimeExitIntent, DifyRunContext+from core.app.entities.queue_entities import (+ QueueAgentMessageEvent,+ QueueAgentThoughtEvent,+ QueueLLMChunkEvent,+ QueueMessageEndEvent,+)from core.repositories.human_input_repository import HumanInputFormRepository, HumanInputFormRepositoryImplfrom core.workflow.nodes.agent_v2.ask_human_hitl import AskHumanFormBuildError, create_ask_human_formfrom core.workflow.nodes.agent_v2.ask_human_resume import build_deferred_tool_results, resolve_ask_human_form@@ -59,6 +60,7 @@ from graphon.model_runtime.entities.message_entities import AssistantPromptMessafrom models.agent_config_entities import AgentSoulConfigfrom models.enums import CreatorUserRolefrom models.model import MessageAgentThought+from tasks.agent_backend_session_cleanup_task import cleanup_conversation_agent_runtime_sessionlogger = logging.getLogger(__name__)@@ -135,6 +137,25 @@ def publish_text_delta(queue_manager.publish(QueueLLMChunkEvent(chunk=chunk), PublishFrom.APPLICATION_MANAGER)+def publish_agent_message_delta(+ *,+ queue_manager: AppQueueManager,+ model_name: str,+ delta: str,+ user_query: str | None = None,+) -> None:+ """Publish one agent-process text delta through the EasyUI chat pipeline."""+ if not delta:+ return+ prompt_messages = _prompt_messages_from_query(user_query)+ chunk = LLMResultChunk(+ model=model_name,+ prompt_messages=prompt_messages,+ delta=LLMResultChunkDelta(index=0, message=AssistantPromptMessage(content=delta)),+ )+ queue_manager.publish(QueueAgentMessageEvent(chunk=chunk), PublishFrom.APPLICATION_MANAGER)++def publish_message_end(*,queue_manager: AppQueueManager,@@ -159,7 +180,7 @@ def publish_message_end(class _TextDeltaDebouncer:- """Batch assistant text deltas on stream-event boundaries for final SSE output."""+ """Batch independent model text deltas before agent-message SSE output."""def __init__(self, *, debounce_seconds: float) -> None:self._debounce_seconds = debounce_seconds@@ -192,7 +213,13 @@ class _TextDeltaDebouncer:class _AgentProcessRecorder:- """Persist Agent v2 thinking/tool process events through the legacy thought model."""+ """Persist Agent v2 process streams through the legacy thought model.++ Thinking and answer rows expose snapshot updates for contiguous model-text+ segments. Tool events close currently open text segments so later model text+ starts a fresh row instead of replaying content that was already streamed+ before the tool.+ """def __init__(self,@@ -206,6 +233,7 @@ class _AgentProcessRecorder:self._queue_manager = queue_managerself._next_position = 1self._thinking_by_index: dict[int, str] = {}+ self._answer_thought_id: str | None = Noneself._tool_by_index: dict[int, str] = {}self._tool_by_call_id: dict[str, str] = {}self._open_tool_by_name: dict[str, set[str]] = {}@@ -261,6 +289,41 @@ class _AgentProcessRecorder:if part_kind in {"tool-return", "builtin-tool-return"}:self._record_tool_return_part(part)+ def append_answer_text(self, content_delta: str) -> None:+ if not content_delta:+ return++ self._thinking_by_index.clear()+ if self._answer_thought_id is None:+ self._answer_thought_id = self._create_thought(answer=content_delta)+ return+ self._update_thought(self._answer_thought_id, answer_delta=content_delta)++ def trim_answer_suffix(self, final_answer: str) -> None:+ if not final_answer or self._answer_thought_id is None:+ return++ row = db.session.get(MessageAgentThought, self._answer_thought_id)+ if row is None:+ return++ answer = row.answer or ""+ overlap = _suffix_prefix_overlap_length(answer, final_answer)+ if overlap == 0:+ return++ row.answer = answer[:-overlap]+ if _is_empty_answer_only_thought(row):+ db.session.delete(row)+ self._answer_thought_id = None+ db.session.commit()+ return++ db.session.commit()+ self._queue_manager.publish(+ QueueAgentThoughtEvent(agent_thought_id=self._answer_thought_id), PublishFrom.APPLICATION_MANAGER+ )+def _handle_tool_call_event(self, data: dict[str, Any]) -> None:part = data.get("part")if isinstance(part, dict):@@ -281,6 +344,7 @@ class _AgentProcessRecorder:)def _append_thinking(self, index: int, content_delta: str) -> None:+ self._answer_thought_id = Nonethought_id = self._thinking_by_index.get(index)if thought_id is None:thought_id = self._create_thought(thought=content_delta)@@ -289,6 +353,7 @@ class _AgentProcessRecorder:self._update_thought(thought_id, thought_delta=content_delta)def _record_tool_call_delta(self, index: int, delta: dict[str, Any]) -> None:+ self._close_thinking_segments()tool_call_id = _string_or_none(delta.get("tool_call_id"))tool_name = _string_or_none(delta.get("tool_name_delta"))args_delta = delta.get("args_delta")@@ -305,8 +370,10 @@ class _AgentProcessRecorder:tool=tool_name,tool_input_delta=_json_or_text(args_delta),)+ self._remember_tool_thought(index=index, tool_call_id=tool_call_id, tool_name=tool_name, thought_id=thought_id)def _record_tool_call_part(self, index: int, part: dict[str, Any]) -> None:+ self._close_thinking_segments()tool_call_id = _string_or_none(part.get("tool_call_id"))tool_name = _string_or_none(part.get("tool_name"))thought_id = self._lookup_tool_thought(index=index, tool_call_id=tool_call_id)@@ -322,8 +389,10 @@ class _AgentProcessRecorder:tool=tool_name,tool_input=_json_or_text(part.get("args")),)+ self._remember_tool_thought(index=index, tool_call_id=tool_call_id, tool_name=tool_name, thought_id=thought_id)def _record_tool_return_part(self, part: dict[str, Any]) -> None:+ self._close_thinking_segments()tool_call_id = _string_or_none(part.get("tool_call_id"))tool_name = _string_or_none(part.get("tool_name"))content = part.get("content")@@ -332,6 +401,7 @@ class _AgentProcessRecorder:self._record_tool_observation(tool_call_id=tool_call_id, tool_name=tool_name, observation=content)def _record_tool_observation(self, *, tool_call_id: str | None, tool_name: str | None, observation: Any) -> None:+ self._close_thinking_segments()thought_id = self._lookup_observation_thought(tool_call_id=tool_call_id, tool_name=tool_name)if thought_id is None:thought_id = self._create_thought(tool=tool_name)@@ -366,8 +436,17 @@ class _AgentProcessRecorder:for open_thought_ids in self._open_tool_by_name.values():open_thought_ids.discard(thought_id)+ def _close_thinking_segments(self) -> None:+ self._thinking_by_index.clear()+ self._answer_thought_id = None+def _create_thought(- self, *, thought: str | None = None, tool: str | None = None, tool_input: str | None = None+ self,+ *,+ thought: str | None = None,+ answer: str | None = None,+ tool: str | None = None,+ tool_input: str | None = None,) -> str:row = MessageAgentThought(message_id=self._message_id,@@ -384,7 +463,7 @@ class _AgentProcessRecorder:message_unit_price=Decimal(0),message_price_unit=Decimal("0.001"),message_files="",- answer="",+ answer=answer or "",answer_token=0,answer_unit_price=Decimal(0),answer_price_unit=Decimal("0.001"),@@ -414,6 +493,7 @@ class _AgentProcessRecorder:tool_input: str | None = None,tool_input_delta: str | None = None,observation: str | None = None,+ answer_delta: str | None = None,) -> None:row = db.session.get(MessageAgentThought, thought_id)if row is None:@@ -430,6 +510,8 @@ class _AgentProcessRecorder:row.tool_input = f"{row.tool_input or ''}{tool_input_delta}"if observation is not None:row.observation = observation+ if answer_delta:+ row.answer = f"{row.answer or ''}{answer_delta}"db.session.commit()self._queue_manager.publish(@@ -468,6 +550,18 @@ def _tool_labels(tool: str | None) -> str:return json.dumps({tool: {"en_US": tool, "zh_Hans": tool}}, ensure_ascii=False)+def _suffix_prefix_overlap_length(text: str, prefix_source: str) -> int:+ max_length = min(len(text), len(prefix_source))+ for length in range(max_length, 0, -1):+ if text.endswith(prefix_source[:length]):+ return length+ return 0+++def _is_empty_answer_only_thought(row: MessageAgentThought) -> bool:+ return not any((row.thought, row.answer, row.tool, row.tool_input, row.observation))++class AgentAppRunner:"""Runs one Agent App conversation turn against the Agent backend."""@@ -500,7 +594,9 @@ class AgentAppRunner:model_name: str,queue_manager: AppQueueManager,session_scope_snapshot_id: str | None | _DefaultSessionScopeSnapshotId = _DEFAULT_SESSION_SCOPE_SNAPSHOT_ID,+ agent_runtime_exit_intent: AgentRuntimeExitIntent = "suspend",) -> None:+ preserve_session = agent_runtime_exit_intent == "suspend"scope = self._build_session_scope(dify_context=dify_context,agent_id=agent_id,@@ -522,10 +618,11 @@ class AgentAppRunner:idempotency_key=message_id,stored=stored,message_id=message_id,+ suspend_on_exit=preserve_session,)create_response = self._agent_backend_client.create_run(runtime.request)- terminal, streamed_answer = self._consume_stream(+ terminal, process_recorder = self._consume_stream(create_response.run_id,dify_context=dify_context,message_id=message_id,@@ -535,6 +632,9 @@ class AgentAppRunner:)if isinstance(terminal, AgentBackendDeferredToolCallInternalEvent):+ if not preserve_session:+ self._mark_session_cleaned(scope=scope, backend_run_id=terminal.run_id)+ raise AgentBackendError("Agent App finalization cannot pause for human input.")# ENG-635: the agent asked a human. End this turn with the question and# a conversation-owned HITL form; a form submission resumes the run.self._pause_for_ask_human(@@ -555,70 +655,49 @@ class AgentAppRunner:error = getattr(terminal, "error", None) or "Agent backend run did not complete successfully."raise AgentBackendError(str(error))- answer = self._extract_answer(terminal.output)- self._publish_terminal_answer(- queue_manager=queue_manager,- model_name=model_name,- answer=answer,- query=query,- streamed_answer=streamed_answer,- usage=_llm_usage_from_agent_backend(terminal.usage),- )- self._save_session(- scope=scope,- backend_run_id=terminal.run_id,- snapshot=terminal.session_snapshot,- runtime_layer_specs=extract_runtime_layer_specs(runtime.request.composition),- )-- def run_stateless(- self,- *,- dify_context: DifyRunContext,- agent_id: str,- agent_config_snapshot_id: str,- agent_config_version_kind: Literal["snapshot", "draft", "build_draft"] = "snapshot",- agent_soul: AgentSoulConfig,- conversation_id: str,- query: str,- idempotency_key: str,- session_scope_snapshot_id: str | None | _DefaultSessionScopeSnapshotId = _DEFAULT_SESSION_SCOPE_SNAPSHOT_ID,- ) -> None:- """Run the Agent backend without creating Dify chat message records.-- This path is used by build-chat finalization: the API must trigger the- backend side effects in the existing conversation session, but it must- not persist a synthetic user/assistant turn, update API-side runtime- session rows, or set up HITL state that depends on one.- """- scope = self._build_session_scope(- dify_context=dify_context,- agent_id=agent_id,- agent_config_snapshot_id=agent_config_snapshot_id,- conversation_id=conversation_id,- session_scope_snapshot_id=session_scope_snapshot_id,- )- runtime = self._build_runtime(- dify_context=dify_context,- agent_id=agent_id,- agent_config_snapshot_id=agent_config_snapshot_id,- agent_config_version_kind=agent_config_version_kind,- agent_soul=agent_soul,- conversation_id=conversation_id,- query=query,- idempotency_key=idempotency_key,- stored=self._session_store.load_active_session(scope),- message_id=None,- )-- create_response = self._agent_backend_client.create_run(runtime.request)- status = self._agent_backend_client.wait_run(- create_response.run_id,- timeout_seconds=dify_config.APP_MAX_EXECUTION_TIME,- )- if status.status != "succeeded":- error = getattr(status, "error", None) or f"Agent backend run ended with status {status.status}."- raise AgentBackendError(str(error))+ answer = self._terminal_output_to_answer(terminal.output)+ try:+ process_recorder.trim_answer_suffix(answer)+ except Exception:+ db.session.rollback()+ logger.warning(+ "Failed to trim Agent App answer text: run_id=%s message_id=%s",+ terminal.run_id,+ message_id,+ exc_info=True,+ )+ if preserve_session:+ superseded_sessions = self._load_superseded_sessions(scope=scope)+ self._publish_terminal_answer(+ queue_manager=queue_manager,+ model_name=model_name,+ answer=answer,+ query=query,+ usage=_llm_usage_from_agent_backend(terminal.usage),+ )+ session_saved = self._save_session(+ scope=scope,+ backend_run_id=terminal.run_id,+ snapshot=terminal.session_snapshot,+ runtime_layer_specs=extract_runtime_layer_specs(runtime.request.composition),+ )+ if session_saved:+ self._cleanup_superseded_sessions(superseded_sessions)+ else:+ # The backend has already accepted a terminal success with+ # delete-on-exit semantics. Local publish/persistence errors must+ # not keep the API-side session row active, and cleanup failures+ # must not replace the original publish/error outcome.+ try:+ self._publish_terminal_answer(+ queue_manager=queue_manager,+ model_name=model_name,+ answer=answer,+ query=query,+ usage=_llm_usage_from_agent_backend(terminal.usage),+ )+ finally:+ self._mark_session_cleaned(scope=scope, backend_run_id=terminal.run_id)def _build_session_scope(self,@@ -654,6 +733,7 @@ class AgentAppRunner:idempotency_key: str,stored: StoredAgentAppSession | None,message_id: str | None,+ suspend_on_exit: bool,) -> AgentAppRuntimeRequest:session_snapshot = stored.session_snapshot if stored is not None else Nonedeferred_tool_results = (@@ -673,6 +753,7 @@ class AgentAppRunner:idempotency_key=idempotency_key,session_snapshot=session_snapshot,deferred_tool_results=deferred_tool_results,+ suspend_on_exit=suspend_on_exit,))@@ -775,46 +856,61 @@ class AgentAppRunner:model_name: str,query: str | None,):- """Consume backend events while preserving raw recorder granularity.-- Process events are recorded immediately for observability. Only the- final assistant text deltas sent through the EasyUI queue are debounced,- with flushes happening on later stream events or terminal boundaries.- """+ """Consume backend events while preserving raw recorder granularity."""terminal = None- streamed_answer_parts: list[str] = []- text_delta_debouncer = _TextDeltaDebouncer(debounce_seconds=self._text_delta_debounce_seconds)process_recorder = _AgentProcessRecorder(dify_context=dify_context,message_id=message_id,queue_manager=queue_manager,)+ text_delta_debouncer = _TextDeltaDebouncer(debounce_seconds=self._text_delta_debounce_seconds)- def flush_pending_text() -> None:+ def persist_answer_text(content_delta: str) -> None:+ try:+ process_recorder.append_answer_text(content_delta)+ except Exception:+ db.session.rollback()+ logger.warning(+ "Failed to persist Agent App answer text: run_id=%s message_id=%s",+ run_id,+ message_id,+ exc_info=True,+ )+ publish_agent_message_delta(+ queue_manager=queue_manager,+ model_name=model_name,+ delta=content_delta,+ user_query=query,+ )++ def flush_pending_agent_message_text() -> None:pending_text = text_delta_debouncer.flush()if pending_text:- publish_text_delta(- queue_manager=queue_manager,- model_name=model_name,- delta=pending_text,- user_query=query,- )+ persist_answer_text(pending_text)for public_event in self._agent_backend_client.stream_events(run_id):if queue_manager.is_stopped():- flush_pending_text()+ flush_pending_agent_message_text()self._cancel_run(run_id)raise GenerateTaskStoppedError()for internal_event in self._event_adapter.adapt(public_event):if queue_manager.is_stopped():- flush_pending_text()+ flush_pending_agent_message_text()self._cancel_run(run_id)raise GenerateTaskStoppedError()if internal_event.type in (AgentBackendInternalEventType.RUN_STARTED,AgentBackendInternalEventType.STREAM_EVENT,+ AgentBackendInternalEventType.AGENT_MESSAGE_DELTA,):+ if isinstance(internal_event, AgentBackendAgentMessageDeltaInternalEvent):+ debounced_delta = text_delta_debouncer.push(internal_event.delta)+ if debounced_delta:+ persist_answer_text(debounced_delta)+ continue+if isinstance(internal_event, AgentBackendStreamInternalEvent):+ flush_pending_agent_message_text()try:process_recorder.handle_stream_event(internal_event)except Exception:@@ -826,26 +922,15 @@ class AgentAppRunner:internal_event.event_kind,exc_info=True,)- text_delta = self._extract_stream_text_delta(internal_event)- if text_delta:- streamed_answer_parts.append(text_delta)- debounced_delta = text_delta_debouncer.push(text_delta)- if debounced_delta:- publish_text_delta(- queue_manager=queue_manager,- model_name=model_name,- delta=debounced_delta,- user_query=query,- )continuecontinue- flush_pending_text()+ flush_pending_agent_message_text()terminal = internal_eventbreakif terminal is not None:break- flush_pending_text()- return terminal, "".join(streamed_answer_parts)+ flush_pending_agent_message_text()+ return terminal, process_recorderdef _cancel_run(self, run_id: str) -> None:try:@@ -867,42 +952,15 @@ class AgentAppRunner:model_name: str,answer: str,query: str | None,- streamed_answer: str,usage: LLMUsage | None,) -> None:- """Finish a successful streamed turn without duplicating the final text."""- if not answer and streamed_answer:- answer = streamed_answer-- if not streamed_answer:- publish_text_answer(- queue_manager=queue_manager,- model_name=model_name,- answer=answer,- user_query=query,- usage=usage,- )- return-- if answer.startswith(streamed_answer):- publish_text_delta(- queue_manager=queue_manager,- model_name=model_name,- delta=answer[len(streamed_answer) :],- user_query=query,- )- elif answer != streamed_answer:- logger.warning(- "Agent App streamed answer does not match terminal output; "- "using terminal output for message persistence."- )-- publish_message_end(+ """Finish a successful turn from the backend terminal output."""+ publish_text_answer(queue_manager=queue_manager,model_name=model_name,answer=answer,- user_query=query,usage=usage,+ user_query=query,)def _save_session(@@ -914,7 +972,7 @@ class AgentAppRunner:runtime_layer_specs: Any,pending_form_id: str | None = None,pending_tool_call_id: str | None = None,- ) -> None:+ ) -> bool:try:self._session_store.save_active_snapshot(scope=scope,@@ -924,6 +982,7 @@ class AgentAppRunner:pending_form_id=pending_form_id,pending_tool_call_id=pending_tool_call_id,)+ return Trueexcept Exception:logger.warning("Failed to persist Agent App conversation session snapshot: "@@ -934,9 +993,91 @@ class AgentAppRunner:scope.agent_id,exc_info=True,)+ return False++ def _load_superseded_sessions(self, *, scope: AgentAppSessionScope) -> list[StoredAgentAppSession]:+ try:+ stored_sessions = self._session_store.list_active_sessions_for_conversation(+ tenant_id=scope.tenant_id,+ app_id=scope.app_id,+ conversation_id=scope.conversation_id,+ )+ except Exception:+ logger.warning(+ "Failed to load existing Agent App conversation sessions before snapshot save: "+ "tenant_id=%s app_id=%s conversation_id=%s agent_id=%s",+ scope.tenant_id,+ scope.app_id,+ scope.conversation_id,+ scope.agent_id,+ exc_info=True,+ )+ return []++ return [stored for stored in stored_sessions if stored.scope != scope]++ def _cleanup_superseded_sessions(self, stored_sessions: list[StoredAgentAppSession]) -> None:+ for stored_session in stored_sessions:+ try:+ if stored_session.runtime_layer_specs:+ payload = AgentBackendSessionCleanupPayload(+ session_snapshot=stored_session.session_snapshot,+ runtime_layer_specs=stored_session.runtime_layer_specs,+ idempotency_key=(+ f"{stored_session.scope.tenant_id}:{stored_session.scope.app_id}:"+ f"{stored_session.scope.conversation_id}:{stored_session.scope.agent_id}:"+ f"{stored_session.scope.agent_config_snapshot_id or 'no-config'}:"+ f"superseded-session-cleanup:{stored_session.backend_run_id or 'no-run'}"+ ),+ metadata={+ "tenant_id": stored_session.scope.tenant_id,+ "app_id": stored_session.scope.app_id,+ "conversation_id": stored_session.scope.conversation_id,+ "agent_id": stored_session.scope.agent_id,+ "agent_config_snapshot_id": stored_session.scope.agent_config_snapshot_id,+ "previous_agent_backend_run_id": stored_session.backend_run_id,+ },+ )+ cleanup_conversation_agent_runtime_session.delay(payload.model_dump(mode="json"))+ except Exception:+ logger.warning(+ "Failed to enqueue Agent backend cleanup for superseded Agent App session: "+ "tenant_id=%s app_id=%s conversation_id=%s agent_id=%s backend_run_id=%s",+ stored_session.scope.tenant_id,+ stored_session.scope.app_id,+ stored_session.scope.conversation_id,+ stored_session.scope.agent_id,+ stored_session.backend_run_id,+ exc_info=True,+ )++ def _mark_session_cleaned(+ self,+ *,+ scope: AgentAppSessionScope,+ backend_run_id: str,+ ) -> None:+ """Best-effort delete-on-exit cleanup for the API-side session row.++ Once the Agent backend reaches a terminal event, cleanup persistence+ must not replace the original publish/error outcome for that turn.+ """+ try:+ self._session_store.mark_cleaned(scope=scope, backend_run_id=backend_run_id)+ except Exception:+ logger.warning(+ "Failed to retire Agent App conversation session after delete-on-exit: "+ "tenant_id=%s app_id=%s conversation_id=%s agent_id=%s backend_run_id=%s",+ scope.tenant_id,+ scope.app_id,+ scope.conversation_id,+ scope.agent_id,+ backend_run_id,+ exc_info=True,+ )@staticmethod- def _extract_answer(output: JsonValue) -> str:+ def _terminal_output_to_answer(output: JsonValue) -> str:"""Normalize the backend's terminal output to assistant text.Free-text Agent Apps return a plain string; if a structured output is@@ -954,27 +1095,5 @@ class AgentAppRunner:return json.dumps(output, ensure_ascii=False)return json.dumps(output, ensure_ascii=False)- @staticmethod- def _extract_stream_text_delta(event: AgentBackendStreamInternalEvent) -> str | None:- data = event.data- if not isinstance(data, dict):- return None-- if data.get("event_kind") == "part_delta":- delta = data.get("delta")- if isinstance(delta, dict) and delta.get("part_delta_kind") == "text":- content_delta = delta.get("content_delta")- if isinstance(content_delta, str):- return content_delta-- if data.get("event_kind") == "part_start":- part = data.get("part")- if isinstance(part, dict) and part.get("part_kind") == "text":- content = part.get("content")- if isinstance(content, str):- return content-- return None-__all__ = ["AgentAppRunner", "publish_message_end", "publish_text_answer", "publish_text_delta"]diff --git a/api/core/app/apps/agent_app/runtime_request_builder.py b/api/core/app/apps/agent_app/runtime_request_builder.pyindex fb1d054e750..c90ab77d681 100644--- a/api/core/app/apps/agent_app/runtime_request_builder.py+++ b/api/core/app/apps/agent_app/runtime_request_builder.py@@ -74,6 +74,7 @@ class AgentAppRuntimeBuildContext:session_snapshot: CompositorSessionSnapshot | None = None# ENG-638: set when resuming a chat turn after a submitted ask_human form.deferred_tool_results: DeferredToolResultsPayload | None = None+ suspend_on_exit: bool = True@dataclass(frozen=True, slots=True)@@ -163,6 +164,7 @@ class AgentAppRuntimeRequestBuilder:# no frontend-internal {{#…#}} marker ever reaches the model.agent_soul_prompt=expand_prompt_mentions(agent_soul.prompt.system_prompt, soul_prompt_resolver).strip()or None,+ agent_config_version_kind=context.agent_config_version_kind,user_prompt=context.user_query,tools=tool_layers.plugin_tools,core_tools=tool_layers.core_tools,@@ -173,6 +175,7 @@ class AgentAppRuntimeRequestBuilder:shell_config=build_shell_layer_config(agent_soul),session_snapshot=context.session_snapshot,deferred_tool_results=context.deferred_tool_results,+ suspend_on_exit=context.suspend_on_exit,idempotency_key=context.idempotency_key,metadata=metadata,)diff --git a/api/core/app/apps/agent_app/session_store.py b/api/core/app/apps/agent_app/session_store.pyindex 35213114e2f..7696155a1c4 100644--- a/api/core/app/apps/agent_app/session_store.py+++ b/api/core/app/apps/agent_app/session_store.py@@ -124,6 +124,41 @@ class AgentAppRuntimeSessionStore:runtime_layer_specs=_deserialize_runtime_layer_specs(row.composition_layer_specs),)+ def list_active_sessions_for_conversation(+ self, *, tenant_id: str, app_id: str, conversation_id: str+ ) -> list[StoredAgentAppSession]:+ """List all ACTIVE conversation-owned sessions for lifecycle cleanup."""+ stmt = (+ select(AgentRuntimeSession)+ .where(+ AgentRuntimeSession.owner_type == AgentRuntimeSessionOwnerType.CONVERSATION,+ AgentRuntimeSession.tenant_id == tenant_id,+ AgentRuntimeSession.app_id == app_id,+ AgentRuntimeSession.conversation_id == conversation_id,+ AgentRuntimeSession.status == AgentRuntimeSessionStatus.ACTIVE,+ )+ .order_by(AgentRuntimeSession.updated_at.desc())+ )+ with session_factory.create_session() as session:+ rows = session.scalars(stmt).all()+ return [+ StoredAgentAppSession(+ scope=AgentAppSessionScope(+ tenant_id=row.tenant_id,+ app_id=row.app_id,+ conversation_id=row.conversation_id or "",+ agent_id=row.agent_id,+ agent_config_snapshot_id=row.agent_config_snapshot_id,+ ),+ session_snapshot=CompositorSessionSnapshot.model_validate_json(row.session_snapshot),+ backend_run_id=row.backend_run_id,+ runtime_layer_specs=_deserialize_runtime_layer_specs(row.composition_layer_specs),+ pending_form_id=row.pending_form_id,+ pending_tool_call_id=row.pending_tool_call_id,+ )+ for row in rows+ ]+def save_active_snapshot(self,*,@@ -134,6 +169,14 @@ class AgentAppRuntimeSessionStore:pending_form_id: str | None = None,pending_tool_call_id: str | None = None,) -> None:+ """Persist the current conversation snapshot and enforce one ACTIVE row.++ Agent App chat treats one conversation as one resumable runtime shell.+ Saving the latest snapshot therefore upserts the scoped row back to+ ACTIVE and retires any other ACTIVE conversation-owned rows for the+ same ``tenant_id + app_id + conversation_id`` so later lookups see a+ single active session.+ """if snapshot is None:returnsnapshot_json = snapshot.model_dump_json()diff --git a/api/core/app/entities/app_invoke_entities.py b/api/core/app/entities/app_invoke_entities.pyindex 690f23c8302..b5f7515cd9f 100644--- a/api/core/app/entities/app_invoke_entities.py+++ b/api/core/app/entities/app_invoke_entities.py@@ -15,6 +15,8 @@ if TYPE_CHECKING:DIFY_RUN_CONTEXT_KEY = "_dify"+AGENT_RUNTIME_EXIT_INTENT_ARG = "_agent_runtime_exit_intent"+type AgentRuntimeExitIntent = Literal["suspend", "delete"]class UserFrom(StrEnum):@@ -228,6 +230,10 @@ class AgentAppGenerateEntity(ChatAppGenerateEntity):``agent_runtime_session_snapshot_id`` carries the runtime session scopeused to resume or suspend within the same editable config surface.+ ``agent_runtime_exit_intent`` is API-internal lifecycle policy for the+ Agent backend session after this turn finishes. Normal chat/resume turns+ suspend on exit; build-chat finalization deletes the backend runtime.+``prompt_file_mappings`` preserves the raw request ``files`` array for theAgent backend prompt. These references are appended to the backend prompttext while the stored chat message keeps the user's original query.@@ -237,6 +243,7 @@ class AgentAppGenerateEntity(ChatAppGenerateEntity):agent_config_snapshot_id: stragent_config_version_kind: Literal["snapshot", "draft", "build_draft"] = "snapshot"agent_runtime_session_snapshot_id: str | None = None+ agent_runtime_exit_intent: AgentRuntimeExitIntent = "suspend"prompt_file_mappings: Sequence[JsonValue] = Field(default_factory=list)diff --git a/api/core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py b/api/core/app/task_pipeline/easy_ui_based_generate_task_pipeline.pyindex b7b3c8b0005..c4224d67442 100644--- a/api/core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py+++ b/api/core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py@@ -309,32 +309,20 @@ class EasyUIBasedGenerateTaskPipeline(BasedGenerateTaskPipeline[EasyUIAppGeneratresponse = self._message_cycle_manager.message_file_to_stream_response(event)if response:yield response- case QueueLLMChunkEvent() | QueueAgentMessageEvent():+ case QueueAgentMessageEvent():chunk = event.chunk- delta_content = chunk.delta.message.content- if delta_content is None:+ delta_text = self._chunk_delta_text(chunk)+ if delta_text is None:+ continue+ yield self._agent_message_to_stream_response(+ answer=delta_text,+ message_id=self._message_id,+ )+ case QueueLLMChunkEvent():+ chunk = event.chunk+ delta_text = self._chunk_delta_text(chunk)+ if delta_text is None:continue- if isinstance(delta_content, list):- # EasyUI streams text only; structured multimodal chunks contribute their text parts.- delta_text = ""- for content in delta_content:- logger.debug(- "The content type %s in LLM chunk delta message content.: %r", type(content), content- )- match content:- case TextPromptMessageContent():- delta_text += content.data- case str():- delta_text += content # failback to str- case _:- logger.warning(- "Unsupported content type %s in LLM chunk delta message content.: %r",- type(content),- content,- )- continue- else:- delta_text = delta_contentif not self._task_state.llm_result.prompt_messages:self._task_state.llm_result.prompt_messages = chunk.prompt_messages@@ -348,23 +336,16 @@ class EasyUIBasedGenerateTaskPipeline(BasedGenerateTaskPipeline[EasyUIAppGeneratcurrent_content += delta_textself._task_state.llm_result.message.content = current_content- match event:- case QueueLLMChunkEvent():- # Determine the event type once, on first LLM chunk, and reuse for subsequent chunks- if not hasattr(self, "_precomputed_event_type") or self._precomputed_event_type is None:- self._precomputed_event_type = self._message_cycle_manager.get_message_event_type(- message_id=self._message_id- )- yield self._message_cycle_manager.message_to_stream_response(- answer=delta_text,- message_id=self._message_id,- event_type=self._precomputed_event_type,- )- case _:- yield self._agent_message_to_stream_response(- answer=delta_text,- message_id=self._message_id,- )+ # Determine the event type once, on first LLM chunk, and reuse for subsequent chunks+ if not hasattr(self, "_precomputed_event_type") or self._precomputed_event_type is None:+ self._precomputed_event_type = self._message_cycle_manager.get_message_event_type(+ message_id=self._message_id+ )+ yield self._message_cycle_manager.message_to_stream_response(+ answer=delta_text,+ message_id=self._message_id,+ event_type=self._precomputed_event_type,+ )case QueueMessageReplaceEvent():yield self._message_cycle_manager.message_replace_to_stream_response(answer=event.text)case QueuePingEvent():@@ -376,6 +357,32 @@ class EasyUIBasedGenerateTaskPipeline(BasedGenerateTaskPipeline[EasyUIAppGeneratif self._conversation_name_generate_thread:logger.debug("Conversation name generation running as daemon thread")+ @staticmethod+ def _chunk_delta_text(chunk: LLMResultChunk) -> str | None:+ delta_content = chunk.delta.message.content+ if delta_content is None:+ return None+ if not isinstance(delta_content, list):+ return delta_content++ delta_text = ""+ # EasyUI streams text only; structured multimodal chunks contribute their text parts.+ for content in delta_content:+ logger.debug("The content type %s in LLM chunk delta message content.: %r", type(content), content)+ match content:+ case TextPromptMessageContent():+ delta_text += content.data+ case str():+ delta_text += content+ case _:+ logger.warning(+ "Unsupported content type %s in LLM chunk delta message content.: %r",+ type(content),+ content,+ )+ continue+ return delta_text+def _save_message(self, *, session: Session, trace_manager: TraceQueueManager | None = None):"""Save message.diff --git a/api/core/workflow/nodes/agent_v2/agent_node.py b/api/core/workflow/nodes/agent_v2/agent_node.pyindex 41778a0ba50..8e27cf63da4 100644--- a/api/core/workflow/nodes/agent_v2/agent_node.py+++ b/api/core/workflow/nodes/agent_v2/agent_node.py@@ -16,6 +16,7 @@ from clients.agent_backend import (AgentBackendRunEventAdapter,AgentBackendRunFailedInternalEvent,AgentBackendRunSucceededInternalEvent,+ AgentBackendSessionCleanupPayload,AgentBackendStreamError,AgentBackendStreamInternalEvent,AgentBackendTransportError,@@ -34,6 +35,7 @@ from graphon.node_events import NodeEventBase, NodeRunResult, PauseRequestedEvenfrom graphon.nodes.base.node import Nodefrom models.agent_config_entities import AgentSoulConfig, WorkflowNodeJobConfigfrom services.agent.prompt_mentions import extract_workflow_node_output_selectors+from tasks.agent_backend_session_cleanup_task import cleanup_workflow_agent_runtime_sessionfrom .ask_human_hitl import AskHumanFormBuildError, build_ask_human_pause_reasonfrom .ask_human_resume import build_deferred_tool_results, resolve_ask_human_form@@ -609,6 +611,44 @@ class DifyAgentNode(Node[DifyAgentNodeData]):) -> None:if self._session_store is None:return+ stored_session = self._session_store.load_active_session(session_scope)+ try:+ if stored_session is not None and stored_session.runtime_layer_specs:+ payload = AgentBackendSessionCleanupPayload(+ session_snapshot=stored_session.session_snapshot,+ runtime_layer_specs=stored_session.runtime_layer_specs,+ idempotency_key=(+ f"{session_scope.tenant_id}:{session_scope.workflow_run_id}:{session_scope.node_id}:"+ f"{session_scope.binding_id}:workflow-agent-failure-cleanup:"+ f"{stored_session.backend_run_id or 'no-stored-run'}:{backend_run_id}"+ ),+ metadata={+ "tenant_id": session_scope.tenant_id,+ "app_id": session_scope.app_id,+ "workflow_id": session_scope.workflow_id,+ "workflow_run_id": session_scope.workflow_run_id,+ "node_id": session_scope.node_id,+ "node_execution_id": session_scope.node_execution_id,+ "binding_id": session_scope.binding_id,+ "agent_id": session_scope.agent_id,+ "agent_config_snapshot_id": session_scope.agent_config_snapshot_id,+ "previous_agent_backend_run_id": stored_session.backend_run_id,+ "failed_agent_backend_run_id": backend_run_id,+ },+ )+ cleanup_workflow_agent_runtime_session.delay(payload.model_dump(mode="json"))+ except Exception:+ logger.warning(+ "Failed to enqueue workflow Agent backend cleanup on agent run failure: "+ "tenant_id=%s workflow_run_id=%s node_id=%s binding_id=%s agent_id=%s backend_run_id=%s",+ session_scope.tenant_id,+ session_scope.workflow_run_id,+ session_scope.node_id,+ session_scope.binding_id,+ session_scope.agent_id,+ backend_run_id,+ exc_info=True,+ )try:self._session_store.mark_cleaned(scope=session_scope, backend_run_id=backend_run_id)agent_backend = dict(metadata.get("agent_backend") or {})diff --git a/api/core/workflow/nodes/agent_v2/runtime_request_builder.py b/api/core/workflow/nodes/agent_v2/runtime_request_builder.pyindex 5301da9805d..3afa740e545 100644--- a/api/core/workflow/nodes/agent_v2/runtime_request_builder.py+++ b/api/core/workflow/nodes/agent_v2/runtime_request_builder.py@@ -454,7 +454,7 @@ class WorkflowAgentRuntimeRequestBuilder:def _resolve_prompt_payload_value(cls, value: Any) -> tuple[Any, bool]:# File-valued workflow context must surface as Agent Stub download# mappings so the model can materialize those inputs with- # `dify-agent file download --mapping ...` inside the sandbox.+ # `dify-agent file download TRANSFER_METHOD REFERENCE_OR_URL` inside the sandbox.download_mapping = cls._agent_stub_download_mapping(value)if download_mapping is not None:return download_mapping, True@@ -499,7 +499,21 @@ class WorkflowAgentRuntimeRequestBuilder:return mapping.model_dump(mode="json", exclude_none=True)if isinstance(value, Mapping):- mapping = AgentStubFileMapping.model_validate(value)+ transfer_method = value.get("transfer_method")+ if not isinstance(transfer_method, str):+ return None+ if transfer_method == "remote_url":+ mapping = AgentStubFileMapping(+ transfer_method="remote_url",+ url=value.get("url") or value.get("remote_url"),+ )+ elif transfer_method in {"local_file", "tool_file", "datasource_file"}:+ mapping = AgentStubFileMapping(+ transfer_method=cast(AgentStubFileTransferMethod, transfer_method),+ reference=value.get("reference"),+ )+ else:+ return Nonereturn mapping.model_dump(mode="json", exclude_none=True)except ValidationError:return None@@ -600,11 +614,12 @@ class WorkflowAgentRuntimeRequestBuilder:broad generated schema but fails API-side output type checking.For files produced inside an Agent run, the supported persisted shape is- narrower than every downloadable mapping: the sandbox must upload the- local artifact via ``dify-agent file upload <path>``, which returns a- ``tool_file`` mapping. ``local_file`` and ``datasource_file`` are valid- for existing file references in workflow context, not for newly produced- Agent output files.+ narrower than the full CLI upload stdout: the sandbox must upload the+ local artifact via ``dify-agent file upload <path>``, then use the+ returned ``reference`` inside the accepted ``tool_file`` mapping shape+ for structured ``final_output``. ``local_file`` and ``datasource_file``+ are valid for existing file references in workflow context, not for+ newly produced Agent output files."""return {"title": "AgentStubFileMapping",@@ -659,9 +674,9 @@ class WorkflowAgentRuntimeRequestBuilder:if output.type == DeclaredOutputType.FILE:file_output_lines.append(f"- `{output.name}`: create the file in the sandbox, run `dify-agent file upload <path>`, "- f"and set `final_output.{output.name}` to the returned AgentStubFileMapping JSON object. "- "Do not call `final_output` before the upload command succeeds. Do not use the local path, "- "filename, URL, or a synthesized/base64-encoded value as the `reference`."+ f"then set `final_output.{output.name}` to a `tool_file` mapping using the returned "+ f"`reference`. Do not call `final_output` before the upload command succeeds. Do not use "+ "the local path, filename, URL, or a synthesized/base64-encoded value as the `reference`.")elif (output.type == DeclaredOutputType.ARRAY@@ -670,9 +685,9 @@ class WorkflowAgentRuntimeRequestBuilder:):file_output_lines.append(f"- `{output.name}`: for every produced file, run `dify-agent file upload <path>` and set "- f"`final_output.{output.name}` to an array of the returned AgentStubFileMapping JSON objects. "- "Do not call `final_output` before all upload commands succeed. Do not use local paths, filenames, "- "URLs, or synthesized/base64-encoded values as `reference` values."+ f"`final_output.{output.name}` to an array of `tool_file` mappings using the returned "+ f"`reference` values. Do not call `final_output` before all upload commands succeed. Do not use "+ "local paths, filenames, URLs, or synthesized/base64-encoded values as `reference` values.")if not file_output_lines:return None@@ -680,8 +695,12 @@ class WorkflowAgentRuntimeRequestBuilder:return "\n".join(["When filling file outputs, do not return a local filesystem path directly.",- "Upload each sandbox-local file through the Agent Stub CLI first. Copy the JSON printed by "- "`dify-agent file upload <path>` verbatim into the final output; never invent the `reference` value.",+ "Upload each sandbox-local file through the Agent Stub CLI first. For structured `final_output`, use "+ "only the accepted file-mapping shape and the returned `reference`; never invent the `reference` "+ "value.",+ "If you are replying to the user in natural language and want them to open or download the produced "+ "file, include the returned `download_url` in that reply instead of copying it into structured "+ "`final_output` unless the schema explicitly asks for it.",*file_output_lines,])@@ -779,6 +798,26 @@ def build_knowledge_layer_config(agent_soul: AgentSoulConfig) -> DifyKnowledgeBadef _knowledge_retrieval_config(retrieval: AgentKnowledgeRetrievalConfig) -> DifyKnowledgeRetrievalConfig:+ weights = None+ if retrieval.weights is not None:+ # The dify-agent runtime payload only consumes the nested vector/keyword+ # settings; ``weight_type`` is an API-side authoring detail and must not+ # leak into the inner request shape.+ weights = (+ cast(+ dict[str, Any],+ {+ key: value+ for key, value in {+ "vector_setting": retrieval.weights.vector_setting,+ "keyword_setting": retrieval.weights.keyword_setting,+ }.items()+ if value is not None+ },+ )+ or None+ )+return DifyKnowledgeRetrievalConfig(mode=retrieval.mode,top_k=retrieval.top_k,@@ -791,9 +830,7 @@ def _knowledge_retrieval_config(retrieval: AgentKnowledgeRetrievalConfig) -> Dif)if retrieval.reranking_model is not Noneelse None,- weights=cast(dict[str, Any], retrieval.weights.model_dump(mode="json", exclude_none=True))- if retrieval.weights is not None- else None,+ weights=weights,model=_knowledge_model_config(retrieval.model),)diff --git a/api/core/workflow/nodes/agent_v2/session_cleanup_layer.py b/api/core/workflow/nodes/agent_v2/session_cleanup_layer.pyindex 809f63b556f..c3a7c23a56c 100644--- a/api/core/workflow/nodes/agent_v2/session_cleanup_layer.py+++ b/api/core/workflow/nodes/agent_v2/session_cleanup_layer.py@@ -1,11 +1,11 @@+"""Workflow terminal layer that retires Agent backend sessions asynchronously."""+from __future__ import annotationsimport loggingfrom typing import override-from clients.agent_backend import AgentBackendError, AgentBackendRunClient, AgentBackendRunRequestBuilder-from clients.agent_backend.factory import create_agent_backend_run_client-from configs import dify_config+from clients.agent_backend import AgentBackendSessionCleanupPayloadfrom core.workflow.system_variables import SystemVariableKey, get_system_textfrom graphon.graph_engine.layers import GraphEngineLayerfrom graphon.graph_events import (@@ -15,56 +15,22 @@ from graphon.graph_events import (GraphRunPartialSucceededEvent,GraphRunSucceededEvent,)+from tasks.agent_backend_session_cleanup_task import cleanup_workflow_agent_runtime_sessionfrom .session_store import StoredWorkflowAgentSession, WorkflowAgentRuntimeSessionStorelogger = logging.getLogger(__name__)-# Upper bound on how long a cleanup-only run is allowed to settle before the-# layer gives up and leaves the row ACTIVE so it can be retried later. Cleanup-# work is mostly local agent-backend bookkeeping (no LLM inference), so 30s is-# generous; a hung backend should never block workflow termination beyond this.-_CLEANUP_WAIT_TIMEOUT_SECONDS = 30.0--class WorkflowAgentSessionCleanupLayer(GraphEngineLayer):- """Retires workflow Agent session snapshots when a workflow reaches a terminal state.-- Implementation notes — there are two failure modes the cleanup path has to- avoid simultaneously:-- 1. The agenton compositor on the agent-backend side validates the cleanup- request's session snapshot against the replayed composition before- running any lifecycle hook. If the snapshot's layer names diverge from- the composition, the run fails asynchronously with ``run_failed`` — but- the initial ``POST /runs`` already returned 202, so the API side has no- visibility of the failure unless it waits for terminal status. The- ``runtime_layer_specs`` persistence in A.1–A.4 plus the- ``_filter_snapshot_to_specs`` shape in ``build_cleanup_request`` keeps- the two name lists in sync.-- 2. The current agent backend's ``runner.py::_run_agent`` always invokes- ``run.get_layer("llm")`` and the structured-output / history validators- before exiting any slot — there is no ``purpose: "cleanup"`` branch- yet. A truly cleanup-only request (no LLM layer) therefore still- crashes inside the runner with ``Layer 'llm' is not defined in this- compositor run.``. Until the backend grows a cleanup-only purpose,- this layer **does not issue an HTTP cleanup run**: it simply retires- the local snapshot row so stale state cannot be re-resumed, and lets- the agent backend's own retention TTL release the suspended layers.-- The HTTP-cleanup machinery (``build_cleanup_request`` + ``wait_run``) is- intentionally still wired into the request builder + integration tests so- that when the agent backend supports cleanup runs we can flip the switch- here with a one-line change (see ``_HTTP_CLEANUP_SUPPORTED``).- """+ """Retire workflow-owned Agent runtime sessions when the workflow ends.- # Flip to True once dify-agent's runner has a ``purpose=cleanup`` branch- # that skips the LLM/output/user-prompt invariants. Until then we only- # update the local row; the spec list is still persisted so the future- # HTTP cleanup path has everything it needs.- _HTTP_CLEANUP_SUPPORTED: bool = False+ Workflow termination is a product-lifecycle boundary: once the run reaches a+ terminal graph event, the local session row must no longer be resumable. The+ actual Agent backend cleanup is therefore dispatched asynchronously with the+ persisted snapshot/specs payload, while the local row is marked CLEANED+ immediately afterwards regardless of enqueue outcome.+ """_TERMINAL_EVENTS = (GraphRunSucceededEvent,@@ -73,19 +39,9 @@ class WorkflowAgentSessionCleanupLayer(GraphEngineLayer):GraphRunAbortedEvent,)- def __init__(- self,- *,- session_store: WorkflowAgentRuntimeSessionStore,- request_builder: AgentBackendRunRequestBuilder,- agent_backend_client: AgentBackendRunClient | None,- cleanup_wait_timeout_seconds: float = _CLEANUP_WAIT_TIMEOUT_SECONDS,- ) -> None:+ def __init__(self, *, session_store: WorkflowAgentRuntimeSessionStore) -> None:super().__init__()self._session_store = session_store- self._request_builder = request_builder- self._agent_backend_client = agent_backend_client- self._cleanup_wait_timeout_seconds = cleanup_wait_timeout_seconds@overridedef on_graph_start(self) -> None:@@ -112,136 +68,59 @@ class WorkflowAgentSessionCleanupLayer(GraphEngineLayer):def _cleanup_session(self, stored_session: StoredWorkflowAgentSession) -> None:scope = stored_session.scope- if not self._HTTP_CLEANUP_SUPPORTED:- # Agent backend has no cleanup-only run mode yet (see class- # docstring). Retire the local row so future re-entries do not- # resume from stale state, and let the backend's retention TTL- # release the suspended layers on its own schedule.- logger.info(- "Workflow Agent session retired locally; HTTP cleanup is disabled "- "until the agent backend supports a cleanup-only run mode. "- "workflow_run_id=%s node_id=%s binding_id=%s agent_id=%s previous_run_id=%s",- scope.workflow_run_id,- scope.node_id,- scope.binding_id,- scope.agent_id,- stored_session.backend_run_id,- )- self._session_store.mark_cleaned(scope=scope, backend_run_id=stored_session.backend_run_id)- return-- if self._agent_backend_client is None:- # HTTP cleanup was enabled by the caller but no client was wired- # in (e.g. the API runs without AGENT_BACKEND_BASE_URL configured).- # Leave the row ACTIVE so an operator restart with proper config- # can drive the cleanup; do not silently retire it.- logger.warning(- "Skipping Agent backend cleanup: HTTP cleanup is enabled but no agent "- "backend client is wired in. workflow_run_id=%s node_id=%s agent_id=%s",- scope.workflow_run_id,- scope.node_id,- scope.agent_id,- )- return-- if not stored_session.runtime_layer_specs:- # Sessions persisted before A.1 landed do not carry the spec list,- # so we cannot replay a valid cleanup composition. Leave the row- # ACTIVE and warn so the absence shows up in observability rather- # than being silently swallowed by a doomed cleanup run.- logger.warning(- "Skipping Agent backend cleanup: no runtime_layer_specs persisted. "- "workflow_run_id=%s node_id=%s agent_id=%s",- scope.workflow_run_id,- scope.node_id,- scope.agent_id,- )- return-- request = self._request_builder.build_cleanup_request(- session_snapshot=stored_session.session_snapshot,- runtime_layer_specs=stored_session.runtime_layer_specs,- idempotency_key=f"{scope.workflow_run_id}:{scope.node_id}:{scope.binding_id}:agent-session-cleanup",- metadata={- "tenant_id": scope.tenant_id,- "app_id": scope.app_id,- "workflow_id": scope.workflow_id,- "workflow_run_id": scope.workflow_run_id,- "node_id": scope.node_id,- "node_execution_id": scope.node_execution_id,- "binding_id": scope.binding_id,- "agent_id": scope.agent_id,- "agent_config_snapshot_id": scope.agent_config_snapshot_id,- "previous_agent_backend_run_id": stored_session.backend_run_id,- },- )try:- response = self._agent_backend_client.create_run(request)- except AgentBackendError:+ if stored_session.runtime_layer_specs:+ payload = AgentBackendSessionCleanupPayload(+ session_snapshot=stored_session.session_snapshot,+ runtime_layer_specs=stored_session.runtime_layer_specs,+ idempotency_key=f"{scope.workflow_run_id}:{scope.node_id}:{scope.binding_id}:agent-session-cleanup",+ metadata={+ "tenant_id": scope.tenant_id,+ "app_id": scope.app_id,+ "workflow_id": scope.workflow_id,+ "workflow_run_id": scope.workflow_run_id,+ "node_id": scope.node_id,+ "node_execution_id": scope.node_execution_id,+ "binding_id": scope.binding_id,+ "agent_id": scope.agent_id,+ "agent_config_snapshot_id": scope.agent_config_snapshot_id,+ "previous_agent_backend_run_id": stored_session.backend_run_id,+ },+ )+ cleanup_workflow_agent_runtime_session.delay(payload.model_dump(mode="json"))+ else:+ logger.warning(+ "Skipping workflow Agent backend cleanup enqueue: no runtime_layer_specs persisted. "+ "workflow_run_id=%s node_id=%s agent_id=%s",+ scope.workflow_run_id,+ scope.node_id,+ scope.agent_id,+ )+ except Exception:logger.warning(- "Agent backend session cleanup request failed: workflow_run_id=%s node_id=%s agent_id=%s",+ "Failed to enqueue workflow Agent backend cleanup: "+ "workflow_run_id=%s node_id=%s agent_id=%s previous_run_id=%s",scope.workflow_run_id,scope.node_id,scope.agent_id,+ stored_session.backend_run_id,exc_info=True,)- return-- try:- status_response = self._agent_backend_client.wait_run(- response.run_id, timeout_seconds=self._cleanup_wait_timeout_seconds- )- except AgentBackendError:- logger.warning(- "Agent backend session cleanup wait_run failed: "- "workflow_run_id=%s node_id=%s agent_id=%s cleanup_run_id=%s",- scope.workflow_run_id,- scope.node_id,- scope.agent_id,- response.run_id,- exc_info=True,- )- return-- if status_response.status != "succeeded":- logger.warning(- "Agent backend session cleanup did not succeed: status=%s error=%s "- "workflow_run_id=%s node_id=%s agent_id=%s cleanup_run_id=%s",- status_response.status,- status_response.error,- scope.workflow_run_id,- scope.node_id,- scope.agent_id,- response.run_id,- )- return-- self._session_store.mark_cleaned(scope=scope, backend_run_id=response.run_id)+ finally:+ try:+ self._session_store.mark_cleaned(scope=scope, backend_run_id=stored_session.backend_run_id)+ except Exception:+ logger.warning(+ "Failed to retire workflow Agent runtime session after cleanup enqueue: "+ "workflow_run_id=%s node_id=%s agent_id=%s previous_run_id=%s",+ scope.workflow_run_id,+ scope.node_id,+ scope.agent_id,+ stored_session.backend_run_id,+ exc_info=True,+ )def build_workflow_agent_session_cleanup_layer() -> WorkflowAgentSessionCleanupLayer:- """Wire the cleanup layer with the standard production dependencies.-- The agent backend client is constructed only when ``AGENT_BACKEND_BASE_URL``- is configured (or the deterministic fake is explicitly enabled). When- neither is set — for example unit tests that bring up the workflow runner- without an Agent node — we pass ``None`` so the layer stays harmless. With- ``_HTTP_CLEANUP_SUPPORTED = False`` the local-retire branch never touches- the client anyway, but keeping it ``None`` avoids importing httpx and lets- test harnesses skip backend configuration.- """- agent_backend_client: AgentBackendRunClient | None- if dify_config.AGENT_BACKEND_USE_FAKE or dify_config.AGENT_BACKEND_BASE_URL:- agent_backend_client = create_agent_backend_run_client(- base_url=dify_config.AGENT_BACKEND_BASE_URL,- use_fake=dify_config.AGENT_BACKEND_USE_FAKE,- fake_scenario=dify_config.AGENT_BACKEND_FAKE_SCENARIO,- )- else:- agent_backend_client = None-- return WorkflowAgentSessionCleanupLayer(- session_store=WorkflowAgentRuntimeSessionStore(),- request_builder=AgentBackendRunRequestBuilder(),- agent_backend_client=agent_backend_client,- )+ """Wire the cleanup layer with the standard workflow-owned session store."""+ return WorkflowAgentSessionCleanupLayer(session_store=WorkflowAgentRuntimeSessionStore())diff --git a/api/fields/conversation_fields.py b/api/fields/conversation_fields.pyindex d256ad96cf0..72eec3f1c7d 100644--- a/api/fields/conversation_fields.py+++ b/api/fields/conversation_fields.py@@ -110,6 +110,7 @@ class AgentThought(ResponseModel):message_id: strposition: intthought: str | None = None+ answer: str | None = Nonetool: str | None = Nonetool_labels: JSONValuetool_input: str | None = Nonediff --git a/api/openapi/markdown/console-openapi.md b/api/openapi/markdown/console-openapi.mdindex 23e02fac98c..7822f330d84 100644--- a/api/openapi/markdown/console-openapi.md+++ b/api/openapi/markdown/console-openapi.md@@ -14626,6 +14626,7 @@ Legacy Chat App model config used only for follow-up question generation.| Name | Type | Description | Required || ---- | ---- | ----------- | -------- |+| answer | string | | No || chain_id | string | | No || created_at | integer | | No || files | [ string ] | | Yes |diff --git a/api/openapi/markdown/service-openapi.md b/api/openapi/markdown/service-openapi.mdindex 590ee66011e..7680ac77111 100644--- a/api/openapi/markdown/service-openapi.md+++ b/api/openapi/markdown/service-openapi.md@@ -2335,6 +2335,7 @@ Retrieve the list of available models by type. Primarily used to query `text-emb| Name | Type | Description | Required || ---- | ---- | ----------- | -------- |+| answer | string | | No || chain_id | string | | No || created_at | integer | | No || files | [ string ] | | Yes |diff --git a/api/openapi/markdown/web-openapi.md b/api/openapi/markdown/web-openapi.mdindex 710fc15cd3c..10cc7a831ad 100644--- a/api/openapi/markdown/web-openapi.md+++ b/api/openapi/markdown/web-openapi.md@@ -936,6 +936,7 @@ Returns Server-Sent Events stream.| Name | Type | Description | Required || ---- | ---- | ----------- | -------- |+| answer | string | | No || chain_id | string | | No || created_at | integer | | No || files | [ string ] | | Yes |diff --git a/api/services/agent/prompt_mentions.py b/api/services/agent/prompt_mentions.pyindex 15d257f474a..5f42bffe3ff 100644--- a/api/services/agent/prompt_mentions.py+++ b/api/services/agent/prompt_mentions.py@@ -318,9 +318,10 @@ def _format_output_mention(output: DeclaredOutputConfig) -> str:if output.type == DeclaredOutputType.FILE:return (f"{output.name} (file output; create the file locally, run "- f"`dify-agent file upload <path>`, then copy the returned AgentStubFileMapping JSON "- f"as final_output.{output.name}; do not call final_output before upload succeeds, and do not use "- "the local path, filename, URL, or a synthesized dify-file-ref as the reference)"+ f"`dify-agent file upload <path>`, then set final_output.{output.name} to a `tool_file` mapping "+ f"using the returned `reference`; if replying to the user in natural language, use the returned "+ f"`download_url`; do not call final_output before upload succeeds, and do not use the local path, "+ "filename, URL, or a synthesized dify-file-ref as the reference)")if (output.type == DeclaredOutputType.ARRAY@@ -329,9 +330,10 @@ def _format_output_mention(output: DeclaredOutputConfig) -> str:):return (f"{output.name} (array[file] output; upload each produced file with "- f"`dify-agent file upload <path>`, then copy the returned AgentStubFileMapping JSON objects "- f"as final_output.{output.name}; do not call final_output before all uploads succeed, and do not use "- "local paths, filenames, URLs, or synthesized dify-file-ref values as references)"+ f"`dify-agent file upload <path>`, then set final_output.{output.name} to `tool_file` mappings "+ f"using the returned `reference` values; if replying to the user in natural language, use the returned "+ f"`download_url`; do not call final_output before all uploads succeed, and do not use local paths, "+ "filenames, URLs, or synthesized dify-file-ref values as references)")return f"{output.name} ({output.type.value})"diff --git a/api/services/agent/roster_service.py b/api/services/agent/roster_service.pyindex de76b3c4eb2..33fd372398b 100644--- a/api/services/agent/roster_service.py+++ b/api/services/agent/roster_service.py@@ -1,9 +1,12 @@+import loggingfrom typing import Any, TypedDictfrom sqlalchemy import and_, func, or_, selectfrom sqlalchemy.exc import IntegrityError+from clients.agent_backend.session_cleanup import AgentBackendSessionCleanupPayloadfrom constants.model_template import default_app_templates+from core.app.apps.agent_app.session_store import AgentAppRuntimeSessionStorefrom core.app.entities.app_invoke_entities import InvokeFromfrom libs.datetime_utils import naive_utc_nowfrom libs.helper import to_timestamp@@ -38,6 +41,9 @@ from services.app_service import AppService, CreateAppParamsfrom services.enterprise.enterprise_service import EnterpriseServicefrom services.entities.agent_entities import RosterAgentCreatePayload, RosterAgentUpdatePayloadfrom services.feature_service import FeatureService+from tasks.agent_backend_session_cleanup_task import cleanup_conversation_agent_runtime_session++logger = logging.getLogger(__name__)class AgentReferencingWorkflow(TypedDict):@@ -603,7 +609,15 @@ class AgentRosterService:def refresh_agent_app_debug_conversation_id(self, *, tenant_id: str, agent_id: str, account_id: str, commit: bool = True) -> str:- """Start a new console debug conversation for the current Agent App editor."""+ """Start a new console debug conversation for the current Agent App editor.++ If this account already has a debug conversation mapping, the previous+ conversation is abandoned first: any ACTIVE conversation-owned Agent+ runtime sessions for that old conversation are sent through best-effort+ backend cleanup and then retired locally even when enqueueing fails.+ The debug mapping is then repointed to the freshly created+ conversation.+ """agent = self._session.scalar(select(Agent).where(@@ -643,6 +657,16 @@ class AgentRosterService:))else:+ previous_app_id = mapping.app_id+ previous_conversation_id = mapping.conversation_id+ if previous_conversation_id:+ self._cleanup_debug_conversation_runtime_sessions(+ tenant_id=tenant_id,+ agent_id=agent_id,+ account_id=account_id,+ app_id=previous_app_id or backing_app_id,+ conversation_id=previous_conversation_id,+ )mapping.app_id = backing_app_idmapping.conversation_id = conversation_idself._session.flush()@@ -650,6 +674,84 @@ class AgentRosterService:self._session.commit()return conversation_id+ def _cleanup_debug_conversation_runtime_sessions(+ self,+ *,+ tenant_id: str,+ agent_id: str,+ account_id: str,+ app_id: str,+ conversation_id: str,+ ) -> None:+ session_store = AgentAppRuntimeSessionStore()+ try:+ stored_sessions = session_store.list_active_sessions_for_conversation(+ tenant_id=tenant_id,+ app_id=app_id,+ conversation_id=conversation_id,+ )+ except Exception:+ logger.warning(+ "Failed to load Agent App runtime sessions for debug conversation refresh: "+ "tenant_id=%s app_id=%s conversation_id=%s",+ tenant_id,+ app_id,+ conversation_id,+ exc_info=True,+ )+ return++ for stored_session in stored_sessions:+ try:+ if stored_session.runtime_layer_specs:+ payload = AgentBackendSessionCleanupPayload(+ session_snapshot=stored_session.session_snapshot,+ runtime_layer_specs=stored_session.runtime_layer_specs,+ idempotency_key=(+ f"{tenant_id}:{agent_id}:{account_id}:{conversation_id}:debug-session-cleanup:"+ f"{stored_session.scope.agent_id}:"+ f"{stored_session.scope.agent_config_snapshot_id or 'no-config'}:"+ f"{stored_session.backend_run_id or 'no-run'}"+ ),+ metadata={+ "tenant_id": stored_session.scope.tenant_id,+ "app_id": stored_session.scope.app_id,+ "conversation_id": stored_session.scope.conversation_id,+ "agent_id": stored_session.scope.agent_id,+ "agent_config_snapshot_id": stored_session.scope.agent_config_snapshot_id,+ "previous_agent_backend_run_id": stored_session.backend_run_id,+ },+ )+ cleanup_conversation_agent_runtime_session.delay(payload.model_dump(mode="json"))+ except Exception:+ logger.warning(+ "Failed to enqueue Agent backend cleanup for debug conversation refresh: "+ "tenant_id=%s app_id=%s conversation_id=%s agent_id=%s backend_run_id=%s",+ stored_session.scope.tenant_id,+ stored_session.scope.app_id,+ stored_session.scope.conversation_id,+ stored_session.scope.agent_id,+ stored_session.backend_run_id,+ exc_info=True,+ )+ finally:+ try:+ session_store.mark_cleaned(+ scope=stored_session.scope,+ backend_run_id=stored_session.backend_run_id,+ )+ except Exception:+ logger.warning(+ "Failed to retire Agent App runtime session for debug conversation refresh: "+ "tenant_id=%s app_id=%s conversation_id=%s agent_id=%s backend_run_id=%s",+ stored_session.scope.tenant_id,+ stored_session.scope.app_id,+ stored_session.scope.conversation_id,+ stored_session.scope.agent_id,+ stored_session.backend_run_id,+ exc_info=True,+ )+def load_or_create_agent_app_debug_conversation_ids_by_agent_id(self, *, tenant_id: str, agents: list[Agent], account_id: str) -> dict[str, str]:diff --git a/api/services/app_generate_service.py b/api/services/app_generate_service.pyindex 940cab5f678..7724555b615 100644--- a/api/services/app_generate_service.py+++ b/api/services/app_generate_service.py@@ -40,35 +40,6 @@ if TYPE_CHECKING:class AppGenerateService:- @classmethod- @trace_span(AppGenerateHandler)- def generate_stateless_agent_app(- cls,- *,- app_model: App,- user: Account | EndUser,- args: Mapping[str, Any],- invoke_from: InvokeFrom,- ):- """Run build-chat finalization as a blocking, non-SSE Agent App action.-- This is the service entry point for the Agent build-chat finalize flow.- It applies the same tracing, quota, and rate-limit guardrails as normal- app generation, but invokes the Agent App generator in stateless mode:- the call waits synchronously for Agent backend completion, triggers only- the backend side effect, and does not create Dify chat/message records.- """- return cls._run_with_guardrails(- app_model=app_model,- streaming=False,- action=lambda _rate_limit, _request_id: AgentAppGenerator().generate_stateless(- app_model=app_model,- user=user,- args=args,- invoke_from=invoke_from,- ),- )-@staticmethoddef _build_streaming_task_on_subscribe(start_task: Callable[[], None]) -> Callable[[], None]:"""diff --git a/api/services/conversation_service.py b/api/services/conversation_service.pyindex 7c3b8d451c5..6ab9c5a8a2b 100644--- a/api/services/conversation_service.py+++ b/api/services/conversation_service.py@@ -6,7 +6,9 @@ from typing import Anyfrom sqlalchemy import asc, desc, func, or_, selectfrom sqlalchemy.orm import Session+from clients.agent_backend import AgentBackendSessionCleanupPayloadfrom configs import dify_config+from core.app.apps.agent_app.session_store import AgentAppRuntimeSessionStorefrom core.app.entities.app_invoke_entities import InvokeFromfrom core.llm_generator.llm_generator import LLMGeneratorfrom factories import variable_factory@@ -22,6 +24,7 @@ from services.errors.conversation import (LastConversationNotExistsError,)from services.errors.message import MessageNotExistsError+from tasks.agent_backend_session_cleanup_task import cleanup_conversation_agent_runtime_sessionfrom tasks.delete_conversation_task import delete_conversation_related_datalogger = logging.getLogger(__name__)@@ -186,10 +189,23 @@ class ConversationService:"""Delete a conversation only if it belongs to the given user and app context.+ Before removing the conversation row, this best-effort lifecycle path+ enumerates any ACTIVE conversation-owned Agent backend runtime sessions,+ enqueues asynchronous backend cleanup for rows with persisted runtime+ layer specs, and then retires the local session rows even if enqueueing+ fails. Conversation deletion and related-data cleanup scheduling still+ proceed when that lifecycle bookkeeping only partially succeeds.+Raises:ConversationNotExistsError: When the conversation is not visible to the current user."""conversation = cls.get_conversation(app_model, conversation_id, user, session=session)+ session_store = AgentAppRuntimeSessionStore()+ stored_sessions = session_store.list_active_sessions_for_conversation(+ tenant_id=app_model.tenant_id,+ app_id=app_model.id,+ conversation_id=conversation.id,+ )try:logger.info(@@ -197,15 +213,66 @@ class ConversationService:app_model.name,conversation_id,)+ for stored_session in stored_sessions:+ try:+ if stored_session.runtime_layer_specs:+ payload = AgentBackendSessionCleanupPayload(+ session_snapshot=stored_session.session_snapshot,+ runtime_layer_specs=stored_session.runtime_layer_specs,+ idempotency_key=(+ f"{stored_session.scope.tenant_id}:{stored_session.scope.app_id}:"+ f"{stored_session.scope.conversation_id}:agent-runtime-session-cleanup:"+ f"{stored_session.scope.agent_id}:"+ f"{stored_session.scope.agent_config_snapshot_id or 'no-config'}:"+ f"{stored_session.backend_run_id or 'no-run'}"+ ),+ metadata={+ "tenant_id": stored_session.scope.tenant_id,+ "app_id": stored_session.scope.app_id,+ "conversation_id": stored_session.scope.conversation_id,+ "agent_id": stored_session.scope.agent_id,+ "agent_config_snapshot_id": stored_session.scope.agent_config_snapshot_id,+ "previous_agent_backend_run_id": stored_session.backend_run_id,+ },+ )+ cleanup_conversation_agent_runtime_session.delay(payload.model_dump(mode="json"))+ except Exception:+ logger.warning(+ "Failed to enqueue Agent backend cleanup for conversation deletion: "+ "tenant_id=%s app_id=%s conversation_id=%s agent_id=%s backend_run_id=%s",+ stored_session.scope.tenant_id,+ stored_session.scope.app_id,+ stored_session.scope.conversation_id,+ stored_session.scope.agent_id,+ stored_session.backend_run_id,+ exc_info=True,+ )+ finally:+ try:+ session_store.mark_cleaned(+ scope=stored_session.scope,+ backend_run_id=stored_session.backend_run_id,+ )+ except Exception:+ logger.warning(+ "Failed to retire Agent App runtime session for conversation deletion: "+ "tenant_id=%s app_id=%s conversation_id=%s agent_id=%s backend_run_id=%s",+ stored_session.scope.tenant_id,+ stored_session.scope.app_id,+ stored_session.scope.conversation_id,+ stored_session.scope.agent_id,+ stored_session.backend_run_id,+ exc_info=True,+ )session.delete(conversation)session.commit()delete_conversation_related_data.delay(conversation.id)- except Exception as e:+ except Exception:session.rollback()- raise e+ raise@classmethoddef get_conversational_variable(diff --git a/api/tasks/agent_backend_session_cleanup_task.py b/api/tasks/agent_backend_session_cleanup_task.pynew file mode 100644index 00000000000..2c799bda97c--- /dev/null+++ b/api/tasks/agent_backend_session_cleanup_task.py@@ -0,0 +1,68 @@+"""Celery tasks that execute Agent backend lifecycle-only session cleanup."""++from __future__ import annotations++import logging++from celery import shared_task++from clients.agent_backend.factory import create_agent_backend_run_client+from clients.agent_backend.request_builder import AgentBackendRunRequestBuilder+from clients.agent_backend.session_cleanup import (+ AgentBackendSessionCleanupPayload,+ cleanup_agent_backend_session,+)+from configs import dify_config++logger = logging.getLogger(__name__)+++def _create_agent_backend_client():+ if not (dify_config.AGENT_BACKEND_USE_FAKE or dify_config.AGENT_BACKEND_BASE_URL):+ return None+ return create_agent_backend_run_client(+ base_url=dify_config.AGENT_BACKEND_BASE_URL,+ use_fake=dify_config.AGENT_BACKEND_USE_FAKE,+ fake_scenario=dify_config.AGENT_BACKEND_FAKE_SCENARIO,+ )+++def _run_cleanup_task(payload_dict: dict[str, object]) -> None:+ payload = AgentBackendSessionCleanupPayload.model_validate(payload_dict)+ result = cleanup_agent_backend_session(+ payload=payload,+ client=_create_agent_backend_client(),+ request_builder=AgentBackendRunRequestBuilder(),+ )+ if result.status == "succeeded":+ return++ log_fields = {+ "tenant_id": payload.metadata.get("tenant_id"),+ "app_id": payload.metadata.get("app_id"),+ "workflow_run_id": payload.metadata.get("workflow_run_id"),+ "node_id": payload.metadata.get("node_id"),+ "conversation_id": payload.metadata.get("conversation_id"),+ "agent_id": payload.metadata.get("agent_id"),+ "previous_agent_backend_run_id": payload.metadata.get("previous_agent_backend_run_id"),+ "failed_agent_backend_run_id": payload.metadata.get("failed_agent_backend_run_id"),+ "cleanup_run_id": result.cleanup_run_id,+ "reason": result.reason,+ }+ if result.status == "skipped":+ logger.info("Agent backend session cleanup skipped: %s", log_fields)+ return++ logger.warning("Agent backend session cleanup failed: %s", log_fields)+++@shared_task(queue="workflow_storage")+def cleanup_workflow_agent_runtime_session(payload_dict: dict[str, object]) -> None:+ """Run one workflow-owned Agent backend cleanup payload."""+ _run_cleanup_task(payload_dict)+++@shared_task(queue="conversation")+def cleanup_conversation_agent_runtime_session(payload_dict: dict[str, object]) -> None:+ """Run one conversation-owned Agent backend cleanup payload."""+ _run_cleanup_task(payload_dict)diff --git a/api/tasks/remove_app_and_related_data_task.py b/api/tasks/remove_app_and_related_data_task.pyindex a4fb6d57207..2010deb4a80 100644--- a/api/tasks/remove_app_and_related_data_task.py+++ b/api/tasks/remove_app_and_related_data_task.py@@ -5,17 +5,25 @@ from typing import Any, castimport clickimport sqlalchemy as sa+from agenton.compositor import CompositorSessionSnapshotfrom celery import shared_task+from dify_agent.protocol import RuntimeLayerSpec+from pydantic import JsonValue, TypeAdapterfrom sqlalchemy import delete, selectfrom sqlalchemy.engine import CursorResultfrom sqlalchemy.exc import SQLAlchemyErrorfrom sqlalchemy.orm import sessionmaker+from clients.agent_backend.session_cleanup import AgentBackendSessionCleanupPayloadfrom configs import dify_configfrom core.db.session_factory import session_factoryfrom extensions.ext_database import dbfrom libs.archive_storage import ArchiveStorageNotConfiguredError, get_archive_storage+from libs.datetime_utils import naive_utc_nowfrom models import (+ AgentRuntimeSession,+ AgentRuntimeSessionOwnerType,+ AgentRuntimeSessionStatus,ApiToken,AppAnnotationHitHistory,AppAnnotationSetting,@@ -50,8 +58,13 @@ from models.workflow import ()from repositories.factory import DifyAPIRepositoryFactoryfrom services.api_token_service import ApiTokenCache+from tasks.agent_backend_session_cleanup_task import (+ cleanup_conversation_agent_runtime_session,+ cleanup_workflow_agent_runtime_session,+)logger = logging.getLogger(__name__)+_RUNTIME_LAYER_SPECS_ADAPTER: TypeAdapter[list[RuntimeLayerSpec]] = TypeAdapter(list[RuntimeLayerSpec])@shared_task(queue="app_deletion", bind=True, max_retries=3)@@ -59,6 +72,7 @@ def remove_app_and_related_data_task(self, tenant_id: str, app_id: str):logger.info(click.style(f"Start deleting app and related data: {tenant_id}:{app_id}", fg="green"))start_at = time.perf_counter()try:+ _cleanup_active_agent_runtime_sessions_for_app(tenant_id, app_id)# Delete related data_delete_app_model_configs(tenant_id, app_id)_delete_app_site(tenant_id, app_id)@@ -99,6 +113,143 @@ def remove_app_and_related_data_task(self, tenant_id: str, app_id: str):raise self.retry(exc=e, countdown=60) # Retry after 60 seconds+def _cleanup_active_agent_runtime_sessions_for_app(tenant_id: str, app_id: str, *, batch_size: int = 100) -> None:+ """Best-effort fan-out for ACTIVE Agent runtime sessions during app deletion.++ App deletion must not block on synchronous Agent backend lifecycle work, so+ this helper scans ACTIVE ``agent_runtime_sessions`` rows in batches,+ dispatches owner-specific cleanup tasks only when enough persisted data+ exists to replay a lifecycle-only run, and then marks each visited row+ ``CLEANED`` locally regardless of enqueue outcome. The local retirement is+ the contract that lets the rest of app deletion continue even when backend+ cleanup dispatch is skipped or fails.+ """+ if batch_size <= 0:+ raise ValueError("batch_size must be positive")++ while True:+ with session_factory.create_session() as session:+ row_ids = session.scalars(+ select(AgentRuntimeSession.id)+ .where(+ AgentRuntimeSession.tenant_id == tenant_id,+ AgentRuntimeSession.app_id == app_id,+ AgentRuntimeSession.status == AgentRuntimeSessionStatus.ACTIVE,+ )+ .order_by(AgentRuntimeSession.updated_at.asc())+ .limit(batch_size)+ ).all()++ if not row_ids:+ return++ retired_count = 0+ for row_id in row_ids:+ with session_factory.create_session() as session:+ row = session.get(AgentRuntimeSession, row_id)+ if row is None or row.status != AgentRuntimeSessionStatus.ACTIVE:+ retired_count += 1+ continue++ try:+ payload = _build_agent_runtime_session_cleanup_payload(row)+ if payload is not None:+ _enqueue_agent_runtime_session_cleanup(row=row, payload=payload)+ except Exception:+ logger.warning(+ "Failed to enqueue Agent backend cleanup during app deletion: "+ "tenant_id=%s app_id=%s owner_type=%s conversation_id=%s workflow_run_id=%s "+ "node_id=%s agent_id=%s backend_run_id=%s",+ row.tenant_id,+ row.app_id,+ row.owner_type,+ row.conversation_id,+ row.workflow_run_id,+ row.node_id,+ row.agent_id,+ row.backend_run_id,+ exc_info=True,+ )+ finally:+ try:+ row.status = AgentRuntimeSessionStatus.CLEANED+ row.cleaned_at = naive_utc_now()+ session.commit()+ retired_count += 1+ except Exception:+ session.rollback()+ logger.warning(+ "Failed to retire Agent runtime session during app deletion: "+ "tenant_id=%s app_id=%s owner_type=%s conversation_id=%s workflow_run_id=%s "+ "node_id=%s agent_id=%s backend_run_id=%s",+ row.tenant_id,+ row.app_id,+ row.owner_type,+ row.conversation_id,+ row.workflow_run_id,+ row.node_id,+ row.agent_id,+ row.backend_run_id,+ exc_info=True,+ )++ if retired_count == 0:+ logger.warning(+ "Failed to retire any active Agent runtime sessions during app deletion: tenant_id=%s app_id=%s",+ tenant_id,+ app_id,+ )+ return+++def _build_agent_runtime_session_cleanup_payload(+ row: AgentRuntimeSession,+) -> AgentBackendSessionCleanupPayload | None:+ runtime_layer_specs = _RUNTIME_LAYER_SPECS_ADAPTER.validate_json(row.composition_layer_specs or "[]")+ if not runtime_layer_specs:+ return None++ metadata: dict[str, JsonValue] = {+ "tenant_id": row.tenant_id,+ "app_id": row.app_id,+ "agent_id": row.agent_id,+ "agent_config_snapshot_id": row.agent_config_snapshot_id,+ "previous_agent_backend_run_id": row.backend_run_id,+ }+ if row.owner_type == AgentRuntimeSessionOwnerType.CONVERSATION:+ metadata["conversation_id"] = row.conversation_id+ idempotency_key = (+ f"{row.tenant_id}:{row.app_id}:{row.conversation_id}:"+ f"{row.agent_id}:app-delete-cleanup:{row.id or row.backend_run_id or 'no-session-id'}"+ )+ else:+ metadata["workflow_run_id"] = row.workflow_run_id+ metadata["node_id"] = row.node_id+ idempotency_key = (+ f"{row.tenant_id}:{row.app_id}:{row.workflow_run_id}:{row.node_id}:"+ f"{row.agent_id}:app-delete-cleanup:{row.id or row.backend_run_id or 'no-session-id'}"+ )++ return AgentBackendSessionCleanupPayload(+ session_snapshot=CompositorSessionSnapshot.model_validate_json(row.session_snapshot),+ runtime_layer_specs=runtime_layer_specs,+ idempotency_key=idempotency_key,+ metadata=metadata,+ )+++def _enqueue_agent_runtime_session_cleanup(+ *,+ row: AgentRuntimeSession,+ payload: AgentBackendSessionCleanupPayload,+) -> None:+ payload_dict = payload.model_dump(mode="json")+ if row.owner_type == AgentRuntimeSessionOwnerType.CONVERSATION:+ cleanup_conversation_agent_runtime_session.delay(payload_dict)+ return+ cleanup_workflow_agent_runtime_session.delay(payload_dict)++def _delete_app_model_configs(tenant_id: str, app_id: str):def del_model_config(session, model_config_id: str):session.execute(diff --git a/api/tests/test_containers_integration_tests/services/test_conversation_service.py b/api/tests/test_containers_integration_tests/services/test_conversation_service.pyindex 19dd4d6cf70..60858df08e8 100644--- a/api/tests/test_containers_integration_tests/services/test_conversation_service.py+++ b/api/tests/test_containers_integration_tests/services/test_conversation_service.py@@ -6,11 +6,13 @@ from unittest.mock import patchfrom uuid import uuid4import pytest+from agenton.compositor import CompositorSessionSnapshotfrom sqlalchemy import selectfrom sqlalchemy.orm import Session+from core.app.apps.agent_app.session_store import AgentAppRuntimeSessionStorefrom core.app.entities.app_invoke_entities import InvokeFrom-from models import TenantAccountRole+from models import AgentRuntimeSession, AgentRuntimeSessionOwnerType, AgentRuntimeSessionStatus, TenantAccountRolefrom models.account import Account, Tenant, TenantAccountJoinfrom models.enums import ConversationFromSource, EndUserTypefrom models.model import App, Conversation, EndUser, Message, MessageAnnotation@@ -1081,8 +1083,9 @@ class TestConversationServiceExport:# Assertassert result == conversation+ @patch("services.conversation_service.cleanup_conversation_agent_runtime_session")@patch("services.conversation_service.delete_conversation_related_data")- def test_delete_conversation(self, mock_delete_task, db_session_with_containers: Session):+ def test_delete_conversation(self, mock_delete_task, mock_cleanup_task, db_session_with_containers: Session):"""Test conversation deletion with async cleanup.@@ -1101,6 +1104,20 @@ class TestConversationServiceExport:user,)conversation_id = conversation.id+ runtime_session = AgentRuntimeSession(+ tenant_id=app_model.tenant_id,+ app_id=app_model.id,+ owner_type=AgentRuntimeSessionOwnerType.CONVERSATION,+ agent_id=str(uuid4()),+ agent_config_snapshot_id=str(uuid4()),+ backend_run_id="backend-run-1",+ session_snapshot=CompositorSessionSnapshot(layers=[]).model_dump_json(),+ composition_layer_specs='[{"name":"history","type":"pydantic_ai.history","deps":{},"metadata":{},"config":null}]',+ conversation_id=conversation.id,+ status=AgentRuntimeSessionStatus.ACTIVE,+ )+ db_session_with_containers.add(runtime_session)+ db_session_with_containers.commit()# Act - Delete the conversationConversationService.delete(@@ -1115,9 +1132,29 @@ class TestConversationServiceExport:# Step 2: Async cleanup task triggered# The Celery task will handle cleanup of messages, annotations, etc.mock_delete_task.delay.assert_called_once_with(conversation_id)+ mock_cleanup_task.delay.assert_called_once()+ cleanup_payload = mock_cleanup_task.delay.call_args.args[0]+ assert cleanup_payload["metadata"]["conversation_id"] == conversation_id+ assert (+ cleanup_payload["idempotency_key"]+ == f"{app_model.tenant_id}:{app_model.id}:{conversation_id}:agent-runtime-session-cleanup:"+ f"{runtime_session.agent_id}:{runtime_session.agent_config_snapshot_id}:{runtime_session.backend_run_id}"+ )+ runtime_session_row = db_session_with_containers.scalar(+ select(AgentRuntimeSession).where(AgentRuntimeSession.id == runtime_session.id)+ )+ assert runtime_session_row is not None+ assert runtime_session_row.status == AgentRuntimeSessionStatus.CLEANED++ @patch("services.conversation_service.cleanup_conversation_agent_runtime_session")@patch("services.conversation_service.delete_conversation_related_data")- def test_delete_conversation_not_owned_by_account(self, mock_delete_task, db_session_with_containers: Session):+ def test_delete_conversation_not_owned_by_account(+ self,+ mock_delete_task,+ mock_cleanup_task,+ db_session_with_containers: Session,+ ):"""Test deletion is denied when conversation belongs to a different account."""@@ -1147,14 +1184,22 @@ class TestConversationServiceExport:not_deleted = db_session_with_containers.scalar(select(Conversation).where(Conversation.id == conversation.id))assert not_deleted is not Nonemock_delete_task.delay.assert_not_called()+ mock_cleanup_task.delay.assert_not_called()+ @patch("services.conversation_service.cleanup_conversation_agent_runtime_session")@patch("services.conversation_service.delete_conversation_related_data")- def test_delete_handles_exception_and_rollback(self, mock_delete_task, db_session_with_containers: Session):+ def test_delete_handles_exception_and_rollback(+ self,+ mock_delete_task,+ mock_cleanup_task,+ db_session_with_containers: Session,+ ):"""Test that delete propagates exceptions and does not trigger the cleanup task.- When a DB error occurs during deletion, the service must rollback the- transaction and re-raise the exception without scheduling async cleanup.+ When a DB error occurs during deletion, the conversation row stays in+ place, but any already-enqueued Agent backend cleanup remains a+ best-effort terminal lifecycle action."""# Arrangeapp_model, user = ConversationServiceIntegrationTestDataFactory.create_app_and_account(@@ -1164,6 +1209,20 @@ class TestConversationServiceExport:db_session_with_containers, app_model, user)conversation_id = conversation.id+ runtime_session = AgentRuntimeSession(+ tenant_id=app_model.tenant_id,+ app_id=app_model.id,+ owner_type=AgentRuntimeSessionOwnerType.CONVERSATION,+ agent_id=str(uuid4()),+ agent_config_snapshot_id=str(uuid4()),+ backend_run_id="backend-run-rollback",+ session_snapshot=CompositorSessionSnapshot(layers=[]).model_dump_json(),+ composition_layer_specs='[{"name":"history","type":"pydantic_ai.history","deps":{},"metadata":{},"config":null}]',+ conversation_id=conversation.id,+ status=AgentRuntimeSessionStatus.ACTIVE,+ )+ db_session_with_containers.add(runtime_session)+ db_session_with_containers.commit()# Act — force an error during the delete to exercise the rollback pathwith patch.object(db_session_with_containers, "delete", side_effect=Exception("DB error")):@@ -1175,9 +1234,111 @@ class TestConversationServiceExport:session=db_session_with_containers,)- # Assert — async cleanup must NOT have been scheduled+ # Assert — related-data deletion is not scheduled, but the backend+ # cleanup task was already enqueued before the row delete failed.mock_delete_task.delay.assert_not_called()+ mock_cleanup_task.delay.assert_called_once()+ cleanup_payload = mock_cleanup_task.delay.call_args.args[0]+ assert (+ cleanup_payload["idempotency_key"]+ == f"{app_model.tenant_id}:{app_model.id}:{conversation_id}:agent-runtime-session-cleanup:"+ f"{runtime_session.agent_id}:{runtime_session.agent_config_snapshot_id}:{runtime_session.backend_run_id}"+ )# Conversation is still present because the deletion was never committedstill_there = db_session_with_containers.scalar(select(Conversation).where(Conversation.id == conversation_id))assert still_there is not None++ @patch("services.conversation_service.cleanup_conversation_agent_runtime_session")+ @patch("services.conversation_service.delete_conversation_related_data")+ def test_delete_ignores_mark_cleaned_failure(+ self,+ mock_delete_task,+ mock_cleanup_task,+ db_session_with_containers: Session,+ ):+ app_model, user = ConversationServiceIntegrationTestDataFactory.create_app_and_account(+ db_session_with_containers+ )+ conversation = ConversationServiceIntegrationTestDataFactory.create_conversation(+ db_session_with_containers,+ app_model,+ user,+ )+ runtime_session = AgentRuntimeSession(+ tenant_id=app_model.tenant_id,+ app_id=app_model.id,+ owner_type=AgentRuntimeSessionOwnerType.CONVERSATION,+ agent_id=str(uuid4()),+ agent_config_snapshot_id=str(uuid4()),+ backend_run_id="backend-run-cleanup-failure",+ session_snapshot=CompositorSessionSnapshot(layers=[]).model_dump_json(),+ composition_layer_specs='[{"name":"history","type":"pydantic_ai.history","deps":{},"metadata":{},"config":null}]',+ conversation_id=conversation.id,+ status=AgentRuntimeSessionStatus.ACTIVE,+ )+ db_session_with_containers.add(runtime_session)+ db_session_with_containers.commit()++ with patch.object(AgentAppRuntimeSessionStore, "mark_cleaned", side_effect=RuntimeError("cleanup failed")):+ ConversationService.delete(+ app_model=app_model,+ conversation_id=conversation.id,+ user=user,+ session=db_session_with_containers,+ )++ deleted = db_session_with_containers.scalar(select(Conversation).where(Conversation.id == conversation.id))+ assert deleted is None+ mock_delete_task.delay.assert_called_once_with(conversation.id)+ mock_cleanup_task.delay.assert_called_once()++ @patch("services.conversation_service.cleanup_conversation_agent_runtime_session")+ @patch("services.conversation_service.delete_conversation_related_data")+ def test_delete_ignores_cleanup_enqueue_failure_and_still_retires_runtime_session(+ self,+ mock_delete_task,+ mock_cleanup_task,+ db_session_with_containers: Session,+ ):+ app_model, user = ConversationServiceIntegrationTestDataFactory.create_app_and_account(+ db_session_with_containers+ )+ conversation = ConversationServiceIntegrationTestDataFactory.create_conversation(+ db_session_with_containers,+ app_model,+ user,+ )+ conversation_id = conversation.id+ runtime_session = AgentRuntimeSession(+ tenant_id=app_model.tenant_id,+ app_id=app_model.id,+ owner_type=AgentRuntimeSessionOwnerType.CONVERSATION,+ agent_id=str(uuid4()),+ agent_config_snapshot_id=str(uuid4()),+ backend_run_id="backend-run-enqueue-failure",+ session_snapshot=CompositorSessionSnapshot(layers=[]).model_dump_json(),+ composition_layer_specs='[{"name":"history","type":"pydantic_ai.history","deps":{},"metadata":{},"config":null}]',+ conversation_id=conversation.id,+ status=AgentRuntimeSessionStatus.ACTIVE,+ )+ db_session_with_containers.add(runtime_session)+ db_session_with_containers.commit()+ mock_cleanup_task.delay.side_effect = RuntimeError("queue down")++ ConversationService.delete(+ app_model=app_model,+ conversation_id=conversation_id,+ user=user,+ session=db_session_with_containers,+ )++ deleted = db_session_with_containers.scalar(select(Conversation).where(Conversation.id == conversation_id))+ assert deleted is None+ mock_delete_task.delay.assert_called_once_with(conversation_id)+ mock_cleanup_task.delay.assert_called_once()+ runtime_session_row = db_session_with_containers.scalar(+ select(AgentRuntimeSession).where(AgentRuntimeSession.id == runtime_session.id)+ )+ assert runtime_session_row is not None+ assert runtime_session_row.status == AgentRuntimeSessionStatus.CLEANEDdiff --git a/api/tests/unit_tests/clients/agent_backend/test_event_adapter.py b/api/tests/unit_tests/clients/agent_backend/test_event_adapter.pyindex f6c73fdb66d..4adef713cfd 100644--- a/api/tests/unit_tests/clients/agent_backend/test_event_adapter.py+++ b/api/tests/unit_tests/clients/agent_backend/test_event_adapter.py@@ -15,6 +15,7 @@ from dify_agent.protocol import (from pydantic_ai.messages import FinalResultEventfrom clients.agent_backend import (+ AgentBackendAgentMessageDeltaInternalEvent,AgentBackendDeferredToolCallInternalEvent,AgentBackendInternalEventType,AgentBackendRunCancelledInternalEvent,@@ -54,6 +55,25 @@ def test_event_adapter_maps_pydantic_ai_stream_event():assert event.data["event_kind"] == "final_result"+def test_event_adapter_maps_pydantic_ai_stream_event_agent_message_delta_annotation():+ adapted = AgentBackendRunEventAdapter().adapt(+ PydanticAIStreamRunEvent(+ id="2-0",+ run_id="run-1",+ data=FinalResultEvent(tool_name=None, tool_call_id=None),+ agent_message_delta="hello",+ )+ )++ assert adapted == [+ AgentBackendAgentMessageDeltaInternalEvent(+ run_id="run-1",+ source_event_id="2-0",+ delta="hello",+ )+ ]++def test_event_adapter_maps_run_succeeded_to_final_output():snapshot = CompositorSessionSnapshot(layers=[])adapted = AgentBackendRunEventAdapter().adapt(diff --git a/api/tests/unit_tests/clients/agent_backend/test_request_builder.py b/api/tests/unit_tests/clients/agent_backend/test_request_builder.pyindex f3aac73aac7..b2b77275fa7 100644--- a/api/tests/unit_tests/clients/agent_backend/test_request_builder.py+++ b/api/tests/unit_tests/clients/agent_backend/test_request_builder.py@@ -88,6 +88,7 @@ def _run_input() -> AgentBackendWorkflowNodeRunInput:def test_request_builder_outputs_dify_agent_create_run_request():request = AgentBackendRunRequestBuilder().build_for_workflow_node(_run_input())+ dumped = request.model_dump(mode="json")assert isinstance(request, CreateRunRequest)assert [layer.name for layer in request.composition.layers] == [@@ -102,6 +103,7 @@ def test_request_builder_outputs_dify_agent_create_run_request():assert request.on_exit.default is ExitIntent.SUSPENDassert request.idempotency_key == "workflow-run-1:node-execution-1"assert request.metadata == {"workflow_id": "workflow-1", "node_id": "node-1"}+ assert "purpose" not in dumpeddef test_request_builder_separates_agent_soul_and_workflow_job_prompt():@@ -121,6 +123,59 @@ def test_request_builder_separates_agent_soul_and_workflow_job_prompt():assert dumped["composition"]["layers"][2]["config"]["user"] == "Summarize the report."[email protected]("agent_config_version_kind", ["snapshot", "draft"])+def test_agent_app_request_builder_keeps_agent_soul_prompt_for_snapshot_and_draft(+ agent_config_version_kind: str,+):+ original_prompt = " You are Iris. \n"+ run_input = _agent_app_input().model_copy(+ update={+ "agent_config_version_kind": agent_config_version_kind,+ "agent_soul_prompt": original_prompt,+ }+ )++ request = AgentBackendRunRequestBuilder().build_for_agent_app(run_input)+ layers = {layer.name: layer for layer in request.composition.layers}++ prompt_config = cast(PromptLayerConfig, layers[AGENT_SOUL_PROMPT_LAYER_ID].config)+ assert prompt_config.prefix == original_prompt+++def test_agent_app_request_builder_wraps_agent_soul_prompt_for_build_draft():+ original_prompt = " You are Iris. \n"+ run_input = _agent_app_input().model_copy(+ update={+ "agent_config_version_kind": "build_draft",+ "agent_soul_prompt": original_prompt,+ }+ )++ request = AgentBackendRunRequestBuilder().build_for_agent_app(run_input)+ layers = {layer.name: layer for layer in request.composition.layers}++ prompt_config = cast(PromptLayerConfig, layers[AGENT_SOUL_PROMPT_LAYER_ID].config)+ assert prompt_config.prefix != original_prompt+ assert prompt_config.prefix.startswith("You are running in build mode.")+ assert "```text\nYou are Iris.\n```" in prompt_config.prefix+++def test_agent_app_request_builder_uses_longer_fence_for_build_draft_prompt_body():+ run_input = _agent_app_input().model_copy(+ update={+ "agent_config_version_kind": "build_draft",+ "agent_soul_prompt": "Keep this snippet:\n```python\nprint('hi')\n```",+ }+ )++ request = AgentBackendRunRequestBuilder().build_for_agent_app(run_input)+ layers = {layer.name: layer for layer in request.composition.layers}++ prompt_config = cast(PromptLayerConfig, layers[AGENT_SOUL_PROMPT_LAYER_ID].config)+ assert "````text" in prompt_config.prefix+ assert "```python" in prompt_config.prefix++def test_request_builder_sets_model_and_output_layer_contract_ids():request = AgentBackendRunRequestBuilder().build_for_workflow_node(_run_input())layers = {layer.name: layer for layer in request.composition.layers}@@ -250,6 +305,7 @@ def test_request_builder_builds_cleanup_request_replays_persisted_layer_specs():assert request.on_exit.default is ExitIntent.DELETEassert request.idempotency_key == "run-1:node-1:binding-1:agent-session-cleanup"assert request.metadata["agent_backend_lifecycle"] == "session_cleanup"+ assert "purpose" not in request.model_dump(mode="json")def test_request_builder_rejects_empty_runtime_layer_specs():@@ -392,6 +448,19 @@ def test_agent_app_request_builder_omits_shell_layer_by_default():assert DIFY_SHELL_LAYER_ID not in {layer.name for layer in request.composition.layers}+def test_agent_app_request_builder_keeps_build_draft_prompt_when_agent_soul_prompt_is_blank():+ run_input = _agent_app_input().model_copy(+ update={"agent_soul_prompt": " ", "agent_config_version_kind": "build_draft"}+ )++ request = AgentBackendRunRequestBuilder().build_for_agent_app(run_input)+ layers = {layer.name: layer for layer in request.composition.layers}++ prompt_config = cast(PromptLayerConfig, layers[AGENT_SOUL_PROMPT_LAYER_ID].config)+ assert "You are running in build mode." in prompt_config.prefix+ assert "No task prompt was provided." in prompt_config.prefix++def test_agent_app_request_builder_adds_shell_layer_when_include_shell():run_input = _agent_app_input(include_shell=True)run_input.shell_config = DifyShellLayerConfig(env=[DifyShellEnvVarConfig(name="APP_ENV", value="enabled")])diff --git a/api/tests/unit_tests/clients/agent_backend/test_session_cleanup.py b/api/tests/unit_tests/clients/agent_backend/test_session_cleanup.pynew file mode 100644index 00000000000..6b72850aeca--- /dev/null+++ b/api/tests/unit_tests/clients/agent_backend/test_session_cleanup.py@@ -0,0 +1,124 @@+from datetime import UTC, datetime++from agenton.compositor import CompositorSessionSnapshot+from agenton.compositor.schemas import LayerSessionSnapshot+from agenton.layers.base import LifecycleState+from dify_agent.protocol import RunStatusResponse++from clients.agent_backend import (+ AgentBackendError,+ AgentBackendSessionCleanupPayload,+ FakeAgentBackendRunClient,+ RuntimeLayerSpec,+ cleanup_agent_backend_session,+)+++def _payload() -> AgentBackendSessionCleanupPayload:+ return AgentBackendSessionCleanupPayload(+ session_snapshot=CompositorSessionSnapshot(+ layers=[+ LayerSessionSnapshot(+ name="history",+ lifecycle_state=LifecycleState.SUSPENDED,+ runtime_state={},+ )+ ]+ ),+ runtime_layer_specs=[RuntimeLayerSpec(name="history", type="pydantic_ai.history")],+ idempotency_key="cleanup-1",+ metadata={"tenant_id": "tenant-1"},+ timeout_seconds=15.0,+ )+++def test_cleanup_agent_backend_session_runs_create_and_wait_until_success():+ client = FakeAgentBackendRunClient(run_id="cleanup-run-1")++ result = cleanup_agent_backend_session(payload=_payload(), client=client)++ assert result.status == "succeeded"+ assert result.cleanup_run_id == "cleanup-run-1"+ assert client.request is not None+ assert [layer.name for layer in client.request.composition.layers] == ["history"]+++def test_cleanup_agent_backend_session_skips_when_client_is_missing():+ result = cleanup_agent_backend_session(+ payload=_payload(),+ client=None,+ )++ assert result.status == "skipped"+ assert result.reason == "no_agent_backend_client"+++def test_cleanup_agent_backend_session_skips_when_session_snapshot_is_missing():+ payload = _payload().model_copy(update={"session_snapshot": None})++ result = cleanup_agent_backend_session(payload=payload, client=FakeAgentBackendRunClient())++ assert result.status == "skipped"+ assert result.reason == "missing_session_snapshot"+++def test_cleanup_agent_backend_session_skips_when_runtime_layer_specs_are_missing():+ payload = _payload().model_copy(update={"runtime_layer_specs": []})++ result = cleanup_agent_backend_session(payload=payload, client=FakeAgentBackendRunClient())++ assert result.status == "skipped"+ assert result.reason == "missing_runtime_layer_specs"+++class _FailedStatusClient(FakeAgentBackendRunClient):+ def wait_run(self, run_id: str, *, timeout_seconds: float | None = None) -> RunStatusResponse:+ del timeout_seconds+ return RunStatusResponse(+ run_id=run_id,+ status="failed",+ created_at=datetime(2026, 1, 1, tzinfo=UTC),+ updated_at=datetime(2026, 1, 1, tzinfo=UTC),+ error="snapshot mismatch",+ )+++def test_cleanup_agent_backend_session_reports_failed_terminal_status():+ client = _FailedStatusClient(run_id="cleanup-run-2")++ result = cleanup_agent_backend_session(payload=_payload(), client=client)++ assert result.status == "failed"+ assert result.reason == "snapshot mismatch"+ assert result.cleanup_run_id == "cleanup-run-2"+++class _CreateRunFailureClient(FakeAgentBackendRunClient):+ def create_run(self, request): # type: ignore[override]+ del request+ raise AgentBackendError("create run failed")+++class _WaitRunFailureClient(FakeAgentBackendRunClient):+ def wait_run(self, run_id: str, *, timeout_seconds: float | None = None) -> RunStatusResponse:+ del run_id, timeout_seconds+ raise AgentBackendError("wait run failed")+++def test_cleanup_agent_backend_session_returns_failed_when_create_run_raises():+ result = cleanup_agent_backend_session(payload=_payload(), client=_CreateRunFailureClient())++ assert result.status == "failed"+ assert result.reason == "create run failed"+ assert result.cleanup_run_id is None+++def test_cleanup_agent_backend_session_returns_failed_with_cleanup_run_id_when_wait_run_raises():+ result = cleanup_agent_backend_session(+ payload=_payload(),+ client=_WaitRunFailureClient(run_id="cleanup-run-3"),+ )++ assert result.status == "failed"+ assert result.reason == "wait run failed"+ assert result.cleanup_run_id == "cleanup-run-3"diff --git a/api/tests/unit_tests/controllers/console/agent/test_agent_controllers.py b/api/tests/unit_tests/controllers/console/agent/test_agent_controllers.pyindex 8f294293c07..51737a859ba 100644--- a/api/tests/unit_tests/controllers/console/agent/test_agent_controllers.py+++ b/api/tests/unit_tests/controllers/console/agent/test_agent_controllers.py@@ -1576,6 +1576,7 @@ def test_build_chat_finalization_helper_forces_debug_build_and_push_prompt(assert args["conversation_id"] == "debug-conversation-1"assert args["inputs"] == {}assert args["auto_generate_name"] is False+ assert args[completion_controller.AGENT_RUNTIME_EXIT_INTENT_ARG] == "delete"assert args["external_trace_id"] == "trace-1"@@ -1664,6 +1665,51 @@ def test_agent_chat_helper_forces_agent_streaming_and_external_trace(assert args["external_trace_id"] == "trace-1"+def test_agent_chat_helper_ignores_private_exit_intent_payload_key(+ app: Flask, monkeypatch: pytest.MonkeyPatch, account_id: str+) -> None:+ app_model = SimpleNamespace(id="app-1", tenant_id="tenant-1", mode="agent")+ current_user = SimpleNamespace(id=account_id)+ captured: dict[str, object] = {}++ def generate(**kwargs: object) -> dict[str, object]:+ captured.update(kwargs)+ return {"answer": "ok"}++ monkeypatch.setattr(completion_controller.AppGenerateService, "generate", generate)+ monkeypatch.setattr(+ completion_controller,+ "_resolve_current_user_agent_debug_conversation_id",+ lambda **kwargs: "debug-conversation-1",+ )+ monkeypatch.setattr(+ completion_controller.helper,+ "compact_generate_response",+ lambda response: {"response": response},+ )++ with app.test_request_context(+ json={+ "inputs": {},+ "query": "hello",+ "response_mode": "streaming",+ completion_controller.AGENT_RUNTIME_EXIT_INTENT_ARG: "delete",+ }+ ):+ result = completion_controller._create_chat_message(+ current_user=current_user,+ app_model=app_model,+ session=Mock(),+ )++ assert result == {"response": {"answer": "ok"}}+ assert captured["streaming"] is True+ args = cast(dict[str, object], captured["args"])+ assert args["response_mode"] == "streaming"+ assert args["conversation_id"] == "debug-conversation-1"+ assert completion_controller.AGENT_RUNTIME_EXIT_INTENT_ARG not in args++def test_agent_chat_helper_rejects_foreign_debug_conversation(app: Flask,monkeypatch: pytest.MonkeyPatch,diff --git a/api/tests/unit_tests/core/app/apps/agent_app/test_app_generator.py b/api/tests/unit_tests/core/app/apps/agent_app/test_app_generator.pyindex 6f8c6af2258..ef030e7e170 100644--- a/api/tests/unit_tests/core/app/apps/agent_app/test_app_generator.py+++ b/api/tests/unit_tests/core/app/apps/agent_app/test_app_generator.py@@ -11,7 +11,6 @@ from __future__ import annotationsimport contextlibimport json-from types import SimpleNamespaceimport pytestfrom pytest_mock import MockerFixture@@ -21,7 +20,8 @@ from core.app.apps.agent_app.app_generator import (AgentAppGeneratorError,)from core.app.apps.exc import GenerateTaskStoppedError-from core.app.entities.app_invoke_entities import InvokeFrom, UserFrom+from core.app.entities.app_invoke_entities import AGENT_RUNTIME_EXIT_INTENT_ARG, InvokeFrom, UserFrom+from core.workflow.file_reference import build_file_referencefrom models import Accountfrom models.agent import AgentConfigDraftType@@ -135,6 +135,79 @@ class TestGenerateSuccess:user=user,)assert generate_entity.call_args.kwargs["prompt_file_mappings"] == file_mappings+ assert generate_entity.call_args.kwargs["agent_runtime_exit_intent"] == "suspend"++ def test_generate_uses_delete_exit_intent_from_internal_arg(self, generator, mocker: MockerFixture):+ app_model = mocker.MagicMock(id="app1", tenant_id="tenant", mode="agent")+ user = DummyAccount("user")++ generator._resolve_agent = mocker.MagicMock(+ return_value=(mocker.MagicMock(id="agent1"), "snap1", "snapshot", mocker.MagicMock())+ )+ generator._prepare_user_inputs = mocker.MagicMock(return_value={})+ generator._init_generate_records = mocker.MagicMock(+ return_value=(mocker.MagicMock(id="conv", mode="agent"), mocker.MagicMock(id="msg"))+ )+ generator._handle_response = mocker.MagicMock(return_value="raw-response")++ mocker.patch(+ f"{MODULE}.AgentAppConfigManager.get_app_config",+ return_value=mocker.MagicMock(variables=[], tenant_id="tenant", app_id="app1"),+ )+ mocker.patch(f"{MODULE}.ModelConfigConverter.convert", return_value=mocker.MagicMock(model="gpt-4o-mini"))+ mocker.patch(f"{MODULE}.TraceQueueManager", return_value=mocker.MagicMock())+ generate_entity = mocker.patch(+ f"{MODULE}.AgentAppGenerateEntity", return_value=mocker.MagicMock(task_id="t", user_id="user")+ )+ mocker.patch(f"{MODULE}.MessageBasedAppQueueManager", return_value=mocker.MagicMock())+ mocker.patch(f"{MODULE}.threading.Thread", return_value=mocker.MagicMock())+ mocker.patch(f"{MODULE}.AgentAppGenerateResponseConverter.convert", return_value={"result": "ok"})++ generator.generate(+ app_model=app_model,+ user=user,+ args={"query": "hello", "inputs": {}, AGENT_RUNTIME_EXIT_INTENT_ARG: "delete"},+ invoke_from=InvokeFrom.DEBUGGER,+ streaming=True,+ )++ assert generate_entity.call_args.kwargs["agent_runtime_exit_intent"] == "delete"++ def test_generate_falls_back_to_suspend_for_invalid_internal_exit_intent(self, generator, mocker: MockerFixture):+ app_model = mocker.MagicMock(id="app1", tenant_id="tenant", mode="agent")+ user = DummyAccount("user")++ generator._resolve_agent = mocker.MagicMock(+ return_value=(mocker.MagicMock(id="agent1"), "snap1", "snapshot", mocker.MagicMock())+ )+ generator._prepare_user_inputs = mocker.MagicMock(return_value={})+ generator._init_generate_records = mocker.MagicMock(+ return_value=(mocker.MagicMock(id="conv", mode="agent"), mocker.MagicMock(id="msg"))+ )+ generator._handle_response = mocker.MagicMock(return_value="raw-response")++ mocker.patch(+ f"{MODULE}.AgentAppConfigManager.get_app_config",+ return_value=mocker.MagicMock(variables=[], tenant_id="tenant", app_id="app1"),+ )+ mocker.patch(f"{MODULE}.ModelConfigConverter.convert", return_value=mocker.MagicMock(model="gpt-4o-mini"))+ mocker.patch(f"{MODULE}.TraceQueueManager", return_value=mocker.MagicMock())+ generate_entity = mocker.patch(+ f"{MODULE}.AgentAppGenerateEntity", return_value=mocker.MagicMock(task_id="t", user_id="user")+ )+ mocker.patch(f"{MODULE}.MessageBasedAppQueueManager", return_value=mocker.MagicMock())+ mocker.patch(f"{MODULE}.threading.Thread", return_value=mocker.MagicMock())+ mocker.patch(f"{MODULE}.AgentAppGenerateResponseConverter.convert", return_value={"result": "ok"})++ generator.generate(+ app_model=app_model,+ user=user,+ args={"query": "hello", "inputs": {}, AGENT_RUNTIME_EXIT_INTENT_ARG: "bogus"},+ invoke_from=InvokeFrom.DEBUGGER,+ streaming=True,+ )++ assert generate_entity.call_args.kwargs["agent_runtime_exit_intent"] == "suspend"def test_generate_loads_existing_conversation(self, generator: AgentAppGenerator, mocker: MockerFixture):app_model = mocker.MagicMock(id="app1", tenant_id="tenant", mode="agent")@@ -205,81 +278,6 @@ class TestGenerateSuccess:assert generate_entity.call_args.kwargs["extras"] == {"auto_generate_conversation_name": True}- def test_generate_stateless_skips_chat_records(self, generator: AgentAppGenerator, mocker: MockerFixture):- app_model = mocker.MagicMock(id="app1", tenant_id="tenant", mode="agent")- user = DummyAccount("user")-- generator._resolve_agent = mocker.MagicMock(- return_value=(mocker.MagicMock(id="agent1"), "build-draft-1", "build_draft", mocker.MagicMock())- )- generator._init_generate_records = mocker.MagicMock()- run_stateless = mocker.patch.object(generator, "_run_stateless", return_value={"result": "success"})- converter = mocker.patch(f"{MODULE}.AgentAppGenerateResponseConverter.convert")-- result = generator.generate_stateless(- app_model=app_model,- user=user,- args={- "query": "finalize",- "inputs": {},- "conversation_id": "debug-conversation-1",- "draft_type": "debug_build",- },- invoke_from=InvokeFrom.DEBUGGER,- )-- assert result == {"result": "success"}- generator._init_generate_records.assert_not_called()- converter.assert_not_called()- run_call = run_stateless.call_args.kwargs- assert run_call["conversation_id"] == "debug-conversation-1"- assert run_call["runtime_session_snapshot_id"] == "build-draft-1"-- def test_generate_stateless_requires_conversation_id(self, generator: AgentAppGenerator, mocker: MockerFixture):- with pytest.raises(AgentAppGeneratorError, match="conversation_id is required"):- generator.generate_stateless(- app_model=mocker.MagicMock(),- user=DummyAccount("user"),- args={"query": "finalize", "inputs": {}, "draft_type": "debug_build"},- invoke_from=InvokeFrom.DEBUGGER,- )-- def test_stateless_run_uses_agent_app_runner(self, generator: AgentAppGenerator, mocker: MockerFixture):- app_model = mocker.MagicMock(id="app1", tenant_id="tenant", app_model_config=mocker.MagicMock())- user = DummyAccount("user")- agent = mocker.MagicMock(id="agent1")- dify_context = SimpleNamespace(tenant_id="tenant", app_id="app1")- mocker.patch(f"{MODULE}.DifyRunContext", return_value=dify_context)- runner = mocker.MagicMock()- build_runner = mocker.patch.object(generator, "_build_runner", return_value=runner)-- result = generator._run_stateless(- app_model=app_model,- user=user,- invoke_from=InvokeFrom.DEBUGGER,- query="finalize",- conversation_id="debug-conversation-1",- agent=agent,- agent_config_id="build-draft-1",- agent_config_version_kind="build_draft",- agent_soul=mocker.MagicMock(),- runtime_session_snapshot_id="build-draft-1",- )-- assert result == {"result": "success"}- build_runner.assert_called_once_with(dify_context)- runner.run_stateless.assert_called_once_with(- dify_context=dify_context,- agent_id="agent1",- agent_config_snapshot_id="build-draft-1",- agent_config_version_kind="build_draft",- agent_soul=mocker.ANY,- conversation_id="debug-conversation-1",- query="finalize",- idempotency_key=mocker.ANY,- session_scope_snapshot_id="build-draft-1",- )-class TestGenerateWorker:@pytest.fixture(autouse=True)@@ -329,6 +327,7 @@ class TestGenerateWorker:query="query",runtime_session_snapshot_id="s",prompt_file_mappings=(),+ agent_runtime_exit_intent="suspend",):generator._generate_worker(flask_app=mocker.MagicMock(),@@ -337,6 +336,7 @@ class TestGenerateWorker:agent_id="a",agent_config_snapshot_id="s",agent_runtime_session_snapshot_id=runtime_session_snapshot_id,+ agent_runtime_exit_intent=agent_runtime_exit_intent,model_conf=mocker.MagicMock(model="m"),query=query,prompt_file_mappings=prompt_file_mappings,@@ -364,6 +364,14 @@ class TestGenerateWorker:assert runner.run.call_args.kwargs["agent_config_snapshot_id"] == "s"assert runner.run.call_args.kwargs["session_scope_snapshot_id"] is None+ def test_worker_forwards_runtime_exit_intent_to_runner(self, generator, mocker: MockerFixture):+ runner = self._wire(generator, mocker)+ queue_manager = mocker.MagicMock()++ self._call(generator, mocker, queue_manager, agent_runtime_exit_intent="delete")++ assert runner.run.call_args.kwargs["agent_runtime_exit_intent"] == "delete"+def test_worker_appends_prompt_files_to_backend_query(self, generator, mocker: MockerFixture):runner = self._wire(generator, mocker, guard_query="你看得见这张图片吗")queue_manager = mocker.MagicMock()@@ -373,7 +381,23 @@ class TestGenerateWorker:"transfer_method": "local_file","url": "","upload_file_id": "upload-file-1",- }+ },+ {+ "type": "document",+ "transfer_method": "remote_url",+ "url": "https://example.com/source.pdf",+ "upload_file_id": "ignored",+ },+ ]+ expected_file_mappings = [+ {+ "transfer_method": "local_file",+ "reference": build_file_reference(record_id="upload-file-1"),+ },+ {+ "transfer_method": "remote_url",+ "url": "https://example.com/source.pdf",+ },]self._call(@@ -385,7 +409,10 @@ class TestGenerateWorker:)assert runner.run.call_args.kwargs["query"] == (- f"你看得见这张图片吗\n{json.dumps(file_mappings, ensure_ascii=False)}"+ "你看得见这张图片吗\nUser provided files: "+ "use dify-agent file download with the listed transfer_method and reference/url "+ "to get the files and investigate them\n"+ f"{json.dumps(expected_file_mappings, ensure_ascii=False, separators=(',', ':'))}")def test_input_guard_short_circuit_skips_backend(self, generator, mocker: MockerFixture):@@ -461,6 +488,7 @@ class TestResumeAfterFormSubmission:# The paused turn's query is re-sent verbatim — never blank.assert entity.call_args.kwargs["query"] == "original question"+ assert "agent_runtime_exit_intent" not in entity.call_args.kwargsdef test_resume_falls_back_to_placeholder_when_no_paused_message(self, generator, mocker: MockerFixture):entity = self._wire(generator, mocker)diff --git a/api/tests/unit_tests/core/app/apps/agent_app/test_app_runner.py b/api/tests/unit_tests/core/app/apps/agent_app/test_app_runner.pyindex e0a7687de95..ffef1cf3be8 100644--- a/api/tests/unit_tests/core/app/apps/agent_app/test_app_runner.py+++ b/api/tests/unit_tests/core/app/apps/agent_app/test_app_runner.py@@ -28,8 +28,6 @@ from pydantic_ai.messages import (FunctionToolCallEvent,FunctionToolResultEvent,PartDeltaEvent,- PartStartEvent,- TextPart,TextPartDelta,ThinkingPartDelta,ToolCallPart,@@ -49,7 +47,12 @@ from core.app.apps.agent_app.runtime_request_builder import AgentAppRuntimeRequefrom core.app.apps.agent_app.session_store import AgentAppSessionScope, StoredAgentAppSessionfrom core.app.apps.exc import GenerateTaskStoppedErrorfrom core.app.entities.app_invoke_entities import InvokeFrom, UserFrom-from core.app.entities.queue_entities import QueueAgentThoughtEvent, QueueLLMChunkEvent, QueueMessageEndEvent+from core.app.entities.queue_entities import (+ QueueAgentMessageEvent,+ QueueAgentThoughtEvent,+ QueueLLMChunkEvent,+ QueueMessageEndEvent,+)from core.workflow.nodes.agent_v2.ask_human_resume import AskHumanResumeOutcomefrom models.agent_config_entities import AgentSoulConfigfrom models.model import MessageAgentThought@@ -98,24 +101,6 @@ class _RecordingFakeAgentBackendRunClient(FakeAgentBackendRunClient):return super().cancel_run(run_id, request=request)-class _BlockingRecordingFakeAgentBackendRunClient(FakeAgentBackendRunClient):- def __init__(self, **kwargs: Any) -> None:- super().__init__(**kwargs)- self.wait_calls: list[tuple[str, float | None]] = []- self.stream_called = False-- @override- def stream_events(self, run_id: str, *, after: str | None = None) -> Iterator[RunEvent]:- del run_id, after- self.stream_called = True- return iter(())-- @override- def wait_run(self, run_id: str, *, timeout_seconds: float | None = None):- self.wait_calls.append((run_id, timeout_seconds))- return super().wait_run(run_id, timeout_seconds=timeout_seconds)--class _StreamingFakeAgentBackendRunClient(FakeAgentBackendRunClient):@overridedef stream_events(self, run_id: str, *, after: str | None = None) -> Iterator[RunEvent]:@@ -127,12 +112,14 @@ class _StreamingFakeAgentBackendRunClient(FakeAgentBackendRunClient):run_id=run_id,created_at=created_at,data=PartDeltaEvent(index=0, delta=TextPartDelta(content_delta="hello ")),+ agent_message_delta="hello ",)yield PydanticAIStreamRunEvent(id="3-0",run_id=run_id,created_at=created_at,data=PartDeltaEvent(index=0, delta=TextPartDelta(content_delta="agent")),+ agent_message_delta="agent",)yield RunSucceededEvent(id="4-0",@@ -157,12 +144,14 @@ class _StreamingRecordingFakeAgentBackendRunClient(_RecordingFakeAgentBackendRunrun_id=run_id,created_at=created_at,data=PartDeltaEvent(index=0, delta=TextPartDelta(content_delta="hello ")),+ agent_message_delta="hello ",)yield PydanticAIStreamRunEvent(id="3-0",run_id=run_id,created_at=created_at,data=PartDeltaEvent(index=0, delta=TextPartDelta(content_delta="agent")),+ agent_message_delta="agent",)yield RunSucceededEvent(id="4-0",@@ -190,6 +179,7 @@ class _StreamingStopAfterFirstDeltaFakeAgentBackendRunClient(_RecordingFakeAgentrun_id=run_id,created_at=created_at,data=PartDeltaEvent(index=0, delta=TextPartDelta(content_delta="hello ")),+ agent_message_delta="hello ",)self._queue_manager.request_stop()yield PydanticAIStreamRunEvent(@@ -197,10 +187,11 @@ class _StreamingStopAfterFirstDeltaFakeAgentBackendRunClient(_RecordingFakeAgentrun_id=run_id,created_at=created_at,data=PartDeltaEvent(index=0, delta=TextPartDelta(content_delta="agent")),+ agent_message_delta="agent",)-class _StreamingPartStartFakeAgentBackendRunClient(FakeAgentBackendRunClient):+class _StreamingSingleAgentMessageDeltaFakeAgentBackendRunClient(FakeAgentBackendRunClient):@overridedef stream_events(self, run_id: str, *, after: str | None = None) -> Iterator[RunEvent]:del after@@ -210,7 +201,8 @@ class _StreamingPartStartFakeAgentBackendRunClient(FakeAgentBackendRunClient):id="2-0",run_id=run_id,created_at=created_at,- data=PartStartEvent(index=0, part=TextPart(content="hello")),+ data=PartDeltaEvent(index=0, delta=TextPartDelta(content_delta="hello")),+ agent_message_delta="hello",)yield RunSucceededEvent(id="3-0",@@ -251,6 +243,7 @@ class _StreamingTextNullOutputFakeAgentBackendRunClient(FakeAgentBackendRunClienrun_id=run_id,created_at=created_at,data=PartDeltaEvent(index=0, delta=TextPartDelta(content_delta="streamed answer")),+ agent_message_delta="streamed answer",)yield RunSucceededEvent(id="3-0",@@ -263,6 +256,37 @@ class _StreamingTextNullOutputFakeAgentBackendRunClient(FakeAgentBackendRunClien)+class _AgentAnswerStreamingFakeAgentBackendRunClient(FakeAgentBackendRunClient):+ @override+ def stream_events(self, run_id: str, *, after: str | None = None) -> Iterator[RunEvent]:+ del after+ created_at = datetime(2026, 1, 1, tzinfo=UTC)+ yield RunStartedEvent(id="1-0", run_id=run_id, created_at=created_at)+ yield PydanticAIStreamRunEvent(+ id="2-0",+ run_id=run_id,+ created_at=created_at,+ data=PartDeltaEvent(index=0, delta=TextPartDelta(content_delta="hello ")),+ agent_message_delta="hello ",+ )+ yield PydanticAIStreamRunEvent(+ id="3-0",+ run_id=run_id,+ created_at=created_at,+ data=PartDeltaEvent(index=0, delta=TextPartDelta(content_delta="agent")),+ agent_message_delta="agent",+ )+ yield RunSucceededEvent(+ id="4-0",+ run_id=run_id,+ created_at=created_at,+ data=RunSucceededEventData(+ output={"text": "final answer"},+ session_snapshot=CompositorSessionSnapshot(layers=[]),+ ),+ )++class _ProcessStreamingFakeAgentBackendRunClient(FakeAgentBackendRunClient):@overridedef stream_events(self, run_id: str, *, after: str | None = None) -> Iterator[RunEvent]:@@ -292,6 +316,7 @@ class _ProcessStreamingFakeAgentBackendRunClient(FakeAgentBackendRunClient):run_id=run_id,created_at=created_at,data=PartDeltaEvent(index=1, delta=TextPartDelta(content_delta="final answer")),+ agent_message_delta="final answer",)yield RunSucceededEvent(id="6-0",@@ -318,6 +343,9 @@ class _FakeDbSession:def get(self, _model: type[MessageAgentThought], row_id: str) -> MessageAgentThought | None:return self.rows.get(row_id)+ def delete(self, row: MessageAgentThought) -> None:+ self.rows.pop(str(row.id), None)+def rollback(self) -> None:self.rollback_count += 1@@ -327,9 +355,11 @@ class _FakeSessionStore:self,loaded: CompositorSessionSnapshot | None = None,loaded_session: StoredAgentAppSession | None = None,+ listed_sessions: list[StoredAgentAppSession] | None = None,) -> None:self.loaded = loadedself._loaded_session = loaded_session+ self._listed_sessions = list(listed_sessions or [])self.loaded_scopes: list[AgentAppSessionScope] = []self.saved: list[tuple[@@ -341,6 +371,7 @@ class _FakeSessionStore:str | None,]] = []+ self.cleaned: list[tuple[AgentAppSessionScope, str | None]] = []def load_active_snapshot(self, scope: AgentAppSessionScope) -> CompositorSessionSnapshot | None:self.loaded_scopes.append(scope)@@ -354,6 +385,14 @@ class _FakeSessionStore:return Nonereturn StoredAgentAppSession(scope=scope, session_snapshot=self.loaded, backend_run_id=None)+ def list_active_sessions_for_conversation(+ self, *, tenant_id: str, app_id: str, conversation_id: str+ ) -> list[StoredAgentAppSession]:+ assert tenant_id == "tenant-1"+ assert app_id == "app-1"+ assert conversation_id == "conv-1"+ return list(self._listed_sessions)+def save_active_snapshot(self,*,@@ -368,6 +407,9 @@ class _FakeSessionStore:(scope, backend_run_id, snapshot, list(runtime_layer_specs), pending_form_id, pending_tool_call_id))+ def mark_cleaned(self, *, scope: AgentAppSessionScope, backend_run_id: str | None = None) -> None:+ self.cleaned.append((scope, backend_run_id))+class _MonotonicClock:def __init__(self, *values: float) -> None:@@ -409,7 +451,7 @@ def _runner(client: FakeAgentBackendRunClient,store: _FakeSessionStore,*,- text_delta_debounce_seconds: float | None = 0,+ text_delta_debounce_seconds: float = 0,) -> AgentAppRunner:return AgentAppRunner(request_builder=AgentAppRuntimeRequestBuilder(@@ -423,7 +465,7 @@ def _runner()-def _run(runner: AgentAppRunner, qm: _FakeQueueManager) -> None:+def _run(runner: AgentAppRunner, qm: _FakeQueueManager, *, agent_runtime_exit_intent: str = "suspend") -> None:runner.run(dify_context=_dify_ctx(),agent_id="agent-1",@@ -434,18 +476,7 @@ def _run(runner: AgentAppRunner, qm: _FakeQueueManager) -> None:message_id="msg-1",model_name="gpt-4o-mini",queue_manager=qm, # type: ignore[arg-type]- )---def _run_stateless(runner: AgentAppRunner) -> None:- runner.run_stateless(- dify_context=_dify_ctx(),- agent_id="agent-1",- agent_config_snapshot_id="snap-1",- agent_soul=_soul(),- conversation_id="conv-1",- query="finalize",- idempotency_key="run-req-1",+ agent_runtime_exit_intent=agent_runtime_exit_intent, # type: ignore[arg-type])@@ -470,6 +501,8 @@ def test_successful_turn_publishes_chunk_and_message_end_and_saves_session():_run(_runner(client, store), qm)+ assert client.request is not None+ assert client.request.on_exit.default.value == "suspend"# One LLM chunk + one message-end, carrying the backend's answer text.chunk_events = [e for e in qm.events if isinstance(e, QueueLLMChunkEvent)]end_events = [e for e in qm.events if isinstance(e, QueueMessageEndEvent)]@@ -490,38 +523,169 @@ def test_successful_turn_publishes_chunk_and_message_end_and_saves_session():# A successful turn carries no ask_human pause correlation.assert pending_form_id is Noneassert pending_tool_call_id is None+ assert store.cleaned == []+++def test_successful_turn_enqueues_cleanup_for_superseded_sessions_after_saving_snapshot(monkeypatch):+ superseded = StoredAgentAppSession(+ scope=AgentAppSessionScope(+ tenant_id="tenant-1",+ app_id="app-1",+ conversation_id="conv-1",+ agent_id="agent-2",+ agent_config_snapshot_id="snap-2",+ ),+ session_snapshot=CompositorSessionSnapshot(layers=[]),+ backend_run_id="run-old",+ runtime_layer_specs=[RuntimeLayerSpec(name="history", type="pydantic_ai.history")],+ )+ current_scope_session = StoredAgentAppSession(+ scope=AgentAppSessionScope(+ tenant_id="tenant-1",+ app_id="app-1",+ conversation_id="conv-1",+ agent_id="agent-1",+ agent_config_snapshot_id="snap-1",+ ),+ session_snapshot=CompositorSessionSnapshot(layers=[]),+ backend_run_id="run-current",+ runtime_layer_specs=[RuntimeLayerSpec(name="history", type="pydantic_ai.history")],+ )+ store = _FakeSessionStore(listed_sessions=[current_scope_session, superseded])+ client = FakeAgentBackendRunClient()+ qm = _FakeQueueManager()+ cleanup_delay = MagicMock()+ monkeypatch.setattr(app_runner_module.cleanup_conversation_agent_runtime_session, "delay", cleanup_delay)+ _run(_runner(client, store), qm)++ assert store.saved+ cleanup_delay.assert_called_once()+ payload = cleanup_delay.call_args.args[0]+ assert payload["metadata"]["conversation_id"] == "conv-1"+ assert payload["metadata"]["agent_id"] == "agent-2"+ assert payload["metadata"]["previous_agent_backend_run_id"] == "run-old"+ assert payload["idempotency_key"] == "tenant-1:app-1:conv-1:agent-2:snap-2:superseded-session-cleanup:run-old"-def test_successful_turn_forwards_agent_backend_stream_text_deltas_without_duplicate_terminal_chunk():++def test_superseded_session_cleanup_enqueue_failure_does_not_fail_turn(monkeypatch):+ superseded = StoredAgentAppSession(+ scope=AgentAppSessionScope(+ tenant_id="tenant-1",+ app_id="app-1",+ conversation_id="conv-1",+ agent_id="agent-2",+ agent_config_snapshot_id="snap-2",+ ),+ session_snapshot=CompositorSessionSnapshot(layers=[]),+ backend_run_id="run-old",+ runtime_layer_specs=[RuntimeLayerSpec(name="history", type="pydantic_ai.history")],+ )+ store = _FakeSessionStore(listed_sessions=[superseded])+ client = FakeAgentBackendRunClient()+ qm = _FakeQueueManager()+ cleanup_delay = MagicMock(side_effect=RuntimeError("queue down"))+ monkeypatch.setattr(app_runner_module.cleanup_conversation_agent_runtime_session, "delay", cleanup_delay)++ _run(_runner(client, store), qm)++ cleanup_delay.assert_called_once()+ end_events = [e for e in qm.events if isinstance(e, QueueMessageEndEvent)]+ assert len(end_events) == 1+ assert end_events[0].llm_result.message.content == "hello agent"+++def test_delete_on_exit_turn_marks_session_cleaned_without_saving_snapshot():+ client = _StreamingRecordingFakeAgentBackendRunClient()+ store = _FakeSessionStore()+ qm = _FakeQueueManager()++ _run(_runner(client, store), qm, agent_runtime_exit_intent="delete")++ assert client.request is not None+ assert client.request.on_exit.default.value == "delete"+ assert store.saved == []+ assert len(store.cleaned) == 1+ cleaned_scope, cleaned_run_id = store.cleaned[0]+ assert cleaned_scope.conversation_id == "conv-1"+ assert cleaned_scope.agent_config_snapshot_id == "snap-1"+ assert cleaned_run_id == "fake-run-1"+ end_events = [e for e in qm.events if isinstance(e, QueueMessageEndEvent)]+ assert len(end_events) == 1+ assert end_events[0].llm_result.message.content == "hello agent"+++def test_delete_on_exit_turn_swallows_cleanup_failure_after_success():+ client = _StreamingRecordingFakeAgentBackendRunClient()+ store = _FakeSessionStore()+ store.mark_cleaned = MagicMock(side_effect=RuntimeError("cleanup failed")) # type: ignore[method-assign]+ qm = _FakeQueueManager()++ _run(_runner(client, store), qm, agent_runtime_exit_intent="delete")++ assert store.saved == []+ store.mark_cleaned.assert_called_once()+ end_events = [e for e in qm.events if isinstance(e, QueueMessageEndEvent)]+ assert len(end_events) == 1+++def test_delete_on_exit_turn_marks_session_cleaned_when_publish_fails():+ client = _StreamingRecordingFakeAgentBackendRunClient()+ store = _FakeSessionStore()+ store.mark_cleaned = MagicMock(side_effect=RuntimeError("cleanup failed")) # type: ignore[method-assign]+ qm = _FakeQueueManager()+ runner = _runner(client, store)+ runner._publish_terminal_answer = MagicMock(side_effect=RuntimeError("publish failed"))++ with pytest.raises(RuntimeError, match="publish failed"):+ _run(runner, qm, agent_runtime_exit_intent="delete")++ assert store.saved == []+ store.mark_cleaned.assert_called_once()+++def test_successful_turn_routes_stream_text_to_agent_message_and_uses_terminal_output(monkeypatch):+ fake_session = _FakeDbSession()+ monkeypatch.setattr(app_runner_module.db, "session", fake_session)client = _StreamingFakeAgentBackendRunClient()store = _FakeSessionStore()qm = _FakeQueueManager()- _run(_runner(client, store, text_delta_debounce_seconds=0), qm)+ _run(_runner(client, store), qm)chunk_events = [e for e in qm.events if isinstance(e, QueueLLMChunkEvent)]+ agent_message_events = [e for e in qm.events if isinstance(e, QueueAgentMessageEvent)]end_events = [e for e in qm.events if isinstance(e, QueueMessageEndEvent)]- assert [event.chunk.delta.message.content for event in chunk_events] == ["hello ", "agent"]+ assert [event.chunk.delta.message.content for event in chunk_events] == ["hello agent"]+ assert [event.chunk.delta.message.content for event in agent_message_events] == ["hello ", "agent"]assert len(end_events) == 1assert end_events[0].llm_result.message.content == "hello agent"assert end_events[0].llm_result.usage.prompt_tokens == 3assert end_events[0].llm_result.usage.completion_tokens == 5assert end_events[0].llm_result.usage.total_tokens == 8+ rows = sorted(fake_session.rows.values(), key=lambda row: row.position)+ assert rows == []assert store.saved-def test_successful_turn_forwards_part_start_text_and_publishes_missing_terminal_suffix():- client = _StreamingPartStartFakeAgentBackendRunClient()+def test_successful_turn_routes_single_agent_message_delta(monkeypatch):+ fake_session = _FakeDbSession()+ monkeypatch.setattr(app_runner_module.db, "session", fake_session)+ client = _StreamingSingleAgentMessageDeltaFakeAgentBackendRunClient()store = _FakeSessionStore()qm = _FakeQueueManager()- _run(_runner(client, store, text_delta_debounce_seconds=0), qm)+ _run(_runner(client, store), qm)chunk_events = [e for e in qm.events if isinstance(e, QueueLLMChunkEvent)]+ agent_message_events = [e for e in qm.events if isinstance(e, QueueAgentMessageEvent)]end_events = [e for e in qm.events if isinstance(e, QueueMessageEndEvent)]- assert [event.chunk.delta.message.content for event in chunk_events] == ["hello", " agent"]+ assert [event.chunk.delta.message.content for event in chunk_events] == ["hello agent"]+ assert [event.chunk.delta.message.content for event in agent_message_events] == ["hello"]assert len(end_events) == 1assert end_events[0].llm_result.message.content == "hello agent"+ rows = sorted(fake_session.rows.values(), key=lambda row: row.position)+ assert rows == []def test_successful_turn_with_null_terminal_output_publishes_empty_answer_not_literal_null():@@ -532,50 +696,65 @@ def test_successful_turn_with_null_terminal_output_publishes_empty_answer_not_li_run(_runner(client, store), qm)chunk_events = [e for e in qm.events if isinstance(e, QueueLLMChunkEvent)]+ agent_message_events = [e for e in qm.events if isinstance(e, QueueAgentMessageEvent)]end_events = [e for e in qm.events if isinstance(e, QueueMessageEndEvent)]assert chunk_events == []+ assert agent_message_events == []assert len(end_events) == 1assert end_events[0].llm_result.message.content == ""-def test_successful_turn_with_streamed_text_and_null_terminal_output_keeps_streamed_answer():+def test_successful_turn_with_stream_text_and_null_terminal_output_keeps_empty_message(monkeypatch):+ fake_session = _FakeDbSession()+ monkeypatch.setattr(app_runner_module.db, "session", fake_session)client = _StreamingTextNullOutputFakeAgentBackendRunClient()store = _FakeSessionStore()qm = _FakeQueueManager()- _run(_runner(client, store, text_delta_debounce_seconds=0), qm)+ _run(_runner(client, store), qm)chunk_events = [e for e in qm.events if isinstance(e, QueueLLMChunkEvent)]+ agent_message_events = [e for e in qm.events if isinstance(e, QueueAgentMessageEvent)]end_events = [e for e in qm.events if isinstance(e, QueueMessageEndEvent)]- assert [event.chunk.delta.message.content for event in chunk_events] == ["streamed answer"]+ assert chunk_events == []+ assert [event.chunk.delta.message.content for event in agent_message_events] == ["streamed answer"]assert len(end_events) == 1- assert end_events[0].llm_result.message.content == "streamed answer"+ assert end_events[0].llm_result.message.content == ""+ rows = sorted(fake_session.rows.values(), key=lambda row: row.position)+ assert len(rows) == 1+ assert rows[0].answer == "streamed answer"-def test_successful_turn_persists_thinking_and_tool_process_events(monkeypatch):+def test_successful_turn_routes_agent_answer_to_agent_message(monkeypatch):fake_session = _FakeDbSession()monkeypatch.setattr(app_runner_module.db, "session", fake_session)- client = _ProcessStreamingFakeAgentBackendRunClient()+ client = _AgentAnswerStreamingFakeAgentBackendRunClient()store = _FakeSessionStore()qm = _FakeQueueManager()- _run(_runner(client, store, text_delta_debounce_seconds=0), qm)+ _run(_runner(client, store), qm)chunk_events = [e for e in qm.events if isinstance(e, QueueLLMChunkEvent)]+ agent_message_events = [e for e in qm.events if isinstance(e, QueueAgentMessageEvent)]assert [event.chunk.delta.message.content for event in chunk_events] == ["final answer"]+ assert [event.chunk.delta.message.content for event in agent_message_events] == ["hello ", "agent"]+ end_events = [e for e in qm.events if isinstance(e, QueueMessageEndEvent)]+ assert len(end_events) == 1+ assert end_events[0].llm_result.message.content == "final answer"thought_events = [e for e in qm.events if isinstance(e, QueueAgentThoughtEvent)]- assert len(thought_events) >= 3+ assert len(thought_events) == 2rows = sorted(fake_session.rows.values(), key=lambda row: row.position)- assert rows[0].thought == "I need to inspect the file."+ assert len(rows) == 1+ assert rows[0].answer == "hello agent"+ assert rows[0].thought == ""assert rows[0].tool == ""- assert rows[1].tool == "bash"- assert rows[1].tool_input == '{"cmd": "ls"}'- assert rows[1].observation == "ok"-def test_streaming_turn_batches_text_deltas_within_debounce_window(monkeypatch):+def test_agent_message_deltas_are_debounced_to_agent_message(monkeypatch):monkeypatch.setattr(app_runner_module.time, "monotonic", _MonotonicClock(0.0, 0.2))+ fake_session = _FakeDbSession()+ monkeypatch.setattr(app_runner_module.db, "session", fake_session)client = _StreamingFakeAgentBackendRunClient()store = _FakeSessionStore()qm = _FakeQueueManager()@@ -583,38 +762,55 @@ def test_streaming_turn_batches_text_deltas_within_debounce_window(monkeypatch):_run(_runner(client, store, text_delta_debounce_seconds=0.5), qm)chunk_events = [e for e in qm.events if isinstance(e, QueueLLMChunkEvent)]- end_events = [e for e in qm.events if isinstance(e, QueueMessageEndEvent)]+ agent_message_events = [e for e in qm.events if isinstance(e, QueueAgentMessageEvent)]assert [event.chunk.delta.message.content for event in chunk_events] == ["hello agent"]- assert len(end_events) == 1- assert end_events[0].llm_result.message.content == "hello agent"+ assert [event.chunk.delta.message.content for event in agent_message_events] == ["hello agent"]+ rows = sorted(fake_session.rows.values(), key=lambda row: row.position)+ assert rows == []-def test_streaming_turn_flushes_pending_text_before_terminal_success(monkeypatch):- monkeypatch.setattr(app_runner_module.time, "monotonic", _MonotonicClock(0.0))- client = _StreamingPartStartFakeAgentBackendRunClient()+def test_successful_turn_persists_thinking_and_tool_process_events(monkeypatch):+ fake_session = _FakeDbSession()+ monkeypatch.setattr(app_runner_module.db, "session", fake_session)+ client = _ProcessStreamingFakeAgentBackendRunClient()store = _FakeSessionStore()qm = _FakeQueueManager()- _run(_runner(client, store, text_delta_debounce_seconds=0.5), qm)+ _run(_runner(client, store), qm)chunk_events = [e for e in qm.events if isinstance(e, QueueLLMChunkEvent)]- end_events = [e for e in qm.events if isinstance(e, QueueMessageEndEvent)]- assert [event.chunk.delta.message.content for event in chunk_events] == ["hello", " agent"]- assert len(end_events) == 1- assert end_events[0].llm_result.message.content == "hello agent"+ agent_message_events = [e for e in qm.events if isinstance(e, QueueAgentMessageEvent)]+ assert [event.chunk.delta.message.content for event in chunk_events] == ["final answer"]+ assert [event.chunk.delta.message.content for event in agent_message_events] == ["final answer"]+ thought_events = [e for e in qm.events if isinstance(e, QueueAgentThoughtEvent)]+ assert len(thought_events) >= 3++ rows = sorted(fake_session.rows.values(), key=lambda row: row.position)+ assert rows[0].thought == "I need to inspect the file."+ assert rows[0].tool == ""+ assert rows[1].tool == "bash"+ assert rows[1].tool_input == '{"cmd": "ls"}'+ assert rows[1].observation == "ok"+ assert len(rows) == 2-def test_streaming_turn_flushes_pending_text_before_stop_and_cancel(monkeypatch):- monkeypatch.setattr(app_runner_module.time, "monotonic", _MonotonicClock(0.0))+def test_streaming_turn_cancels_after_persisting_seen_agent_answer(monkeypatch):+ fake_session = _FakeDbSession()+ monkeypatch.setattr(app_runner_module.db, "session", fake_session)store = _FakeSessionStore()qm = _FakeQueueManager()client = _StreamingStopAfterFirstDeltaFakeAgentBackendRunClient(queue_manager=qm)with pytest.raises(GenerateTaskStoppedError):- _run(_runner(client, store, text_delta_debounce_seconds=0.5), qm)+ _run(_runner(client, store), qm)chunk_events = [e for e in qm.events if isinstance(e, QueueLLMChunkEvent)]- assert [event.chunk.delta.message.content for event in chunk_events] == ["hello "]+ agent_message_events = [e for e in qm.events if isinstance(e, QueueAgentMessageEvent)]+ assert chunk_events == []+ assert [event.chunk.delta.message.content for event in agent_message_events] == ["hello "]+ rows = sorted(fake_session.rows.values(), key=lambda row: row.position)+ assert len(rows) == 1+ assert rows[0].answer == "hello "assert client.cancelled_run_ids == ["fake-run-1"]@@ -662,6 +858,143 @@ def test_tool_result_without_identity_does_not_attach_to_previous_tool(monkeypatassert rows[1].observation == "Knowledge base search results: browser skill"+def test_answer_suffix_trim_keeps_non_terminal_prefix(monkeypatch):+ fake_session = _FakeDbSession()+ monkeypatch.setattr(app_runner_module.db, "session", fake_session)+ qm = _FakeQueueManager()+ recorder = app_runner_module._AgentProcessRecorder(+ dify_context=_dify_ctx(),+ message_id="msg-1",+ queue_manager=qm, # type: ignore[arg-type]+ )++ recorder.append_answer_text("intermediate final answer")+ recorder.trim_answer_suffix("final answer")++ rows = sorted(fake_session.rows.values(), key=lambda row: row.position)+ assert len(rows) == 1+ assert rows[0].answer == "intermediate "+++def test_tool_call_part_binds_late_call_id_to_delta_row(monkeypatch):+ fake_session = _FakeDbSession()+ monkeypatch.setattr(app_runner_module.db, "session", fake_session)+ qm = _FakeQueueManager()+ recorder = app_runner_module._AgentProcessRecorder(+ dify_context=_dify_ctx(),+ message_id="msg-1",+ queue_manager=qm, # type: ignore[arg-type]+ )++ recorder.handle_stream_event(+ AgentBackendStreamInternalEvent(+ run_id="run-1",+ data={+ "event_kind": "part_delta",+ "index": 0,+ "delta": {+ "part_delta_kind": "tool_call",+ "tool_name_delta": "knowledge_base_search",+ "args_delta": {"query": "browser"},+ },+ },+ )+ )+ recorder.handle_stream_event(+ AgentBackendStreamInternalEvent(+ run_id="run-1",+ data={+ "event_kind": "part_start",+ "index": 0,+ "part": {+ "part_kind": "tool-call",+ "tool_name": "knowledge_base_search",+ "args": {"query": "browser"},+ "tool_call_id": "tool-call-1",+ },+ },+ )+ )+ recorder.handle_stream_event(+ AgentBackendStreamInternalEvent(+ run_id="run-1",+ data={+ "event_kind": "function_tool_result",+ "part": {+ "part_kind": "tool-return",+ "tool_name": "knowledge_base_search",+ "content": "Knowledge base search results: browser skill",+ "tool_call_id": "tool-call-1",+ },+ },+ )+ )++ rows = sorted(fake_session.rows.values(), key=lambda row: row.position)+ assert len(rows) == 1+ assert rows[0].tool == "knowledge_base_search"+ assert rows[0].tool_input == '{"query": "browser"}'+ assert rows[0].observation == "Knowledge base search results: browser skill"+++def test_thinking_after_tool_starts_new_snapshot_row(monkeypatch):+ fake_session = _FakeDbSession()+ monkeypatch.setattr(app_runner_module.db, "session", fake_session)+ qm = _FakeQueueManager()+ recorder = app_runner_module._AgentProcessRecorder(+ dify_context=_dify_ctx(),+ message_id="msg-1",+ queue_manager=qm, # type: ignore[arg-type]+ )++ recorder.handle_stream_event(+ AgentBackendStreamInternalEvent(+ run_id="run-1",+ data={+ "event_kind": "part_delta",+ "index": 0,+ "delta": {+ "part_delta_kind": "thinking",+ "content_delta": "The first thought.",+ },+ },+ )+ )+ recorder.handle_stream_event(+ AgentBackendStreamInternalEvent(+ run_id="run-1",+ data={+ "event_kind": "function_tool_call",+ "part": {+ "part_kind": "tool-call",+ "tool_name": "shell_run",+ "args": {"cmd": "date"},+ "tool_call_id": "tool-call-1",+ },+ },+ )+ )+ recorder.handle_stream_event(+ AgentBackendStreamInternalEvent(+ run_id="run-1",+ data={+ "event_kind": "part_delta",+ "index": 0,+ "delta": {+ "part_delta_kind": "thinking",+ "content_delta": "The next thought.",+ },+ },+ )+ )++ rows = sorted(fake_session.rows.values(), key=lambda row: row.position)+ assert [row.thought for row in rows] == ["The first thought.", "", "The next thought."]+ assert rows[0].id != rows[2].id+ assert rows[1].tool == "shell_run"+ assert rows[1].tool_input == '{"cmd": "date"}'++def test_tool_result_without_call_id_matches_unique_open_tool_name(monkeypatch):fake_session = _FakeDbSession()monkeypatch.setattr(app_runner_module.db, "session", fake_session)@@ -743,31 +1076,6 @@ def test_debug_session_scope_can_reuse_conversation_across_config_snapshots():assert store.saved[0][0].agent_config_snapshot_id is None-def test_stateless_run_uses_bounded_wait_and_does_not_save_session_state():- prior = CompositorSessionSnapshot(layers=[])- client = _BlockingRecordingFakeAgentBackendRunClient()- store = _FakeSessionStore(loaded=prior)-- _run_stateless(_runner(client, store))-- assert client.request is not None- assert client.request.session_snapshot is prior- assert client.wait_calls == [("fake-run-1", app_runner_module.dify_config.APP_MAX_EXECUTION_TIME)]- assert client.stream_called is False- assert store.saved == []---def test_stateless_run_raises_backend_error_on_failed_bounded_wait():- client = _BlockingRecordingFakeAgentBackendRunClient(scenario=FakeAgentBackendScenario.FAILED)- store = _FakeSessionStore()-- with pytest.raises(AgentBackendError):- _run_stateless(_runner(client, store))-- assert client.wait_calls == [("fake-run-1", app_runner_module.dify_config.APP_MAX_EXECUTION_TIME)]- assert store.saved == []--def test_failed_run_raises_agent_backend_error():client = FakeAgentBackendRunClient(scenario=FakeAgentBackendScenario.FAILED)store = _FakeSessionStore()@@ -792,11 +1100,11 @@ def test_stopped_task_cancels_agent_backend_run_and_skips_session_save():assert store.saved == []-def test_extract_answer_handles_plain_string_and_dict():- assert AgentAppRunner._extract_answer(None) == ""- assert AgentAppRunner._extract_answer("plain text") == "plain text"- assert AgentAppRunner._extract_answer({"text": "hi"}) == "hi"- assert AgentAppRunner._extract_answer({"a": 1}) == '{"a": 1}'+def test_terminal_output_to_answer_handles_plain_string_and_dict():+ assert AgentAppRunner._terminal_output_to_answer(None) == ""+ assert AgentAppRunner._terminal_output_to_answer("plain text") == "plain text"+ assert AgentAppRunner._terminal_output_to_answer({"text": "hi"}) == "hi"+ assert AgentAppRunner._terminal_output_to_answer({"a": 1}) == '{"a": 1}'def test_ask_human_pauses_turn_creates_form_and_persists_correlation():@@ -827,6 +1135,22 @@ def test_ask_human_pauses_turn_creates_form_and_persists_correlation():assert store.saved[0][5] == "fake-ask-human-1"+def test_delete_on_exit_deferred_tool_marks_session_cleaned_and_raises_error():+ client = FakeAgentBackendRunClient(scenario=FakeAgentBackendScenario.PAUSED)+ store = _FakeSessionStore()+ store.mark_cleaned = MagicMock(side_effect=RuntimeError("cleanup failed")) # type: ignore[method-assign]+ qm = _FakeQueueManager()+ runner = _runner(client, store)+ runner._pause_for_ask_human = MagicMock()++ with pytest.raises(AgentBackendError, match="finalization cannot pause for human input"):+ _run(runner, qm, agent_runtime_exit_intent="delete")++ runner._pause_for_ask_human.assert_not_called()+ assert store.saved == []+ store.mark_cleaned.assert_called_once()++def test_submitted_form_resumes_turn_with_deferred_tool_results(monkeypatch):# ENG-638: a turn that runs while a pending form is answered threads the# human's reply into the request as deferred_tool_results.diff --git a/api/tests/unit_tests/core/app/apps/agent_app/test_runtime_request_builder.py b/api/tests/unit_tests/core/app/apps/agent_app/test_runtime_request_builder.pyindex 9828216f3b8..b3ea05b8a87 100644--- a/api/tests/unit_tests/core/app/apps/agent_app/test_runtime_request_builder.py+++ b/api/tests/unit_tests/core/app/apps/agent_app/test_runtime_request_builder.py@@ -57,7 +57,6 @@ class TestBuildForAgentApp:"llm",]assert "workflow_node_job_prompt" not in names- assert request.purpose == "agent_app"# Agent App keeps layers alive across turns by default.assert request.on_exit.default.value == "suspend"@@ -143,6 +142,7 @@ def _ctx(*,query: str = "hello",agent_config_version_kind: str = "snapshot",+ suspend_on_exit: bool = True,) -> AgentAppRuntimeBuildContext:dify_context = SimpleNamespace(tenant_id="tenant-1",@@ -160,6 +160,7 @@ def _ctx(user_query=query,idempotency_key="msg-1",agent_config_version_kind=agent_config_version_kind, # type: ignore[arg-type]+ suspend_on_exit=suspend_on_exit,)@@ -185,7 +186,6 @@ class TestAgentAppRuntimeRequestBuilder:result = builder.build(_ctx(_soul_with_model()))req = result.request- assert req.purpose == "agent_app"names = [layer.name for layer in req.composition.layers]assert names == ["agent_soul_prompt",@@ -207,10 +207,52 @@ class TestAgentAppRuntimeRequestBuilder:assert exec_ctx.config.user_from == "end-user"assert exec_ctx.config.invoke_from == "web-app"assert exec_ctx.config.agent_mode == "agent_app"+ assert req.on_exit.default.value == "suspend"# credentials are redacted in the log-safe view.assert result.redacted_request["composition"]["layers"][-1]["config"]["credentials"] == "[REDACTED]"assert result.metadata["conversation_id"] == "conv-1"+ def test_build_wraps_agent_soul_prompt_for_build_draft(self):+ builder = AgentAppRuntimeRequestBuilder(+ credentials_provider=_FakeCredentialsProvider(),+ dify_tools_builder=_NoToolsBuilder(), # type: ignore[arg-type]+ )++ result = builder.build(_ctx(_soul_with_model(), agent_config_version_kind="build_draft"))++ prompt_layer = next(layer for layer in result.request.composition.layers if layer.name == "agent_soul_prompt")+ assert prompt_layer.config.prefix != _soul_with_model().prompt+ assert prompt_layer.config.prefix.startswith("You are running in build mode.")+ assert "```text\nYou are Iris.\n```" in prompt_layer.config.prefix++ def test_build_propagates_draft_version_kind_without_wrapping_prompt(self):+ builder = AgentAppRuntimeRequestBuilder(+ credentials_provider=_FakeCredentialsProvider(),+ dify_tools_builder=_NoToolsBuilder(), # type: ignore[arg-type]+ )++ result = builder.build(_ctx(_soul_with_model(), agent_config_version_kind="draft"))++ prompt_layer = next(layer for layer in result.request.composition.layers if layer.name == "agent_soul_prompt")+ execution_context = next(+ layer for layer in result.request.composition.layers if layer.name == "execution_context"+ )+ config_layer = next(layer for layer in result.request.composition.layers if layer.name == DIFY_CONFIG_LAYER_ID)++ assert prompt_layer.config.prefix == "You are Iris."+ assert execution_context.config.agent_config_version_kind == "draft"+ assert config_layer.config.config_version.kind == "draft"++ def test_build_uses_delete_on_exit_when_requested(self):+ builder = AgentAppRuntimeRequestBuilder(+ credentials_provider=_FakeCredentialsProvider(),+ dify_tools_builder=_NoToolsBuilder(), # type: ignore[arg-type]+ )++ result = builder.build(_ctx(_soul_with_model(), suspend_on_exit=False))++ assert result.request.on_exit.default.value == "delete"+def test_build_includes_plugin_tools_layer_returned_by_injected_builder_for_draft(self):soul = _soul_with_model()soul.tools.dify_tools = [diff --git a/api/tests/unit_tests/core/app/apps/agent_app/test_session_store.py b/api/tests/unit_tests/core/app/apps/agent_app/test_session_store.pyindex 458b0a26dbe..fc9bf1b48e6 100644--- a/api/tests/unit_tests/core/app/apps/agent_app/test_session_store.py+++ b/api/tests/unit_tests/core/app/apps/agent_app/test_session_store.py@@ -303,3 +303,46 @@ def test_load_active_session_for_conversation_isolates_other_conversations():store.load_active_session_for_conversation(tenant_id="tenant-1", app_id="app-1", conversation_id="conv-A")is not None)+++def test_list_active_sessions_for_conversation_returns_all_active_rows():+ store = AgentAppRuntimeSessionStore()+ with session_factory.create_session() as session:+ session.add(+ AgentRuntimeSession(+ tenant_id="tenant-1",+ app_id="app-1",+ owner_type=AgentRuntimeSessionOwnerType.CONVERSATION,+ agent_id="agent-1",+ agent_config_snapshot_id="snap-1",+ conversation_id="conv-1",+ backend_run_id="run-1",+ session_snapshot=_snapshot(messages=1).model_dump_json(),+ composition_layer_specs='[{"name":"execution_context","type":"dify.execution_context","deps":{},"metadata":{},"config":{"tenant_id":"tenant-1"}},{"name":"history","type":"pydantic_ai.history","deps":{},"metadata":{},"config":null}]',+ status=AgentRuntimeSessionStatus.ACTIVE,+ )+ )+ session.add(+ AgentRuntimeSession(+ tenant_id="tenant-1",+ app_id="app-1",+ owner_type=AgentRuntimeSessionOwnerType.CONVERSATION,+ agent_id="agent-2",+ agent_config_snapshot_id="snap-2",+ conversation_id="conv-1",+ backend_run_id="run-2",+ session_snapshot=_snapshot(messages=2).model_dump_json(),+ composition_layer_specs='[{"name":"execution_context","type":"dify.execution_context","deps":{},"metadata":{},"config":{"tenant_id":"tenant-1"}},{"name":"history","type":"pydantic_ai.history","deps":{},"metadata":{},"config":null}]',+ status=AgentRuntimeSessionStatus.ACTIVE,+ )+ )+ session.commit()++ loaded = store.list_active_sessions_for_conversation(+ tenant_id="tenant-1",+ app_id="app-1",+ conversation_id="conv-1",+ )++ assert [session.scope.agent_id for session in loaded] == ["agent-2", "agent-1"]+ assert all(session.scope.conversation_id == "conv-1" for session in loaded)diff --git a/api/tests/unit_tests/core/app/task_pipeline/test_easy_ui_based_generate_task_pipeline_core.py b/api/tests/unit_tests/core/app/task_pipeline/test_easy_ui_based_generate_task_pipeline_core.pyindex 54e57d04d99..153157337e1 100644--- a/api/tests/unit_tests/core/app/task_pipeline/test_easy_ui_based_generate_task_pipeline_core.py+++ b/api/tests/unit_tests/core/app/task_pipeline/test_easy_ui_based_generate_task_pipeline_core.py@@ -203,6 +203,7 @@ def _agent_thought() -> MessageAgentThought:tool="tool",tool_labels_str="{}",tool_input="input",+ answer="answer",message_files="[]",)thought.id = "thought"@@ -678,7 +679,7 @@ class TestEasyUiBasedGenerateTaskPipeline:assert agent_response.answer == "agent"assert isinstance(responses[-1], ErrorStreamResponse)assert isinstance(responses[-1].err, ValueError)- assert pipeline._task_state.llm_result.message.content == "annotatedagent"+ assert pipeline._task_state.llm_result.message.content == "annotated"def test_agent_thought_to_stream_response_returns_payload(self, monkeypatch: pytest.MonkeyPatch):conversation = _make_conversation(AppMode.CHAT)@@ -720,6 +721,7 @@ class TestEasyUiBasedGenerateTaskPipeline:assert response is not Noneassert response.id == "thought"+ assert response.thought == "t"def test_agent_thought_to_stream_response_normalizes_null_display_fields(self, monkeypatch: pytest.MonkeyPatch):conversation = _make_conversation(AppMode.CHAT)@@ -735,6 +737,7 @@ class TestEasyUiBasedGenerateTaskPipeline:agent_thought = _agent_thought()agent_thought.thought = None+ agent_thought.answer = Noneagent_thought.observation = Noneagent_thought.tool = Noneagent_thought.tool_input = Nonediff --git a/api/tests/unit_tests/core/workflow/nodes/agent_v2/test_agent_node.py b/api/tests/unit_tests/core/workflow/nodes/agent_v2/test_agent_node.pyindex 99448f7f5a9..407b5e59f7f 100644--- a/api/tests/unit_tests/core/workflow/nodes/agent_v2/test_agent_node.py+++ b/api/tests/unit_tests/core/workflow/nodes/agent_v2/test_agent_node.py@@ -498,6 +498,37 @@ def test_agent_node_failed_run_without_session_store_skips_mark_cleaned():assert "session_snapshot_cleaned_on_failure" not in agent_backend+def test_agent_node_failed_run_enqueues_backend_cleanup_before_local_retirement(monkeypatch):+ store = FakeSessionStore()+ store.loaded_session = StoredWorkflowAgentSession(+ scope=_pending_session(CompositorSessionSnapshot(layers=[])).scope,+ session_snapshot=CompositorSessionSnapshot(layers=[]),+ backend_run_id="stored-run-1",+ runtime_layer_specs=[RuntimeLayerSpec(name="history", type="pydantic_ai.history")],+ )+ queued_payloads: list[dict[str, object]] = []+ monkeypatch.setattr(+ "core.workflow.nodes.agent_v2.agent_node.cleanup_workflow_agent_runtime_session.delay",+ lambda payload: queued_payloads.append(payload),+ )++ events = list(_node(scenario=FakeAgentBackendScenario.FAILED, session_store=store)._run())++ assert len(events) == 1+ result = cast(StreamCompletedEvent, events[0]).node_run_result+ assert result.status == WorkflowNodeExecutionStatus.FAILED+ assert store.cleaned[0][1] == "fake-run-1"+ assert store.cleaned[0][0].workflow_run_id == "workflow-run-1"+ assert store.cleaned[0][0].node_id == "agent-node"+ assert len(queued_payloads) == 1+ assert (+ queued_payloads[0]["idempotency_key"]+ == "tenant-1:workflow-run-1:agent-node:binding-1:workflow-agent-failure-cleanup:stored-run-1:fake-run-1"+ )+ assert queued_payloads[0]["metadata"]["previous_agent_backend_run_id"] == "stored-run-1"+ assert queued_payloads[0]["metadata"]["failed_agent_backend_run_id"] == "fake-run-1"++def test_agent_node_paused_run_requests_workflow_pause_and_persists_snapshot():store = FakeSessionStore()node = _node(scenario=FakeAgentBackendScenario.PAUSED, session_store=store)diff --git a/api/tests/unit_tests/core/workflow/nodes/agent_v2/test_runtime_request_builder.py b/api/tests/unit_tests/core/workflow/nodes/agent_v2/test_runtime_request_builder.pyindex 14210c5e553..9d0089e8e08 100644--- a/api/tests/unit_tests/core/workflow/nodes/agent_v2/test_runtime_request_builder.py+++ b/api/tests/unit_tests/core/workflow/nodes/agent_v2/test_runtime_request_builder.py@@ -429,6 +429,8 @@ def test_builds_workflow_run_request_with_file_output_schema_and_reserved_metadaassert "final_output.report" in output_descriptionassert "never invent the `reference` value" in output_descriptionassert "Do not call `final_output` before the upload command succeeds" in output_description+ assert "accepted file-mapping shape and the returned `reference`" in output_description+ assert "include the returned `download_url` in that reply" in output_descriptionassert output_schema["properties"]["confidence"]["type"] == "number"assert output_schema["required"] == ["report"]assert layers[DIFY_AGENT_MODEL_LAYER_ID]["config"]["model_settings"] == {"temperature": 0.2}@@ -728,7 +730,11 @@ def test_build_maps_agent_soul_knowledge_to_knowledge_layer_config():"top_k": 6,"score_threshold": 0.4,"reranking_model": {"provider": "cohere", "model": "rerank-v3"},- "weights": {"weight_type": "weighted_score", "vector_setting": {"vector_weight": 0.7}},+ "weights": {+ "weight_type": "weighted_score",+ "vector_setting": {"vector_weight": 0.7},+ "keyword_setting": {"keyword_weight": 0.3},+ },},"metadata_filtering": {"mode": "manual",@@ -795,7 +801,10 @@ def test_build_maps_agent_soul_knowledge_to_knowledge_layer_config():"reranking_mode": "reranking_model","reranking_enable": True,"reranking_model": {"provider": "cohere", "model": "rerank-v3"},- "weights": {"weight_type": "weighted_score", "vector_setting": {"vector_weight": 0.7}},+ "weights": {+ "vector_setting": {"vector_weight": 0.7},+ "keyword_setting": {"keyword_weight": 0.3},+ },"model": None,},"metadata_filtering": {@@ -1174,6 +1183,37 @@ def test_previous_node_file_output_uses_agent_stub_download_mapping_in_workflow_}+def test_previous_node_file_mapping_strips_extra_fields_in_workflow_context():+ file_reference = build_file_reference(record_id="tool-file-1")++ class FileMappingVariablePool(FakeVariablePool):+ def get(self, selector):+ if list(selector) == ["previous-node", "report"]:+ return SimpleNamespace(+ value={+ "filename": "report.pdf",+ "transfer_method": "tool_file",+ "reference": file_reference,+ "external": True,+ }+ )+ return super().get(selector)++ context = replace(_context(), variable_pool=FileMappingVariablePool())+ context.binding.node_job_config = WorkflowNodeJobConfig.model_validate(+ {+ "workflow_prompt": "Review {{#previous-node.report#}} before responding.",+ }+ )++ result = WorkflowAgentRuntimeRequestBuilder(credentials_provider=FakeCredentialsProvider()).build(context)++ assert _previous_node_prompt_payload(result, "previous-node.report") == {+ "transfer_method": "tool_file",+ "reference": file_reference,+ }++def test_scalar_previous_node_output_appears_in_workflow_context_section():context = _context()context.binding.node_job_config = WorkflowNodeJobConfig.model_validate(diff --git a/api/tests/unit_tests/core/workflow/nodes/agent_v2/test_session_cleanup_layer.py b/api/tests/unit_tests/core/workflow/nodes/agent_v2/test_session_cleanup_layer.pyindex 67e7bfafca7..eda2962198e 100644--- a/api/tests/unit_tests/core/workflow/nodes/agent_v2/test_session_cleanup_layer.py+++ b/api/tests/unit_tests/core/workflow/nodes/agent_v2/test_session_cleanup_layer.py@@ -1,15 +1,15 @@-from datetime import UTCfrom typing import castimport pytestfrom agenton.compositor import CompositorSessionSnapshotfrom agenton.compositor.schemas import LayerSessionSnapshotfrom agenton.layers.base import LifecycleState-from dify_agent.protocol import CancelRunRequest, RunEvent, RunStatusResponse+from dify_agent.protocol import RuntimeLayerSpec-from clients.agent_backend import AgentBackendRunRequestBuilder, FakeAgentBackendRunClient, RuntimeLayerSpec-from clients.agent_backend.errors import AgentBackendHTTPError-from core.workflow.nodes.agent_v2.session_cleanup_layer import WorkflowAgentSessionCleanupLayer+from core.workflow.nodes.agent_v2.session_cleanup_layer import (+ WorkflowAgentSessionCleanupLayer,+ build_workflow_agent_session_cleanup_layer,+)from core.workflow.nodes.agent_v2.session_store import (StoredWorkflowAgentSession,WorkflowAgentRuntimeSessionStore,@@ -37,13 +37,21 @@ def _layer_snapshot(name: str) -> LayerSessionSnapshot:)-def _stored_session(scope: WorkflowAgentSessionScope, *, index: int = 1) -> StoredWorkflowAgentSession:- """A typical stored session with prompt + execution_context + history + llm specs.+def _default_scope() -> WorkflowAgentSessionScope:+ return WorkflowAgentSessionScope(+ tenant_id="tenant-1",+ app_id="app-1",+ workflow_id="workflow-1",+ workflow_run_id="workflow-run-1",+ node_id="agent-node",+ node_execution_id="node-exec-1",+ binding_id="binding-1",+ agent_id="agent-1",+ agent_config_snapshot_id="snapshot-1",+ )+- The LLM layer is *not* in ``runtime_layer_specs`` because the cleanup- contract excludes credential-bearing plugin layers, but it *is* present in- the saved snapshot so the layer's filter logic gets exercised.- """+def _stored_session(scope: WorkflowAgentSessionScope, *, index: int = 1) -> StoredWorkflowAgentSession:return StoredWorkflowAgentSession(scope=scope,session_snapshot=CompositorSessionSnapshot(@@ -64,8 +72,6 @@ def _stored_session(scope: WorkflowAgentSessionScope, *, index: int = 1) -> Storclass FakeSessionStore:- """In-memory stand-in for ``WorkflowAgentRuntimeSessionStore``."""-def __init__(self, *, stored: list[StoredWorkflowAgentSession] | None = None) -> None:self._stored = stored if stored is not None else [_stored_session(_default_scope())]self.list_calls: list[str] = []@@ -79,69 +85,7 @@ class FakeSessionStore:self.cleaned.append((scope, backend_run_id))-def _default_scope() -> WorkflowAgentSessionScope:- return WorkflowAgentSessionScope(- tenant_id="tenant-1",- app_id="app-1",- workflow_id="workflow-1",- workflow_run_id="workflow-run-1",- node_id="agent-node",- node_execution_id="node-exec-1",- binding_id="binding-1",- agent_id="agent-1",- agent_config_snapshot_id="snapshot-1",- )---class _WaitableFakeAgentBackendRunClient(FakeAgentBackendRunClient):- """``FakeAgentBackendRunClient`` plus the ``wait_run`` hook the layer needs."""-- def __init__(- self,- *,- run_id: str = "cleanup-run-1",- wait_status: str = "succeeded",- wait_error: str | None = None,- wait_raises: Exception | None = None,- ) -> None:- super().__init__(run_id=run_id)- self._wait_status = wait_status- self._wait_error = wait_error- self._wait_raises = wait_raises- self.wait_calls: list[tuple[str, float | None]] = []-- def wait_run(self, run_id: str, *, timeout_seconds: float | None = None) -> RunStatusResponse:- self.wait_calls.append((run_id, timeout_seconds))- if self._wait_raises is not None:- raise self._wait_raises- from datetime import datetime-- return RunStatusResponse(- run_id=run_id,- status=cast(object, self._wait_status), # protocol Literal; cast keeps tests flexible- created_at=datetime(2026, 1, 1, tzinfo=UTC),- updated_at=datetime(2026, 1, 1, tzinfo=UTC),- error=self._wait_error,- )-- # Inherit ``create_run`` from FakeAgentBackendRunClient; the missing protocol- # methods below are stub-only because the cleanup layer never calls them.- def cancel_run(self, run_id: str, request: CancelRunRequest | None = None): # pragma: no cover- del run_id, request- raise NotImplementedError-- def stream_events(self, run_id: str, *, after: str | None = None): # pragma: no cover- del run_id, after- if False:- yield cast(RunEvent, None)---def _build_layer(- *,- session_store: FakeSessionStore,- agent_backend_client: _WaitableFakeAgentBackendRunClient,- http_cleanup_supported: bool = True,-) -> WorkflowAgentSessionCleanupLayer:+def _build_layer(*, session_store: FakeSessionStore) -> WorkflowAgentSessionCleanupLayer:variable_pool = VariablePool.from_bootstrap(system_variables=build_system_variables(workflow_execution_id="workflow-run-1"),user_inputs={},@@ -150,12 +94,7 @@ def _build_layer(runtime_state = GraphRuntimeState(variable_pool=variable_pool, start_at=0.0)layer = WorkflowAgentSessionCleanupLayer(session_store=cast(WorkflowAgentRuntimeSessionStore, session_store),- request_builder=AgentBackendRunRequestBuilder(),- agent_backend_client=agent_backend_client,)- # Tests opt in to the future HTTP-cleanup branch; the production default- # (False) is exercised by the dedicated tests below.- layer._HTTP_CLEANUP_SUPPORTED = http_cleanup_supported # type: ignore[reportPrivateUsage]layer.initialize(ReadOnlyGraphRuntimeStateWrapper(runtime_state), cast(CommandChannel, object()))return layer@@ -170,30 +109,22 @@ def _build_layer(],ids=["succeeded", "partial_succeeded", "failed", "aborted"],)-def test_cleanup_layer_triggers_cleanup_only_run_on_each_terminal_event(terminal_event):+def test_cleanup_layer_enqueues_cleanup_and_marks_cleaned_on_terminal_events(monkeypatch, terminal_event):session_store = FakeSessionStore()- agent_backend_client = _WaitableFakeAgentBackendRunClient()- layer = _build_layer(session_store=session_store, agent_backend_client=agent_backend_client)+ queued_payloads: list[dict[str, object]] = []+ monkeypatch.setattr(+ "core.workflow.nodes.agent_v2.session_cleanup_layer.cleanup_workflow_agent_runtime_session.delay",+ lambda payload: queued_payloads.append(payload),+ )+ layer = _build_layer(session_store=session_store)layer.on_event(terminal_event)assert session_store.list_calls == ["workflow-run-1"]- assert agent_backend_client.request is not None- # Cleanup composition replays the persisted (non-plugin) layer specs so the- # agent backend's snapshot-vs-composition name match succeeds.- layer_names = [layer.name for layer in agent_backend_client.request.composition.layers]- assert layer_names == ["workflow_node_job_prompt", "execution_context", "history"]- assert agent_backend_client.request.on_exit.default.value == "delete"- assert agent_backend_client.request.metadata["agent_backend_lifecycle"] == "session_cleanup"- # Snapshot is filtered to drop the plugin layer entry so names match the- # cleanup composition.- assert agent_backend_client.request.session_snapshot is not None- snapshot_names = [layer.name for layer in agent_backend_client.request.session_snapshot.layers]- assert snapshot_names == ["workflow_node_job_prompt", "execution_context", "history"]- # The layer waited for terminal status and the run succeeded, so the row- # is marked CLEANED with the cleanup run id.- assert agent_backend_client.wait_calls- assert session_store.cleaned == [(_default_scope(), "cleanup-run-1")]+ assert len(queued_payloads) == 1+ assert queued_payloads[0]["metadata"]["workflow_run_id"] == "workflow-run-1"+ assert queued_payloads[0]["metadata"]["previous_agent_backend_run_id"] == "agent-run-1"+ assert session_store.cleaned == [(_default_scope(), "agent-run-1")]@pytest.mark.parametrize(@@ -204,91 +135,79 @@ def test_cleanup_layer_triggers_cleanup_only_run_on_each_terminal_event(terminal],ids=["started", "paused"],)-def test_cleanup_layer_ignores_non_terminal_events(non_terminal_event):+def test_cleanup_layer_ignores_non_terminal_events(monkeypatch, non_terminal_event):session_store = FakeSessionStore()- agent_backend_client = _WaitableFakeAgentBackendRunClient()- layer = _build_layer(session_store=session_store, agent_backend_client=agent_backend_client)+ queued_payloads: list[dict[str, object]] = []+ monkeypatch.setattr(+ "core.workflow.nodes.agent_v2.session_cleanup_layer.cleanup_workflow_agent_runtime_session.delay",+ lambda payload: queued_payloads.append(payload),+ )+ layer = _build_layer(session_store=session_store)layer.on_event(non_terminal_event)assert session_store.list_calls == []- assert agent_backend_client.request is None+ assert queued_payloads == []assert session_store.cleaned == []-def test_cleanup_layer_does_not_mark_cleaned_when_cleanup_run_fails():- """Trap D: cleanup-only run goes ``run_failed`` (e.g. snapshot validation- error) — the layer must leave the row ACTIVE so it can be retried instead- of silently leaking suspended agent-backend layers."""- session_store = FakeSessionStore()- agent_backend_client = _WaitableFakeAgentBackendRunClient(- wait_status="failed",- wait_error="snapshot mismatch",+def test_cleanup_layer_marks_cleaned_even_when_specs_are_missing(monkeypatch, caplog: pytest.LogCaptureFixture):+ scope = _default_scope()+ session_store = FakeSessionStore(+ stored=[+ StoredWorkflowAgentSession(+ scope=scope,+ session_snapshot=CompositorSessionSnapshot(layers=[_layer_snapshot("history")]),+ backend_run_id="legacy-run",+ runtime_layer_specs=[],+ )+ ]+ )+ queued_payloads: list[dict[str, object]] = []+ monkeypatch.setattr(+ "core.workflow.nodes.agent_v2.session_cleanup_layer.cleanup_workflow_agent_runtime_session.delay",+ lambda payload: queued_payloads.append(payload),)- layer = _build_layer(session_store=session_store, agent_backend_client=agent_backend_client)+ layer = _build_layer(session_store=session_store)layer.on_event(GraphRunSucceededEvent(outputs={}))- assert agent_backend_client.wait_calls- assert session_store.cleaned == []+ assert queued_payloads == []+ assert session_store.cleaned == [(scope, "legacy-run")]+ assert any("no runtime_layer_specs persisted" in record.message for record in caplog.records)-def test_cleanup_layer_does_not_mark_cleaned_when_wait_raises():+def test_cleanup_layer_marks_cleaned_even_when_enqueue_fails(monkeypatch):session_store = FakeSessionStore()- agent_backend_client = _WaitableFakeAgentBackendRunClient(- wait_raises=AgentBackendHTTPError("boom", status_code=500, detail=None),- )- layer = _build_layer(session_store=session_store, agent_backend_client=agent_backend_client)- layer.on_event(GraphRunSucceededEvent(outputs={}))-- assert session_store.cleaned == []+ def _explode(_payload: dict[str, object]) -> None:+ raise RuntimeError("queue down")--def test_cleanup_layer_marks_cleaned_locally_when_http_cleanup_disabled():- """Production default: dify-agent has no cleanup-only run mode yet, so the- layer must retire the local row without issuing a doomed HTTP request that- would crash inside the agent backend's runner on the missing LLM layer."""- session_store = FakeSessionStore()- agent_backend_client = _WaitableFakeAgentBackendRunClient()- layer = _build_layer(- session_store=session_store,- agent_backend_client=agent_backend_client,- http_cleanup_supported=False,+ monkeypatch.setattr(+ "core.workflow.nodes.agent_v2.session_cleanup_layer.cleanup_workflow_agent_runtime_session.delay",+ _explode,)+ layer = _build_layer(session_store=session_store)layer.on_event(GraphRunSucceededEvent(outputs={}))- # No HTTP call goes out — the trap is avoided entirely.- assert agent_backend_client.request is None- assert agent_backend_client.wait_calls == []- # Local row is still retired so a workflow loop cannot resume from stale state.assert session_store.cleaned == [(_default_scope(), "agent-run-1")]-def test_cleanup_layer_skips_sessions_without_persisted_specs():- """Backwards-compatible safety net: a row written before A.1 landed has- no runtime_layer_specs, so cleanup would unavoidably hit the snapshot-- validation trap. The layer must skip such rows instead of issuing a- doomed request."""- scope = _default_scope()- legacy_session = StoredWorkflowAgentSession(- scope=scope,- session_snapshot=CompositorSessionSnapshot(layers=[_layer_snapshot("history")]),- backend_run_id="legacy-run",- runtime_layer_specs=[],- )- session_store = FakeSessionStore(stored=[legacy_session])- agent_backend_client = _WaitableFakeAgentBackendRunClient()- layer = _build_layer(session_store=session_store, agent_backend_client=agent_backend_client)+def test_cleanup_layer_does_not_raise_when_mark_cleaned_fails(monkeypatch):+ session_store = FakeSessionStore()- layer.on_event(GraphRunSucceededEvent(outputs={}))+ def _explode(*, scope: WorkflowAgentSessionScope, backend_run_id: str | None = None) -> None:+ del scope, backend_run_id+ raise RuntimeError("cleanup bookkeeping failed")- assert agent_backend_client.request is None- assert session_store.cleaned == []+ monkeypatch.setattr(session_store, "mark_cleaned", _explode)+ layer = _build_layer(session_store=session_store)++ layer.on_event(GraphRunSucceededEvent(outputs={}))-def test_cleanup_layer_fans_out_to_every_active_session():+def test_cleanup_layer_fans_out_to_every_active_session(monkeypatch):scopes = [WorkflowAgentSessionScope(tenant_id="tenant-1",@@ -304,109 +223,34 @@ def test_cleanup_layer_fans_out_to_every_active_session():for i in range(3)]session_store = FakeSessionStore(stored=[_stored_session(scope, index=i) for i, scope in enumerate(scopes, 1)])- agent_backend_client = _WaitableFakeAgentBackendRunClient(run_id="cleanup-run-many")- layer = _build_layer(session_store=session_store, agent_backend_client=agent_backend_client)+ queued_payloads: list[dict[str, object]] = []+ monkeypatch.setattr(+ "core.workflow.nodes.agent_v2.session_cleanup_layer.cleanup_workflow_agent_runtime_session.delay",+ lambda payload: queued_payloads.append(payload),+ )+ layer = _build_layer(session_store=session_store)layer.on_event(GraphRunSucceededEvent(outputs={}))- # One cleanup row per stored ACTIVE session, all marked cleaned with the- # backend run id returned by the agent backend client.+ assert len(queued_payloads) == 3assert [entry[0] for entry in session_store.cleaned] == scopes- assert {entry[1] for entry in session_store.cleaned} == {"cleanup-run-many"}---def test_cleanup_layer_warns_when_http_enabled_but_client_missing(caplog: pytest.LogCaptureFixture):- """The HTTP cleanup branch must defensively skip when no client was wired.-- This is the deployment-misconfig path: ``_HTTP_CLEANUP_SUPPORTED`` was- flipped to ``True`` but ``AGENT_BACKEND_BASE_URL`` is unset, so the- factory returned ``None``. The layer must not crash and must not silently- retire the row — the warning surfaces the misconfig.- """- import logging-- session_store = FakeSessionStore()- layer = WorkflowAgentSessionCleanupLayer(- session_store=cast(WorkflowAgentRuntimeSessionStore, session_store),- request_builder=AgentBackendRunRequestBuilder(),- agent_backend_client=None,- )- layer._HTTP_CLEANUP_SUPPORTED = True # type: ignore[reportPrivateUsage]- variable_pool = VariablePool.from_bootstrap(- system_variables=build_system_variables(workflow_execution_id="workflow-run-1"),- user_inputs={},- conversation_variables=[],- )- runtime_state = GraphRuntimeState(variable_pool=variable_pool, start_at=0.0)- layer.initialize(ReadOnlyGraphRuntimeStateWrapper(runtime_state), cast(CommandChannel, object()))-- with caplog.at_level(logging.WARNING):- layer.on_event(GraphRunSucceededEvent(outputs={}))-- assert session_store.cleaned == []- assert any("no agent backend client is wired in" in record.message for record in caplog.records)-def test_cleanup_layer_skips_workflow_terminal_when_workflow_run_id_missing(caplog: pytest.LogCaptureFixture):- """``workflow_run_id`` is the keying field; without it the fanout cannot- target a row, so the layer logs a warning and bails."""- import logging-+def test_cleanup_layer_skips_when_workflow_run_id_missing(caplog: pytest.LogCaptureFixture):session_store = FakeSessionStore()- agent_backend_client = _WaitableFakeAgentBackendRunClient()- layer = WorkflowAgentSessionCleanupLayer(- session_store=cast(WorkflowAgentRuntimeSessionStore, session_store),- request_builder=AgentBackendRunRequestBuilder(),- agent_backend_client=agent_backend_client,- )- # Bootstrap *without* a workflow_execution_id system variable.- variable_pool = VariablePool.from_bootstrap(- system_variables=build_system_variables(workflow_execution_id=""),- user_inputs={},- conversation_variables=[],- )+ variable_pool = VariablePool.from_bootstrap(system_variables={}, user_inputs={}, conversation_variables=[])runtime_state = GraphRuntimeState(variable_pool=variable_pool, start_at=0.0)+ layer = WorkflowAgentSessionCleanupLayer(session_store=cast(WorkflowAgentRuntimeSessionStore, session_store))layer.initialize(ReadOnlyGraphRuntimeStateWrapper(runtime_state), cast(CommandChannel, object()))- with caplog.at_level(logging.WARNING):- layer.on_event(GraphRunSucceededEvent(outputs={}))+ layer.on_event(GraphRunSucceededEvent(outputs={}))assert session_store.list_calls == []assert session_store.cleaned == []assert any("workflow_run_id is missing" in record.message for record in caplog.records)-def test_build_workflow_agent_session_cleanup_layer_returns_layer_without_client_when_unconfigured(- monkeypatch,-):- """The production builder must pass ``None`` for the agent backend client- when neither AGENT_BACKEND_BASE_URL nor AGENT_BACKEND_USE_FAKE is set, so- that unit-test environments without backend config don't crash at runner- construction."""- from configs import dify_config- from core.workflow.nodes.agent_v2.session_cleanup_layer import (- build_workflow_agent_session_cleanup_layer,- )-- monkeypatch.setattr(dify_config, "AGENT_BACKEND_BASE_URL", None, raising=False)- monkeypatch.setattr(dify_config, "AGENT_BACKEND_USE_FAKE", False, raising=False)-+def test_build_workflow_agent_session_cleanup_layer_returns_layer() -> None:layer = build_workflow_agent_session_cleanup_layer()- assert layer._agent_backend_client is None # type: ignore[reportPrivateUsage]--def test_build_workflow_agent_session_cleanup_layer_returns_layer_with_fake_client(monkeypatch):- """With ``AGENT_BACKEND_USE_FAKE`` enabled the helper wires in the- deterministic fake client without needing a base_url."""- from clients.agent_backend.fake_client import FakeAgentBackendRunClient- from configs import dify_config- from core.workflow.nodes.agent_v2.session_cleanup_layer import (- build_workflow_agent_session_cleanup_layer,- )-- monkeypatch.setattr(dify_config, "AGENT_BACKEND_BASE_URL", None, raising=False)- monkeypatch.setattr(dify_config, "AGENT_BACKEND_USE_FAKE", True, raising=False)- monkeypatch.setattr(dify_config, "AGENT_BACKEND_FAKE_SCENARIO", "success", raising=False)-- layer = build_workflow_agent_session_cleanup_layer()- assert isinstance(layer._agent_backend_client, FakeAgentBackendRunClient) # type: ignore[reportPrivateUsage]+ assert isinstance(layer, WorkflowAgentSessionCleanupLayer)diff --git a/api/tests/unit_tests/services/agent/test_agent_services.py b/api/tests/unit_tests/services/agent/test_agent_services.pyindex f896a761904..22c3f4c5500 100644--- a/api/tests/unit_tests/services/agent/test_agent_services.py+++ b/api/tests/unit_tests/services/agent/test_agent_services.py@@ -1,8 +1,11 @@import jsonfrom datetime import UTC, datetimefrom types import SimpleNamespace+from unittest.mock import MagicMockimport pytest+from agenton.compositor import CompositorSessionSnapshot+from dify_agent.protocol import RuntimeLayerSpecfrom sqlalchemy.exc import IntegrityErrorfrom core.workflow.nodes.agent_v2.validators import WorkflowAgentNodeValidationError@@ -3170,6 +3173,159 @@ class TestAgentAppBackingAgent:assert session.deleted == []assert session.commits == 1+ def test_refresh_agent_app_debug_conversation_enqueues_cleanup_for_old_runtime_sessions(+ self, monkeypatch: pytest.MonkeyPatch+ ):+ agent = Agent(+ id="agent-1",+ tenant_id="tenant-1",+ name="Iris",+ description="",+ agent_kind=AgentKind.DIFY_AGENT,+ scope=AgentScope.ROSTER,+ source=AgentSource.AGENT_APP,+ status=AgentStatus.ACTIVE,+ app_id="app-1",+ )+ mapping = SimpleNamespace(app_id="old-app", conversation_id="old-conversation")+ stored_session = SimpleNamespace(+ scope=SimpleNamespace(+ tenant_id="tenant-1",+ app_id="old-app",+ conversation_id="old-conversation",+ agent_id="agent-9",+ agent_config_snapshot_id="snap-9",+ ),+ session_snapshot=CompositorSessionSnapshot(layers=[]),+ backend_run_id="run-old",+ runtime_layer_specs=[RuntimeLayerSpec(name="history", type="pydantic_ai.history")],+ )+ session = FakeSession(scalar=[agent, mapping])+ service = AgentRosterService(session)+ cleanup_delay = MagicMock()+ cleanup_store = MagicMock()+ cleanup_store.list_active_sessions_for_conversation.return_value = [stored_session]+ monkeypatch.setattr(roster_service, "AgentAppRuntimeSessionStore", lambda: cleanup_store)+ monkeypatch.setattr(roster_service.cleanup_conversation_agent_runtime_session, "delay", cleanup_delay)++ conversation_id = service.refresh_agent_app_debug_conversation_id(+ tenant_id="tenant-1",+ agent_id="agent-1",+ account_id="account-1",+ )++ cleanup_store.list_active_sessions_for_conversation.assert_called_once_with(+ tenant_id="tenant-1",+ app_id="old-app",+ conversation_id="old-conversation",+ )+ cleanup_delay.assert_called_once()+ payload = cleanup_delay.call_args.args[0]+ assert payload["metadata"]["conversation_id"] == "old-conversation"+ assert payload["metadata"]["agent_id"] == "agent-9"+ assert (+ payload["idempotency_key"] == "tenant-1:agent-1:account-1:old-conversation:debug-session-cleanup:"+ "agent-9:snap-9:run-old"+ )+ cleanup_store.mark_cleaned.assert_called_once_with(+ scope=stored_session.scope,+ backend_run_id="run-old",+ )+ assert mapping.app_id == "app-1"+ assert mapping.conversation_id == conversation_id++ def test_refresh_agent_app_debug_conversation_marks_old_runtime_sessions_clean_when_enqueue_fails(+ self, monkeypatch: pytest.MonkeyPatch+ ):+ agent = Agent(+ id="agent-1",+ tenant_id="tenant-1",+ name="Iris",+ description="",+ agent_kind=AgentKind.DIFY_AGENT,+ scope=AgentScope.ROSTER,+ source=AgentSource.AGENT_APP,+ status=AgentStatus.ACTIVE,+ app_id="app-1",+ )+ mapping = SimpleNamespace(app_id="old-app", conversation_id="old-conversation")+ stored_session = SimpleNamespace(+ scope=SimpleNamespace(+ tenant_id="tenant-1",+ app_id="old-app",+ conversation_id="old-conversation",+ agent_id="agent-9",+ agent_config_snapshot_id="snap-9",+ ),+ session_snapshot=CompositorSessionSnapshot(layers=[]),+ backend_run_id="run-old",+ runtime_layer_specs=[RuntimeLayerSpec(name="history", type="pydantic_ai.history")],+ )+ session = FakeSession(scalar=[agent, mapping])+ service = AgentRosterService(session)+ cleanup_store = MagicMock()+ cleanup_store.list_active_sessions_for_conversation.return_value = [stored_session]+ monkeypatch.setattr(roster_service, "AgentAppRuntimeSessionStore", lambda: cleanup_store)+ monkeypatch.setattr(+ roster_service.cleanup_conversation_agent_runtime_session,+ "delay",+ MagicMock(side_effect=RuntimeError("queue down")),+ )++ service.refresh_agent_app_debug_conversation_id(+ tenant_id="tenant-1",+ agent_id="agent-1",+ account_id="account-1",+ )++ cleanup_store.mark_cleaned.assert_called_once_with(+ scope=stored_session.scope,+ backend_run_id="run-old",+ )++ def test_refresh_agent_app_debug_conversation_ignores_mark_cleaned_failure(self, monkeypatch: pytest.MonkeyPatch):+ agent = Agent(+ id="agent-1",+ tenant_id="tenant-1",+ name="Iris",+ description="",+ agent_kind=AgentKind.DIFY_AGENT,+ scope=AgentScope.ROSTER,+ source=AgentSource.AGENT_APP,+ status=AgentStatus.ACTIVE,+ app_id="app-1",+ )+ mapping = SimpleNamespace(app_id="old-app", conversation_id="old-conversation")+ stored_session = SimpleNamespace(+ scope=SimpleNamespace(+ tenant_id="tenant-1",+ app_id="old-app",+ conversation_id="old-conversation",+ agent_id="agent-9",+ agent_config_snapshot_id="snap-9",+ ),+ session_snapshot=CompositorSessionSnapshot(layers=[]),+ backend_run_id="run-old",+ runtime_layer_specs=[RuntimeLayerSpec(name="history", type="pydantic_ai.history")],+ )+ session = FakeSession(scalar=[agent, mapping])+ service = AgentRosterService(session)+ cleanup_store = MagicMock()+ cleanup_store.list_active_sessions_for_conversation.return_value = [stored_session]+ cleanup_store.mark_cleaned.side_effect = RuntimeError("cleanup bookkeeping failed")+ monkeypatch.setattr(roster_service, "AgentAppRuntimeSessionStore", lambda: cleanup_store)+ monkeypatch.setattr(roster_service.cleanup_conversation_agent_runtime_session, "delay", MagicMock())++ conversation_id = service.refresh_agent_app_debug_conversation_id(+ tenant_id="tenant-1",+ agent_id="agent-1",+ account_id="account-1",+ )++ assert mapping.app_id == "app-1"+ assert mapping.conversation_id == conversation_id+ assert session.commits == 1+def test_duplicate_agent_app_copies_app_config_and_active_soul(self, monkeypatch: pytest.MonkeyPatch):source_config = SimpleNamespace(opening_statement="hello",diff --git a/api/tests/unit_tests/services/agent/test_prompt_mentions.py b/api/tests/unit_tests/services/agent/test_prompt_mentions.pyindex b65f8b6f410..6051c96b50b 100644--- a/api/tests/unit_tests/services/agent/test_prompt_mentions.py+++ b/api/tests/unit_tests/services/agent/test_prompt_mentions.py@@ -243,9 +243,10 @@ def test_node_job_resolver_resolves_each_kind(node_job: WorkflowNodeJobConfig):assert expanded == ("Read START/tenders and produce qna_report (file output; create the file locally, run "- "`dify-agent file upload <path>`, then copy the returned AgentStubFileMapping JSON "- "as final_output.qna_report; do not call final_output before upload succeeds, and do not use "- "the local path, filename, URL, or a synthesized dify-file-ref as the reference); "+ "`dify-agent file upload <path>`, then set final_output.qna_report to a `tool_file` mapping "+ "using the returned `reference`; if replying to the user in natural language, use the returned "+ "`download_url`; do not call final_output before upload succeeds, and do not use the local path, "+ "filename, URL, or a synthesized dify-file-ref as the reference); ""if unsure contact EMAIL · David Hayes.")diff --git a/api/tests/unit_tests/services/test_agent_app_sandbox_service.py b/api/tests/unit_tests/services/test_agent_app_sandbox_service.pyindex c36980f5829..f3052a4ab49 100644--- a/api/tests/unit_tests/services/test_agent_app_sandbox_service.py+++ b/api/tests/unit_tests/services/test_agent_app_sandbox_service.py@@ -84,7 +84,12 @@ class FakeClient:self.locators.append(locator)self.calls.append(("upload", path))return SandboxUploadResponse(- path=path, file={"transfer_method": "tool_file", "reference": "dify-file-ref:file-1"}+ path=path,+ file={+ "transfer_method": "tool_file",+ "reference": "dify-file-ref:file-1",+ "download_url": "https://files.example/report.txt?token=1",+ },)@@ -151,7 +156,11 @@ def test_agent_app_sandbox_service_upload_returns_download_url(monkeypatch: pyteassert store.scope == ("tenant-1", "app-1", "conv-1")assert captured == {"tenant_id": "tenant-1",- "file_mapping": {"transfer_method": "tool_file", "reference": "dify-file-ref:file-1"},+ "file_mapping": {+ "transfer_method": "tool_file",+ "reference": "dify-file-ref:file-1",+ "download_url": "https://files.example/report.txt?token=1",+ },}@@ -265,7 +274,11 @@ def test_workflow_sandbox_service_resolves_locator_and_returns_download_url(assert client.calls == [("upload", "report.txt")]assert captured == {"tenant_id": "tenant-1",- "file_mapping": {"transfer_method": "tool_file", "reference": "dify-file-ref:file-1"},+ "file_mapping": {+ "transfer_method": "tool_file",+ "reference": "dify-file-ref:file-1",+ "download_url": "https://files.example/report.txt?token=1",+ },}diff --git a/api/tests/unit_tests/services/test_app_generate_service.py b/api/tests/unit_tests/services/test_app_generate_service.pyindex 22c7514a522..552403e0d0b 100644--- a/api/tests/unit_tests/services/test_app_generate_service.py+++ b/api/tests/unit_tests/services/test_app_generate_service.py@@ -310,22 +310,6 @@ class TestGenerate:assert result == {"result": "chat"}gen_spy.assert_called_once()- def test_stateless_agent_mode(self, mocker: MockerFixture):- gen_spy = mocker.patch(- "services.app_generate_service.AgentAppGenerator.generate_stateless",- return_value={"result": "stateless-agent"},- )-- result = AppGenerateService.generate_stateless_agent_app(- app_model=_make_app(AppMode.AGENT),- user=_make_user(),- args={"inputs": {}},- invoke_from=InvokeFrom.SERVICE_API,- )-- assert result == {"result": "stateless-agent"}- gen_spy.assert_called_once()-# -- ADVANCED_CHAT blocking ---------------------------------------------def test_advanced_chat_blocking(self, mocker: MockerFixture):workflow = _make_workflow()@@ -581,73 +565,6 @@ class TestGenerateBilling:# exit is called in finally block for non-streamingassert exit_calls == ["dummy-request-id"]- def test_stateless_agent_app_uses_billing_and_rate_limit_guardrails(- self, mocker: MockerFixture, monkeypatch: pytest.MonkeyPatch- ):- monkeypatch.setattr(ags_module.dify_config, "BILLING_ENABLED", True)- quota_charge = MagicMock()- reserve_mock = mocker.patch(- "services.app_generate_service.QuotaService.reserve",- return_value=quota_charge,- )- exit_calls: list[str] = []-- class _TrackingRateLimit(_DummyRateLimit):- def exit(self, request_id: str) -> None:- exit_calls.append(request_id)-- mocker.patch("services.app_generate_service.RateLimit", _TrackingRateLimit)- gen_spy = mocker.patch(- "services.app_generate_service.AgentAppGenerator.generate_stateless",- return_value={"ok": True},- )-- result = AppGenerateService.generate_stateless_agent_app(- app_model=_make_app(AppMode.AGENT),- user=_make_user(),- args={"inputs": {}},- invoke_from=InvokeFrom.SERVICE_API,- )-- assert result == {"ok": True}- reserve_mock.assert_called_once_with(QuotaType.WORKFLOW, "tenant-id")- quota_charge.commit.assert_called_once()- assert exit_calls == ["dummy-request-id"]- gen_spy.assert_called_once()-- def test_stateless_agent_app_failure_refunds_quota_and_exits_once(- self, mocker: MockerFixture, monkeypatch: pytest.MonkeyPatch- ):- monkeypatch.setattr(ags_module.dify_config, "BILLING_ENABLED", True)- quota_charge = MagicMock()- mocker.patch(- "services.app_generate_service.QuotaService.reserve",- return_value=quota_charge,- )- exit_calls: list[str] = []-- class _TrackingRateLimit(_DummyRateLimit):- def exit(self, request_id: str) -> None:- exit_calls.append(request_id)-- mocker.patch("services.app_generate_service.RateLimit", _TrackingRateLimit)- mocker.patch(- "services.app_generate_service.AgentAppGenerator.generate_stateless",- side_effect=RuntimeError("boom"),- )-- with pytest.raises(RuntimeError, match="boom"):- AppGenerateService.generate_stateless_agent_app(- app_model=_make_app(AppMode.AGENT),- user=_make_user(),- args={"inputs": {}},- invoke_from=InvokeFrom.SERVICE_API,- )-- quota_charge.commit.assert_called_once()- quota_charge.refund.assert_called_once()- assert exit_calls == ["dummy-request-id"]-def test_blocking_failure_exits_rate_limit_once(self, mocker: MockerFixture, monkeypatch: pytest.MonkeyPatch):monkeypatch.setattr(ags_module.dify_config, "BILLING_ENABLED", True)quota_charge = MagicMock()diff --git a/api/tests/unit_tests/services/test_file_request_service.py b/api/tests/unit_tests/services/test_file_request_service.pyindex f5d1a59c17e..57abdeaa322 100644--- a/api/tests/unit_tests/services/test_file_request_service.py+++ b/api/tests/unit_tests/services/test_file_request_service.py@@ -30,8 +30,9 @@ def test_request_download_url_builds_file_under_bound_scope(patch("services.file_request_service.bind_file_access_scope", return_value=nullcontext()) as bind_scope,patch.object(service, "_build_file", return_value=fake_file) as build_file,patch(- "services.file_request_service.file_helpers.resolve_file_url", return_value="https://files.example.com/x"- ),+ "services.file_request_service.file_helpers.resolve_file_url",+ return_value="https://files.example.com/x",+ ) as resolve_file_url,):result = service.request_download_url(tenant_id="tenant-1",@@ -51,6 +52,7 @@ def test_request_download_url_builds_file_under_bound_scope(build_file.assert_called_once_with(mapping={"transfer_method": "tool_file", "reference": reference}, tenant_id="tenant-1")+ resolve_file_url.assert_called_once_with(fake_file, for_external=True)assert result.filename == "report.pdf"assert result.mime_type == "application/pdf"assert result.size == 123diff --git a/api/tests/unit_tests/tasks/test_agent_backend_session_cleanup_task.py b/api/tests/unit_tests/tasks/test_agent_backend_session_cleanup_task.pynew file mode 100644index 00000000000..f7bc8a4a9ac--- /dev/null+++ b/api/tests/unit_tests/tasks/test_agent_backend_session_cleanup_task.py@@ -0,0 +1,51 @@+import logging++from agenton.compositor import CompositorSessionSnapshot++from clients.agent_backend.session_cleanup import (+ AgentBackendSessionCleanupPayload,+ AgentBackendSessionCleanupResult,+)+from tasks import agent_backend_session_cleanup_task as cleanup_task_module+++def _payload_dict() -> dict[str, object]:+ return AgentBackendSessionCleanupPayload(+ session_snapshot=CompositorSessionSnapshot(layers=[]),+ runtime_layer_specs=[],+ metadata={"tenant_id": "tenant-1", "app_id": "app-1"},+ ).model_dump(mode="json")+++def test_run_cleanup_task_logs_info_for_skipped_result(monkeypatch, caplog):+ monkeypatch.setattr(cleanup_task_module, "_create_agent_backend_client", lambda: object())+ monkeypatch.setattr(+ cleanup_task_module,+ "cleanup_agent_backend_session",+ lambda **kwargs: AgentBackendSessionCleanupResult.skipped("missing_runtime_layer_specs"),+ )++ with caplog.at_level(logging.INFO, logger="tasks.agent_backend_session_cleanup_task"):+ cleanup_task_module._run_cleanup_task(_payload_dict())++ assert "Agent backend session cleanup skipped" in caplog.text+ assert "missing_runtime_layer_specs" in caplog.text+++def test_run_cleanup_task_logs_warning_for_failed_result(monkeypatch, caplog):+ monkeypatch.setattr(cleanup_task_module, "_create_agent_backend_client", lambda: object())+ monkeypatch.setattr(+ cleanup_task_module,+ "cleanup_agent_backend_session",+ lambda **kwargs: AgentBackendSessionCleanupResult.failed(+ "backend exploded",+ cleanup_run_id="cleanup-run-1",+ ),+ )++ with caplog.at_level(logging.WARNING, logger="tasks.agent_backend_session_cleanup_task"):+ cleanup_task_module._run_cleanup_task(_payload_dict())++ assert "Agent backend session cleanup failed" in caplog.text+ assert "backend exploded" in caplog.text+ assert "cleanup-run-1" in caplog.textdiff --git a/api/tests/unit_tests/tasks/test_remove_app_and_related_data_task.py b/api/tests/unit_tests/tasks/test_remove_app_and_related_data_task.pyindex 9fc94547468..1e4b37612ba 100644--- a/api/tests/unit_tests/tasks/test_remove_app_and_related_data_task.py+++ b/api/tests/unit_tests/tasks/test_remove_app_and_related_data_task.py@@ -1,10 +1,16 @@import logging+from collections.abc import Generatorfrom unittest.mock import MagicMock, call, patchimport pytest+from agenton.compositor import CompositorSessionSnapshot+from sqlalchemy import delete, select+from core.db.session_factory import session_factoryfrom libs.archive_storage import ArchiveStorageNotConfiguredError+from models import AgentRuntimeSession, AgentRuntimeSessionOwnerType, AgentRuntimeSessionStatusfrom tasks.remove_app_and_related_data_task import (+ _cleanup_active_agent_runtime_sessions_for_app,_delete_app_stars,_delete_app_workflow_archive_logs,_delete_archived_workflow_run_files,@@ -14,6 +20,29 @@ from tasks.remove_app_and_related_data_task import ()[email protected](autouse=True)+def _create_agent_runtime_sessions_table() -> Generator[None, None, None]:+ engine = session_factory.get_session_maker().kw["bind"]+ AgentRuntimeSession.__table__.create(bind=engine, checkfirst=True)+ yield+ with session_factory.create_session() as session:+ session.execute(delete(AgentRuntimeSession))+ session.commit()+ AgentRuntimeSession.__table__.drop(bind=engine, checkfirst=True)+++def _runtime_session_specs_json() -> str:+ return (+ '[{"name":"execution_context","type":"dify.execution_context","deps":{},"metadata":{},'+ '"config":{"tenant_id":"tenant-1"}},{"name":"history","type":"pydantic_ai.history","deps":{},'+ '"metadata":{},"config":null}]'+ )+++def _snapshot_json() -> str:+ return CompositorSessionSnapshot(layers=[]).model_dump_json()++class TestDeleteDraftVariablesBatch:def test_delete_draft_variables_batch_invalid_batch_size(self):"""Test that invalid batch size raises ValueError."""@@ -149,3 +178,215 @@ class TestDeleteArchivedWorkflowRunFiles:storage.list_objects.assert_called_once_with("tenant-1/app_id=app-1/")storage.delete_object.assert_has_calls([call("key-1"), call("key-2")], any_order=False)assert "Deleted 2 archive objects for app app-1" in caplog.text+++class TestCleanupActiveAgentRuntimeSessionsForApp:+ @patch("tasks.remove_app_and_related_data_task.cleanup_workflow_agent_runtime_session")+ @patch("tasks.remove_app_and_related_data_task.cleanup_conversation_agent_runtime_session")+ def test_enqueues_cleanup_for_active_rows_and_marks_rows_cleaned(+ self,+ mock_conversation_cleanup,+ mock_workflow_cleanup,+ ):+ with session_factory.create_session() as session:+ session.add(+ AgentRuntimeSession(+ tenant_id="tenant-1",+ app_id="app-1",+ owner_type=AgentRuntimeSessionOwnerType.CONVERSATION,+ agent_id="agent-1",+ agent_config_snapshot_id="snap-1",+ conversation_id="conv-1",+ backend_run_id="run-conv",+ session_snapshot=_snapshot_json(),+ composition_layer_specs=_runtime_session_specs_json(),+ status=AgentRuntimeSessionStatus.ACTIVE,+ )+ )+ session.add(+ AgentRuntimeSession(+ tenant_id="tenant-1",+ app_id="app-1",+ owner_type=AgentRuntimeSessionOwnerType.WORKFLOW_RUN,+ agent_id="agent-2",+ workflow_id="wf-1",+ workflow_run_id="wf-run-1",+ node_id="node-1",+ backend_run_id="run-wf",+ session_snapshot=_snapshot_json(),+ composition_layer_specs=_runtime_session_specs_json(),+ status=AgentRuntimeSessionStatus.ACTIVE,+ )+ )+ session.add(+ AgentRuntimeSession(+ tenant_id="tenant-1",+ app_id="other-app",+ owner_type=AgentRuntimeSessionOwnerType.CONVERSATION,+ agent_id="agent-3",+ conversation_id="conv-2",+ backend_run_id="run-other",+ session_snapshot=_snapshot_json(),+ composition_layer_specs=_runtime_session_specs_json(),+ status=AgentRuntimeSessionStatus.ACTIVE,+ )+ )+ session.commit()++ _cleanup_active_agent_runtime_sessions_for_app("tenant-1", "app-1", batch_size=1)++ assert mock_conversation_cleanup.delay.call_count == 1+ assert mock_workflow_cleanup.delay.call_count == 1+ conversation_payload = mock_conversation_cleanup.delay.call_args.args[0]+ workflow_payload = mock_workflow_cleanup.delay.call_args.args[0]+ assert conversation_payload["metadata"]["conversation_id"] == "conv-1"+ assert workflow_payload["metadata"]["workflow_run_id"] == "wf-run-1"+ assert conversation_payload["idempotency_key"].startswith("tenant-1:app-1:conv-1:agent-1:app-delete-cleanup:")+ assert workflow_payload["idempotency_key"].startswith(+ "tenant-1:app-1:wf-run-1:node-1:agent-2:app-delete-cleanup:"+ )+ with session_factory.create_session() as session:+ app_rows = session.scalars(+ select(AgentRuntimeSession).where(+ AgentRuntimeSession.tenant_id == "tenant-1",+ AgentRuntimeSession.app_id == "app-1",+ )+ ).all()+ assert {row.status for row in app_rows} == {AgentRuntimeSessionStatus.CLEANED}+ other_row = session.scalar(+ select(AgentRuntimeSession).where(+ AgentRuntimeSession.tenant_id == "tenant-1",+ AgentRuntimeSession.app_id == "other-app",+ )+ )+ assert other_row is not None+ assert other_row.status == AgentRuntimeSessionStatus.ACTIVE++ @patch("tasks.remove_app_and_related_data_task.cleanup_workflow_agent_runtime_session")+ @patch("tasks.remove_app_and_related_data_task.cleanup_conversation_agent_runtime_session")+ def test_marks_rows_cleaned_even_when_enqueue_fails(+ self,+ mock_conversation_cleanup,+ mock_workflow_cleanup,+ ):+ mock_conversation_cleanup.delay.side_effect = RuntimeError("queue down")+ with session_factory.create_session() as session:+ session.add(+ AgentRuntimeSession(+ tenant_id="tenant-1",+ app_id="app-1",+ owner_type=AgentRuntimeSessionOwnerType.CONVERSATION,+ agent_id="agent-1",+ conversation_id="conv-1",+ backend_run_id="run-conv",+ session_snapshot=_snapshot_json(),+ composition_layer_specs=_runtime_session_specs_json(),+ status=AgentRuntimeSessionStatus.ACTIVE,+ )+ )+ session.add(+ AgentRuntimeSession(+ tenant_id="tenant-1",+ app_id="app-1",+ owner_type=AgentRuntimeSessionOwnerType.WORKFLOW_RUN,+ agent_id="agent-2",+ workflow_id="wf-1",+ workflow_run_id="wf-run-1",+ node_id="node-1",+ backend_run_id="run-wf",+ session_snapshot=_snapshot_json(),+ composition_layer_specs=_runtime_session_specs_json(),+ status=AgentRuntimeSessionStatus.ACTIVE,+ )+ )+ session.commit()++ _cleanup_active_agent_runtime_sessions_for_app("tenant-1", "app-1")++ mock_conversation_cleanup.delay.assert_called_once()+ mock_workflow_cleanup.delay.assert_called_once()+ with session_factory.create_session() as session:+ rows = session.scalars(+ select(AgentRuntimeSession).where(+ AgentRuntimeSession.tenant_id == "tenant-1",+ AgentRuntimeSession.app_id == "app-1",+ )+ ).all()+ assert rows+ assert {row.status for row in rows} == {AgentRuntimeSessionStatus.CLEANED}++ @patch("tasks.remove_app_and_related_data_task.cleanup_workflow_agent_runtime_session")+ @patch("tasks.remove_app_and_related_data_task.cleanup_conversation_agent_runtime_session")+ def test_uses_row_identity_to_keep_distinct_app_delete_cleanup_jobs_distinct(+ self,+ mock_conversation_cleanup,+ mock_workflow_cleanup,+ ):+ del mock_workflow_cleanup+ with session_factory.create_session() as session:+ first = AgentRuntimeSession(+ tenant_id="tenant-1",+ app_id="app-1",+ owner_type=AgentRuntimeSessionOwnerType.CONVERSATION,+ agent_id="agent-1",+ agent_config_snapshot_id="snap-1",+ conversation_id="conv-1",+ backend_run_id="run-conv-1",+ session_snapshot=_snapshot_json(),+ composition_layer_specs=_runtime_session_specs_json(),+ status=AgentRuntimeSessionStatus.ACTIVE,+ )+ second = AgentRuntimeSession(+ tenant_id="tenant-1",+ app_id="app-1",+ owner_type=AgentRuntimeSessionOwnerType.CONVERSATION,+ agent_id="agent-1",+ agent_config_snapshot_id="snap-2",+ conversation_id="conv-1",+ backend_run_id="run-conv-2",+ session_snapshot=_snapshot_json(),+ composition_layer_specs=_runtime_session_specs_json(),+ status=AgentRuntimeSessionStatus.ACTIVE,+ )+ session.add(first)+ session.add(second)+ session.commit()++ _cleanup_active_agent_runtime_sessions_for_app("tenant-1", "app-1")++ assert mock_conversation_cleanup.delay.call_count == 2+ payloads = [queued_call.args[0] for queued_call in mock_conversation_cleanup.delay.call_args_list]+ assert payloads[0]["idempotency_key"] != payloads[1]["idempotency_key"]+ assert payloads[0]["idempotency_key"].endswith(first.id)+ assert payloads[1]["idempotency_key"].endswith(second.id)++ @patch("tasks.remove_app_and_related_data_task.cleanup_workflow_agent_runtime_session")+ @patch("tasks.remove_app_and_related_data_task.cleanup_conversation_agent_runtime_session")+ def test_marks_empty_runtime_layer_specs_rows_clean_without_enqueue(+ self,+ mock_conversation_cleanup,+ mock_workflow_cleanup,+ ):+ del mock_workflow_cleanup+ with session_factory.create_session() as session:+ row = AgentRuntimeSession(+ tenant_id="tenant-1",+ app_id="app-1",+ owner_type=AgentRuntimeSessionOwnerType.CONVERSATION,+ agent_id="agent-1",+ conversation_id="conv-1",+ backend_run_id="run-no-specs",+ session_snapshot=_snapshot_json(),+ composition_layer_specs="[]",+ status=AgentRuntimeSessionStatus.ACTIVE,+ )+ session.add(row)+ session.commit()++ _cleanup_active_agent_runtime_sessions_for_app("tenant-1", "app-1")++ mock_conversation_cleanup.delay.assert_not_called()+ with session_factory.create_session() as session:+ stored_row = session.scalar(select(AgentRuntimeSession).where(AgentRuntimeSession.id == row.id))+ assert stored_row is not None+ assert stored_row.status == AgentRuntimeSessionStatus.CLEANEDdiff --git a/dify-agent/src/dify_agent/adapters/llm/model.py b/dify-agent/src/dify_agent/adapters/llm/model.pyindex 59f54de2271..e48ccc8bb17 100644--- a/dify-agent/src/dify_agent/adapters/llm/model.py+++ b/dify-agent/src/dify_agent/adapters/llm/model.py@@ -334,7 +334,7 @@ def _map_model_response_to_prompt_message(content_parts: list[PromptMessageContentUnionTypes] = []tool_calls: list[AssistantPromptMessage.ToolCall] = []- for part in message.parts:+ for index, part in enumerate(message.parts):if isinstance(part, TextPart):if part.content:content_parts.append(TextPromptMessageContent(data=part.content))@@ -346,7 +346,7 @@ def _map_model_response_to_prompt_message(elif isinstance(part, ToolCallPart):tool_calls.append(AssistantPromptMessage.ToolCall(- id=part.tool_call_id or f"tool-call-{part.tool_name}",+ id=part.tool_call_id or f"tool-call-{index}-{part.tool_name}",type="function",function=AssistantPromptMessage.ToolCall.ToolCallFunction(name=part.tool_name,diff --git a/dify-agent/src/dify_agent/agent_stub/cli/_files.py b/dify-agent/src/dify_agent/agent_stub/cli/_files.pyindex 467e7b7e2b5..5e3635fde14 100644--- a/dify-agent/src/dify_agent/agent_stub/cli/_files.py+++ b/dify-agent/src/dify_agent/agent_stub/cli/_files.py@@ -5,7 +5,7 @@ from __future__ import annotationsimport mimetypesfrom dataclasses import dataclassfrom pathlib import Path-from typing import ClassVar, Literal, cast+from typing import ClassVar, Literal, Protocol, castfrom pydantic import BaseModel, ConfigDict, ValidationError@@ -21,11 +21,16 @@ from dify_agent.agent_stub.client import (from dify_agent.agent_stub.protocol.agent_stub import AgentStubFileMapping, is_canonical_dify_file_reference+class _AgentStubFileDownloadResponse(Protocol):+ download_url: str++class UploadedToolFileMapping(BaseModel):"""Canonical Agent output mapping returned by ``dify-agent file upload``."""transfer_method: Literal["tool_file"] = "tool_file"reference: str+ download_url: strmodel_config: ClassVar[ConfigDict] = ConfigDict(extra="forbid")@@ -39,9 +44,9 @@ class DownloadedFileResult:@dataclass(frozen=True, slots=True)class UploadedToolFileResource:- """Lower-level upload result carrying both public mapping and ToolFile id."""+ """Lower-level upload result carrying the internal mapping and ToolFile id."""- mapping: UploadedToolFileMapping+ mapping: AgentStubFileMappingtool_file_id: str@@ -49,11 +54,22 @@ def upload_file_from_environment(*, path: str) -> UploadedToolFileMapping:"""Upload one sandbox-local file through the Agent Stub control plane.The signed upload data-plane response must carry the Dify-generated- ``reference`` for the new ``ToolFile`` so the sandbox can return the- canonical Agent output file mapping without synthesizing reference format.+ ``reference`` for the new ``ToolFile``. The helper then resolves the same+ mapping through the signed download-request control plane so the public CLI+ output includes a ready-to-share external ``download_url``."""- return upload_tool_file_resource_from_environment(path=path).mapping+ resource = upload_tool_file_resource_from_environment(path=path)+ reference = resource.mapping.reference+ if not isinstance(reference, str) or not reference:+ raise AgentStubTransferError("signed file upload response is missing reference")+ environment = read_agent_stub_environment()+ download_url = _request_uploaded_tool_file_download_url(+ url=environment.url,+ auth_jwe=environment.auth_jwe,+ reference=reference,+ )+ return UploadedToolFileMapping(reference=reference, download_url=download_url)def upload_tool_file_resource_from_environment(*, path: str) -> UploadedToolFileResource:@@ -62,6 +78,8 @@ def upload_tool_file_resource_from_environment(*, path: str) -> UploadedToolFileThis lower-level helper backs ``drive push``. The signed upload data-planeresponse must include both the canonical Dify ``reference`` used by publicCLI output and the raw ToolFile ``id`` required by drive commit payloads.+ It intentionally stops after the upload allocation so internal flows that+ only need the ToolFile identity do not pay for signed download enrichment.Raises:AgentStubValidationError: if ``path`` does not resolve to a local file.@@ -92,7 +110,11 @@ def upload_tool_file_resource_from_environment(*, path: str) -> UploadedToolFilefile_obj=file_obj,mimetype=mime_type,)- return _normalize_uploaded_tool_file_resource(payload)+ reference, tool_file_id = _normalize_uploaded_tool_file_payload(payload)+ return UploadedToolFileResource(+ mapping=AgentStubFileMapping(transfer_method="tool_file", reference=reference),+ tool_file_id=tool_file_id,+ )def download_file_from_environment(@@ -164,7 +186,7 @@ def _build_download_mapping(raise AgentStubValidationError("invalid file download arguments") from exc-def _normalize_uploaded_tool_file_resource(payload: dict[str, object]) -> UploadedToolFileResource:+def _normalize_uploaded_tool_file_payload(payload: dict[str, object]) -> tuple[str, str]:reference = payload.get("reference")if not isinstance(reference, str) or not reference:raise AgentStubTransferError("signed file upload response is missing reference")@@ -173,10 +195,22 @@ def _normalize_uploaded_tool_file_resource(payload: dict[str, object]) -> Uploadtool_file_id = payload.get("id")if not isinstance(tool_file_id, str) or not tool_file_id:raise AgentStubTransferError("signed file upload response is missing id")- return UploadedToolFileResource(- mapping=UploadedToolFileMapping(reference=reference),- tool_file_id=tool_file_id,+ return reference, tool_file_id+++def _request_uploaded_tool_file_download_url(*, url: str, auth_jwe: str, reference: str) -> str:+ download_request = cast(+ _AgentStubFileDownloadResponse,+ request_agent_stub_file_download_sync(+ url=url,+ auth_jwe=auth_jwe,+ file=AgentStubFileMapping(transfer_method="tool_file", reference=reference),+ ),)+ download_url = download_request.download_url+ if not isinstance(download_url, str) or not download_url:+ raise AgentStubTransferError("signed file download response is missing download_url")+ return download_urldef _deduplicate_destination_path(path: Path) -> Path:diff --git a/dify-agent/src/dify_agent/agent_stub/cli/main.py b/dify-agent/src/dify_agent/agent_stub/cli/main.pyindex d815a67dd20..ee00059d1e5 100644--- a/dify-agent/src/dify_agent/agent_stub/cli/main.py+++ b/dify-agent/src/dify_agent/agent_stub/cli/main.py@@ -24,6 +24,13 @@ _CONFIG_MANIFEST_STDOUT_EXCLUDE = {"skills": {"items": {"__all__": {"hash"}}},"files": {"items": {"__all__": {"hash"}}},}+_FILE_DOWNLOAD_TRANSFER_METHOD_HELP = (+ "File mapping transfer_method: local_file, tool_file, datasource_file, or remote_url."+)+_FILE_DOWNLOAD_REFERENCE_OR_URL_HELP = (+ "File mapping reference or URL. Use dify-file-ref:... with local_file, tool_file, or datasource_file; "+ "use https://... with remote_url."+)app = typer.Typer(@@ -76,16 +83,18 @@ def upload(path: str = typer.Argument(..., metavar="PATH")) -> None:@file_app.command("download")def download(- transfer_method: str | None = typer.Argument(None, metavar="TRANSFER_METHOD"),- reference_or_url: str | None = typer.Argument(None, metavar="REFERENCE_OR_URL"),- mapping: str | None = typer.Option(None, "--mapping", help="Download one file from a mapping JSON object."),+ transfer_method: str = typer.Argument(..., metavar="TRANSFER_METHOD", help=_FILE_DOWNLOAD_TRANSFER_METHOD_HELP),+ reference_or_url: str = typer.Argument(+ ...,+ metavar="REFERENCE_OR_URL",+ help=_FILE_DOWNLOAD_REFERENCE_OR_URL_HELP,+ ),local_dir: str | None = typer.Option(None, "--to", help="Local directory for the downloaded file."),) -> None:"""Download one workflow file mapping into the local sandbox directory."""_run_file_download(transfer_method=transfer_method,reference_or_url=reference_or_url,- mapping=mapping,local_dir=local_dir,)@@ -361,9 +370,8 @@ def _run_file_upload(*, path: str) -> None:def _run_file_download(*,- transfer_method: str | None,- reference_or_url: str | None,- mapping: str | None,+ transfer_method: str,+ reference_or_url: str,local_dir: str | None,) -> None:env_module = _env_module()@@ -373,7 +381,6 @@ def _run_file_download(response = files_module.download_file_from_environment(transfer_method=transfer_method,reference_or_url=reference_or_url,- mapping=mapping,local_dir=local_dir,)except env_module.MissingAgentStubEnvironmentError as exc:diff --git a/dify-agent/src/dify_agent/layers/_agent_file_cli_help.py b/dify-agent/src/dify_agent/layers/_agent_file_cli_help.pynew file mode 100644index 00000000000..50deef3d851--- /dev/null+++ b/dify-agent/src/dify_agent/layers/_agent_file_cli_help.py@@ -0,0 +1,7 @@+"""Shared model-facing guidance for Agent Stub file CLI usage in prompt surfaces."""++AGENT_FILE_UPLOAD_REPLY_HINT = (+ "When you want to provide a generated or sandbox-local file to the user in a "+ "natural-language reply, run the installed CLI command `dify-agent file upload PATH` and include the returned "+ "`download_url` so the user can open or download the file."+)diff --git a/dify-agent/src/dify_agent/layers/config/configs.py b/dify-agent/src/dify_agent/layers/config/configs.pyindex c3d20c878f1..5f8eae360eb 100644--- a/dify-agent/src/dify_agent/layers/config/configs.py+++ b/dify-agent/src/dify_agent/layers/config/configs.py@@ -59,6 +59,9 @@ class DifyConfigLayerConfig(LayerConfig):class DifyConfigRuntimeState(BaseModel):"""Serializable config-layer values computed once during context entry.+ ``config_cli_help`` stores pre-rendered shell-visible ``dify-agent`` help snippets+ for config commands and file upload/download commands.+The ``push_spec_*`` fields are compatibility leftovers from the removed rootJSON-spec config mutation workflow. This change keeps them in the runtime-stateschema to avoid snapshot churn, but new code should treat them as inertdiff --git a/dify-agent/src/dify_agent/layers/config/layer.py b/dify-agent/src/dify_agent/layers/config/layer.pyindex d914f599efb..6a4a5dea4db 100644--- a/dify-agent/src/dify_agent/layers/config/layer.py+++ b/dify-agent/src/dify_agent/layers/config/layer.py@@ -11,6 +11,7 @@ from typing_extensions import Self, overridefrom agenton.layers import LayerDeps, PlainLayerfrom dify_agent.agent_stub.cli.main import render_agent_stub_cli_help+from dify_agent.layers._agent_file_cli_help import AGENT_FILE_UPLOAD_REPLY_HINT as _AGENT_FILE_UPLOAD_REPLY_HINTfrom dify_agent.layers.config.configs import (DIFY_CONFIG_LAYER_TYPE_ID,DifyConfigLayerConfig,@@ -18,14 +19,19 @@ from dify_agent.layers.config.configs import ()from dify_agent.layers.shell.layer import DifyShellLayer-_CONFIG_CONTEXT_HEADING = "Agent config context from the current Agent Soul:"-_CONFIG_CONTEXT_COMMAND = "$ dify-agent config manifest"-_CONFIG_CLI_USAGE_PROMPT = """Agent config CLI usage is available inside shell jobs. The command help below is generated-from the same `dify-agent` CLI definitions available in shell jobs.+_CONFIG_CONTEXT_HEADING = "Current Agent config manifest for this run:"+_CONFIG_CONTEXT_COMMAND = "dify-agent config manifest"+_CONFIG_CLI_USAGE_PROMPT = """`dify-agent` is an installed CLI tool in the shell environment. Use it directly in shell_run scripts.-Local edits to config files, skills, env, or notes are not saved by themselves. Config changes are saved only by a-matching resource mutation command. Those commands are available only when the Agent config context reports-`config_version.kind` as `build_draft` and `config_version.writable` as true."""+The command outputs below are generated from the `dify-agent` CLI available in this run. Use them as the source of truth+for command names, arguments, and options.++Config persistence rules:++- Local shell edits to config files, skills, env, or notes are not saved by themselves.+- To persist an Agent config change, run the matching `dify-agent config ...` mutation command.+- Mutation commands are available only when the manifest shows `config_version.kind` as `build_draft` and+ `config_version.writable` as true."""_CONFIG_CLI_HELP_COMMANDS: dict[str, tuple[str, ...]] = {"dify-agent config --help": ("config",),"dify-agent config manifest --help": ("config", "manifest"),@@ -41,6 +47,10 @@ _CONFIG_CLI_MUTATION_HELP_COMMANDS: dict[str, tuple[str, ...]] = {"dify-agent config skills push --help": ("config", "skills", "push"),"dify-agent config skills delete --help": ("config", "skills", "delete"),}+_AGENT_FILE_CLI_HELP_COMMANDS: dict[str, tuple[str, ...]] = {+ "dify-agent file upload --help": ("file", "upload"),+ "dify-agent file download --help": ("file", "download"),+}_CONFIG_CONTEXT_EXCLUDE = {"mentioned_skill_names": True, "mentioned_file_names": True}@@ -91,6 +101,7 @@ class DifyConfigLayer(PlainLayer[DifyConfigDeps, DifyConfigLayerConfig, DifyConfcommand_paths = dict(_CONFIG_CLI_HELP_COMMANDS)if self._config_writable:command_paths.update(_CONFIG_CLI_MUTATION_HELP_COMMANDS)+ command_paths.update(_AGENT_FILE_CLI_HELP_COMMANDS)self.runtime_state.config_context_json = self._format_config_context_json()self.runtime_state.config_cli_help = {command: render_agent_stub_cli_help(args) for command, args in command_paths.items()@@ -107,15 +118,22 @@ class DifyConfigLayer(PlainLayer[DifyConfigDeps, DifyConfigLayerConfig, DifyConfoutput = self.runtime_state.pulled_skill_outputs.get(name)if output is None:continue- loaded_skill_sections.append(f"Name: {name}\nPull output:\n{output}")+ command = f"dify-agent config skills pull {shlex.quote(name)}"+ loaded_skill_sections.append(+ f"Name: {name}\nPull command output for this run:\n{_format_command_output(command, output)}"+ )if loaded_skill_sections:sections.append("Loaded mentioned skills:\n\n" + "\n\n".join(loaded_skill_sections))- mentioned_file_sections = [- f"Name: {name}\nPull output:\n{self.runtime_state.pulled_file_outputs[name]}"- for name in self.config.mentioned_file_names- if name in self.runtime_state.pulled_file_outputs- ]+ mentioned_file_sections = []+ for name in self.config.mentioned_file_names:+ output = self.runtime_state.pulled_file_outputs.get(name)+ if output is None:+ continue+ command = f"dify-agent config files pull {shlex.quote(name)}"+ mentioned_file_sections.append(+ f"Name: {name}\nPull command output for this run:\n{_format_command_output(command, output)}"+ )if mentioned_file_sections:sections.append("Mentioned files pulled locally:\n\n" + "\n\n".join(mentioned_file_sections))@@ -125,11 +143,14 @@ class DifyConfigLayer(PlainLayer[DifyConfigDeps, DifyConfigLayerConfig, DifyConfsections: list[str] = []if self.runtime_state.config_context_json:sections.append(- f"{_CONFIG_CONTEXT_COMMAND}\n{_CONFIG_CONTEXT_HEADING}\n{self.runtime_state.config_context_json}"+ f"{_CONFIG_CONTEXT_HEADING}\n"+ f"{_format_command_output(_CONFIG_CONTEXT_COMMAND, self.runtime_state.config_context_json)}")usage_lines = [_CONFIG_CLI_USAGE_PROMPT]if cli_help := self._format_config_cli_help():usage_lines.append(cli_help)+ if file_cli_help := self._format_agent_file_cli_help():+ usage_lines.append(file_cli_help)sections.append("\n".join(usage_lines))return "\n\n".join(section for section in sections if section)@@ -142,13 +163,27 @@ class DifyConfigLayer(PlainLayer[DifyConfigDeps, DifyConfigLayerConfig, DifyConfif self._config_writable:commands.extend(_CONFIG_CLI_MUTATION_HELP_COMMANDS)command_sections = [- f"$ {command}\n{self.runtime_state.config_cli_help[command]}"+ _format_command_output(command, self.runtime_state.config_cli_help[command])for command in commandsif command in self.runtime_state.config_cli_help]if not command_sections:return ""- return "Agent config CLI help:\n" + "\n\n".join(command_sections)+ return "Agent config CLI reference for installed `dify-agent`:\n" + "\n\n".join(command_sections)++ def _format_agent_file_cli_help(self) -> str:+ command_sections = [+ _format_command_output(command, self.runtime_state.config_cli_help[command])+ for command in _AGENT_FILE_CLI_HELP_COMMANDS+ if command in self.runtime_state.config_cli_help+ ]+ if not command_sections:+ return ""+ return (+ "Agent file CLI reference for installed `dify-agent`:\n"+ + "\n\n".join(command_sections)+ + f"\n\n{_AGENT_FILE_UPLOAD_REPLY_HINT}"+ )def _format_config_context_json(self) -> str:return self.config.model_dump_json(exclude=_CONFIG_CONTEXT_EXCLUDE, exclude_none=True)@@ -226,4 +261,8 @@ class DifyConfigLayer(PlainLayer[DifyConfigDeps, DifyConfigLayerConfig, DifyConfreturn "\n".join(lines)+def _format_command_output(command: str, output: str) -> str:+ return f"Command:\n$ {command}\nOutput:\n{output}"++__all__ = ["DifyConfigLayer", "DifyConfigLayerError"]diff --git a/dify-agent/src/dify_agent/layers/drive/layer.py b/dify-agent/src/dify_agent/layers/drive/layer.pyindex fec1109e74d..8ac4b91c189 100644--- a/dify-agent/src/dify_agent/layers/drive/layer.py+++ b/dify-agent/src/dify_agent/layers/drive/layer.py@@ -21,6 +21,7 @@ from typing_extensions import Self, overridefrom agenton.layers import EmptyRuntimeState, LayerDeps, PlainLayerfrom dify_agent.agent_stub.protocol import agent_stub_drive_base_for_ref+from dify_agent.layers._agent_file_cli_help import AGENT_FILE_UPLOAD_REPLY_HINT as _AGENT_FILE_UPLOAD_REPLY_HINTfrom dify_agent.layers.drive.configs import DIFY_DRIVE_LAYER_TYPE_ID, DifyDriveLayerConfigfrom dify_agent.layers.shell.layer import DifyShellLayer@@ -122,13 +123,17 @@ class DifyDriveLayer(PlainLayer[DifyDriveDeps, DifyDriveLayerConfig, EmptyRuntimdef _format_agent_stub_cli_help(self) -> str:command_sections = [- f"$ {command}\n{self._agent_stub_cli_help[command]}"+ _format_command_output(command, self._agent_stub_cli_help[command])for command in _AGENT_STUB_FILE_HELP_COMMANDSif command in self._agent_stub_cli_help]if not command_sections:return ""- return "Agent Stub file CLI help:\n" + "\n\n".join(command_sections)+ return (+ "Agent Stub file CLI reference for installed `dify-agent`:\n"+ + "\n\n".join(command_sections)+ + f"\n\n{_AGENT_FILE_UPLOAD_REPLY_HINT}"+ )async def _load_agent_stub_cli_help(self) -> None:self._agent_stub_cli_help = {}@@ -256,4 +261,8 @@ class DifyDriveLayer(PlainLayer[DifyDriveDeps, DifyDriveLayerConfig, EmptyRuntimreturn f"{skill_key.rsplit('/', 1)[0]}/"+def _format_command_output(command: str, output: str) -> str:+ return f"Command:\n$ {command}\nOutput:\n{output}"++__all__ = ["DifyDriveLayer", "DifyDriveLayerError"]diff --git a/dify-agent/src/dify_agent/layers/shell/layer.py b/dify-agent/src/dify_agent/layers/shell/layer.pyindex 529e99034df..b2939aadadd 100644--- a/dify-agent/src/dify_agent/layers/shell/layer.py+++ b/dify-agent/src/dify_agent/layers/shell/layer.py@@ -72,36 +72,38 @@ _SHELL_OUTPUT_PROMPT_EDGE_BYTES = 8 * 1024_SHELLCTL_OUTPUT_LIMIT_BYTES = 2 * _SHELL_OUTPUT_PROMPT_EDGE_BYTES_REMOTE_COMPLETE_OUTPUT_MAX_BYTES = 1024 * 1024_REMOTE_COMMAND_TIMEOUT_SECONDS = 60.0-_SHELL_LAYER_PREFIX_PROMPT = """You have access to a shell layer. It provides four tools:+_SHELL_LAYER_PREFIX_PROMPT = """You can run commands in an isolated shell workspace.++Available shell tools:1. shell_run- Start a new shell job in the current isolated workspace.- Use it to execute commands or scripts.+ Starts a new shell job in the current workspace.+ Use it to run commands or scripts.2. shell_wait- Wait for more output or completion from an existing shell job.+ Waits for more output or completion from an existing shell job.Use it when shell_run returns done=false.3. shell_input- Send stdin text to a running shell job, then wait for new output.- Use it for interactive commands that are waiting for input.+ Sends stdin text to a running shell job, then waits for new output.+ Use it only when an interactive command is waiting for input.4. shell_interrupt- Interrupt a running shell job.+ Interrupts a running shell job.Use it to stop a long-running, stuck, or no-longer-needed command.Common arguments:- script:- The command or script to execute. Used by shell_run.+ Command or script to execute. Used by shell_run.- job_id:- The id of a shell job returned by shell_run.+ Shell job id returned by shell_run.Use it with shell_wait, shell_input, and shell_interrupt.Never invent a job_id.- timeout:- Maximum time, in seconds, to wait for output or completion for this tool call.+ Maximum time in seconds to wait for output or completion for this tool call.A timeout does not necessarily mean the job has stopped; if done=false, use shell_wait again.- text:@@ -118,25 +120,33 @@ Usage rules:- Use shell_input only when the job is running and waiting for stdin.- Use shell_interrupt when a job is stuck or should be stopped.+Installed CLI:++- `dify-agent` is already installed in this shell environment and can be used directly.+- Use the generated `dify-agent ... --help` output in the config prompt for exact command syntax.+- Do not install or recreate the `dify-agent` CLI.+Workspace persistence rules:-- The current workspace cwd is stable during this agent run, but it is temporary and may be deleted later.-- Do not use the current workspace cwd as persistent storage.-- $HOME outside the current workspace cwd is persistent storage. In build draft mode, when Agent config context reports- `config_version.kind` as `build_draft` and `config_version.writable` as true, changes there can be persisted for- later runs. In non-build-draft modes, those changes are rolled back.-- Saving config files, skills, env, or notes still requires the corresponding Agent config CLI mutation command; follow- the Agent config CLI help in the config layer. Shell file edits alone do not save config.+- The current workspace cwd is stable during this run, but it is temporary and may be deleted later.+- Do not treat files in the current workspace cwd as persisted state.+- In build mode, config changes persist only after you run the matching `dify-agent config ...` mutation command.+- Shell file edits alone do not save Agent config files, skills, env, or notes.+- In non-build modes, local shell changes are not a persistence mechanism for Agent configuration.++shell_run script rules:-The script argument of shell_run can be a normal shell script, or a shebang script.-If the first line is a shebang, the shell layer executes the script directly.+- The script argument can be a normal shell script or a shebang script.+- If the first line is a shebang, the shell executes the script directly.Tips:- When using Python, prefer a uv script with a PEP 723 dependency header.+- If you need MCP, install the MCP server in the shell environment and start that server when you use it.- Example:+Example shell_run script:+[begin script]#!/usr/bin/env -S uv run --quiet --script# /// script# requires-python = ">=3.12"@@ -150,7 +160,8 @@ import httpxfrom rich import printresponse = httpx.get("https://example.com", timeout=10)-print(f"[green]status:[/green] {response.status_code}")"""+print(f"[green]status:[/green] {response.status_code}")+[end script]"""_SHELL_LAYER_SUFFIX_PROMPT = """Environment variables may contain API keys, tokens, or credentials.You may refer to environment variable names when needed."""diff --git a/dify-agent/src/dify_agent/protocol/__init__.py b/dify-agent/src/dify_agent/protocol/__init__.pyindex a43b6cd4812..2fc5bd517ed 100644--- a/dify-agent/src/dify_agent/protocol/__init__.py+++ b/dify-agent/src/dify_agent/protocol/__init__.py@@ -28,7 +28,6 @@ from .schemas import (RunEventsResponse,RunFailedEvent,RunFailedEventData,- RunPurpose,RunLayerSpec,RunStartedEvent,RunStatus,@@ -78,7 +77,6 @@ __all__ = ["RunEventsResponse","RunFailedEvent","RunFailedEventData",- "RunPurpose","RunLayerSpec","RunStartedEvent","RunStatus",diff --git a/dify-agent/src/dify_agent/protocol/sandbox.py b/dify-agent/src/dify_agent/protocol/sandbox.pyindex 83f3d4b0adc..db375e6a7b5 100644--- a/dify-agent/src/dify_agent/protocol/sandbox.py+++ b/dify-agent/src/dify_agent/protocol/sandbox.py@@ -112,6 +112,7 @@ class SandboxUploadedFile(BaseModel):transfer_method: Literal["tool_file"] = "tool_file"reference: str+ download_url: strmodel_config: ClassVar[ConfigDict] = ConfigDict(extra="forbid")diff --git a/dify-agent/src/dify_agent/protocol/schemas.py b/dify-agent/src/dify_agent/protocol/schemas.pyindex 1a02c7232a4..1cfafdc8123 100644--- a/dify-agent/src/dify_agent/protocol/schemas.py+++ b/dify-agent/src/dify_agent/protocol/schemas.py@@ -24,10 +24,13 @@ whether each active layer is suspended or deleted when the run exits, withsuspend as the default so successful terminal events can include resumablesnapshots. Successful runs always publish the resumable Agenton session snapshoton the terminal ``run_succeeded`` event together with exactly one of the final-JSON-safe ``output`` or a deferred external ``deferred_tool_call`` payload. That-lets consumers treat terminal success events as complete run summaries without a-separate pause protocol. Session snapshots carry only layer lifecycle/runtime-state in compositor order; they do not persist output-layer config. Resumed+JSON-safe ``output`` or a deferred external ``deferred_tool_call`` payload. A+lifecycle-only run may also succeed with ``output = null`` and ``usage = null``+when the composition intentionally omits the reserved model layer and only+replays layer enter/exit work from a supplied snapshot. That lets consumers+treat terminal success events as complete run summaries without a separate pause+protocol. Session snapshots carry only layer lifecycle/runtime state in+compositor order; they do not persist output-layer config. Resumedstructured-output runs therefore must resubmit the same ``output`` layer in``composition.layers[]`` so snapshot layer name/order still matches thecomposition and the runtime can rebuild the same structured output contract.@@ -50,7 +53,6 @@ DIFY_AGENT_MODEL_LAYER_ID: Final[str] = "llm"DIFY_AGENT_HISTORY_LAYER_ID: Final[str] = "history"DIFY_AGENT_OUTPUT_LAYER_ID: Final[str] = "output"RunStatus = Literal["running", "succeeded", "failed", "cancelled"]-RunPurpose = Literal["workflow_node", "single_step", "agent_app", "babysit", "fasten_preview"]RunEventType = Literal["run_started","pydantic_ai_event",@@ -136,7 +138,6 @@ class CreateRunRequest(BaseModel):"""composition: RunComposition- purpose: RunPurpose = "workflow_node"idempotency_key: str | None = Nonemetadata: dict[str, JsonValue] = Field(default_factory=dict)session_snapshot: CompositorSessionSnapshot | None = None@@ -334,10 +335,11 @@ class RunStartedEvent(BaseRunEvent):class PydanticAIStreamRunEvent(BaseRunEvent):- """Pydantic AI stream event using the upstream typed event model."""+ """Pydantic AI stream event with optional Dify Agent semantic annotations."""type: Literal["pydantic_ai_event"] = "pydantic_ai_event"data: AgentStreamEvent+ agent_message_delta: str | None = Noneclass RunSucceededEvent(BaseRunEvent):@@ -402,7 +404,6 @@ __all__ = ["RunEventsResponse","RunFailedEvent","RunFailedEventData",- "RunPurpose","RunStartedEvent","RunStatus","RunStatusResponse",diff --git a/dify-agent/src/dify_agent/runtime/event_sink.py b/dify-agent/src/dify_agent/runtime/event_sink.pyindex 5dbe9fce62d..71df75b4916 100644--- a/dify-agent/src/dify_agent/runtime/event_sink.py+++ b/dify-agent/src/dify_agent/runtime/event_sink.py@@ -89,11 +89,22 @@ async def emit_run_started(sink: RunEventSink, *, run_id: str) -> str:)-async def emit_pydantic_ai_event(sink: RunEventSink, *, run_id: str, data: AgentStreamEvent) -> str:+async def emit_pydantic_ai_event(+ sink: RunEventSink,+ *,+ run_id: str,+ data: AgentStreamEvent,+ agent_message_delta: str | None = None,+) -> str:"""Emit one typed Pydantic AI stream event."""return await emit_run_event(sink,- event=PydanticAIStreamRunEvent(run_id=run_id, data=data, created_at=utc_now()),+ event=PydanticAIStreamRunEvent(+ run_id=run_id,+ data=data,+ agent_message_delta=agent_message_delta,+ created_at=utc_now(),+ ),)diff --git a/dify-agent/src/dify_agent/runtime/runner.py b/dify-agent/src/dify_agent/runtime/runner.pyindex 97fbfe4ba4c..2ad3aa99d8f 100644--- a/dify-agent/src/dify_agent/runtime/runner.py+++ b/dify-agent/src/dify_agent/runtime/runner.py@@ -1,14 +1,21 @@"""Runtime execution for one scheduled Dify Agent run.The runner is storage-agnostic: it normalizes the public Dify composition into-Agenton's graph/config split, enters a fresh ``CompositorRun`` (or resumes one-from a snapshot), renders the current Dify system prompts into temporary-``message_history``, runs pydantic-ai with either the current ``run.user_prompts``-or deferred external tool results, emits stream events, applies request-level-``on_exit`` signals, and then publishes a terminal success or failure event. The-Pydantic AI model is resolved from the active Agenton layer named by+Agenton's graph/config split and chooses one of two execution modes after the+composition is normalized and the ``on_exit`` policy is validated:++- model runs: enter a fresh ``CompositorRun`` (or resume one from a snapshot),+ render the current Dify system prompts into temporary ``message_history``, run+ pydantic-ai with either the current ``run.user_prompts`` or deferred external+ tool results, emit raw stream events with agent-message delta annotations, apply+ request-level ``on_exit`` signals, and publish a terminal success or failure event;+- lifecycle-only runs: enter from a supplied snapshot, apply request-level+ ``on_exit`` signals, exit without invoking a model, and succeed with explicit+ ``output = null`` and ``usage = null``.++The Pydantic AI model is resolved from the active Agenton layer named by``DIFY_AGENT_MODEL_LAYER_ID``. An optional history layer contributes stored-message history only through session state; successful runs append only+message history only through session state; successful model runs append only``result.new_messages()`` back into that layer so current system prompts are notpersisted. An optional structured output layer named by``DIFY_AGENT_OUTPUT_LAYER_ID`` is read after entry and resolved into an output@@ -31,11 +38,11 @@ from typing import Any, Literal, Protocol, cast, runtime_checkableimport httpxfrom pydantic import JsonValue, TypeAdapter-from pydantic_ai.messages import AgentStreamEvent+from pydantic_ai.messages import AgentStreamEvent, PartDeltaEvent, PartStartEvent, TextPart, TextPartDeltafrom pydantic_ai.output import OutputSpecfrom pydantic_ai.tools import DeferredToolRequests, DeferredToolResults-from agenton.compositor import CompositorSessionSnapshot, LayerProviderInput+from agenton.compositor import CompositorSessionSnapshot, LayerConfigInput, LayerProviderInputfrom agenton.layers.types import PydanticAIToolfrom dify_agent.layers.ask_human.layer import get_ask_human_layer, validate_ask_human_layer_compositionfrom dify_agent.layers.dify_core_tools.layer import DifyCoreToolsLayer@@ -97,6 +104,20 @@ class AgentRunValidationError(ValueError):"""Raised when a run request is valid JSON but cannot execute."""+def _has_model_layer(request: CreateRunRequest) -> bool:+ """Return whether the public composition includes the reserved model layer."""+ return any(layer.name == DIFY_AGENT_MODEL_LAYER_ID for layer in request.composition.layers)+++def _extract_agent_message_delta(event: AgentStreamEvent) -> str | None:+ """Return agent-message text content from Pydantic AI stream events."""+ if isinstance(event, PartDeltaEvent) and isinstance(event.delta, TextPartDelta):+ return event.delta.content_delta+ if isinstance(event, PartStartEvent) and isinstance(event.part, TextPart):+ return event.part.content+ return None++@dataclass(slots=True)class RunSuccessOutcome:"""Normalized successful runner output before event emission."""@@ -163,7 +184,7 @@ class AgentRunRunner:await self.sink.update_status(self.run_id, "succeeded")async def _run_agent(self) -> RunSuccessOutcome:- """Run pydantic-ai inside an entered Agenton run.+ """Run the normalized request in model or lifecycle-only mode.Known request-shaped Agenton enter-time failures are normalized to``AgentRunValidationError``. That includes the existing small class of@@ -190,6 +211,57 @@ class AgentRunRunner:except (KeyError, TypeError, ValueError) as exc:raise AgentRunValidationError(str(exc)) from exc+ if not _has_model_layer(self.request):+ return await self._run_lifecycle_only(compositor=compositor, layer_configs=layer_configs)+ return await self._run_model(compositor=compositor, layer_configs=layer_configs)++ async def _run_lifecycle_only(+ self,+ *,+ compositor: Any,+ layer_configs: dict[str, LayerConfigInput],+ ) -> RunSuccessOutcome:+ """Replay only layer lifecycle work for a no-LLM composition plus snapshot."""+ if self.request.session_snapshot is None:+ raise AgentRunValidationError(+ f"Missing '{DIFY_AGENT_MODEL_LAYER_ID}' requires a session_snapshot for lifecycle-only runs."+ )+ if self.request.deferred_tool_results is not None:+ raise AgentRunValidationError(+ f"Deferred tool results require the reserved '{DIFY_AGENT_MODEL_LAYER_ID}' layer."+ )++ entered_run = False+ try:+ async with compositor.enter(configs=layer_configs, session_snapshot=self.request.session_snapshot) as run:+ entered_run = True+ apply_layer_exit_signals(run, self.request.on_exit)+ except RuntimeError as exc:+ if not entered_run and is_agenton_enter_validation_runtime_error(exc):+ raise AgentRunValidationError(str(exc)) from exc+ raise+ except ValueError as exc:+ if not entered_run:+ raise AgentRunValidationError(str(exc)) from exc+ raise++ if run.session_snapshot is None:+ raise RuntimeError("Agenton run did not produce a session snapshot after exit.")+ return RunSuccessOutcome(+ result_kind="output",+ output=None,+ deferred_tool_call=None,+ session_snapshot=run.session_snapshot,+ usage=None,+ )++ async def _run_model(+ self,+ *,+ compositor: Any,+ layer_configs: dict[str, LayerConfigInput],+ ) -> RunSuccessOutcome:+ """Run the normal model/deferred-tool path inside an entered Agenton run."""entered_run = Falseoutput: JsonValue | None = Nonedeferred_tool_call: DeferredToolCallPayload | None = None@@ -206,7 +278,13 @@ class AgentRunRunner:async def handle_events(_ctx: object, events: AsyncIterable[AgentStreamEvent]) -> None:async for event in events:- _ = await emit_pydantic_ai_event(self.sink, run_id=self.run_id, data=event)+ text_delta = _extract_agent_message_delta(event)+ _ = await emit_pydantic_ai_event(+ self.sink,+ run_id=self.run_id,+ data=event,+ agent_message_delta=text_delta,+ )try:output_contract = resolve_run_output_contract(run)diff --git a/dify-agent/tests/local/dify_agent/adapters/llm/test_model.py b/dify-agent/tests/local/dify_agent/adapters/llm/test_model.pyindex 1f952669a08..69d71f865cf 100644--- a/dify-agent/tests/local/dify_agent/adapters/llm/test_model.py+++ b/dify-agent/tests/local/dify_agent/adapters/llm/test_model.py@@ -242,6 +242,45 @@ class DifyLLMAdapterModelTests(unittest.IsolatedAsyncioTestCase):self.assertEqual(response.parts[0].part_kind, "text")self.assertEqual(cast(TextPart, response.parts[0]).content, "adapter response")+ async def test_request_uses_unique_fallback_ids_for_same_name_tool_calls(self) -> None:+ messages = [+ ModelRequest(parts=[UserPromptPart("hello")]),+ ModelResponse(+ parts=[+ ToolCallPart(tool_name="lookup", args={"query": "first"}, tool_call_id=""),+ ToolCallPart(tool_name="lookup", args={"query": "second"}, tool_call_id=""),+ ]+ ),+ ]++ def handler(request: httpx.Request) -> httpx.Response:+ payload = json.loads(request.content.decode("utf-8"))+ prompt_messages = payload["data"]["prompt_messages"]+ tool_calls = prompt_messages[1]["tool_calls"]++ self.assertEqual(tool_calls[0]["id"], "tool-call-0-lookup")+ self.assertEqual(tool_calls[1]["id"], "tool-call-1-lookup")++ return build_stream_response(*single_text_chunk("adapter response", prompt_tokens=11, completion_tokens=7))++ async with self.mock_daemon_stream(httpx.MockTransport(handler)):+ adapter = DifyLLMAdapterModel(+ "demo-model",+ self.make_provider(),+ model_provider="openai",+ credentials={"api_key": "secret"},+ )++ response = await adapter.request(+ messages,+ model_settings=None,+ model_request_parameters=ModelRequestParameters(),+ )++ self.assertEqual(response.model_name, "demo-model")+ self.assertEqual(response.parts[0].part_kind, "text")+ self.assertEqual(cast(TextPart, response.parts[0]).content, "adapter response")+async def test_request_collapses_text_only_assistant_history_parts_to_string_content(self) -> None:messages = [ModelRequest(parts=[UserPromptPart("initial request")]),diff --git a/dify-agent/tests/local/dify_agent/agent_stub/cli/test_drive.py b/dify-agent/tests/local/dify_agent/agent_stub/cli/test_drive.pyindex 61ffcec9e3a..5dbf0bafe5a 100644--- a/dify-agent/tests/local/dify_agent/agent_stub/cli/test_drive.py+++ b/dify-agent/tests/local/dify_agent/agent_stub/cli/test_drive.py@@ -1,5 +1,7 @@from __future__ import annotations+import base64+import jsonfrom io import BytesIOfrom pathlib import Pathimport stat@@ -14,16 +16,22 @@ from dify_agent.agent_stub.cli._drive import (pull_drive_from_environment,push_drive_from_environment,)-from dify_agent.agent_stub.cli._files import UploadedToolFileMapping, UploadedToolFileResource+from dify_agent.agent_stub.cli._files import UploadedToolFileResourcefrom dify_agent.agent_stub.client._errors import AgentStubTransferError, AgentStubValidationErrorfrom dify_agent.agent_stub.protocol.agent_stub import (AgentStubDriveCommitRequest,AgentStubDriveCommitResponse,AgentStubDriveItem,+ AgentStubFileMapping,AgentStubDriveManifestResponse,)+def _reference(record_id: str) -> str:+ payload = base64.urlsafe_b64encode(json.dumps({"record_id": record_id}, separators=(",", ":")).encode()).decode()+ return f"dify-file-ref:{payload}"++def test_list_drive_manifest_from_environment_returns_manifest_model(monkeypatch: pytest.MonkeyPatch) -> None:monkeypatch.setenv("DIFY_AGENT_STUB_API_BASE_URL", "https://agent.example.com/agent-stub")monkeypatch.setenv("DIFY_AGENT_STUB_AUTH_JWE", "test-jwe")@@ -535,7 +543,7 @@ def test_push_drive_from_environment_commits_single_file(monkeypatch: pytest.Monmonkeypatch.setattr("dify_agent.agent_stub.cli._drive.upload_tool_file_resource_from_environment",lambda *, path: UploadedToolFileResource(- mapping=UploadedToolFileMapping(reference="dify-file-ref:tool-file-1"),+ mapping=AgentStubFileMapping(transfer_method="tool_file", reference=_reference("tool-file-1")),tool_file_id="tool-file-1",),)@@ -640,7 +648,10 @@ def test_push_drive_from_environment_kind_skill_standardizes_skill_directory(def fake_upload(*, path: str) -> UploadedToolFileResource:uploaded_paths.append(Path(path).name)return UploadedToolFileResource(- mapping=UploadedToolFileMapping(reference=f"dify-file-ref:{Path(path).name}"),+ mapping=AgentStubFileMapping(+ transfer_method="tool_file",+ reference=_reference(Path(path).name),+ ),tool_file_id=Path(path).name,)@@ -697,7 +708,10 @@ def test_push_drive_from_environment_kind_skill_archive_excludes_transient_entriwith ZipFile(path) as archive:archive_entries.extend(sorted(archive.namelist()))return UploadedToolFileResource(- mapping=UploadedToolFileMapping(reference=f"dify-file-ref:{Path(path).name}"),+ mapping=AgentStubFileMapping(+ transfer_method="tool_file",+ reference=_reference(Path(path).name),+ ),tool_file_id=Path(path).name,)@@ -821,7 +835,10 @@ def test_push_drive_from_environment_kind_dir_keeps_user_files_that_skill_packagdef fake_upload(*, path: str) -> UploadedToolFileResource:uploaded_paths.append(Path(path).relative_to(root).as_posix())return UploadedToolFileResource(- mapping=UploadedToolFileMapping(reference=f"dify-file-ref:{Path(path).name}"),+ mapping=AgentStubFileMapping(+ transfer_method="tool_file",+ reference=_reference(Path(path).name),+ ),tool_file_id=Path(path).name,)diff --git a/dify-agent/tests/local/dify_agent/agent_stub/cli/test_files.py b/dify-agent/tests/local/dify_agent/agent_stub/cli/test_files.pyindex c2f2d44afb4..6a65daccb9a 100644--- a/dify-agent/tests/local/dify_agent/agent_stub/cli/test_files.py+++ b/dify-agent/tests/local/dify_agent/agent_stub/cli/test_files.py@@ -12,6 +12,7 @@ from dify_agent.agent_stub.cli._files import (upload_tool_file_resource_from_environment,)from dify_agent.agent_stub.client._errors import AgentStubTransferError, AgentStubValidationError+from dify_agent.agent_stub.protocol.agent_stub import AgentStubFileMappingdef _reference(record_id: str) -> str:@@ -48,18 +49,42 @@ def test_upload_file_from_environment_requests_signed_url_and_normalizes_output("dify_agent.agent_stub.cli._files.upload_file_to_signed_url_sync",fake_upload_file_to_signed_url_sync,)+ captured_download_request: dict[str, object] = {}++ def fake_request_agent_stub_file_download_sync(**kwargs):+ captured_download_request["file"] = kwargs["file"]+ return type(+ "Response",+ (),+ {+ "filename": "report.pdf",+ "mime_type": "application/pdf",+ "size": 12,+ "download_url": "https://files.example.com/download",+ },+ )()++ monkeypatch.setattr(+ "dify_agent.agent_stub.cli._files.request_agent_stub_file_download_sync",+ fake_request_agent_stub_file_download_sync,+ )result = upload_file_from_environment(path=str(source))assert result.model_dump() == {"transfer_method": "tool_file","reference": _reference("tool-file-1"),+ "download_url": "https://files.example.com/download",}assert captured == {"filename": "report.pdf","mimetype": "application/pdf","file_bytes": b"report-bytes",}+ assert captured_download_request["file"] == AgentStubFileMapping(+ transfer_method="tool_file",+ reference=_reference("tool-file-1"),+ )def test_upload_tool_file_resource_from_environment_preserves_tool_file_id(@@ -79,12 +104,17 @@ def test_upload_tool_file_resource_from_environment_preserves_tool_file_id("dify_agent.agent_stub.cli._files.upload_file_to_signed_url_sync",lambda **_kwargs: {"id": "tool-file-1", "reference": _reference("tool-file-1")},)+ monkeypatch.setattr(+ "dify_agent.agent_stub.cli._files.request_agent_stub_file_download_sync",+ lambda **_kwargs: pytest.fail("resource helper must not request download_url"),+ )result = upload_tool_file_resource_from_environment(path=str(source))assert result.mapping.model_dump() == {"transfer_method": "tool_file","reference": _reference("tool-file-1"),+ "url": None,}assert result.tool_file_id == "tool-file-1"@@ -187,6 +217,34 @@ def test_upload_file_from_environment_rejects_non_canonical_reference(_ = upload_file_from_environment(path=str(source))+def test_upload_file_from_environment_rejects_missing_download_url(+ monkeypatch: pytest.MonkeyPatch,+ tmp_path: Path,+) -> None:+ source = tmp_path / "report.pdf"+ source.write_bytes(b"report-bytes")+ monkeypatch.setenv("DIFY_AGENT_STUB_API_BASE_URL", "https://agent.example.com/agent-stub")+ monkeypatch.setenv("DIFY_AGENT_STUB_AUTH_JWE", "test-jwe")++ monkeypatch.setattr(+ "dify_agent.agent_stub.cli._files.request_agent_stub_file_upload_sync",+ lambda **_kwargs: type("Response", (), {"upload_url": "https://files.example.com/upload"})(),+ )+ monkeypatch.setattr(+ "dify_agent.agent_stub.cli._files.upload_file_to_signed_url_sync",+ lambda **_kwargs: {"id": "tool-file-1", "reference": _reference("tool-file-1")},+ )+ monkeypatch.setattr(+ "dify_agent.agent_stub.cli._files.request_agent_stub_file_download_sync",+ lambda **_kwargs: type(+ "Response", (), {"filename": "report.pdf", "mime_type": "application/pdf", "size": 12}+ )(),+ )++ with pytest.raises(AgentStubTransferError, match="missing download_url"):+ _ = upload_file_from_environment(path=str(source))++def test_download_file_from_environment_supports_mapping_json(monkeypatch: pytest.MonkeyPatch,tmp_path: Path,diff --git a/dify-agent/tests/local/dify_agent/agent_stub/cli/test_main.py b/dify-agent/tests/local/dify_agent/agent_stub/cli/test_main.pyindex 1c27fee25af..3018629e105 100644--- a/dify-agent/tests/local/dify_agent/agent_stub/cli/test_main.py+++ b/dify-agent/tests/local/dify_agent/agent_stub/cli/test_main.py@@ -9,6 +9,7 @@ import pytestfrom dify_agent.agent_stub.cli._drive import DrivePullResultfrom dify_agent.agent_stub.cli.main import main+from dify_agent.agent_stub.client._errors import AgentStubTransferErrorfrom dify_agent.agent_stub.protocol.agent_stub import (AgentStubConfigFileItemsResponse,AgentStubConfigFileItem,@@ -450,6 +451,7 @@ def test_cli_file_upload_prints_uploaded_tool_file_json({"transfer_method": "tool_file","reference": _reference(Path(path).name),+ "download_url": f"https://files.example.com/{Path(path).name}",})},@@ -464,9 +466,31 @@ def test_cli_file_upload_prints_uploaded_tool_file_json(assert json.loads(captured.out) == {"transfer_method": "tool_file","reference": _reference("report.pdf"),+ "download_url": "https://files.example.com/report.pdf",}+def test_cli_file_upload_exits_non_zero_without_partial_json_when_download_lookup_fails(+ monkeypatch: pytest.MonkeyPatch,+ capsys: pytest.CaptureFixture[str],+) -> None:+ _patch_cli_module(+ monkeypatch,+ "_files_module",+ upload_file_from_environment=lambda *, path: (_ for _ in ()).throw(+ AgentStubTransferError("signed file download request failed")+ ),+ )++ with pytest.raises(SystemExit) as exc_info:+ main(["file", "upload", "/tmp/report.pdf"])++ captured = capsys.readouterr()+ assert exc_info.value.code == 1+ assert captured.out == ""+ assert "signed file download request failed" in captured.err++def test_cli_file_download_prints_saved_path(monkeypatch: pytest.MonkeyPatch,capsys: pytest.CaptureFixture[str],@@ -485,14 +509,14 @@ def test_cli_file_download_prints_saved_path(assert captured.out.strip() == "/tmp/report.pdf"-def test_cli_file_download_supports_mapping_json(+def test_cli_file_download_rejects_mapping_option(monkeypatch: pytest.MonkeyPatch,- capsys: pytest.CaptureFixture[str],) -> None:- captured_kwargs: dict[str, object] = {}+ called = False- def fake_download_file_from_environment(**kwargs):- captured_kwargs.update(kwargs)+ def fake_download_file_from_environment(**_kwargs):+ nonlocal called+ called = Truereturn type("Response", (), {"path": Path("/tmp/inputs/report.pdf")})()_patch_cli_module(@@ -513,15 +537,8 @@ def test_cli_file_download_supports_mapping_json(])- captured = capsys.readouterr()- assert exc_info.value.code == 0- assert captured_kwargs == {- "transfer_method": None,- "reference_or_url": None,- "mapping": json.dumps({"transfer_method": "tool_file", "reference": _reference("tool-file-1")}),- "local_dir": "/tmp/inputs",- }- assert captured.out.strip() == "/tmp/inputs/report.pdf"+ assert exc_info.value.code == 2+ assert called is Falsedef test_cli_file_download_rejects_legacy_positional_directory(diff --git a/dify-agent/tests/local/dify_agent/client/test_client.py b/dify-agent/tests/local/dify_agent/client/test_client.pyindex 3a1525f015c..9f15ea9d2e6 100644--- a/dify-agent/tests/local/dify_agent/client/test_client.py+++ b/dify-agent/tests/local/dify_agent/client/test_client.py@@ -259,7 +259,11 @@ def test_sync_sandbox_methods_post_dtos_and_parse_responses() -> None:200,json={"path": "report.txt",- "file": {"transfer_method": "tool_file", "reference": "dify-file-ref:file-1"},+ "file": {+ "transfer_method": "tool_file",+ "reference": "dify-file-ref:file-1",+ "download_url": "https://files.example.com/report.txt",+ },},)raise AssertionError(f"unexpected request: {request.method} {request.url}")@@ -276,6 +280,7 @@ def test_sync_sandbox_methods_post_dtos_and_parse_responses() -> None:assert preview.text == "hello"assert isinstance(uploaded, SandboxUploadResponse)assert uploaded.file.reference == "dify-file-ref:file-1"+ assert uploaded.file.download_url == "https://files.example.com/report.txt"def test_async_sandbox_methods_post_dtos_and_parse_responses() -> None:@@ -293,7 +298,11 @@ def test_async_sandbox_methods_post_dtos_and_parse_responses() -> None:200,json={"path": "report.txt",- "file": {"transfer_method": "tool_file", "reference": "dify-file-ref:file-1"},+ "file": {+ "transfer_method": "tool_file",+ "reference": "dify-file-ref:file-1",+ "download_url": "https://files.example.com/report.txt",+ },},)raise AssertionError(f"unexpected request: {request.method} {request.url}")@@ -309,11 +318,35 @@ def test_async_sandbox_methods_post_dtos_and_parse_responses() -> None:assert listing.path == "."assert preview.text == "hello"assert uploaded.file.reference == "dify-file-ref:file-1"+ assert uploaded.file.download_url == "https://files.example.com/report.txt"await http_client.aclose()asyncio.run(scenario())+def test_sync_upload_sandbox_file_rejects_missing_download_url() -> None:+ locator = _sandbox_locator()++ def handler(request: httpx.Request) -> httpx.Response:+ if request.url.path != "/sandbox/files/upload":+ raise AssertionError(f"unexpected request: {request.method} {request.url}")+ return httpx.Response(+ 200,+ json={+ "path": "report.txt",+ "file": {+ "transfer_method": "tool_file",+ "reference": "dify-file-ref:file-1",+ },+ },+ )++ client = Client(base_url="http://testserver", sync_http_client=httpx.Client(transport=httpx.MockTransport(handler)))++ with pytest.raises(DifyAgentValidationError):+ _ = client.upload_sandbox_file_sync(locator, "report.txt")++def test_sync_sandbox_methods_map_invalid_json_to_validation_error() -> None:responses = iter([httpx.Response(200, text="not-json"), httpx.Response(404, json={"detail": "missing"})])diff --git a/dify-agent/tests/local/dify_agent/layers/config/test_layer.py b/dify-agent/tests/local/dify_agent/layers/config/test_layer.pyindex 0ea4bf1195f..f085f6cc51b 100644--- a/dify-agent/tests/local/dify_agent/layers/config/test_layer.py+++ b/dify-agent/tests/local/dify_agent/layers/config/test_layer.py@@ -9,7 +9,11 @@ import pytestfrom dify_agent.adapters.shell.shellctl import ShellctlProviderfrom dify_agent.layers.config import DifyConfigLayerConfig-from dify_agent.layers.config.layer import DifyConfigLayer, DifyConfigLayerError+from dify_agent.layers.config.layer import (+ DifyConfigLayer,+ DifyConfigLayerError,+ _AGENT_FILE_UPLOAD_REPLY_HINT,+)from dify_agent.layers.shell import DifyShellLayerConfigfrom dify_agent.layers.shell.layer import CompleteRemoteCommandResult, DifyShellLayer@@ -127,7 +131,19 @@ async def test_on_context_create_computes_runtime_fields_and_pulls_mentioned_assassert layer.runtime_state.pulled_skill_outputs == {"alpha": "/workspace/.dify_conf/skills/alpha\n# Alpha\nUse it."}assert layer.runtime_state.pulled_file_outputs == {"guide.txt": "/workspace/.dify_conf/files/guide.txt"}assert "dify-agent config note push --help" in layer.runtime_state.config_cli_help+ assert "dify-agent file upload --help" in layer.runtime_state.config_cli_help+ assert "dify-agent file download --help" in layer.runtime_state.config_cli_helpassert layer.runtime_state.push_spec_json_schema == ""+ suffix_prompt = layer.build_suffix_prompt()+ assert suffix_prompt.index("Agent config CLI reference for installed `dify-agent`:") < suffix_prompt.index(+ "Agent file CLI reference for installed `dify-agent`:"+ )+ assert "$ dify-agent file upload --help" in suffix_prompt+ assert "$ dify-agent file download --help" in suffix_prompt+ assert suffix_prompt.index("$ dify-agent file upload --help") < suffix_prompt.index(+ "$ dify-agent file download --help"+ )+ assert _AGENT_FILE_UPLOAD_REPLY_HINT in suffix_prompt@pytest.mark.anyiodiff --git a/dify-agent/tests/local/dify_agent/layers/drive/test_layer.py b/dify-agent/tests/local/dify_agent/layers/drive/test_layer.pyindex 86b04f95297..afcef5cc396 100644--- a/dify-agent/tests/local/dify_agent/layers/drive/test_layer.py+++ b/dify-agent/tests/local/dify_agent/layers/drive/test_layer.py@@ -8,7 +8,7 @@ import pytestfrom dify_agent.adapters.shell.shellctl import ShellctlProviderfrom dify_agent.layers.drive import DifyDriveLayerConfig, DifyDriveSkillConfig-from dify_agent.layers.drive.layer import DifyDriveLayer, DifyDriveLayerError+from dify_agent.layers.drive.layer import DifyDriveLayer, DifyDriveLayerError, _AGENT_FILE_UPLOAD_REPLY_HINTfrom dify_agent.layers.shell import DifyShellLayerConfigfrom dify_agent.layers.shell.layer import CompleteRemoteCommandResult, DifyShellLayer@@ -112,14 +112,18 @@ def test_drive_layer_exposes_agent_stub_cli_usage_suffix_prompt() -> None:layer._agent_stub_cli_help = {"dify-agent file --help": _file_help_output("dify-agent file --help"),"dify-agent file upload --help": _file_help_output("dify-agent file upload --help"),+ "dify-agent file download --help": _file_help_output("dify-agent file download --help"),}assert len(layer.suffix_prompts) == 1prompt = layer.suffix_prompts[0]assert "Other available skills" in promptassert "other-skill: Other Skill" in prompt- assert "Agent Stub file CLI help" in prompt+ assert "Agent Stub file CLI reference for installed `dify-agent`" in promptassert "$ dify-agent file upload --help" in prompt+ assert "$ dify-agent file download --help" in prompt+ assert prompt.index("$ dify-agent file upload --help") < prompt.index("$ dify-agent file download --help")+ assert _AGENT_FILE_UPLOAD_REPLY_HINT in promptassert "dify-agent drive" not in promptdiff --git a/dify-agent/tests/local/dify_agent/protocol/test_protocol_schemas.py b/dify-agent/tests/local/dify_agent/protocol/test_protocol_schemas.pyindex 75fa8dda204..be5ac5be9a5 100644--- a/dify-agent/tests/local/dify_agent/protocol/test_protocol_schemas.py+++ b/dify-agent/tests/local/dify_agent/protocol/test_protocol_schemas.py@@ -42,7 +42,11 @@ from dify_agent.layers.dify_plugin.configs import (def test_run_event_adapter_round_trips_typed_variants() -> None:events = [RunStartedEvent(run_id="run-1"),- PydanticAIStreamRunEvent(run_id="run-1", data=FinalResultEvent(tool_name=None, tool_call_id=None)),+ PydanticAIStreamRunEvent(+ run_id="run-1",+ data=FinalResultEvent(tool_name=None, tool_call_id=None),+ agent_message_delta="hello",+ ),RunSucceededEvent(run_id="run-1",data=RunSucceededEventData(@@ -101,6 +105,7 @@ def test_create_run_request_rejects_old_compositor_payload_and_model_layer_id_isdef test_protocol_package_no_longer_exports_execution_context_dto() -> None:assert not hasattr(protocol_exports, "ExecutionContext")+ assert not hasattr(protocol_exports, "RunPurpose")def test_create_run_request_accepts_dto_first_public_composition_and_normalizes_graph_config() -> None:@@ -131,7 +136,6 @@ def test_create_run_request_accepts_dto_first_public_composition_and_normalizes_})request = CreateRunRequest(- purpose="workflow_node",idempotency_key="workflow-run-1:node-execution-1",metadata={"source": "unit_test"},composition=RunComposition(@@ -177,7 +181,6 @@ def test_create_run_request_accepts_dto_first_public_composition_and_normalizes_"invoke_from": "service-api","trace_id": "trace-1",}- assert payload["purpose"] == "workflow_node"assert payload["idempotency_key"] == "workflow-run-1:node-execution-1"assert payload["metadata"] == {"source": "unit_test"}assert payload["composition"]["layers"][0]["config"] == {"prefix": "system", "user": "hello", "suffix": []}@@ -456,6 +459,16 @@ def test_create_run_request_rejects_removed_top_level_execution_context() -> Non)+def test_create_run_request_rejects_removed_top_level_purpose() -> None:+ with pytest.raises(ValidationError):+ _ = CreateRunRequest.model_validate(+ {+ "composition": {"layers": []},+ "purpose": "session_cleanup",+ }+ )++def test_layer_exit_signals_reject_extra_fields() -> None:with pytest.raises(ValidationError):_ = LayerExitSignals.model_validate({"default": "suspend", "unknown": "value"})diff --git a/dify-agent/tests/local/dify_agent/runtime/test_runner.py b/dify-agent/tests/local/dify_agent/runtime/test_runner.pyindex 6c05cb65703..87e12854496 100644--- a/dify-agent/tests/local/dify_agent/runtime/test_runner.py+++ b/dify-agent/tests/local/dify_agent/runtime/test_runner.py@@ -56,6 +56,7 @@ from dify_agent.protocol.schemas import (CreateRunRequest,DeferredToolResultsPayload,LayerExitSignals,+ PydanticAIStreamRunEvent,RunComposition,RunLayerSpec,RunSucceededEvent,@@ -196,6 +197,44 @@ def _request()+def _lifecycle_only_request(+ *,+ on_exit: LayerExitSignals | None = None,+ session_snapshot: CompositorSessionSnapshot | None = None,+ deferred_tool_results: DeferredToolResultsPayload | None = None,+) -> CreateRunRequest:+ snapshot = session_snapshot or CompositorSessionSnapshot(+ layers=[+ LayerSessionSnapshot(name="prompt", lifecycle_state=LifecycleState.SUSPENDED, runtime_state={}),+ LayerSessionSnapshot(name="execution_context", lifecycle_state=LifecycleState.SUSPENDED, runtime_state={}),+ ]+ )+ return CreateRunRequest(+ composition=RunComposition(+ layers=[+ RunLayerSpec(+ name="prompt",+ type="plain.prompt",+ config=PromptLayerConfig(prefix="system", user="hello"),+ ),+ RunLayerSpec(+ name="execution_context",+ type=DIFY_EXECUTION_CONTEXT_LAYER_TYPE_ID,+ config=DifyExecutionContextLayerConfig(+ tenant_id="tenant-1",+ user_from="account",+ agent_mode="workflow_run",+ invoke_from="service-api",+ ),+ ),+ ]+ ),+ session_snapshot=snapshot,+ deferred_tool_results=deferred_tool_results,+ on_exit=on_exit or LayerExitSignals(default=ExitIntent.DELETE),+ )++def _recursive_output_schema() -> dict[str, object]:return {"type": "object",@@ -381,6 +420,8 @@ def test_runner_emits_terminal_success_and_snapshot(monkeypatch: pytest.MonkeyPaassert "agent_output" not in event_typesassert "session_snapshot" not in event_typesassert event_types[-1:] == ["run_succeeded"]+ pydantic_events = [event for event in sink.events["run-1"] if isinstance(event, PydanticAIStreamRunEvent)]+ assert "".join(event.agent_message_delta or "" for event in pydantic_events) == "done"terminal = sink.events["run-1"][-1]assert isinstance(terminal, RunSucceededEvent)assert terminal.data.output == "done"@@ -902,9 +943,15 @@ def test_runner_passes_dynamic_dify_plugin_tools_to_agent(monkeypatch: pytest.Moassert http_client.is_closed is Falsereturn TestModel(custom_output_text="done") # pyright: ignore[reportReturnType]- async def fake_get_tools(self: DifyPluginToolsLayer, *, http_client: httpx.AsyncClient) -> list[Tool[object]]:+ async def fake_get_tools(+ self: DifyPluginToolsLayer,+ *,+ http_client: httpx.AsyncClient,+ dify_api_http_client: httpx.AsyncClient,+ ) -> list[Tool[object]]:assert self.config.tools[0].tool_name == "web_search"assert http_client.is_closed is False+ assert dify_api_http_client.is_closed is Falsereturn [Tool(plugin_tool, name="web_search")]class FakeResult:@@ -1218,8 +1265,14 @@ def test_runner_rejects_duplicate_tool_names_across_dynamic_tool_layers(assert http_client.is_closed is Falsereturn TestModel(custom_output_text="done") # pyright: ignore[reportReturnType]- async def fake_get_tools(_self: DifyPluginToolsLayer, *, http_client: httpx.AsyncClient) -> list[Tool[object]]:+ async def fake_get_tools(+ _self: DifyPluginToolsLayer,+ *,+ http_client: httpx.AsyncClient,+ dify_api_http_client: httpx.AsyncClient,+ ) -> list[Tool[object]]:assert http_client.is_closed is False+ assert dify_api_http_client.is_closed is Falsereturn [Tool(duplicate_tool, name="shared_tool")]def fake_create_agent(model: object, *, tools: list[Tool[object]], output_type: object) -> object:@@ -1336,8 +1389,14 @@ def test_runner_rejects_duplicate_tool_names_between_static_and_dynamic_tools(assert http_client.is_closed is Falsereturn TestModel(custom_output_text="done") # pyright: ignore[reportReturnType]- async def fake_get_tools(_self: DifyPluginToolsLayer, *, http_client: httpx.AsyncClient) -> list[Tool[object]]:+ async def fake_get_tools(+ _self: DifyPluginToolsLayer,+ *,+ http_client: httpx.AsyncClient,+ dify_api_http_client: httpx.AsyncClient,+ ) -> list[Tool[object]]:assert http_client.is_closed is False+ assert dify_api_http_client.is_closed is Falsereturn [Tool(dynamic_duplicate_tool, name="web_search")]def fake_create_agent(model: object, *, tools: list[Tool[object]], output_type: object) -> object:@@ -1440,8 +1499,14 @@ def test_runner_rejects_duplicate_tool_names_between_shell_and_other_layers(assert http_client.is_closed is Falsereturn TestModel(custom_output_text="done") # pyright: ignore[reportReturnType]- async def fake_get_tools(_self: DifyPluginToolsLayer, *, http_client: httpx.AsyncClient) -> list[Tool[object]]:+ async def fake_get_tools(+ _self: DifyPluginToolsLayer,+ *,+ http_client: httpx.AsyncClient,+ dify_api_http_client: httpx.AsyncClient,+ ) -> list[Tool[object]]:assert http_client.is_closed is False+ assert dify_api_http_client.is_closed is Falseasync def duplicate_shell_run() -> str:return "tool"@@ -1483,17 +1548,23 @@ def test_runner_rejects_duplicate_tool_names_between_shell_and_other_layers(type="plain.prompt",config=PromptLayerConfig(prefix="system", user="hello"),),- RunLayerSpec(name="shell", type=DIFY_SHELL_LAYER_TYPE_ID, config=DifyShellLayerConfig()),RunLayerSpec(name="execution_context",type=DIFY_EXECUTION_CONTEXT_LAYER_TYPE_ID,config=DifyExecutionContextLayerConfig(tenant_id="tenant-1",+ agent_id="agent-1",user_from="account",agent_mode="workflow_run",invoke_from="service-api",),),+ RunLayerSpec(+ name="shell",+ type=DIFY_SHELL_LAYER_TYPE_ID,+ deps={"execution_context": "execution_context"},+ config=DifyShellLayerConfig(),+ ),RunLayerSpec(name=DIFY_AGENT_MODEL_LAYER_ID,type="dify.plugin.llm",@@ -1760,6 +1831,112 @@ def test_runner_applies_on_exit_overrides_to_success_snapshot(monkeypatch: pytes}+def test_runner_lifecycle_only_cleanup_succeeds_without_model_and_emits_no_pydantic_ai_events() -> None:+ request = _lifecycle_only_request()+ sink = InMemoryRunEventSink()++ async def scenario() -> None:+ async with httpx.AsyncClient() as client:+ await AgentRunRunner(+ sink=sink,+ request=request,+ run_id="run-lifecycle-only",+ plugin_daemon_http_client=client,+ dify_api_http_client=client,+ ).run()++ asyncio.run(scenario())++ events = sink.events["run-lifecycle-only"]+ assert [event.type for event in events] == ["run_started", "run_succeeded"]+ terminal = events[-1]+ assert isinstance(terminal, RunSucceededEvent)+ assert terminal.data.output is None+ assert terminal.data.usage is None+ assert {layer.name: layer.lifecycle_state for layer in terminal.data.session_snapshot.layers} == {+ "prompt": LifecycleState.CLOSED,+ "execution_context": LifecycleState.CLOSED,+ }+++def test_runner_lifecycle_only_requires_session_snapshot() -> None:+ request = _request(llm_layer_name="not-llm")+ sink = InMemoryRunEventSink()++ async def scenario() -> None:+ async with httpx.AsyncClient() as client:+ with pytest.raises(AgentRunValidationError, match="session_snapshot"):+ await AgentRunRunner(+ sink=sink,+ request=request,+ run_id="run-lifecycle-only-missing-snapshot",+ plugin_daemon_http_client=client,+ dify_api_http_client=client,+ ).run()++ asyncio.run(scenario())++ assert [event.type for event in sink.events["run-lifecycle-only-missing-snapshot"]] == ["run_started", "run_failed"]+ assert sink.statuses["run-lifecycle-only-missing-snapshot"] == "failed"+++def test_runner_lifecycle_only_rejects_deferred_tool_results() -> None:+ request = _lifecycle_only_request(+ deferred_tool_results=DeferredToolResultsPayload.model_validate({"calls": {"tool-call-1": {"ok": True}}})+ )+ sink = InMemoryRunEventSink()++ async def scenario() -> None:+ async with httpx.AsyncClient() as client:+ with pytest.raises(AgentRunValidationError, match="Deferred tool results"):+ await AgentRunRunner(+ sink=sink,+ request=request,+ run_id="run-lifecycle-only-deferred-results",+ plugin_daemon_http_client=client,+ dify_api_http_client=client,+ ).run()++ asyncio.run(scenario())++ assert [event.type for event in sink.events["run-lifecycle-only-deferred-results"]] == [+ "run_started",+ "run_failed",+ ]+ assert sink.statuses["run-lifecycle-only-deferred-results"] == "failed"+++def test_runner_lifecycle_only_exit_hook_failure_emits_run_failed_not_validation_error(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ request = _lifecycle_only_request()+ sink = InMemoryRunEventSink()++ def _explode(_run: object, _signals: LayerExitSignals) -> None:+ raise RuntimeError("delete hook failed")++ monkeypatch.setattr("dify_agent.runtime.runner.apply_layer_exit_signals", _explode)++ async def scenario() -> None:+ async with httpx.AsyncClient() as client:+ with pytest.raises(RuntimeError, match="delete hook failed"):+ await AgentRunRunner(+ sink=sink,+ request=request,+ run_id="run-lifecycle-only-exit-hook-failure",+ plugin_daemon_http_client=client,+ dify_api_http_client=client,+ ).run()++ asyncio.run(scenario())++ assert [event.type for event in sink.events["run-lifecycle-only-exit-hook-failure"]] == [+ "run_started",+ "run_failed",+ ]+ assert sink.statuses["run-lifecycle-only-exit-hook-failure"] == "failed"++def test_runner_passes_output_layer_spec_to_agent_and_serializes_structured_result(monkeypatch: pytest.MonkeyPatch,) -> None:@@ -2363,13 +2540,39 @@ def test_runner_fails_blank_string_user_prompt_list() -> None:assert sink.statuses["run-3"] == "failed"-def test_runner_requires_llm_layer_id() -> None:- request = _request(llm_layer_name="not-llm")+def test_runner_rejects_reserved_llm_layer_name_with_wrong_type() -> None:+ request = CreateRunRequest(+ composition=RunComposition(+ layers=[+ RunLayerSpec(+ name="prompt",+ type="plain.prompt",+ config=PromptLayerConfig(prefix="system", user="hello"),+ ),+ RunLayerSpec(+ name="execution_context",+ type=DIFY_EXECUTION_CONTEXT_LAYER_TYPE_ID,+ config=DifyExecutionContextLayerConfig(+ tenant_id="tenant-1",+ user_from="account",+ agent_mode="workflow_run",+ invoke_from="service-api",+ ),+ ),+ RunLayerSpec(+ name=DIFY_AGENT_MODEL_LAYER_ID,+ type="plain.prompt",+ config=PromptLayerConfig(user="not an llm"),+ ),+ ]+ ),+ on_exit=LayerExitSignals(),+ )sink = InMemoryRunEventSink()async def scenario() -> None:async with httpx.AsyncClient() as client:- with pytest.raises(AgentRunValidationError, match="llm"):+ with pytest.raises(AgentRunValidationError, match="DifyPluginLLMLayer"):await AgentRunRunner(sink=sink,request=request,diff --git a/dify-agent/tests/local/dify_agent/server/test_sandbox_files.py b/dify-agent/tests/local/dify_agent/server/test_sandbox_files.pyindex 520aae02248..6bbe954ad7f 100644--- a/dify-agent/tests/local/dify_agent/server/test_sandbox_files.py+++ b/dify-agent/tests/local/dify_agent/server/test_sandbox_files.py@@ -394,7 +394,7 @@ def test_embedded_scripts_allow_parent_relative_paths(tmp_path: Path) -> None:"import sys",'if sys.argv[1:] != ["file", "upload", "../shared/notes.txt"]:',' raise SystemExit(f"unexpected args: {sys.argv[1:]!r}")',- 'print(json.dumps({"transfer_method": "tool_file", "reference": "file-ref"}))',+ 'print(json.dumps({"transfer_method": "tool_file", "reference": "file-ref", "download_url": "https://files.example.com/notes.txt"}))',])+ "\n",@@ -424,7 +424,11 @@ def test_embedded_scripts_allow_parent_relative_paths(tmp_path: Path) -> None:}assert upload_payload == {"path": "../shared/notes.txt",- "file": {"transfer_method": "tool_file", "reference": "file-ref"},+ "file": {+ "transfer_method": "tool_file",+ "reference": "file-ref",+ "download_url": "https://files.example.com/notes.txt",+ },}@@ -448,7 +452,7 @@ def test_embedded_scripts_expand_home_relative_paths(tmp_path: Path) -> None:"import sys",'if sys.argv[1:] != ["file", "upload", "~/shared/notes.txt"]:',' raise SystemExit(f"unexpected args: {sys.argv[1:]!r}")',- 'print(json.dumps({"transfer_method": "tool_file", "reference": "file-ref"}))',+ 'print(json.dumps({"transfer_method": "tool_file", "reference": "file-ref", "download_url": "https://files.example.com/notes.txt"}))',])+ "\n",@@ -474,7 +478,11 @@ def test_embedded_scripts_expand_home_relative_paths(tmp_path: Path) -> None:}assert upload_payload == {"path": "~/shared/notes.txt",- "file": {"transfer_method": "tool_file", "reference": "file-ref"},+ "file": {+ "transfer_method": "tool_file",+ "reference": "file-ref",+ "download_url": "https://files.example.com/notes.txt",+ },}@@ -508,7 +516,11 @@ def test_upload_injects_agent_stub_env_and_returns_mapping() -> None:output=_wrap({"path": "report.txt",- "file": {"transfer_method": "tool_file", "reference": "file-ref"},+ "file": {+ "transfer_method": "tool_file",+ "reference": "file-ref",+ "download_url": "https://files.example.com/report.txt",+ },},noise=True,),@@ -519,6 +531,7 @@ def test_upload_injects_agent_stub_env_and_returns_mapping() -> None:assert result.file.transfer_method == "tool_file"assert result.file.reference == "file-ref"+ assert result.file.download_url == "https://files.example.com/report.txt"script_call = _sandbox_python_run_call(client)assert script_call.cwd == "/home/agent-1/workspace/abc12ff"assert script_call.env == {@@ -529,6 +542,26 @@ def test_upload_injects_agent_stub_env_and_returns_mapping() -> None:}+def test_upload_rejects_missing_download_url_in_shell_payload() -> None:+ service, _client = _service(+ lambda script, cwd, env, timeout: _Job(+ job_id="sandbox-job",+ output=_wrap(+ {+ "path": "report.txt",+ "file": {+ "transfer_method": "tool_file",+ "reference": "file-ref",+ },+ }+ ),+ )+ )++ with pytest.raises(SandboxFileError, match="sandbox command returned invalid payload"):+ _ = asyncio.run(service.upload_file(SandboxUploadRequest(locator=_locator(), path="report.txt")))++def test_shell_result_details_include_output_metadata_and_tail() -> None:details = _shell_result_details(_complete_result(output="hello", output_complete=False, incomplete_reason="output_limit")@@ -572,7 +605,14 @@ def test_read_and_upload_allow_relative_paths(output=_wrap({"path": expected_path, "size": 5, "truncated": False, "binary": False, "text": "hello"}if isinstance(sandbox_request, SandboxReadRequest)- else {"path": expected_path, "file": {"transfer_method": "tool_file", "reference": "file-ref"}}+ else {+ "path": expected_path,+ "file": {+ "transfer_method": "tool_file",+ "reference": "file-ref",+ "download_url": "https://files.example.com/report.txt",+ },+ }),))@@ -583,5 +623,6 @@ def test_read_and_upload_allow_relative_paths(else:result = asyncio.run(service.upload_file(sandbox_request))assert result.path == expected_path+ assert result.file.download_url == "https://files.example.com/report.txt"assert expected_command in _sandbox_python_run_call(client).scriptdiff --git a/e2e/features/agent-v2/AGENTS.md b/e2e/features/agent-v2/AGENTS.mdindex f432eff7d77..33b74103ee7 100644--- a/e2e/features/agent-v2/AGENTS.md+++ b/e2e/features/agent-v2/AGENTS.md@@ -28,7 +28,7 @@ Use tags in three layers:- `@build` — Build mode and Build draft behavior.- `@build-unavailable-resources` — feature-gated Build chat recovery when the user requests unavailable Skills or Tools.- `@files` — Files section upload, display, and fixture behavior.-- `@files-limits` — file limit behavior. Multiple-file drop is stable core coverage; format, size, count, and in-progress upload recovery remain feature-gated until their product contracts are stable.+- `@files-limits` — file limit behavior. Multiple-file drop is stable core coverage; format and size rejection remain feature-gated until their product contracts are stable.- `@knowledge` — Knowledge Retrieval configuration display, persistence, and reference cleanup.- `@advanced-settings` — Env Editor, Content Moderation, and related Advanced Settings behavior.- `@agent-create` — Agent Roster creation and initial Configure navigation.@@ -225,6 +225,6 @@ Order blocked steps by the real owner of the first unresolved condition. If a scUse partial coverage only when current product behavior is intentionally narrower than the written requirement and the test still asserts a real user-visible behavior. Example: Files are currently flat in Agent config files, so the flat Files list can be asserted while tree display remains blocked until product support exists.-Multiple-file drop is already covered as stable `@core @files-limits` behavior. File format, size, count, and in-progress upload limit cases remain feature-gated until the product exposes stable Agent config file restrictions and user-visible recovery/error states. Do not convert those gated `@files-limits` scenarios to passing tests by relying on default environment behavior; first align the product contract or seed configuration.+Multiple-file drop is already covered as stable `@core @files-limits` behavior. File format and size rejection remain feature-gated until the product exposes stable Agent config file restrictions and user-visible error states. Do not convert those gated `@files-limits` scenarios to passing tests by relying on default environment behavior; first align the product contract or seed configuration.Do not mark a scenario as complete if it only proves setup state and does not assert the user-visible behavior or persisted product contract required by the case.diff --git a/e2e/features/agent-v2/files.feature b/e2e/features/agent-v2/files.featureindex 700f90d2d30..233e57dc69e 100644--- a/e2e/features/agent-v2/files.feature+++ b/e2e/features/agent-v2/files.feature@@ -60,19 +60,3 @@ Feature: Agent v2 filesAnd I drop multiple Agent v2 files into the Files upload dialogThen the Agent v2 Files upload dialog should reject the multiple-file dropAnd I should not see the dropped Agent v2 files in the Files section-- @files-limits @feature-gated- Scenario: Agent v2 total file count limits are enforced- Given I am signed in as the default E2E admin- And Agent v2 total file count limits are available- And a basic configured Agent v2 test agent has been created via API- When I open the Agent v2 configure page- Then Agent v2 total file count limits should be available-- @files-limits @feature-gated- Scenario: Leaving during Agent v2 file upload keeps a recoverable state- Given I am signed in as the default E2E admin- And Agent v2 in-progress file upload recovery is available- And a basic configured Agent v2 test agent has been created via API- When I open the Agent v2 configure page- Then Agent v2 in-progress file upload recovery should be availablediff --git a/e2e/features/agent-v2/output-variables.feature b/e2e/features/agent-v2/output-variables.featureindex 0877d1ea0ae..9410ff656ff 100644--- a/e2e/features/agent-v2/output-variables.feature+++ b/e2e/features/agent-v2/output-variables.feature@@ -1,13 +1,5 @@@agent-v2 @authenticated @output-variablesFeature: Agent v2 output variables- @standalone-output-variables @feature-gated- Scenario: Standalone Agent configure exposes Output Variables- Given I am signed in as the default E2E admin- And Agent v2 standalone Output Variables are available- And a basic configured Agent v2 test agent has been created via API- When I open the Agent v2 configure page- Then Agent v2 standalone Output Variables should be available-@core @stable-modelScenario: Workflow Agent v2 output variables persist after refreshGiven I am signed in as the default E2E admin@@ -63,23 +55,3 @@ Feature: Agent v2 output variablesAnd I open the Agent v2 workflow node panelAnd I insert a file output reference from the Agent v2 workflow node task editorThen Agent v2 workflow task output reference deletion consistency should be available-- @output-retry-strategy @feature-gated @stable-model- Scenario: Workflow Agent v2 output retry strategy can be saved after refresh- Given I am signed in as the default E2E admin- And Agent v2 workflow output retry strategy is available- And the Agent Builder stable chat model is available- And a workflow app with an Agent v2 node has been created via API- When I open the app from the app list- And I open the Agent v2 workflow node panel- Then Agent v2 workflow output retry strategy should be available-- @output-retry-validation @feature-gated @stable-model- Scenario: Workflow Agent v2 output retry count validation is enforced- Given I am signed in as the default E2E admin- And Agent v2 workflow output retry count validation is available- And the Agent Builder stable chat model is available- And a workflow app with an Agent v2 node has been created via API- When I open the app from the app list- And I open the Agent v2 workflow node panel- Then Agent v2 workflow output retry count validation should be availablediff --git a/e2e/features/agent-v2/support/test-materials.ts b/e2e/features/agent-v2/support/test-materials.tsindex 1f047d4c1f4..a1b9a811ce8 100644--- a/e2e/features/agent-v2/support/test-materials.ts+++ b/e2e/features/agent-v2/support/test-materials.ts@@ -10,14 +10,9 @@ export const agentBuilderTestMaterials = {invalidEnv: 'agent-invalid.env',buildInstruction: 'agent-build-instruction.txt',summarySkill: 'e2e-summary-skill/SKILL.md',- countBatch5: 'count_batch_5_valid_files',- countBatch6: 'count_batch_6_valid_files',- countTotal50: 'count_total_50_valid_files',- countTotalExtra1: 'count_total_extra_1_valid_file',} as constexport const agentBuilderGeneratedTestMaterials = {- slowUploadFile: 'agent-slow-upload-file.txt',tooLargeFile: 'agent-too-large-file.txt',} as const@@ -30,10 +25,3 @@ export const getTooLargeAgentFilePath = () =>sizeBytes: 16 * 1024 * 1024,seedText: 'E2E_TOO_LARGE_FILE_FIXTURE',})--export const getSlowUploadAgentFilePath = () =>- getGeneratedTextMaterialPath({- fileName: 'agent-slow-upload-file.txt',- sizeBytes: 2 * 1024 * 1024,- seedText: 'E2E_SLOW_UPLOAD_FILE_FIXTURE',- })diff --git a/e2e/features/step-definitions/agent-v2/build-draft.steps.ts b/e2e/features/step-definitions/agent-v2/build-draft.steps.tsindex 7a4c738ea73..6071f072876 100644--- a/e2e/features/step-definitions/agent-v2/build-draft.steps.ts+++ b/e2e/features/step-definitions/agent-v2/build-draft.steps.ts@@ -175,7 +175,20 @@ const expectPageResponseOK = async (response: Response, action: string) => {}When('I discard the Agent v2 Build draft', async function (this: DifyWorld) {- await this.getPage().getByRole('button', { exact: true, name: 'Discard' }).click()+ const page = this.getPage()+ const agentId = getCurrentAgentId(this)++ await page.getByRole('button', { exact: true, name: 'Discard' }).click()+ const confirmDialog = page.getByRole('alertdialog', { name: 'Clear session and discard changes?' })+ await expect(confirmDialog).toBeVisible()++ const discardResponsePromise = page.waitForResponse(response => (+ response.request().method() === 'DELETE'+ && new URL(response.url()).pathname.endsWith(`/console/api/agent/${agentId}/build-draft`)+ ))++ await confirmDialog.getByRole('button', { name: 'Confirm' }).click()+ await expectPageResponseOK(await discardResponsePromise, 'Discard Agent v2 Build draft')})When(diff --git a/e2e/features/step-definitions/agent-v2/configure.steps.ts b/e2e/features/step-definitions/agent-v2/configure.steps.tsindex c41298fc84f..02ed9004d3c 100644--- a/e2e/features/step-definitions/agent-v2/configure.steps.ts+++ b/e2e/features/step-definitions/agent-v2/configure.steps.ts@@ -282,10 +282,13 @@ Then('I should be on the Agent v2 configure page', async function (this: DifyWorThen('I should see the Agent v2 configure workspace', async function (this: DifyWorld) {const page = this.getPage()+ const agentName = this.lastCreatedAgentName+ if (!agentName)+ throw new Error('No Agent v2 name found. Create an Agent v2 test agent first.')await expect(page.getByRole('region', { name: 'Configure' })).toBeVisible({ timeout: 30_000 })await expect(page.getByRole('heading', { name: 'Configure' })).toBeVisible()- await expect(page.getByText(this.lastCreatedAgentName!)).toBeVisible()+ await expect(page.getByText(agentName, { exact: true })).toBeVisible()})Then(diff --git a/e2e/features/step-definitions/agent-v2/files.steps.ts b/e2e/features/step-definitions/agent-v2/files.steps.tsindex 15e2f15c42b..ddce18f62d7 100644--- a/e2e/features/step-definitions/agent-v2/files.steps.ts+++ b/e2e/features/step-definitions/agent-v2/files.steps.ts@@ -140,41 +140,3 @@ Given('Agent v2 oversized file rejection is available', async function (this: DiThen('Agent v2 oversized file rejection should be available', async function (this: DifyWorld) {return skipOversizedFileRejection(this)})--async function skipTotalFileCountLimits(world: DifyWorld) {- return skipBlockedPrecondition(- world,- 'Agent v2 total file count limits are not defined for Agent config files in the current product contract.',- {- owner: 'product',- remediation: 'Define the Agent config file total-count limit and user-visible error before enabling this scenario.',- },- )-}--Given('Agent v2 total file count limits are available', async function (this: DifyWorld) {- return skipTotalFileCountLimits(this)-})--Then('Agent v2 total file count limits should be available', async function (this: DifyWorld) {- return skipTotalFileCountLimits(this)-})--async function skipInProgressFileUploadRecovery(world: DifyWorld) {- return skipBlockedPrecondition(- world,- 'Agent v2 in-progress file upload recovery is not stable: the current dialog has no deterministic slow-upload fixture or user-visible navigation guard contract.',- {- owner: 'product/test-infra',- remediation: 'Define upload-in-progress navigation behavior and provide a deterministic slow upload fixture before enabling this scenario.',- },- )-}--Given('Agent v2 in-progress file upload recovery is available', async function (this: DifyWorld) {- return skipInProgressFileUploadRecovery(this)-})--Then('Agent v2 in-progress file upload recovery should be available', async function (this: DifyWorld) {- return skipInProgressFileUploadRecovery(this)-})diff --git a/e2e/features/step-definitions/agent-v2/output-variables.steps.ts b/e2e/features/step-definitions/agent-v2/output-variables.steps.tsindex f21f1944217..5619f5bae8a 100644--- a/e2e/features/step-definitions/agent-v2/output-variables.steps.ts+++ b/e2e/features/step-definitions/agent-v2/output-variables.steps.ts@@ -330,44 +330,6 @@ async function expectAgentTaskOutputReference(await expect(page.getByText(unexpectedName, { exact: true })).toHaveCount(0)}-async function skipStandaloneOutputVariables(world: DifyWorld) {- return skipBlockedPrecondition(- world,- 'Standalone Agent Output Variables are not available: output variables currently belong to Workflow Agent v2 nodes.',- {- owner: 'product',- remediation: 'Expose standalone Agent Output Variables or keep this scenario excluded until the product path exists.',- },- )-}--Given('Agent v2 standalone Output Variables are available', async function (this: DifyWorld) {- return skipStandaloneOutputVariables(this)-})--Then('Agent v2 standalone Output Variables should be available', async function (this: DifyWorld) {- return skipStandaloneOutputVariables(this)-})--async function skipWorkflowOutputRetryStrategy(world: DifyWorld) {- return skipBlockedPrecondition(- world,- 'Agent v2 workflow Output Variables retry strategy is not available in the current editor UI.',- {- owner: 'product',- remediation: 'Expose user-visible retry strategy controls before enabling this scenario.',- },- )-}--Given('Agent v2 workflow output retry strategy is available', async function (this: DifyWorld) {- return skipWorkflowOutputRetryStrategy(this)-})--Then('Agent v2 workflow output retry strategy should be available', async function (this: DifyWorld) {- return skipWorkflowOutputRetryStrategy(this)-})-async function skipWorkflowTaskOutputReferenceDeletionConsistency(world: DifyWorld) {return skipBlockedPrecondition(world,@@ -392,22 +354,3 @@ Then(return skipWorkflowTaskOutputReferenceDeletionConsistency(this)},)--async function skipWorkflowOutputRetryCountValidation(world: DifyWorld) {- return skipBlockedPrecondition(- world,- 'Agent v2 workflow Output Variables retry count validation is not reachable because retry strategy controls are not available in the current editor UI.',- {- owner: 'product',- remediation: 'Expose retry count controls and validation states before enabling this scenario.',- },- )-}--Given('Agent v2 workflow output retry count validation is available', async function (this: DifyWorld) {- return skipWorkflowOutputRetryCountValidation(this)-})--Then('Agent v2 workflow output retry count validation should be available', async function (this: DifyWorld) {- return skipWorkflowOutputRetryCountValidation(this)-})diff --git a/e2e/fixtures/test-materials/count_batch_5_valid_files/file-1.txt b/e2e/fixtures/test-materials/count_batch_5_valid_files/file-1.txtdeleted file mode 100644index a64cd23552d..00000000000--- a/e2e/fixtures/test-materials/count_batch_5_valid_files/file-1.txt+++ /dev/null@@ -1 +0,0 @@-Batch 5 valid file 1 token E2E_BATCH_5_1diff --git a/e2e/fixtures/test-materials/count_batch_5_valid_files/file-2.txt b/e2e/fixtures/test-materials/count_batch_5_valid_files/file-2.txtdeleted file mode 100644index 1a65ed90e76..00000000000--- a/e2e/fixtures/test-materials/count_batch_5_valid_files/file-2.txt+++ /dev/null@@ -1 +0,0 @@-Batch 5 valid file 2 token E2E_BATCH_5_2diff --git a/e2e/fixtures/test-materials/count_batch_5_valid_files/file-3.txt b/e2e/fixtures/test-materials/count_batch_5_valid_files/file-3.txtdeleted file mode 100644index c5c00a2477e..00000000000--- a/e2e/fixtures/test-materials/count_batch_5_valid_files/file-3.txt+++ /dev/null@@ -1 +0,0 @@-Batch 5 valid file 3 token E2E_BATCH_5_3diff --git a/e2e/fixtures/test-materials/count_batch_5_valid_files/file-4.txt b/e2e/fixtures/test-materials/count_batch_5_valid_files/file-4.txtdeleted file mode 100644index 120e4ee335c..00000000000--- a/e2e/fixtures/test-materials/count_batch_5_valid_files/file-4.txt+++ /dev/null@@ -1 +0,0 @@-Batch 5 valid file 4 token E2E_BATCH_5_4diff --git a/e2e/fixtures/test-materials/count_batch_5_valid_files/file-5.txt b/e2e/fixtures/test-materials/count_batch_5_valid_files/file-5.txtdeleted file mode 100644index 4efaff6d828..00000000000--- a/e2e/fixtures/test-materials/count_batch_5_valid_files/file-5.txt+++ /dev/null@@ -1 +0,0 @@-Batch 5 valid file 5 token E2E_BATCH_5_5diff --git a/e2e/fixtures/test-materials/count_batch_6_valid_files/file-1.txt b/e2e/fixtures/test-materials/count_batch_6_valid_files/file-1.txtdeleted file mode 100644index 6ce029a426b..00000000000--- a/e2e/fixtures/test-materials/count_batch_6_valid_files/file-1.txt+++ /dev/null@@ -1 +0,0 @@-Batch 6 valid file 1 token E2E_BATCH_6_1diff --git a/e2e/fixtures/test-materials/count_batch_6_valid_files/file-2.txt b/e2e/fixtures/test-materials/count_batch_6_valid_files/file-2.txtdeleted file mode 100644index 08620c1994f..00000000000--- a/e2e/fixtures/test-materials/count_batch_6_valid_files/file-2.txt+++ /dev/null@@ -1 +0,0 @@-Batch 6 valid file 2 token E2E_BATCH_6_2diff --git a/e2e/fixtures/test-materials/count_batch_6_valid_files/file-3.txt b/e2e/fixtures/test-materials/count_batch_6_valid_files/file-3.txtdeleted file mode 100644index 73deeefa755..00000000000--- a/e2e/fixtures/test-materials/count_batch_6_valid_files/file-3.txt+++ /dev/null@@ -1 +0,0 @@-Batch 6 valid file 3 token E2E_BATCH_6_3diff --git a/e2e/fixtures/test-materials/count_batch_6_valid_files/file-4.txt b/e2e/fixtures/test-materials/count_batch_6_valid_files/file-4.txtdeleted file mode 100644index 5b62b0d7075..00000000000--- a/e2e/fixtures/test-materials/count_batch_6_valid_files/file-4.txt+++ /dev/null@@ -1 +0,0 @@-Batch 6 valid file 4 token E2E_BATCH_6_4diff --git a/e2e/fixtures/test-materials/count_batch_6_valid_files/file-5.txt b/e2e/fixtures/test-materials/count_batch_6_valid_files/file-5.txtdeleted file mode 100644index c0192f87bb4..00000000000--- a/e2e/fixtures/test-materials/count_batch_6_valid_files/file-5.txt+++ /dev/null@@ -1 +0,0 @@-Batch 6 valid file 5 token E2E_BATCH_6_5diff --git a/e2e/fixtures/test-materials/count_batch_6_valid_files/file-6.txt b/e2e/fixtures/test-materials/count_batch_6_valid_files/file-6.txtdeleted file mode 100644index e3505c43d59..00000000000--- a/e2e/fixtures/test-materials/count_batch_6_valid_files/file-6.txt+++ /dev/null@@ -1 +0,0 @@-Batch 6 valid file 6 token E2E_BATCH_6_6diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-01.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-01.txtdeleted file mode 100644index db1a55a0021..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-01.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 01 token E2E_TOTAL_50_01diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-02.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-02.txtdeleted file mode 100644index bdcd785ab8f..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-02.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 02 token E2E_TOTAL_50_02diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-03.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-03.txtdeleted file mode 100644index cf00c92b0a3..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-03.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 03 token E2E_TOTAL_50_03diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-04.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-04.txtdeleted file mode 100644index 01522864989..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-04.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 04 token E2E_TOTAL_50_04diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-05.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-05.txtdeleted file mode 100644index 22a118ddd0f..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-05.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 05 token E2E_TOTAL_50_05diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-06.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-06.txtdeleted file mode 100644index 3cee5574426..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-06.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 06 token E2E_TOTAL_50_06diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-07.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-07.txtdeleted file mode 100644index 381bf4d24d5..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-07.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 07 token E2E_TOTAL_50_07diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-08.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-08.txtdeleted file mode 100644index 8cc4d21fc86..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-08.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 08 token E2E_TOTAL_50_08diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-09.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-09.txtdeleted file mode 100644index 490cc4b779c..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-09.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 09 token E2E_TOTAL_50_09diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-10.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-10.txtdeleted file mode 100644index fe4089625f5..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-10.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 10 token E2E_TOTAL_50_10diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-11.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-11.txtdeleted file mode 100644index b5a9ae2ea3f..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-11.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 11 token E2E_TOTAL_50_11diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-12.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-12.txtdeleted file mode 100644index 33e0f0b77c0..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-12.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 12 token E2E_TOTAL_50_12diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-13.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-13.txtdeleted file mode 100644index 0bf532f9a32..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-13.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 13 token E2E_TOTAL_50_13diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-14.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-14.txtdeleted file mode 100644index 60b3cb0d751..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-14.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 14 token E2E_TOTAL_50_14diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-15.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-15.txtdeleted file mode 100644index 15c0e3769be..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-15.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 15 token E2E_TOTAL_50_15diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-16.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-16.txtdeleted file mode 100644index 6c80e6e66bb..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-16.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 16 token E2E_TOTAL_50_16diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-17.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-17.txtdeleted file mode 100644index 9ac689f667a..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-17.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 17 token E2E_TOTAL_50_17diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-18.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-18.txtdeleted file mode 100644index 3a9c6725090..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-18.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 18 token E2E_TOTAL_50_18diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-19.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-19.txtdeleted file mode 100644index 35d544714c8..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-19.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 19 token E2E_TOTAL_50_19diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-20.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-20.txtdeleted file mode 100644index cc53594e52f..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-20.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 20 token E2E_TOTAL_50_20diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-21.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-21.txtdeleted file mode 100644index 2e0af50430c..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-21.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 21 token E2E_TOTAL_50_21diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-22.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-22.txtdeleted file mode 100644index fe09be37a12..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-22.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 22 token E2E_TOTAL_50_22diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-23.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-23.txtdeleted file mode 100644index 70bb91ee326..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-23.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 23 token E2E_TOTAL_50_23diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-24.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-24.txtdeleted file mode 100644index a8ba2e60d61..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-24.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 24 token E2E_TOTAL_50_24diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-25.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-25.txtdeleted file mode 100644index ddfe2afed46..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-25.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 25 token E2E_TOTAL_50_25diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-26.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-26.txtdeleted file mode 100644index 1a56d928a9a..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-26.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 26 token E2E_TOTAL_50_26diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-27.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-27.txtdeleted file mode 100644index a8182ad2e71..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-27.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 27 token E2E_TOTAL_50_27diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-28.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-28.txtdeleted file mode 100644index a6f78f011db..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-28.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 28 token E2E_TOTAL_50_28diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-29.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-29.txtdeleted file mode 100644index 7a76d201194..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-29.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 29 token E2E_TOTAL_50_29diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-30.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-30.txtdeleted file mode 100644index 5a37417ca8c..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-30.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 30 token E2E_TOTAL_50_30diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-31.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-31.txtdeleted file mode 100644index 1baa8eb8c7b..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-31.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 31 token E2E_TOTAL_50_31diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-32.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-32.txtdeleted file mode 100644index e5ff1a42437..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-32.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 32 token E2E_TOTAL_50_32diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-33.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-33.txtdeleted file mode 100644index dcbc2995748..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-33.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 33 token E2E_TOTAL_50_33diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-34.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-34.txtdeleted file mode 100644index fefc133eed1..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-34.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 34 token E2E_TOTAL_50_34diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-35.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-35.txtdeleted file mode 100644index 1c1a93172cb..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-35.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 35 token E2E_TOTAL_50_35diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-36.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-36.txtdeleted file mode 100644index d7e0bab1aaf..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-36.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 36 token E2E_TOTAL_50_36diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-37.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-37.txtdeleted file mode 100644index 6a78127243f..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-37.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 37 token E2E_TOTAL_50_37diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-38.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-38.txtdeleted file mode 100644index fc5ef9123db..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-38.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 38 token E2E_TOTAL_50_38diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-39.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-39.txtdeleted file mode 100644index 37765df65e5..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-39.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 39 token E2E_TOTAL_50_39diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-40.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-40.txtdeleted file mode 100644index 74de5e2ed4e..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-40.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 40 token E2E_TOTAL_50_40diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-41.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-41.txtdeleted file mode 100644index 13d3dee7c51..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-41.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 41 token E2E_TOTAL_50_41diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-42.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-42.txtdeleted file mode 100644index befc45f2387..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-42.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 42 token E2E_TOTAL_50_42diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-43.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-43.txtdeleted file mode 100644index 521ad583a5a..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-43.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 43 token E2E_TOTAL_50_43diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-44.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-44.txtdeleted file mode 100644index e4b315b675f..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-44.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 44 token E2E_TOTAL_50_44diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-45.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-45.txtdeleted file mode 100644index c97738e4fac..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-45.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 45 token E2E_TOTAL_50_45diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-46.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-46.txtdeleted file mode 100644index 22b73767b42..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-46.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 46 token E2E_TOTAL_50_46diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-47.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-47.txtdeleted file mode 100644index b327026efd0..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-47.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 47 token E2E_TOTAL_50_47diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-48.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-48.txtdeleted file mode 100644index 5458e0cf222..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-48.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 48 token E2E_TOTAL_50_48diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-49.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-49.txtdeleted file mode 100644index 90bf454dd5f..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-49.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 49 token E2E_TOTAL_50_49diff --git a/e2e/fixtures/test-materials/count_total_50_valid_files/file-50.txt b/e2e/fixtures/test-materials/count_total_50_valid_files/file-50.txtdeleted file mode 100644index b5760aed272..00000000000--- a/e2e/fixtures/test-materials/count_total_50_valid_files/file-50.txt+++ /dev/null@@ -1 +0,0 @@-Total 50 valid file 50 token E2E_TOTAL_50_50diff --git a/e2e/fixtures/test-materials/count_total_extra_1_valid_file/file-01.txt b/e2e/fixtures/test-materials/count_total_extra_1_valid_file/file-01.txtdeleted file mode 100644index 4df2e230c05..00000000000--- a/e2e/fixtures/test-materials/count_total_extra_1_valid_file/file-01.txt+++ /dev/null@@ -1 +0,0 @@-Total extra valid file token E2E_TOTAL_EXTRA_1diff --git a/eslint-suppressions.json b/eslint-suppressions.jsonindex 5207eae92bc..81d07357845 100644--- a/eslint-suppressions.json+++ b/eslint-suppressions.json@@ -1183,7 +1183,7 @@"count": 2},"ts/no-explicit-any": {- "count": 17+ "count": 12}},"web/app/components/base/chat/chat/log/index.tsx": {diff --git a/packages/contracts/generated/api/console/agent/types.gen.ts b/packages/contracts/generated/api/console/agent/types.gen.tsindex bc74f6ebf56..3f3bee9fdd2 100644--- a/packages/contracts/generated/api/console/agent/types.gen.ts+++ b/packages/contracts/generated/api/console/agent/types.gen.ts@@ -921,6 +921,7 @@ export type AgentLogMessageItemResponse = {}export type AgentThought = {+ answer?: string | nullchain_id?: string | nullcreated_at?: number | nullfiles: Array<string>diff --git a/packages/contracts/generated/api/console/agent/zod.gen.ts b/packages/contracts/generated/api/console/agent/zod.gen.tsindex 6be9ce9e118..d62307a61d0 100644--- a/packages/contracts/generated/api/console/agent/zod.gen.ts+++ b/packages/contracts/generated/api/console/agent/zod.gen.ts@@ -802,6 +802,7 @@ export const zJsonValue = z* AgentThought*/export const zAgentThought = z.object({+ answer: z.string().nullish(),chain_id: z.string().nullish(),created_at: z.int().nullish(),files: z.array(z.string()),diff --git a/packages/contracts/generated/api/console/apps/types.gen.ts b/packages/contracts/generated/api/console/apps/types.gen.tsindex 627e65bfc81..f18eec3f8b9 100644--- a/packages/contracts/generated/api/console/apps/types.gen.ts+++ b/packages/contracts/generated/api/console/apps/types.gen.ts@@ -1648,6 +1648,7 @@ export type ConversationVariableResponse = {}export type AgentThought = {+ answer?: string | nullchain_id?: string | nullcreated_at?: number | nullfiles: Array<string>diff --git a/packages/contracts/generated/api/console/apps/zod.gen.ts b/packages/contracts/generated/api/console/apps/zod.gen.tsindex f9742c91d64..91d6f6bd01e 100644--- a/packages/contracts/generated/api/console/apps/zod.gen.ts+++ b/packages/contracts/generated/api/console/apps/zod.gen.ts@@ -1342,6 +1342,7 @@ export const zPaginatedConversationVariableResponse = z.object({* AgentThought*/export const zAgentThought = z.object({+ answer: z.string().nullish(),chain_id: z.string().nullish(),created_at: z.int().nullish(),files: z.array(z.string()),diff --git a/packages/contracts/generated/api/console/installed-apps/types.gen.ts b/packages/contracts/generated/api/console/installed-apps/types.gen.tsindex 4692d77db63..59b4619c11a 100644--- a/packages/contracts/generated/api/console/installed-apps/types.gen.ts+++ b/packages/contracts/generated/api/console/installed-apps/types.gen.ts@@ -247,6 +247,7 @@ export type InstalledAppInfoResponse = {}export type AgentThought = {+ answer?: string | nullchain_id?: string | nullcreated_at?: number | nullfiles: Array<string>diff --git a/packages/contracts/generated/api/console/installed-apps/zod.gen.ts b/packages/contracts/generated/api/console/installed-apps/zod.gen.tsindex 6e5680ab1b8..60c4f1448c4 100644--- a/packages/contracts/generated/api/console/installed-apps/zod.gen.ts+++ b/packages/contracts/generated/api/console/installed-apps/zod.gen.ts@@ -266,6 +266,7 @@ export const zInstalledAppListResponse = z.object({* AgentThought*/export const zAgentThought = z.object({+ answer: z.string().nullish(),chain_id: z.string().nullish(),created_at: z.int().nullish(),files: z.array(z.string()),diff --git a/packages/contracts/generated/api/service/types.gen.ts b/packages/contracts/generated/api/service/types.gen.tsindex b9497dabca3..4a58a619741 100644--- a/packages/contracts/generated/api/service/types.gen.ts+++ b/packages/contracts/generated/api/service/types.gen.ts@@ -5,6 +5,7 @@ export type ClientOptions = {}export type AgentThought = {+ answer?: string | nullchain_id?: string | nullcreated_at?: number | nullfiles: Array<string>diff --git a/packages/contracts/generated/api/service/zod.gen.ts b/packages/contracts/generated/api/service/zod.gen.tsindex cedeb77dab9..a5da8668e5c 100644--- a/packages/contracts/generated/api/service/zod.gen.ts+++ b/packages/contracts/generated/api/service/zod.gen.ts@@ -1129,6 +1129,7 @@ export const zJsonValue = z* AgentThought*/export const zAgentThought = z.object({+ answer: z.string().nullish(),chain_id: z.string().nullish(),created_at: z.int().nullish(),files: z.array(z.string()),diff --git a/packages/contracts/generated/api/web/types.gen.ts b/packages/contracts/generated/api/web/types.gen.tsindex 44a461c1592..69e4ebdecd0 100644--- a/packages/contracts/generated/api/web/types.gen.ts+++ b/packages/contracts/generated/api/web/types.gen.ts@@ -18,6 +18,7 @@ export type AccessTokenResultResponse = {}export type AgentThought = {+ answer?: string | nullchain_id?: string | nullcreated_at?: number | nullfiles: Array<string>diff --git a/packages/contracts/generated/api/web/zod.gen.ts b/packages/contracts/generated/api/web/zod.gen.tsindex 55cefb12e14..c663be89564 100644--- a/packages/contracts/generated/api/web/zod.gen.ts+++ b/packages/contracts/generated/api/web/zod.gen.ts@@ -363,6 +363,7 @@ export const zJsonValue = z* AgentThought*/export const zAgentThought = z.object({+ answer: z.string().nullish(),chain_id: z.string().nullish(),created_at: z.int().nullish(),files: z.array(z.string()),diff --git a/web/AGENTS.md b/web/AGENTS.mdindex 2281cfab4bf..c6a0b184fe4 100644--- a/web/AGENTS.md+++ b/web/AGENTS.md@@ -9,6 +9,10 @@- User-facing strings must use `web/i18n/en-US/` keys instead of hardcoded text.- When adding or renaming an i18n key, update all supported locale files with correct localized values. Do not leave fallback English in non-English locales unless the repo already intentionally does so for that exact key.+## Backend API Calls++- For new backend calls, and for surfaces already migrated to generated contracts, use `consoleQuery` / `consoleClient` from `@/service/client`. Do not add handwritten REST helpers, handwritten API types, mock-backed app state, or direct edits to generated contract files.+## Overlay Components (Mandatory)- `../packages/dify-ui/README.md` is the permanent contract for overlay primitives, portals, root `isolation: isolate`, and the `z-50` / `z-60` layering.@@ -16,6 +20,10 @@- In new or modified code, use only overlay primitives from `@langgenius/dify-ui/*`.- Do not introduce overlay imports from `@/app/components/base/*`; when touching existing callers, migrate them.+## UI Components++- Use `@langgenius/dify-ui/*` primitives and primitive data/CSS selectors first. Add call-site Tailwind only for real design deltas, avoid arbitrary values when token utilities exist, and keep focus rings visible without making inert layout regions focusable.+## SVG Icons (Mandatory)- New custom SVG icons must be added under `../packages/iconify-collections/assets/...`.@@ -38,15 +46,6 @@- Keep storage keys and raw/custom formats in the owner module; callers should import the named storage hooks instead of scattering direct storage access.- Do not add ad hoc global event listeners for shared state. Prefer atoms, existing stores, or a shared subscription hook so listeners are centralized and deduplicated.-## Agent V2 Frontend--- Keep Agent V2 separate from legacy workflow Agent. Use `web/features/agent-v2`, `web/app/components/workflow/nodes/agent-v2`, the `agent_node_kind: 'dify_agent'` and `version: '2'` payload discriminator, and `BlockEnum.AgentV2` where the graph type is already migrated. Do not bridge Agent V2 to legacy `agent_strategy_*` behavior or data shapes.-- Use generated contracts and `consoleQuery` / `consoleClient` from `@/service/client` for Agent V2 backend calls. Do not add handwritten REST helpers, handwritten API types, mock-backed app state, or direct edits to generated contract files.-- Treat TanStack Query as the server source of truth. Scope editable drafts with an instance-level `AgentComposerProvider`, hydrate Jotai `originalDraft`, `publishedDraft`, and `draft` from contract data, and compute dirty or unpublished state from those draft snapshots.-- Keep transitional defaults and mock data at the owning surface, such as the configure page or workflow node, not in shared composer defaults.-- Use `@langgenius/dify-ui/*` primitives and primitive data/CSS selectors first. Add call-site Tailwind only for real design deltas, avoid arbitrary values when token utilities exist, and keep focus rings visible without making inert layout regions focusable.-- Keep Agent V2 copy in the `agentV2` i18n namespace, currently backed by `agent-v-2.json` in the maintained locale set.-## Automated Test Generation- Use `./docs/test.md` as the canonical instruction set for generating frontend automated tests.diff --git a/web/app/(shareLayout)/agent/[token]/page.tsx b/web/app/(shareLayout)/agent/[token]/page.tsxindex 5dc2777c9c4..d46ebf0ba56 100644--- a/web/app/(shareLayout)/agent/[token]/page.tsx+++ b/web/app/(shareLayout)/agent/[token]/page.tsx@@ -2,12 +2,13 @@import * as React from 'react'import ChatWithHistoryWrap from '@/app/components/base/chat/chat-with-history'+import { AgentRosterResponseContent } from '@/app/components/base/chat/chat/answer/agent-roster-response-content'import AuthenticatedLayout from '../../components/authenticated-layout'function Agent() {return (<AuthenticatedLayout>- <ChatWithHistoryWrap />+ <ChatWithHistoryWrap isNewAgent renderAgentContent={AgentRosterResponseContent} /></AuthenticatedLayout>)}diff --git a/web/app/components/app/configuration/__tests__/configuration-view.spec.tsx b/web/app/components/app/configuration/__tests__/configuration-view.spec.tsxindex 459df5d0638..c185fe2bd40 100644--- a/web/app/components/app/configuration/__tests__/configuration-view.spec.tsx+++ b/web/app/components/app/configuration/__tests__/configuration-view.spec.tsx@@ -7,6 +7,12 @@ import * as React from 'react'import { AppModeEnum, ModelModeType } from '@/types/app'import ConfigurationView from '../configuration-view'+const mockIsAgentV2Enabled = vi.hoisted(() => vi.fn(() => false))++vi.mock('@/features/agent-v2/feature-flag', () => ({+ isAgentV2Enabled: () => mockIsAgentV2Enabled(),+}))+vi.mock('@/app/components/app/app-publisher/features-wrapper', () => ({default: () => <div data-testid="app-publisher" />,}))@@ -254,6 +260,7 @@ const createViewModel = (overrides: Partial<ConfigurationViewModel> = {}): Confidescribe('ConfigurationView', () => {beforeEach(() => {vi.clearAllMocks()+ mockIsAgentV2Enabled.mockReturnValue(false)})it('should render a loading state before configuration data is ready', () => {@@ -280,4 +287,31 @@ describe('ConfigurationView', () => {expect(setShowUseGPT4Confirm).toHaveBeenCalledWith(false)})++ it('should show the legacy Agent badge for legacy Agent apps when Agent v2 is enabled', async () => {+ mockIsAgentV2Enabled.mockReturnValue(true)+ const contextValue = createContextValue()+ contextValue.mode = AppModeEnum.AGENT_CHAT++ render(<ConfigurationView {...createViewModel({ contextValue })} />)++ const badge = screen.getByRole('button', { name: 'appDebug.legacyAgentBadge.description' })+ expect(badge).toHaveTextContent('appDebug.legacyAgentBadge.label')++ fireEvent.click(badge)++ expect(await screen.findByText('appDebug.legacyAgentBadge.description')).toBeInTheDocument()+ expect(screen.getByRole('link', { name: /appDebug\.legacyAgentBadge\.action/ })).toHaveAttribute('href', '/roster')+ expect(screen.getByRole('link', { name: /appDebug\.legacyAgentBadge\.action/ })).toHaveAttribute('target', '_blank')+ expect(screen.getByRole('link', { name: /appDebug\.legacyAgentBadge\.action/ })).toHaveAttribute('rel', 'noopener noreferrer')+ })++ it('should not show the legacy Agent badge when Agent v2 is disabled', () => {+ const contextValue = createContextValue()+ contextValue.mode = AppModeEnum.AGENT_CHAT++ render(<ConfigurationView {...createViewModel({ contextValue })} />)++ expect(screen.queryByText('appDebug.legacyAgentBadge.label')).not.toBeInTheDocument()+ })})diff --git a/web/app/components/app/configuration/configuration-view.tsx b/web/app/components/app/configuration/configuration-view.tsxindex 90f2d429720..b100b90f190 100644--- a/web/app/components/app/configuration/configuration-view.tsx+++ b/web/app/components/app/configuration/configuration-view.tsx@@ -21,6 +21,11 @@ import {DrawerPortal,DrawerViewport,} from '@langgenius/dify-ui/drawer'+import {+ Popover,+ PopoverContent,+ PopoverTrigger,+} from '@langgenius/dify-ui/popover'import * as React from 'react'import { useTranslation } from 'react-i18next'import AppPublisher from '@/app/components/app/app-publisher/features-wrapper'@@ -37,8 +42,47 @@ import ModelParameterModal from '@/app/components/header/account-setting/model-pimport PluginDependency from '@/app/components/workflow/plugin-dependency'import ConfigContext from '@/context/debug-configuration'import { MittProvider } from '@/context/mitt-context-provider'+import { isAgentV2Enabled } from '@/features/agent-v2/feature-flag'+import Link from '@/next/link'import { AppModeEnum, ModelModeType } from '@/types/app'+function LegacyAgentBadge() {+ const { t } = useTranslation()+ const description = t('legacyAgentBadge.description', { ns: 'appDebug' })++ return (+ <Popover>+ <PopoverTrigger+ openOnHover+ delay={300}+ closeDelay={200}+ type="button"+ aria-label={description}+ className="inline-flex h-5 shrink-0 cursor-pointer items-center gap-0.5 rounded-[5px] border border-text-warning bg-components-badge-bg-dimm px-1.25 system-2xs-medium-uppercase whitespace-nowrap text-text-warning outline-hidden hover:bg-state-warning-hover focus-visible:ring-2 focus-visible:ring-state-accent-solid"+ >+ <span aria-hidden className="i-ri-alert-fill size-3 shrink-0" />+ {t('legacyAgentBadge.label', { ns: 'appDebug' })}+ </PopoverTrigger>+ <PopoverContent+ placement="bottom-start"+ sideOffset={6}+ popupClassName="max-w-[300px] px-3 py-2 system-xs-regular text-text-tertiary"+ >+ <div>{description}</div>+ <Link+ href="/roster"+ target="_blank"+ rel="noopener noreferrer"+ className="mt-1 inline-flex items-center gap-0.5 rounded-md system-xs-medium text-text-accent outline-hidden hover:underline focus-visible:ring-2 focus-visible:ring-state-accent-solid"+ >+ <span>{t('legacyAgentBadge.action', { ns: 'appDebug' })}</span>+ <span aria-hidden className="i-ri-arrow-right-up-line size-3.5" />+ </Link>+ </PopoverContent>+ </Popover>+ )+}+const ConfigurationView: FC<ConfigurationViewModel> = ({appPublisherProps,contextValue,@@ -76,6 +120,7 @@ const ConfigurationView: FC<ConfigurationViewModel> = ({}) => {const { t } = useTranslation()const debugWithMultipleModel = appPublisherProps.debugWithMultipleModel+ const showLegacyAgentBadge = isAgentV2Enabled() && contextValue.mode === AppModeEnum.AGENT_CHATif (showLoading) {return (@@ -93,15 +138,14 @@ const ConfigurationView: FC<ConfigurationViewModel> = ({<div className="relative flex h-[200px] grow pt-14"><div className="bg-default-subtle absolute top-0 left-0 h-14 w-full"><div className="flex h-14 items-center justify-between px-6">- <div className="flex items-center">+ <div className="flex items-center gap-2"><div className="system-xl-semibold text-text-primary">{t('orchestrate', { ns: 'appDebug' })}</div>- <div className="flex h-[14px] items-center space-x-1 text-xs">- {isAdvancedMode && (- <div className="ml-1 flex h-5 items-center rounded-md border border-components-button-secondary-border px-1.5 system-xs-medium-uppercase text-text-tertiary uppercase">- {t('promptMode.advanced', { ns: 'appDebug' })}- </div>- )}- </div>+ {showLegacyAgentBadge && <LegacyAgentBadge />}+ {isAdvancedMode && (+ <div className="flex h-5 items-center rounded-md border border-components-button-secondary-border px-1.5 system-xs-medium-uppercase text-text-tertiary uppercase">+ {t('promptMode.advanced', { ns: 'appDebug' })}+ </div>+ )}</div><div className="flex items-center">{isAgent && (diff --git a/web/app/components/app/overview/settings/index.tsx b/web/app/components/app/overview/settings/index.tsxindex e621a5aaacd..1a1a3a1a0cf 100644--- a/web/app/components/app/overview/settings/index.tsx+++ b/web/app/components/app/overview/settings/index.tsx@@ -57,6 +57,12 @@ type SettingsSiteInfo = Pick<| 'use_icon_as_answer_icon'>+type SettingsAppIconSelection = AppIconSelection | {+ type: 'link'+ icon: string+ url: string+}+export type SettingsAppInfo = {id: stringmode: AppModeEnum@@ -128,12 +134,16 @@ const createInputInfo = (appInfo: ISettingsModalProps['appInfo']) => {}}-const createAppIcon = (appInfo: ISettingsModalProps['appInfo']): AppIconSelection => {+const createAppIcon = (appInfo: ISettingsModalProps['appInfo']): SettingsAppIconSelection => {const { icon_type, icon, icon_background, icon_url } = appInfo.site- return icon_type === 'image'- ? { type: 'image', url: icon_url!, fileId: icon }- : { type: 'emoji', icon, background: icon_background! }+ if (icon_type === 'image')+ return { type: 'image', url: icon_url!, fileId: icon }++ if (icon_type === 'link')+ return { type: 'link', icon, url: icon }++ return { type: 'emoji', icon, background: icon_background! }}const getSettingsResetKey = (appInfo: ISettingsModalProps['appInfo']) => JSON.stringify([@@ -175,7 +185,7 @@ const SettingsModal: FC<ISettingsModalProps> = ({const { t } = useTranslation()const [showAppIconPicker, setShowAppIconPicker] = useState(false)- const [appIcon, setAppIcon] = useState<AppIconSelection>(nextAppIcon)+ const [appIcon, setAppIcon] = useState<SettingsAppIconSelection>(nextAppIcon)const [previousIsShow, setPreviousIsShow] = useState(isShow)const [previousSettingsResetKey, setPreviousSettingsResetKey] = useState(settingsResetKey)@@ -302,7 +312,7 @@ const SettingsModal: FC<ISettingsModalProps> = ({? '': (inputInfo.inputPlaceholder ?? '').slice(0, INPUT_PLACEHOLDER_MAX_LENGTH),icon_type: appIcon.type,- icon: appIcon.type === 'emoji' ? appIcon.icon : appIcon.fileId,+ icon: appIcon.type === 'image' ? appIcon.fileId : appIcon.icon,icon_background: appIcon.type === 'emoji' ? appIcon.background : undefined,show_workflow_steps: inputInfo.show_workflow_steps,use_icon_as_answer_icon: inputInfo.use_icon_as_answer_icon,@@ -366,10 +376,10 @@ const SettingsModal: FC<ISettingsModalProps> = ({size="xxl"onClick={() => { setShowAppIconPicker(true) }}className="mt-2 cursor-pointer"- iconType={appIcon.type}+ iconType={appIcon.type === 'link' ? 'image' : appIcon.type}icon={appIcon.type === 'image' ? appIcon.fileId : appIcon.icon}- background={appIcon.type === 'image' ? undefined : appIcon.background}- imageUrl={appIcon.type === 'image' ? appIcon.url : undefined}+ background={appIcon.type === 'emoji' ? appIcon.background : undefined}+ imageUrl={appIcon.type === 'emoji' ? undefined : appIcon.url}/></div>{/* description */}diff --git a/web/app/components/base/chat/chat-with-history/__tests__/chat-wrapper.spec.tsx b/web/app/components/base/chat/chat-with-history/__tests__/chat-wrapper.spec.tsxindex be62a5a2115..c8752a7a6e7 100644--- a/web/app/components/base/chat/chat-with-history/__tests__/chat-wrapper.spec.tsx+++ b/web/app/components/base/chat/chat-with-history/__tests__/chat-wrapper.spec.tsx@@ -6,6 +6,7 @@ import type { HumanInputFormData } from '@/types/workflow'import { fireEvent, render, screen, waitFor } from '@testing-library/react'import { InputVarType } from '@/app/components/workflow/types'import {+ fetchChatList,fetchSuggestedQuestions,stopChatMessageResponding,submitHumanInputForm,@@ -42,6 +43,7 @@ vi.mock('../../utils', () => ({}))vi.mock('@/service/share', () => ({+ fetchChatList: vi.fn(),fetchSuggestedQuestions: vi.fn(),getUrl: vi.fn(() => 'mock-url'),stopChatMessageResponding: vi.fn(),@@ -663,6 +665,55 @@ describe('ChatWrapper', () => {expect(fetchSuggestedQuestions).toHaveBeenCalledWith('response-id', 'webApp', 'test-app-id')})+ it('should fetch current conversation messages after new agent send completes', async () => {+ const handleSend = vi.fn()+ vi.mocked(fetchChatList).mockResolvedValue({ data: [] })+ vi.mocked(useChat).mockReturnValue({+ ...defaultChatHookReturn,+ handleSend,+ chatList: [{ id: '1', isOpeningStatement: true, content: 'Welcome', suggestedQuestions: ['Q1'] }],+ suggestedQuestions: ['Q1'],+ } as unknown as ChatHookReturn)++ vi.mocked(useChatWithHistoryContext).mockReturnValue({+ ...defaultContextValue,+ currentConversationId: '',+ isNewAgent: true,+ })++ render(<ChatWrapper />)++ fireEvent.click(await screen.findByText('Q1'))++ const options = handleSend.mock.calls[0]![2]+ await options.onGetConversationMessages('conversation-1')++ expect(fetchChatList).toHaveBeenCalledWith('conversation-1', 'webApp', 'test-app-id')+ })++ it('should not fetch current conversation messages for non-new-agent chat', async () => {+ const handleSend = vi.fn()+ vi.mocked(useChat).mockReturnValue({+ ...defaultChatHookReturn,+ handleSend,+ chatList: [{ id: '1', isOpeningStatement: true, content: 'Welcome', suggestedQuestions: ['Q1'] }],+ suggestedQuestions: ['Q1'],+ } as unknown as ChatHookReturn)++ vi.mocked(useChatWithHistoryContext).mockReturnValue({+ ...defaultContextValue,+ currentConversationId: '',+ isNewAgent: false,+ })++ render(<ChatWrapper />)++ fireEvent.click(await screen.findByText('Q1'))++ const options = handleSend.mock.calls[0]![2]+ expect(options.onGetConversationMessages).toBeUndefined()+ })+it('should call fetchSuggestedQuestions in doSwitchSibling', async () => {const handleSwitchSibling = vi.fn()vi.mocked(useChat).mockReturnValue({diff --git a/web/app/components/base/chat/chat-with-history/chat-wrapper.tsx b/web/app/components/base/chat/chat-with-history/chat-wrapper.tsxindex 966528c93f2..d9c8628fd4c 100644--- a/web/app/components/base/chat/chat-with-history/chat-wrapper.tsx+++ b/web/app/components/base/chat/chat-with-history/chat-wrapper.tsx@@ -18,6 +18,7 @@ import { Markdown } from '@/app/components/base/markdown'import { InputVarType } from '@/app/components/workflow/types'import {AppSourceType,+ fetchChatList,fetchSuggestedQuestions,getUrl,stopChatMessageResponding,@@ -57,6 +58,8 @@ const ChatWrapper = () => {setIsResponding,allInputsHidden,initUserVariables,+ isNewAgent,+ renderAgentContent,} = useChatWithHistoryContext()const appSourceType = isInstalledApp ? AppSourceType.installedApp : AppSourceType.webApp@@ -98,7 +101,7 @@ const ChatWrapper = () => {clearChatList,setClearChatList,undefined,- { timezone },+ { isNewAgent, timezone },)const inputsFormValue = currentConversationId ? currentConversationInputs : newConversationInputsRef?.currentconst inputDisabled = useMemo(() => {@@ -205,12 +208,15 @@ const ChatWrapper = () => {getUrl('chat-messages', appSourceType, appId || ''),data,{+ onGetConversationMessages: isNewAgent+ ? conversationId => fetchChatList(conversationId, appSourceType, appId)+ : undefined,onGetSuggestedQuestions: responseItemId => fetchSuggestedQuestions(responseItemId, appSourceType, appId),onConversationComplete: isHistoryConversation ? undefined : handleNewConversationCompleted,isPublicAPI: appSourceType === AppSourceType.webApp,},)- }, [inputsForms, currentConversationId, currentConversationInputs, newConversationInputs, chatList, handleSend, appSourceType, appId, isHistoryConversation, handleNewConversationCompleted])+ }, [inputsForms, currentConversationId, currentConversationInputs, newConversationInputs, chatList, handleSend, appSourceType, appId, isHistoryConversation, handleNewConversationCompleted, isNewAgent])const doRegenerate = useCallback((chatItem: ChatItem, editedQuestion?: { message: string, files?: FileEntity[] }) => {const question = editedQuestion ? chatItem : chatList.find(item => item.id === chatItem.parentMessageId)!@@ -418,6 +424,7 @@ const ChatWrapper = () => {switchSibling={doSwitchSibling}inputDisabled={inputDisabled}sidebarCollapseState={sidebarCollapseState}+ renderAgentContent={renderAgentContent}questionIcon={initUserVariables?.avatar_url? (diff --git a/web/app/components/base/chat/chat-with-history/context.ts b/web/app/components/base/chat/chat-with-history/context.tsindex 49dd06ca527..c27b23553bf 100644--- a/web/app/components/base/chat/chat-with-history/context.ts+++ b/web/app/components/base/chat/chat-with-history/context.ts@@ -1,6 +1,7 @@'use client'import type { RefObject } from 'react'+import type { ChatProps } from '../chat'import type { ThemeBuilder } from '../embedded-chatbot/theme/theme-context'import type {Callback,@@ -60,6 +61,8 @@ export type ChatWithHistoryContextValue = {name?: stringavatar_url?: string}+ isNewAgent?: boolean+ renderAgentContent?: ChatProps['renderAgentContent']}export const ChatWithHistoryContext = createContext<ChatWithHistoryContextValue>({@@ -95,5 +98,6 @@ export const ChatWithHistoryContext = createContext<ChatWithHistoryContextValue>setCurrentConversationInputs: noop,allInputsHidden: false,initUserVariables: {},+ isNewAgent: false,})export const useChatWithHistoryContext = () => useContext(ChatWithHistoryContext)diff --git a/web/app/components/base/chat/chat-with-history/index.tsx b/web/app/components/base/chat/chat-with-history/index.tsxindex 41cdeaa9193..9e003889c5a 100644--- a/web/app/components/base/chat/chat-with-history/index.tsx+++ b/web/app/components/base/chat/chat-with-history/index.tsx@@ -1,5 +1,6 @@'use client'import type { FC } from 'react'+import type { ChatProps } from '../chat'import type { InstalledApp } from '@/models/explore'import { cn } from '@langgenius/dify-ui/cn'import {@@ -100,10 +101,14 @@ const ChatWithHistory: FC<ChatWithHistoryProps> = ({type ChatWithHistoryWrapProps = {installedAppInfo?: InstalledAppclassName?: string+ isNewAgent?: boolean+ renderAgentContent?: ChatProps['renderAgentContent']}const ChatWithHistoryWrap: FC<ChatWithHistoryWrapProps> = ({installedAppInfo,className,+ isNewAgent = false,+ renderAgentContent,}) => {const media = useBreakpoints()const isMobile = media === MediaType.mobile@@ -190,6 +195,8 @@ const ChatWithHistoryWrap: FC<ChatWithHistoryWrapProps> = ({setCurrentConversationInputs,allInputsHidden,initUserVariables,+ isNewAgent,+ renderAgentContent,}}><ChatWithHistory className={className} />@@ -200,11 +207,15 @@ const ChatWithHistoryWrap: FC<ChatWithHistoryWrapProps> = ({const ChatWithHistoryWrapWithCheckToken: FC<ChatWithHistoryWrapProps> = ({installedAppInfo,className,+ isNewAgent,+ renderAgentContent,}) => {return (<ChatWithHistoryWrapinstalledAppInfo={installedAppInfo}className={className}+ isNewAgent={isNewAgent}+ renderAgentContent={renderAgentContent}/>)}diff --git a/web/app/components/base/chat/chat/__tests__/hooks.spec.tsx b/web/app/components/base/chat/chat/__tests__/hooks.spec.tsxindex ebcb6a1d1eb..f1a2e34c6c4 100644--- a/web/app/components/base/chat/chat/__tests__/hooks.spec.tsx+++ b/web/app/components/base/chat/chat/__tests__/hooks.spec.tsx@@ -444,7 +444,7 @@ describe('useChat', () => {// onThoughtcallbacks.onThought({ id: 'th-1', message_id: 'm-2', thought: 'thinking...', message_files: [] })- // onData (for agent mode, appends to thought)+ // onData appends to answer content, not agent thought.callbacks.onData(' detailed', false, { messageId: 'm-2' })// onThought (update same thought)@@ -476,7 +476,7 @@ describe('useChat', () => {const lastResponse = result.current.chatList[1]expect(lastResponse!.agent_thoughts).toHaveLength(2)- expect(lastResponse!.agent_thoughts![0]!.thought).toContain('thinking...')+ expect(lastResponse!.agent_thoughts![0]!.thought).toBe('thinking... detailed updated')expect(lastResponse!.agent_thoughts![1]!.thought).toContain('second thought')expect(lastResponse!.workflowProcess?.tracing).toHaveLength(3) // node, iteration, loop})@@ -1094,7 +1094,7 @@ describe('useChat', () => {})const lastResponse = result.current.chatList[result.current.chatList.length - 1]- expect(lastResponse!.agent_thoughts![0]!.thought).toContain('resumed')+ expect(lastResponse!.agent_thoughts![0]!.thought).toBe('thinking updated')expect(lastResponse!.workflowProcess?.tracing?.length).toBeGreaterThan(0)expect(lastResponse!.workflowProcess?.status).toBe('paused')@@ -1897,6 +1897,137 @@ describe('useChat', () => {expect(lastResponse!.more?.tokens_per_second).toBeUndefined()})+ it('should handle completed conversation history when message log is missing', async () => {+ let callbacks: HookCallbacks+ vi.mocked(ssePost).mockImplementation(async (_url, _params, options) => {+ callbacks = options as HookCallbacks+ })++ const onGetConversationMessages = vi.fn().mockResolvedValue({+ data: [{+ id: 'm-without-log',+ answer: 'final answer',+ agent_thoughts: [],+ created_at: Date.now(),+ inputs: {},+ query: 'hi',+ }],+ })++ const { result } = renderHook(() => useChat())+ act(() => {+ result.current.handleSend('test-url', { query: 'fetch test missing log' }, {+ onGetConversationMessages,+ })+ })++ await act(async () => {+ callbacks.onData(' data', true, { messageId: 'm-without-log', conversationId: 'c-without-log' })+ await callbacks.onCompleted()+ })++ const lastResponse = result.current.chatList[1]+ expect(lastResponse!.content).toBe('final answer')+ expect(lastResponse!.log).toEqual([{+ role: 'assistant',+ text: 'final answer',+ files: [],+ }])+ expect(lastResponse!.more?.tokens).toBe(0)+ expect(lastResponse!.more?.latency).toBe('0.00')+ expect(lastResponse!.more?.tokens_per_second).toBeUndefined()+ })++ it('should replace new agent streaming response parts with completed conversation history', async () => {+ let callbacks: HookCallbacks+ vi.mocked(ssePost).mockImplementation(async (_url, _params, options) => {+ callbacks = options as HookCallbacks+ })++ const onGetConversationMessages = vi.fn().mockResolvedValue({+ data: [{+ id: 'm-new-agent-history',+ answer: 'history top-level answer',+ message: [{ role: 'user', text: 'hi' }],+ agent_thoughts: [+ {+ id: 'history-thought',+ thought: 'history thought',+ answer: 'history agent answer',+ tool: '',+ tool_input: '',+ observation: '',+ position: 1,+ },+ ],+ message_files: [{+ id: 'history-file',+ belongs_to: 'assistant',+ type: 'image',+ url: 'history.png',+ }],+ retriever_resources: [{ id: 'history-citation', content: 'history citation' }],+ metadata: { reasoning: { history: 'history reasoning' } },+ created_at: Date.now(),+ answer_tokens: 10,+ message_tokens: 5,+ provider_response_latency: 0.5,+ workflow_run_id: 'history-workflow-run',+ feedback: { rating: 'like' },+ inputs: {},+ query: 'hi',+ }],+ })++ const { result } = renderHook(() => useChat(+ undefined,+ undefined,+ undefined,+ undefined,+ undefined,+ undefined,+ undefined,+ { isNewAgent: true },+ ))++ act(() => {+ result.current.handleSend('test-url', { query: 'new agent history' }, {+ onGetConversationMessages,+ })+ })++ await act(async () => {+ callbacks.onWorkflowStarted({ workflow_run_id: 'stream-workflow-run', task_id: 'stream-task' })+ callbacks.onThought({ id: 'stream-thought', thought: 'stream thought' })+ callbacks.onData(' stream answer', true, { event: 'agent_message', messageId: 'm-new-agent-history', conversationId: 'c-new-agent-history' })+ callbacks.onReasoning({ data: { message_id: 'm-new-agent-history', node_id: 'stream', reasoning: 'stream reasoning' } })+ callbacks.onMessageEnd({+ id: 'm-new-agent-history',+ metadata: { retriever_resources: [{ id: 'stream-citation', content: 'stream citation' }] },+ files: [{ id: 'stream-file', type: 'image', url: 'stream.png' }],+ })+ await callbacks.onCompleted()+ })++ const lastResponse = result.current.chatList[1]+ expect(lastResponse!.content).toBe('')+ expect(lastResponse!.agent_response_parts).toBeUndefined()+ expect(lastResponse!.workflow_run_id).toBe('history-workflow-run')+ expect(lastResponse!.workflowProcess).toBeUndefined()+ expect(lastResponse!.citation).toEqual([{ id: 'history-citation', content: 'history citation' }])+ expect(lastResponse!.reasoningContent).toEqual({ history: 'history reasoning' })+ expect(lastResponse!.message_files).toEqual([expect.objectContaining({ id: 'history-file' })])+ expect(lastResponse!.allFiles).toBeUndefined()+ expect(lastResponse!.feedback).toEqual({ rating: 'like' })+ expect(lastResponse!.agent_thoughts).toEqual([+ expect.objectContaining({+ id: 'history-thought',+ thought: 'history thought',+ answer: 'history agent answer',+ }),+ ])+ })+it('should handle onCompleted using agent thought when thought matches answer', async () => {let callbacks: HookCallbacksvi.mocked(ssePost).mockImplementation(async (_url, _params, options) => {@@ -1977,7 +2108,7 @@ describe('useChat', () => {expect(lastResponse!.workflowProcess?.status).toBe('succeeded')})- it('should cover onThought creating tracing and appending message correctly when isAgentMode=true', () => {+ it('should append message chunks to agent thought by default after agent thoughts', () => {let callbacks: HookCallbacksvi.mocked(ssePost).mockImplementation(async (_url, _params, options) => {callbacks = options as HookCallbacks@@ -1994,14 +2125,56 @@ describe('useChat', () => {// onThought when array is implicitly emptycallbacks.onThought({ id: 'th-1', thought: 'initial thought' })- // onData which appends to last thought+ // onData comes from message/agent_message events and should render as answer content.callbacks.onData(' appended', false, { messageId: 'm-thought' })})const lastResponse = result.current.chatList[result.current.chatList.length - 1]+ expect(lastResponse!.content).toBe('')expect(lastResponse!.agent_thoughts).toHaveLength(1)expect(lastResponse!.agent_thoughts![0]!.thought).toBe('initial thought appended')})++ it('should preserve response part order for new agent when agent thoughts and messages interleave', () => {+ let callbacks: HookCallbacks+ vi.mocked(ssePost).mockImplementation(async (_url, _params, options) => {+ callbacks = options as HookCallbacks+ })++ const { result } = renderHook(() => useChat(+ undefined,+ undefined,+ undefined,+ undefined,+ undefined,+ undefined,+ undefined,+ { isNewAgent: true },+ ))+ act(() => {+ result.current.handleSend('url', { query: 'agent onThought' }, {})+ })++ act(() => {+ callbacks.onWorkflowStarted({ workflow_run_id: 'wr-1', task_id: 't-1' })+ callbacks.onThought({ id: 'th-1', thought: 'initial thought' })+ callbacks.onData(' first answer', false, { event: 'agent_message', messageId: 'm-thought' })+ callbacks.onData(' continued answer', false, { event: 'message', messageId: 'm-thought' })+ callbacks.onThought({ id: 'th-2', thought: 'second thought' })+ callbacks.onData(' second answer', false, { event: 'agent_message', messageId: 'm-thought' })+ })++ const lastResponse = result.current.chatList[result.current.chatList.length - 1]+ expect(lastResponse!.content).toBe('')+ expect(lastResponse!.agent_thoughts).toHaveLength(2)+ expect(lastResponse!.agent_thoughts![0]!.thought).toBe('initial thought')+ expect(lastResponse!.agent_response_parts).toEqual([+ { type: 'thought', thought: expect.objectContaining({ id: 'th-1', thought: 'initial thought' }) },+ { type: 'message', content: ' first answer continued answer' },+ { type: 'thought', thought: expect.objectContaining({ id: 'th-2', thought: 'second thought' }) },+ { type: 'message', content: ' second answer' },+ ])+ })})it('should cover produceChatTreeNode traversing deeply nested child nodes to find the target item', () => {diff --git a/web/app/components/base/chat/chat/answer/__tests__/agent-roster-response-content.spec.tsx b/web/app/components/base/chat/chat/answer/__tests__/agent-roster-response-content.spec.tsxnew file mode 100644index 00000000000..7b22218b895--- /dev/null+++ b/web/app/components/base/chat/chat/answer/__tests__/agent-roster-response-content.spec.tsx@@ -0,0 +1,111 @@+import type { ChatItem } from '../../../types'+import { render, screen, waitFor } from '@testing-library/react'+import { AgentRosterResponseContent } from '../agent-roster-response-content'++describe('AgentRosterResponseContent', () => {+ it('should render historical agent thought answer as markdown instead of thought process', async () => {+ const item = {+ id: 'answer-history',+ content: '',+ isAnswer: true,+ agent_thoughts: [+ {+ id: 'thought-with-answer',+ thought: 'internal thought should not render',+ answer: '**history answer**',+ tool: '',+ tool_input: '',+ observation: '',+ message_id: 'answer-history',+ conversation_id: 'conversation-history',+ position: 1,+ },+ ],+ } satisfies ChatItem++ render(<AgentRosterResponseContent item={item} />)++ await waitFor(() => {+ expect(screen.getByTestId('agent-roster-response-content')).toHaveTextContent('history answer')+ })++ expect(screen.queryByText('internal thought should not render')).not.toBeInTheDocument()+ })++ it('should render new agent response parts in event order when thoughts and messages interleave', async () => {+ const item = {+ id: 'answer-1',+ content: 'first answer second answer',+ isAnswer: true,+ agent_thoughts: [+ {+ id: 'thought-1',+ thought: 'first thought',+ tool: '',+ tool_input: '',+ observation: '',+ message_id: 'answer-1',+ conversation_id: 'conversation-1',+ position: 1,+ },+ {+ id: 'thought-2',+ thought: 'second thought',+ tool: '',+ tool_input: '',+ observation: '',+ message_id: 'answer-1',+ conversation_id: 'conversation-1',+ position: 2,+ },+ ],+ agent_response_parts: [+ {+ type: 'thought',+ thought: {+ id: 'thought-1',+ thought: 'first thought',+ tool: '',+ tool_input: '',+ observation: '',+ message_id: 'answer-1',+ conversation_id: 'conversation-1',+ position: 1,+ },+ },+ {+ type: 'message',+ content: 'first answer',+ },+ {+ type: 'thought',+ thought: {+ id: 'thought-2',+ thought: 'second thought',+ tool: '',+ tool_input: '',+ observation: '',+ message_id: 'answer-1',+ conversation_id: 'conversation-1',+ position: 2,+ },+ },+ {+ type: 'message',+ content: 'second answer',+ },+ ],+ } satisfies ChatItem++ render(<AgentRosterResponseContent item={item} responding />)++ await waitFor(() => {+ expect(screen.getByTestId('agent-roster-response-content')).toHaveTextContent('second answer')+ })++ const content = screen.getByTestId('agent-roster-response-content').textContent ?? ''+ expect(content.indexOf('first thought')).toBeLessThan(content.indexOf('first answer'))+ expect(content.indexOf('first answer')).toBeLessThan(content.indexOf('second thought'))+ expect(content.indexOf('second thought')).toBeLessThan(content.indexOf('second answer'))+ })+})diff --git a/web/app/components/base/chat/chat/answer/__tests__/index.spec.tsx b/web/app/components/base/chat/chat/answer/__tests__/index.spec.tsxindex d5951fdd807..1216c734100 100644--- a/web/app/components/base/chat/chat/answer/__tests__/index.spec.tsx+++ b/web/app/components/base/chat/chat/answer/__tests__/index.spec.tsx@@ -81,6 +81,23 @@ describe('Answer Component', () => {expect(container.querySelector('.group')).toBeInTheDocument()})+ it('should render custom agent content when only agent response parts exist', () => {+ render(+ <Answer+ {...defaultProps}+ item={{+ id: 'msg-with-parts',+ content: '',+ isAnswer: true,+ agent_response_parts: [{ type: 'message', content: 'streamed answer' }],+ } as ChatItem}+ renderAgentContent={() => <div data-testid="custom-agent-content">streamed answer</div>}+ />,+ )++ expect(screen.getByTestId('custom-agent-content')).toHaveTextContent('streamed answer')+ })+it('should render file lists', () => {render(<Answerdiff --git a/web/app/components/base/chat/chat/answer/agent-roster-response-content.tsx b/web/app/components/base/chat/chat/answer/agent-roster-response-content.tsxnew file mode 100644index 00000000000..c6203c2f21a--- /dev/null+++ b/web/app/components/base/chat/chat/answer/agent-roster-response-content.tsx@@ -0,0 +1,447 @@+import type { ReactNode } from 'react'+import type { ThoughtItem } from '@/app/components/base/chat/chat/type'+import type { ChatItem } from '@/app/components/base/chat/types'+import { cn } from '@langgenius/dify-ui/cn'+import { useEffect, useRef, useState } from 'react'+import { useTranslation } from 'react-i18next'+import { FileList } from '@/app/components/base/file-uploader'+import { Markdown } from '@/app/components/base/markdown'++type AgentRosterResponseContentProps = {+ item: ChatItem+ responding?: boolean+ content?: string+}++type ToolProcess = {+ name: string+ label: string+ input: string+ output: string+ isFinished: boolean+}++function readIndexedValue(value: string, isArray: boolean, index: number) {+ if (!isArray)+ return value++ try {+ const parsed = JSON.parse(value) as unknown+ return Array.isArray(parsed) ? String(parsed[index] ?? '') : value+ }+ catch {+ return value+ }+}++function getToolProcesses(thought: ThoughtItem, responding?: boolean): ToolProcess[] {+ let toolNames = [thought.tool]+ let isArray = false++ try {+ const parsed = JSON.parse(thought.tool) as unknown+ if (Array.isArray(parsed)) {+ toolNames = parsed.map(item => String(item))+ isArray = true+ }+ }+ catch {+ }++ return toolNames+ .filter(Boolean)+ .map((name, index) => ({+ name,+ label: thought.tool_labels?.toolName?.en_US ?? name,+ input: readIndexedValue(thought.tool_input, isArray, index),+ output: readIndexedValue(thought.observation, isArray, index),+ isFinished: !!thought.observation || !responding,+ }))+}++function formatDuration(seconds: number, t: ReturnType<typeof useTranslation<'agentV2'>>['t']) {+ const safeSeconds = Math.max(0, seconds)+ if (safeSeconds < 60)+ return t('agentDetail.configure.answer.duration.second', { count: Number(safeSeconds.toFixed(2)) })++ const minutes = Math.floor(safeSeconds / 60)+ const remainingSeconds = Math.floor(safeSeconds % 60)++ return [+ t('agentDetail.configure.answer.duration.minute', { count: minutes }),+ t('agentDetail.configure.answer.duration.second', { count: remainingSeconds }),+ ].join(' ')+}++function formatLatencyDuration(latency: NonNullable<ChatItem['more']>['latency'], t: ReturnType<typeof useTranslation<'agentV2'>>['t']) {+ const numericLatency = Number(latency)+ if (!Number.isNaN(numericLatency))+ return formatDuration(numericLatency, t)++ return String(latency)+}++function getCompletedTitle(latency: NonNullable<ChatItem['more']>['latency'] | undefined, t: ReturnType<typeof useTranslation<'agentV2'>>['t']) {+ const numericLatency = Number(latency)+ if (latency != null && !Number.isNaN(numericLatency) && numericLatency > 0) {+ return t('agentDetail.configure.answer.workedFor', {+ duration: formatLatencyDuration(latency, t),+ })+ }++ return t('agentDetail.configure.answer.workFinished')+}++function hasThoughtAnswer(thought: ThoughtItem) {+ return !!thought.answer?.trim()+}++function useWorkingDuration(enabled?: boolean) {+ const startedAtRef = useRef<number | null>(null)+ const [now, setNow] = useState(0)++ useEffect(() => {+ if (!enabled)+ return++ startedAtRef.current = Date.now()+ const timer = window.setInterval(() => {+ setNow(Date.now())+ }, 1000)++ return () => window.clearInterval(timer)+ }, [enabled])++ const elapsedSeconds = enabled && startedAtRef.current !== null+ ? Math.max(0, Math.floor((now - startedAtRef.current) / 1000))+ : 0++ return elapsedSeconds+}++function ProcessShell({+ children,+ collapsed,+ icon,+ title,+ defaultOpen = false,+}: {+ children?: ReactNode+ collapsed?: boolean+ icon: ReactNode+ title: ReactNode+ defaultOpen?: boolean+}) {+ const [open, setOpen] = useState(defaultOpen)+ const canExpand = !!children+ const expanded = canExpand && open && !collapsed++ return (+ <div className={cn(+ 'rounded-xl p-2',+ expanded ? 'bg-background-default' : 'bg-background-default-subtle',+ )}+ >+ <button+ type="button"+ className="flex w-full items-center gap-1 text-left"+ onClick={() => canExpand && setOpen(value => !value)}+ >+ <span className="flex size-5 shrink-0 items-center justify-center text-text-secondary">+ {icon}+ </span>+ <span className={cn(+ 'min-w-0 flex-1 truncate text-text-secondary',+ expanded ? 'system-xs-medium-uppercase' : 'system-sm-regular',+ )}+ >+ {title}+ </span>+ {canExpand && (+ expanded+ ? <span className="i-ri-arrow-down-s-line size-4 shrink-0 text-text-quaternary" aria-hidden />+ : <span className="i-ri-arrow-right-s-line size-4 shrink-0 text-text-quaternary" aria-hidden />+ )}+ </button>+ {expanded && (+ <div className="mt-1 flex gap-1">+ <div className="w-5 shrink-0 border-l border-divider-subtle" />+ <div className="min-w-0 flex-1 py-1 body-sm-regular text-text-tertiary">+ {children}+ </div>+ </div>+ )}+ </div>+ )+}++function ThoughtProcess({+ thought,+ defaultOpen,+}: {+ thought: ThoughtItem+ defaultOpen?: boolean+}) {+ const { t } = useTranslation()+ const summary = thought.thought.trim() || t('chat.thought', { ns: 'common' })++ return (+ <ProcessShell+ icon={<span className="i-ri-sparkling-2-line size-3.5" aria-hidden />}+ title={defaultOpen ? t('chat.thought', { ns: 'common' }) : summary}+ defaultOpen={defaultOpen}+ >+ <Markdown content={summary} />+ </ProcessShell>+ )+}++function ToolProcessCard({+ tool,+}: {+ tool: ToolProcess+}) {+ const { t } = useTranslation()+ const [open, setOpen] = useState(false)++ return (+ <div className="rounded-xl bg-background-default-subtle p-2">+ <button+ type="button"+ className="flex w-full items-center gap-1 text-left"+ onClick={() => setOpen(value => !value)}+ >+ <span className="flex size-5 shrink-0 items-center justify-center rounded-md border border-divider-subtle bg-components-icon-bg-midnight-solid p-[3px] text-text-primary-on-surface shadow-xs">+ {tool.isFinished+ ? <span className="i-ri-terminal-box-line size-3.5" aria-hidden />+ : <span className="i-ri-loader-2-line size-3.5 animate-spin" aria-hidden />}+ </span>+ <span className="min-w-0 flex-1 truncate system-sm-medium text-text-secondary">{tool.label}</span>+ {open+ ? <span className="i-ri-arrow-down-s-line size-4 shrink-0 text-text-quaternary" aria-hidden />+ : <span className="i-ri-arrow-right-s-line size-4 shrink-0 text-text-quaternary" aria-hidden />}+ </button>+ {open && (+ <div className="mt-2 space-y-1">+ <div className="rounded-[10px] bg-components-panel-on-panel-item-bg px-3 py-2">+ <div className="system-xs-semibold-uppercase text-text-tertiary">+ {t('thought.requestTitle', { ns: 'tools' })}+ </div>+ <div className="mt-1 code-xs-regular wrap-break-word text-text-secondary">{tool.input}</div>+ </div>+ <div className="rounded-[10px] bg-components-panel-on-panel-item-bg px-3 py-2">+ <div className="system-xs-semibold-uppercase text-text-tertiary">+ {t('thought.responseTitle', { ns: 'tools' })}+ </div>+ <div className="mt-1 code-xs-regular wrap-break-word text-text-secondary">{tool.output}</div>+ </div>+ </div>+ )}+ </div>+ )+}++function AgentThoughtsProcessList({+ item,+ responding,+}: {+ item: ChatItem+ responding?: boolean+}) {+ return (+ <div className="mt-2 flex flex-col gap-1">+ {item.agent_thoughts?.map((thought, index) => (+ <AgentThoughtProcessItem+ key={thought.id || `${thought.message_id}-${thought.position}`}+ thought={thought}+ responding={responding}+ defaultOpen={index === 0}+ />+ ))}+ </div>+ )+}++function AgentThoughtProcessItem({+ thought,+ responding,+ defaultOpen,+}: {+ thought: ThoughtItem+ responding?: boolean+ defaultOpen?: boolean+}) {+ const tools = getToolProcesses(thought, responding)+ const answer = thought.answer?.trim()++ return (+ <div className="flex flex-col gap-1">+ {answer && (+ <div className="px-2 py-2 body-md-regular text-text-primary" data-testid="agent-content-markdown">+ <Markdown content={thought.answer || ''} />+ </div>+ )}+ {!answer && thought.thought && (+ <ThoughtProcess+ thought={thought}+ defaultOpen={defaultOpen}+ />+ )}+ {tools.map(tool => (+ <ToolProcessCard+ key={`${thought.id}-${tool.name}`}+ tool={tool}+ />+ ))}+ {!!thought.message_files?.length && (+ <FileList+ className="px-2 py-1"+ files={thought.message_files}+ showDeleteAction={false}+ showDownloadAction+ canPreview+ />+ )}+ </div>+ )+}++function AgentResponsePartList({+ item,+ responding,+}: {+ item: ChatItem+ responding?: boolean+}) {+ return (+ <div className="flex flex-col gap-1">+ {item.agent_response_parts?.map((part, index) => {+ if (part.type === 'message') {+ if (!part.content)+ return null++ return (+ <div key={`message-${index}`} className="px-2 py-2 body-md-regular text-text-primary" data-testid="agent-content-markdown">+ <Markdown content={part.content} />+ </div>+ )+ }++ return (+ <AgentThoughtProcessItem+ key={part.thought.id || `${part.thought.message_id}-${part.thought.position}-${index}`}+ thought={part.thought}+ responding={responding}+ defaultOpen={index === 0}+ />+ )+ })}+ </div>+ )+}++function AgentThoughtsProcessGroup({+ item,+ responding,+}: {+ item: ChatItem+ responding?: boolean+}) {+ const { t } = useTranslation('agentV2')+ const [open, setOpen] = useState(false)+ const workingDuration = formatDuration(useWorkingDuration(responding), t)+ const completedTitle = getCompletedTitle(item.more?.latency, t)++ if (responding) {+ return (+ <div className="flex flex-col">+ <div className="flex h-9 w-full items-center border-b border-divider-subtle text-left">+ <span className="system-md-regular text-text-tertiary">+ {t('agentDetail.configure.answer.workingFor', { duration: workingDuration })}+ </span>+ </div>+ <AgentThoughtsProcessList+ item={item}+ responding={responding}+ />+ </div>+ )+ }++ return (+ <div className="flex flex-col">+ <button+ type="button"+ className="flex h-9 w-full items-center gap-1 border-b border-divider-subtle text-left"+ aria-expanded={open}+ onClick={() => setOpen(value => !value)}+ >+ <span className="system-md-regular text-text-tertiary">+ {completedTitle}+ </span>+ {open+ ? <span className="i-ri-arrow-down-s-line size-4 text-text-tertiary" aria-hidden />+ : <span className="i-ri-arrow-right-s-line size-4 text-text-tertiary" aria-hidden />}+ </button>+ {open && (+ <AgentThoughtsProcessList+ item={item}+ responding={responding}+ />+ )}+ </div>+ )+}++export function AgentRosterResponseContent({+ item,+ responding,+ content,+}: AgentRosterResponseContentProps) {+ const {+ annotation,+ agent_thoughts,+ } = item+ const hasAgentThoughtAnswer = agent_thoughts?.some(hasThoughtAnswer)++ if (annotation?.logAnnotation) {+ return (+ <Markdown+ content={annotation.logAnnotation.content || ''}+ data-testid="agent-content-markdown"+ />+ )+ }++ return (+ <div className="flex w-full flex-col gap-1" data-testid="agent-roster-response-content">+ {!!item.agent_response_parts?.length && (+ <AgentResponsePartList+ item={item}+ responding={responding}+ />+ )}+ {!item.agent_response_parts?.length && (+ <>+ {!!agent_thoughts?.length && hasAgentThoughtAnswer && (+ <AgentThoughtsProcessList+ item={item}+ responding={responding}+ />+ )}+ {!!agent_thoughts?.length && !hasAgentThoughtAnswer && (+ <AgentThoughtsProcessGroup+ item={item}+ responding={responding}+ />+ )}+ {content && (+ <div className="px-2 py-2 body-md-regular text-text-primary" data-testid="agent-content-markdown">+ <Markdown content={content} />+ </div>+ )}+ </>+ )}+ </div>+ )+}diff --git a/web/app/components/base/chat/chat/answer/index.tsx b/web/app/components/base/chat/chat/answer/index.tsxindex e46f80369a3..850506bcf29 100644--- a/web/app/components/base/chat/chat/answer/index.tsx+++ b/web/app/components/base/chat/chat/answer/index.tsx@@ -42,6 +42,11 @@ type AnswerProps = {noChatInput?: booleanswitchSibling?: (siblingMessageId: string) => voidhideAvatar?: boolean+ renderAgentContent?: (props: {+ item: ChatItem+ responding?: boolean+ content?: string+ }) => ReactNodeonHumanInputFormSubmit?: (formToken: string, formData: HumanInputFormSubmitData) => Promise<void>}const Answer: FC<AnswerProps> = ({@@ -58,6 +63,7 @@ const Answer: FC<AnswerProps> = ({noChatInput,switchSibling,hideAvatar,+ renderAgentContent,onHumanInputFormSubmit,}) => {const { t } = useTranslation()@@ -74,6 +80,8 @@ const Answer: FC<AnswerProps> = ({humanInputFilledFormDataList,} = itemconst hasAgentThoughts = !!agent_thoughts?.length+ const hasAgentResponseParts = !!item.agent_response_parts?.length+ const hasAgentContent = hasAgentThoughts || hasAgentResponsePartsconst hasHumanInputs = !!humanInputFormDataList?.length || !!humanInputFilledFormDataList?.length// Truthy only when there is real reasoning text. Rehydrated messages carry an empty// `{}` (the field is always persisted), and `!!{}` would otherwise be truthy.@@ -144,6 +152,15 @@ const Answer: FC<AnswerProps> = ({}, [switchSibling, item.prevSibling, item.nextSibling])const contentIsEmpty = typeof content === 'string' && content.trim() === ''+ const agentContentNode = renderAgentContent+ ? renderAgentContent({ item, responding, content })+ : (+ <AgentContent+ item={item}+ responding={responding}+ content={content}+ />+ )// Reasoning is "done" — freeze the elapsed timer and collapse the panel — as soon as ANY of:// ① the answer has begun streaming (first text delta): the only signal that fires// mid-node, so it drives the normal think→answer handoff;@@ -175,7 +192,7 @@ const Answer: FC<AnswerProps> = ({className={cn('relative inline-block w-full max-w-full rounded-2xl bg-chat-bubble-bg px-4 py-3 body-lg-regular text-text-primary')}>{- !responding && contentIsEmpty && !hasAgentThoughts && (+ !responding && contentIsEmpty && !hasAgentContent && (<OperationhasWorkflowProcess={!!workflowProcess}maxSize={containerWidth - humanInputFormContainerWidth - 4}@@ -220,7 +237,7 @@ const Answer: FC<AnswerProps> = ({&& item.siblingCount > 1&& !responding&& contentIsEmpty- && !hasAgentThoughts+ && !hasAgentContent&& (<ContentSwitchcount={item.siblingCount}@@ -236,7 +253,7 @@ const Answer: FC<AnswerProps> = ({)}{/* Block 2: Response Content (when human inputs exist) */}- {hasHumanInputs && (responding || !contentIsEmpty || hasAgentThoughts || hasReasoning) && (+ {hasHumanInputs && (responding || !contentIsEmpty || hasAgentContent || hasReasoning) && (<div className={cn('group relative mt-2 pr-10', chatAnswerContainerInner)}><div className="absolute -top-2 left-6 h-3 w-0.5 bg-chat-answer-human-input-form-divider-bg" /><div@@ -266,24 +283,20 @@ const Answer: FC<AnswerProps> = ({)}{- responding && contentIsEmpty && !hasAgentThoughts && !hasReasoning && (+ responding && contentIsEmpty && !hasAgentContent && !hasReasoning && (<div className="flex h-5 w-6 items-center justify-center"><LoadingAnim type="text" /></div>)}{- !contentIsEmpty && !hasAgentThoughts && (+ !contentIsEmpty && !hasAgentContent && (<BasicContent item={item} />)}{- hasAgentThoughts && (- <AgentContent- item={item}- responding={responding}- content={content}- />+ hasAgentContent && (+ agentContentNode)}{@@ -380,24 +393,20 @@ const Answer: FC<AnswerProps> = ({)}{- responding && contentIsEmpty && !hasAgentThoughts && !hasReasoning && (+ responding && contentIsEmpty && !hasAgentContent && !hasReasoning && (<div className="flex h-5 w-6 items-center justify-center"><LoadingAnim type="text" /></div>)}{- !contentIsEmpty && !hasAgentThoughts && (+ !contentIsEmpty && !hasAgentContent && (<BasicContent item={item} />)}{- hasAgentThoughts && (- <AgentContent- item={item}- responding={responding}- content={content}- />+ hasAgentContent && (+ agentContentNode)}{diff --git a/web/app/components/base/chat/chat/chat-input-area/index.tsx b/web/app/components/base/chat/chat/chat-input-area/index.tsxindex 8f3119b32d6..e79368a61bd 100644--- a/web/app/components/base/chat/chat/chat-input-area/index.tsx+++ b/web/app/components/base/chat/chat/chat-input-area/index.tsx@@ -49,6 +49,7 @@ type ChatInputAreaProps = {sendButtonLoading?: booleanfooterNotice?: ReactNodefooterNoticeTooltip?: ReactNode+ autoFocus?: boolean/*** Controls whether pressing Enter sends the message.* - true (default): Enter sends, Shift+Enter inserts newline@@ -57,7 +58,7 @@ type ChatInputAreaProps = {*/sendOnEnter?: boolean}-const ChatInputArea = ({ readonly, botName, customPlaceholder, showFeatureBar, showFileUpload, featureBarReadonly = readonly, featureBarDisabled, onFeatureBarClick, visionConfig, speechToTextConfig = { enabled: true }, onSend, inputs = {}, inputsForm = [], theme, isResponding, disabled, sendButtonLabel, sendButtonLoading, footerNotice, footerNoticeTooltip, sendOnEnter = true }: ChatInputAreaProps) => {+const ChatInputArea = ({ readonly, botName, customPlaceholder, showFeatureBar, showFileUpload, featureBarReadonly = readonly, featureBarDisabled, onFeatureBarClick, visionConfig, speechToTextConfig = { enabled: true }, onSend, inputs = {}, inputsForm = [], theme, isResponding, disabled, sendButtonLabel, sendButtonLoading, footerNotice, footerNoticeTooltip, autoFocus = true, sendOnEnter = true }: ChatInputAreaProps) => {const { t } = useTranslation()const { wrapperRef, textareaRef, textValueRef, holdSpaceRef, handleTextareaResize, isMultipleLine } = useTextAreaHeight()const [query, setQuery] = useState('')@@ -187,7 +188,7 @@ const ChatInputArea = ({ readonly, botName, customPlaceholder, showFeatureBar, splaceholder={!readonly && customPlaceholder?.trim() ? customPlaceholder : decode(t(readonly ? 'chat.inputDisabledPlaceholder' : 'chat.inputPlaceholder', { ns: 'common', botName }) || '')}// Existing chat behavior focuses the composer as soon as it opens.// eslint-disable-next-line jsx-a11y/no-autofocus- autoFocus+ autoFocus={autoFocus}minRows={1}value={query}onChange={e => handleQueryChange(e.target.value)}diff --git a/web/app/components/base/chat/chat/hooks.ts b/web/app/components/base/chat/chat/hooks.tsindex df1a1619042..612f977d38b 100644--- a/web/app/components/base/chat/chat/hooks.ts+++ b/web/app/components/base/chat/chat/hooks.ts@@ -4,7 +4,7 @@ import type {ChatItemInTree,Inputs,} from '../types'-import type { InputForm } from './type'+import type { InputForm, ThoughtItem } from './type'import type AudioPlayer from '@/app/components/base/audio-btn/audio'import type { FileEntity } from '@/app/components/base/file-uploader/types'import type { Annotation } from '@/models/log'@@ -12,7 +12,8 @@ import type {IOnDataMoreInfo,IOtherOptions,} from '@/service/base'-import type { ReasoningChunkResponse } from '@/types/workflow'+import type { VisionFile } from '@/types/app'+import type { FileResponse, ReasoningChunkResponse } from '@/types/workflow'import { toast } from '@langgenius/dify-ui/toast'import { uniqBy } from 'es-toolkit/compat'import { noop } from 'es-toolkit/function'@@ -33,6 +34,7 @@ import {getProcessedFilesFromResponse,} from '@/app/components/base/file-uploader/utils'import { isInstalledAppPath } from '@/app/components/explore/installed-app/routes'+import { addFileInfos, sortAgentSorts } from '@/app/components/tools/utils'import { NodeRunningStatus, WorkflowRunningStatus } from '@/app/components/workflow/types'import useTimestamp from '@/hooks/use-timestamp'import { useParams, usePathname } from '@/next/navigation'@@ -48,9 +50,35 @@ import {} from './utils'type GetAbortController = (abortController: AbortController) => void+type HistoryMessageFile = Partial<FileResponse> & {+ id?: string+ belongs_to?: string+}+type HistoryConversationMessage = {+ id: string+ answer?: string+ message?: { role: string, text: string, files?: FileEntity[] }[]+ message_files?: HistoryMessageFile[]+ agent_thoughts?: ThoughtItem[] | null+ retriever_resources?: ChatItem['citation']+ metadata?: {+ reasoning?: ChatItem['reasoningContent']+ }+ created_at?: number+ answer_tokens?: number+ message_tokens?: number+ provider_response_latency?: number+ workflow_run_id?: string+ feedback?: ChatItem['feedback']+ inputs?: unknown+ query?: string+}+type ConversationMessagesResponse = {+ data: HistoryConversationMessage[]+}type SendCallback = {- onGetConversationMessages?: (conversationId: string, getAbortController: GetAbortController) => Promise<any>- onGetSuggestedQuestions?: (responseItemId: string, getAbortController: GetAbortController) => Promise<any>+ onGetConversationMessages?: (conversationId: string, getAbortController: GetAbortController) => Promise<unknown>+ onGetSuggestedQuestions?: (responseItemId: string, getAbortController: GetAbortController) => Promise<unknown>onConversationComplete?: (conversationId: string, workflowRunId?: string) => voidonUnhandledEvent?: IOtherOptions['onUnhandledEvent']onSendSettled?: (hasError?: boolean) => void@@ -58,9 +86,107 @@ type SendCallback = {}type UseChatOptions = {+ isNewAgent?: booleantimezone?: string}+function mergeStreamingThought(currentThought: ThoughtItem, nextThought: ThoughtItem): ThoughtItem {+ return {+ ...nextThought,+ message_files: nextThought.message_files?.length ? nextThought.message_files : currentThought.message_files,+ }+}++function appendAgentResponseMessagePart(responseItem: ChatItemInTree, message: string) {+ if (!responseItem.agent_response_parts)+ responseItem.agent_response_parts = []++ const lastPart = responseItem.agent_response_parts.at(-1)+ if (lastPart?.type === 'message') {+ lastPart.content += message+ }+ else {+ responseItem.agent_response_parts.push({+ type: 'message',+ content: message,+ })+ }+}++function upsertAgentResponseThoughtPart(responseItem: ChatItemInTree, thought: ThoughtItem) {+ if (!responseItem.agent_response_parts)+ responseItem.agent_response_parts = []++ const partIndex = responseItem.agent_response_parts.findIndex(part =>+ part.type === 'thought' && part.thought.id === thought.id,+ )+ if (partIndex > -1) {+ responseItem.agent_response_parts[partIndex] = {+ type: 'thought',+ thought,+ }+ return+ }++ responseItem.agent_response_parts.push({+ type: 'thought',+ thought,+ })+}++function getHistoryAgentThoughts(responseItem: HistoryConversationMessage) {+ if (!Array.isArray(responseItem.agent_thoughts))+ return []++ const messageFiles: VisionFile[] = responseItem.message_files?.map(file => ({+ id: file.id,+ type: file.type || '',+ transfer_method: file.transfer_method || TransferMethod.remote_url,+ url: file.url || '',+ upload_file_id: file.upload_file_id || '',+ belongs_to: file.belongs_to,+ })) || []++ return addFileInfos(sortAgentSorts(responseItem.agent_thoughts), messageFiles)+}++function toHistoryFileResponse(file: HistoryMessageFile): FileResponse {+ return {+ related_id: file.related_id || file.id || '',+ extension: file.extension || '',+ filename: file.filename || '',+ size: file.size || 0,+ mime_type: file.mime_type || file.type || '',+ transfer_method: file.transfer_method || TransferMethod.remote_url,+ type: file.type || '',+ url: file.url || '',+ upload_file_id: file.upload_file_id || '',+ remote_url: file.remote_url || '',+ }+}++function getHistoryAnswerFiles(responseItem: HistoryConversationMessage) {+ const answerFiles = responseItem.message_files?.filter(file => file.belongs_to === 'assistant') || []++ return getProcessedFilesFromResponse(answerFiles.map(file => toHistoryFileResponse({+ ...file,+ related_id: file.related_id || file.id || '',+ upload_file_id: file.upload_file_id || '',+ })))+}++function isHistoryConversationMessage(value: unknown): value is HistoryConversationMessage {+ return typeof value === 'object' && value !== null && typeof (value as { id?: unknown }).id === 'string'+}++function getConversationMessagesData(response: unknown): ConversationMessagesResponse['data'] {+ if (typeof response !== 'object' || response === null)+ return []++ const data = (response as { data?: unknown }).data+ return Array.isArray(data) ? data.filter(isHistoryConversationMessage) : []+}+export const useChat = (config?: ChatConfig,formSettings?: {@@ -279,14 +405,18 @@ export const useChat = (getAbortController: (abortController) => {workflowEventsAbortControllerRef.current = abortController},- onData: (message: string, isFirstMessage: boolean, { conversationId: newConversationId, messageId, taskId }: IOnDataMoreInfo) => {+ onData: (message: string, isFirstMessage: boolean, { event, conversationId: newConversationId, messageId, taskId }: IOnDataMoreInfo) => {updateChatTreeNode(messageId, (responseItem) => {- const isAgentMode = responseItem.agent_thoughts && responseItem.agent_thoughts.length > 0- if (!isAgentMode) {+ const agentThoughts = responseItem.agent_thoughts ?? []+ const isNewAgentMessage = options.isNewAgent && (event === 'agent_message' || event === 'message')+ if (isNewAgentMessage) {+ appendAgentResponseMessagePart(responseItem, message)+ }+ else if (!agentThoughts.length || options.isNewAgent) {responseItem.content = responseItem.content + message}else {- const lastThought = responseItem.agent_thoughts?.[responseItem.agent_thoughts?.length - 1]+ const lastThought = agentThoughts[agentThoughts.length - 1]if (lastThought)lastThought.thought = lastThought.thought + message}@@ -388,14 +518,16 @@ export const useChat = (else {const lastThought = responseItem.agent_thoughts.at(-1)if (lastThought?.id === thought.id) {- thought.thought = lastThought.thought- thought.message_files = lastThought.message_files- responseItem.agent_thoughts[responseItem.agent_thoughts.length - 1] = thought+ responseItem.agent_thoughts[responseItem.agent_thoughts.length - 1] = mergeStreamingThought(lastThought, thought)}else {responseItem.agent_thoughts.push(thought)}}+ if (options.isNewAgent) {+ const currentThought = responseItem.agent_thoughts.find(item => item.id === thought.id) ?? thought+ upsertAgentResponseThoughtPart(responseItem, currentThought)+ }})},onMessageEnd: (messageEnd) => {@@ -637,7 +769,7 @@ export const useChat = ({},otherOptions,)- }, [updateChatTreeNode, handleResponding, createAudioPlayerManager, config?.suggested_questions_after_answer])+ }, [updateChatTreeNode, handleResponding, createAudioPlayerManager, config?.suggested_questions_after_answer, options.isNewAgent])const updateCurrentQAOnTree = useCallback(({parentId,@@ -780,12 +912,16 @@ export const useChat = (getAbortController: (abortController) => {workflowEventsAbortControllerRef.current = abortController},- onData: (message: string, isFirstMessage: boolean, { conversationId: newConversationId, messageId, taskId }: any) => {- if (!isAgentMode) {+ onData: (message: string, isFirstMessage: boolean, { event, conversationId: newConversationId, messageId, taskId }: any) => {+ const isNewAgentMessage = options.isNewAgent && (event === 'agent_message' || event === 'message')+ if (isNewAgentMessage) {+ appendAgentResponseMessagePart(responseItem, message)+ }+ else if (!isAgentMode || options.isNewAgent) {responseItem.content = responseItem.content + message}else {- const lastThought = responseItem.agent_thoughts?.[responseItem.agent_thoughts?.length - 1]+ const lastThought = responseItem.agent_thoughts?.[responseItem.agent_thoughts.length - 1]if (lastThought)lastThought.thought = lastThought.thought + message // need immer setAutoFreeze}@@ -837,35 +973,55 @@ export const useChat = (let completedWorkflowRunId = responseItem.workflow_run_idif (conversationIdRef.current && !hasStopRespondedRef.current && onGetConversationMessages) {- const { data }: any = await onGetConversationMessages(+ const conversationMessagesResponse = await onGetConversationMessages(conversationIdRef.current,newAbortController => conversationMessagesAbortControllerRef.current = newAbortController,)- const newResponseItem = data.find((item: any) => item.id === responseItem.id)+ const data = getConversationMessagesData(conversationMessagesResponse)+ const newResponseItem = data.find(item => item.id === responseItem.id)completedWorkflowRunId = newResponseItem?.workflow_run_id ?? completedWorkflowRunIdif (!newResponseItem)return onConversationComplete?.(conversationIdRef.current, completedWorkflowRunId)- const isUseAgentThought = newResponseItem.agent_thoughts?.length > 0 && newResponseItem.agent_thoughts[newResponseItem.agent_thoughts?.length - 1].thought === newResponseItem.answer+ const historyAgentThoughts = getHistoryAgentThoughts(newResponseItem)+ const hasHistoryAgentThoughtAnswer = historyAgentThoughts.some(thought => thought.answer?.trim())+ const lastHistoryAgentThought = historyAgentThoughts.at(-1)+ const historyAnswer = newResponseItem.answer || ''+ const isUseAgentThought = (lastHistoryAgentThought?.thought === historyAnswer) || (options.isNewAgent && hasHistoryAgentThoughtAnswer)+ const messageLog = Array.isArray(newResponseItem.message) ? newResponseItem.message : []+ const answerTokens = newResponseItem.answer_tokens ?? 0+ const messageTokens = newResponseItem.message_tokens ?? 0+ const providerResponseLatency = newResponseItem.provider_response_latency ?? 0+ const historyAnswerFiles = getHistoryAnswerFiles(newResponseItem)updateChatTreeNode(responseItem.id, {- content: isUseAgentThought ? '' : newResponseItem.answer,+ content: isUseAgentThought ? '' : historyAnswer,+ agent_thoughts: historyAgentThoughts,+ agent_response_parts: undefined,+ citation: newResponseItem.retriever_resources,+ reasoningContent: newResponseItem.metadata?.reasoning,+ reasoningFinished: true,+ message_files: historyAnswerFiles,+ allFiles: undefined,+ workflowProcess: undefined,+ workflow_run_id: newResponseItem.workflow_run_id ?? completedWorkflowRunId,+ feedback: newResponseItem.feedback,log: [- ...newResponseItem.message,- ...(newResponseItem.message.at(-1).role !== 'assistant'+ ...messageLog,+ ...(messageLog.at(-1)?.role !== 'assistant'? [{role: 'assistant',- text: newResponseItem.answer,- files: newResponseItem.message_files?.filter((file: any) => file.belongs_to === 'assistant') || [],+ text: historyAnswer,+ files: historyAnswerFiles,},]: []),],more: {- time: formatTime(newResponseItem.created_at, 'hh:mm A'),- tokens: newResponseItem.answer_tokens + newResponseItem.message_tokens,- latency: newResponseItem.provider_response_latency.toFixed(2),- tokens_per_second: newResponseItem.provider_response_latency > 0 ? (newResponseItem.answer_tokens / newResponseItem.provider_response_latency).toFixed(2) : undefined,+ time: formatTime(newResponseItem.created_at ?? Date.now(), 'hh:mm A'),+ tokens: answerTokens + messageTokens,+ latency: providerResponseLatency.toFixed(2),+ tokens_per_second: providerResponseLatency > 0 ? (answerTokens / providerResponseLatency).toFixed(2) : undefined,},// for agent logconversationId: conversationIdRef.current,@@ -953,14 +1109,16 @@ export const useChat = (const lastThought = response.agent_thoughts.at(-1)// thought changed but still the same thought, so update.if (lastThought.id === thought.id) {- thought.thought = lastThought.thought- thought.message_files = lastThought.message_files- responseItem.agent_thoughts![response.agent_thoughts.length - 1] = thought+ responseItem.agent_thoughts![response.agent_thoughts.length - 1] = mergeStreamingThought(lastThought, thought)}else {responseItem.agent_thoughts!.push(thought)}}+ if (options.isNewAgent) {+ const currentThought = responseItem.agent_thoughts?.find(item => item.id === thought.id) ?? thought+ upsertAgentResponseThoughtPart(responseItem, currentThought)+ }updateCurrentQAOnTree({placeholderQuestionId,questionItem,@@ -1283,6 +1441,7 @@ export const useChat = (formatTime,createAudioPlayerManager,formSettings,+ options.isNewAgent,])const handleAnnotationEdited = useCallback((query: string, answer: string, index: number) => {diff --git a/web/app/components/base/chat/chat/index.tsx b/web/app/components/base/chat/chat/index.tsxindex 733abcae322..7cc861e6719 100644--- a/web/app/components/base/chat/chat/index.tsx+++ b/web/app/components/base/chat/chat/index.tsx@@ -78,6 +78,11 @@ export type ChatProps = {sidebarCollapseState?: booleanhideAvatar?: booleansendOnEnter?: boolean+ renderAgentContent?: (props: {+ item: ChatItem+ responding?: boolean+ content?: string+ }) => ReactNodeonHumanInputFormSubmit?: (formToken: string, formData: HumanInputFormSubmitData) => Promise<void>getHumanInputNodeData?: (nodeID: string) => Node<HumanInputNodeType> | undefined}@@ -130,6 +135,7 @@ const Chat: FC<ChatProps> = ({sidebarCollapseState,hideAvatar,sendOnEnter,+ renderAgentContent,onHumanInputFormSubmit,getHumanInputNodeData,}) => {@@ -204,6 +210,7 @@ const Chat: FC<ChatProps> = ({noChatInput={noChatInput}switchSibling={switchSibling}hideAvatar={hideAvatar}+ renderAgentContent={renderAgentContent}onHumanInputFormSubmit={onHumanInputFormSubmit}/>)diff --git a/web/app/components/base/chat/chat/type.ts b/web/app/components/base/chat/chat/type.tsindex 167a6a3548b..4c0c80f975b 100644--- a/web/app/components/base/chat/chat/type.ts+++ b/web/app/components/base/chat/chat/type.ts@@ -41,6 +41,7 @@ export type ThoughtItem = {id: stringtool: string // plugin or dataset. May has multi.thought: string+ answer?: stringtool_input: stringtool_labels?: { [key: string]: TypeWithI18N }message_id: string@@ -51,6 +52,16 @@ export type ThoughtItem = {message_files?: FileEntity[]}+type AgentResponsePart+ = | {+ type: 'thought'+ thought: ThoughtItem+ }+ | {+ type: 'message'+ content: string+ }+export type CitationItem = {content: stringdata_source_type: string@@ -113,6 +124,7 @@ export type IChatItem = {suggestedQuestions?: string[]log?: { role: string, text: string, files?: FileEntity[] }[]agent_thoughts?: ThoughtItem[]+ agent_response_parts?: AgentResponsePart[]// for LLM reasoning (chain-of-thought) in "separated" mode, keyed by LLM node idreasoningContent?: Record<string, string>reasoningFinished?: booleandiff --git a/web/app/components/base/prompt-editor/__tests__/prompt-editor-content.spec.tsx b/web/app/components/base/prompt-editor/__tests__/prompt-editor-content.spec.tsxindex 3d6766b0024..7146fc09332 100644--- a/web/app/components/base/prompt-editor/__tests__/prompt-editor-content.spec.tsx+++ b/web/app/components/base/prompt-editor/__tests__/prompt-editor-content.spec.tsx@@ -8,6 +8,7 @@ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContextimport { act, fireEvent, render, screen, waitFor } from '@testing-library/react'import {$getRoot,+ $isElementNode,BLUR_COMMAND,COMMAND_PRIORITY_EDITOR,createCommand,@@ -245,7 +246,7 @@ describe('PromptEditorContent', () => {})})- it('should infer file type when rendering a file-name output token', async () => {+ it('should render file-name output tokens with the declared output type', async () => {const captures: Captures = { editor: null, eventEmitter: null }render(@@ -266,7 +267,7 @@ describe('PromptEditorContent', () => {await waitFor(() => {expect(screen.getByText('qna_report.pdf')).toBeInTheDocument()- expect(screen.getByText('file')).toBeInTheDocument()+ expect(screen.getByText('string')).toBeInTheDocument()})})@@ -317,6 +318,95 @@ describe('PromptEditorContent', () => {expect(screen.queryByText('string')).not.toBeInTheDocument()})+ it('should preserve committed output name selection state when refreshing output block props', async () => {+ const captures: Captures = { editor: null, eventEmitter: null }+ const initialOnChange = vi.fn()+ const nextOnChange = vi.fn()+ const nextOutputs = [{ name: 'summary', type: 'string' as const }]++ const { rerender } = render(+ <PromptEditorContentHarness+ captures={captures}+ initialText="[§output:output:output§]"+ shortcutPopups={[]}+ floatingAnchorElem={document.createElement('div')}+ onEditorChange={vi.fn()}+ agentOutputBlock={{+ show: true,+ outputs: [{ name: 'output', type: 'string' }],+ onChange: initialOnChange,+ }}+ />,+ )++ await waitFor(() => {+ expect(captures.editor).not.toBeNull()+ expect(screen.getByText('output')).toBeInTheDocument()+ })++ act(() => {+ captures.editor?.update(() => {+ const visitNode = (node: Parameters<typeof $isElementNode>[0]) => {+ if (!$isElementNode(node))+ return++ node.getChildren().forEach((child) => {+ if (child instanceof AgentOutputBlockNode) {+ child.setOutput('summary', 'string', true, nextOutputs, initialOnChange, undefined, false, true)+ return+ }++ visitNode(child)+ })+ }++ visitNode($getRoot())+ })+ })++ rerender(+ <PromptEditorContentHarness+ captures={captures}+ initialText="[§output:output:output§]"+ shortcutPopups={[]}+ floatingAnchorElem={document.createElement('div')}+ onEditorChange={vi.fn()}+ agentOutputBlock={{+ show: true,+ outputs: [...nextOutputs],+ onChange: nextOnChange,+ }}+ />,+ )++ await waitFor(() => {+ captures.editor!.getEditorState().read(() => {+ const root = $getRoot()++ const findOutputNode = (node: Parameters<typeof $isElementNode>[0]): AgentOutputBlockNode | null => {+ if (!$isElementNode(node))+ return null++ for (const child of node.getChildren()) {+ if (child instanceof AgentOutputBlockNode)+ return child++ const outputNode = findOutputNode(child)+ if (outputNode)+ return outputNode+ }++ return null+ }++ const outputNode = findOutputNode(root)+ expect(outputNode?.shouldSelectNameOnEdit()).toBe(false)+ expect(outputNode?.shouldOpenTypeSelectOnEdit()).toBe(true)+ expect(outputNode?.getOnChange()).toBe(nextOnChange)+ })+ })+ })+it('should render optional blocks and open shortcut popups with the real editor runtime', async () => {const captures: Captures = { editor: null, eventEmitter: null }const onEditorChange = vi.fn()diff --git a/web/app/components/base/prompt-editor/index.tsx b/web/app/components/base/prompt-editor/index.tsxindex ebd6968dd69..b5f493c6052 100644--- a/web/app/components/base/prompt-editor/index.tsx+++ b/web/app/components/base/prompt-editor/index.tsx@@ -110,7 +110,7 @@ const EditableSyncPlugin: FC<{ editable: boolean }> = ({ editable }) => {return null}-type PromptEditorAriaProps = Pick<React.AriaAttributes, 'aria-label' | 'aria-labelledby'>+type PromptEditorAriaProps = Pick<React.AriaAttributes, 'aria-controls' | 'aria-haspopup' | 'aria-label' | 'aria-labelledby'>export type PromptEditorProps = PromptEditorAriaProps & {instanceId?: string@@ -150,6 +150,8 @@ export type PromptEditorProps = PromptEditorAriaProps & {}const PromptEditor: FC<PromptEditorProps> = ({+ 'aria-controls': ariaControls,+ 'aria-haspopup': ariaHasPopup,'aria-label': ariaLabel,'aria-labelledby': ariaLabelledBy,instanceId,@@ -252,6 +254,8 @@ const PromptEditor: FC<PromptEditorProps> = ({<LexicalComposer initialConfig={{ ...initialConfig, editable }}><div className={cn('relative', wrapperClassName)} ref={onRef}><PromptEditorContent+ aria-controls={ariaControls}+ aria-haspopup={ariaHasPopup}aria-label={ariaLabel}aria-labelledby={ariaLabelledBy}compact={compact}diff --git a/web/app/components/base/prompt-editor/plugins/agent-output-block/__tests__/component.spec.tsx b/web/app/components/base/prompt-editor/plugins/agent-output-block/__tests__/component.spec.tsxindex 9fce0509aa3..629ce6244f2 100644--- a/web/app/components/base/prompt-editor/plugins/agent-output-block/__tests__/component.spec.tsx+++ b/web/app/components/base/prompt-editor/plugins/agent-output-block/__tests__/component.spec.tsx@@ -5,16 +5,15 @@ import { fireEvent, render, screen, waitFor } from '@testing-library/react'import userEvent from '@testing-library/user-event'import { $getNodeByKey } from 'lexical'import AgentOutputBlockComponent from '../component'-import { $createAgentOutputBlockNode } from '../node'-const { mockEditorFocus, mockEditorUpdate, mockGetRootText, mockNodeReplace, mockSelectNext } = vi.hoisted(() => ({+const { mockEditorFocus, mockEditorUpdate, mockGetRootText, mockSelectNext, mockSetOutput } = vi.hoisted(() => ({mockEditorFocus: vi.fn(),mockEditorUpdate: vi.fn((callback: () => void) => callback()),mockGetRootText: {value: '[§output:summary:summary§]',},- mockNodeReplace: vi.fn(),mockSelectNext: vi.fn(),+ mockSetOutput: vi.fn(),}))vi.mock('@lexical/react/LexicalComposerContext')@@ -22,11 +21,14 @@ vi.mock('@langgenius/dify-ui/select', () => ({Select: ({children,onValueChange,+ open,}: {children: ReactNodeonValueChange: (value: string) => void+ open?: boolean}) => (<div>+ <span data-testid="type-select-state">{open ? 'open' : 'closed'}</span>{children}<button type="button" onClick={() => onValueChange('file')}>Select file</button></div>@@ -62,11 +64,6 @@ vi.mock('lexical', async (importOriginal) => {})vi.mock('../node', () => ({- $createAgentOutputBlockNode: vi.fn((name: string, outputType: string, isEditing: boolean) => ({- isEditing,- name,- outputType,- })),$isAgentOutputBlockNode: () => true,}))@@ -90,13 +87,65 @@ describe('AgentOutputBlockComponent', () => {{},] as unknown as ReturnType<typeof useLexicalComposerContext>)vi.mocked($getNodeByKey).mockReturnValue({- replace: mockNodeReplace.mockReturnValue({- selectNext: mockSelectNext,- }),+ selectNext: mockSelectNext,+ setOutput: mockSetOutput,} as never)})- it('does not replace the Lexical node while typing an output name and commits on blur', async () => {+ it('focuses and selects the output name while editing a newly inserted output block', () => {+ render(+ <AgentOutputBlockComponent+ nodeKey="output-node"+ name="output"+ outputType="string"+ isEditing+ outputs={outputs}+ />,+ )++ const input = screen.getByRole('textbox', { name: 'workflow.nodes.agent.outputVars.nameLabel' }) as HTMLInputElement++ expect(input).toHaveFocus()+ expect(input.selectionStart).toBe(0)+ expect(input.selectionEnd).toBe('output'.length)+ })++ it('focuses without selecting the output name after an edited output name is committed', () => {+ render(+ <AgentOutputBlockComponent+ nodeKey="output-node"+ name="summary"+ outputType="string"+ isEditing+ selectNameOnEdit={false}+ outputs={outputs}+ />,+ )++ const input = screen.getByRole('textbox', { name: 'workflow.nodes.agent.outputVars.nameLabel' }) as HTMLInputElement++ expect(input).toHaveFocus()+ expect(input.selectionStart).toBe('summary'.length)+ expect(input.selectionEnd).toBe('summary'.length)+ })++ it('keeps the type select open after the edited output block is remounted', () => {+ render(+ <AgentOutputBlockComponent+ nodeKey="output-node"+ name="summary"+ outputType="string"+ isEditing+ selectNameOnEdit={false}+ openTypeSelectOnEdit+ outputs={outputs}+ />,+ )++ expect(screen.getByTestId('type-select-state')).toHaveTextContent('open')+ })++ it('does not update the Lexical node while typing an output name and commits on blur', async () => {const user = userEvent.setup()const onChange = vi.fn()@@ -117,12 +166,12 @@ describe('AgentOutputBlockComponent', () => {await user.type(input, 'summary')expect(input).toHaveValue('summary')- expect(mockNodeReplace).not.toHaveBeenCalled()+ expect(mockSetOutput).not.toHaveBeenCalled()expect(onChange).not.toHaveBeenCalled()- await user.tab()+ fireEvent.blur(input)- expect($createAgentOutputBlockNode).toHaveBeenCalledWith(+ expect(mockSetOutput).toHaveBeenCalledWith('summary','string',false,@@ -135,9 +184,10 @@ describe('AgentOutputBlockComponent', () => {]),onChange,undefined,+ false,+ false,)- expect(mockNodeReplace).toHaveBeenCalledTimes(1)- expect(mockSelectNext).not.toHaveBeenCalled()+ expect(mockSetOutput).toHaveBeenCalledTimes(1)expect(mockEditorFocus).not.toHaveBeenCalled()expect(onChange).toHaveBeenCalledWith(expect.arrayContaining([expect.objectContaining({@@ -148,8 +198,10 @@ describe('AgentOutputBlockComponent', () => {]), '[§output:summary:summary§]')})- it('moves the editor selection after the output block when committing with Enter', async () => {+ it('syncs the output name and moves the editor selection after the output block when committing with Enter', async () => {const user = userEvent.setup()+ const onChange = vi.fn()+ mockGetRootText.value = 'Generate [§output:output:output§]'render(<AgentOutputBlockComponent@@ -158,6 +210,7 @@ describe('AgentOutputBlockComponent', () => {outputType="string"isEditingoutputs={outputs}+ onChange={onChange}/>,)@@ -167,15 +220,37 @@ describe('AgentOutputBlockComponent', () => {await user.type(input, 'summary')await user.keyboard('{Enter}')- expect(mockNodeReplace).toHaveBeenCalledTimes(1)+ expect(mockSetOutput).toHaveBeenCalledWith(+ 'summary',+ 'string',+ false,+ expect.arrayContaining([+ expect.objectContaining({+ name: 'summary',+ type: 'string',+ }),+ ]),+ onChange,+ undefined,+ false,+ false,+ )expect(mockSelectNext).toHaveBeenCalledTimes(1)+ expect(screen.getByTestId('type-select-state')).toHaveTextContent('closed')+ expect(onChange).toHaveBeenCalledWith(expect.arrayContaining([+ expect.objectContaining({+ name: 'summary',+ }),+ ]), 'Generate [§output:summary:summary§]')await waitFor(() => {expect(mockEditorFocus).toHaveBeenCalledTimes(1)})})- it('commits the input DOM value on Enter even before React state rerenders', () => {+ it('syncs the output name and opens the type select when committing with Tab', async () => {+ const user = userEvent.setup()const onChange = vi.fn()+ mockGetRootText.value = 'Generate [§output:output:output§]'render(<AgentOutputBlockComponent@@ -190,26 +265,39 @@ describe('AgentOutputBlockComponent', () => {const input = screen.getByRole('textbox', { name: 'workflow.nodes.agent.outputVars.nameLabel' })- fireEvent.change(input, { target: { value: 'summary' } })- fireEvent.keyDown(input, { key: 'Enter' })+ await user.clear(input)+ await user.type(input, 'summary')+ await user.keyboard('{Tab}')- expect($createAgentOutputBlockNode).toHaveBeenCalledWith(+ expect(mockSetOutput).toHaveBeenCalledWith('summary','string',- false,+ true,expect.arrayContaining([expect.objectContaining({name: 'summary',+ type: 'string',}),]),onChange,undefined,+ false,+ true,)+ expect(mockSelectNext).not.toHaveBeenCalled()+ expect(screen.getByTestId('type-select-state')).toHaveTextContent('open')+ expect(input).not.toHaveFocus()+ expect((input as HTMLInputElement).selectionStart).toBe('summary'.length)+ expect((input as HTMLInputElement).selectionEnd).toBe('summary'.length)+ expect(onChange).toHaveBeenCalledWith(expect.arrayContaining([+ expect.objectContaining({+ name: 'summary',+ }),+ ]), 'Generate [§output:summary:summary§]')})- it('automatically commits file-name outputs as file type', () => {+ it('commits the input DOM value on Enter even before React state rerenders', () => {const onChange = vi.fn()- mockGetRootText.value = '[§output:qna_report.pdf:qna_report.pdf§]'render(<AgentOutputBlockComponent@@ -224,37 +312,28 @@ describe('AgentOutputBlockComponent', () => {const input = screen.getByRole('textbox', { name: 'workflow.nodes.agent.outputVars.nameLabel' })- fireEvent.change(input, { target: { value: 'qna_report.pdf' } })+ fireEvent.change(input, { target: { value: 'summary' } })fireEvent.keyDown(input, { key: 'Enter' })- expect($createAgentOutputBlockNode).toHaveBeenCalledWith(- 'qna_report.pdf',- 'file',+ expect(mockSetOutput).toHaveBeenCalledWith(+ 'summary',+ 'string',false,expect.arrayContaining([expect.objectContaining({- name: 'qna_report.pdf',- type: 'file',- file: {- extensions: [],- mime_types: [],- },+ name: 'summary',}),]),onChange,undefined,+ false,+ false,)- expect(onChange).toHaveBeenCalledWith(expect.arrayContaining([- expect.objectContaining({- name: 'qna_report.pdf',- type: 'file',- }),- ]), '[§output:qna_report.pdf:qna_report.pdf§]')+ expect(mockSelectNext).toHaveBeenCalledTimes(1)})- it('keeps dotted output names as the selected type when the extension is not whitelisted', () => {+ it('does not commit output names containing dots', () => {const onChange = vi.fn()- mockGetRootText.value = '[§output:report.customext:report.customext§]'render(<AgentOutputBlockComponent@@ -269,22 +348,12 @@ describe('AgentOutputBlockComponent', () => {const input = screen.getByRole('textbox', { name: 'workflow.nodes.agent.outputVars.nameLabel' })- fireEvent.change(input, { target: { value: 'report.customext' } })+ fireEvent.change(input, { target: { value: 'qna_report.pdf' } })fireEvent.keyDown(input, { key: 'Enter' })- expect($createAgentOutputBlockNode).toHaveBeenCalledWith(- 'report.customext',- 'string',- false,- expect.arrayContaining([- expect.objectContaining({- name: 'report.customext',- type: 'string',- }),- ]),- onChange,- undefined,- )+ expect(mockSetOutput).not.toHaveBeenCalled()+ expect(mockSelectNext).not.toHaveBeenCalled()+ expect(onChange).not.toHaveBeenCalled()})it('does not commit the name blur before selecting an output type', () => {@@ -313,7 +382,7 @@ describe('AgentOutputBlockComponent', () => {fireEvent.click(screen.getByRole('button', { name: 'Select file' }))- expect($createAgentOutputBlockNode).toHaveBeenCalledWith(+ expect(mockSetOutput).toHaveBeenCalledWith('summary','file',false,@@ -325,6 +394,8 @@ describe('AgentOutputBlockComponent', () => {]),onChange,undefined,+ false,+ false,)})@@ -350,7 +421,7 @@ describe('AgentOutputBlockComponent', () => {await user.type(input, 'summary')await user.keyboard('{Enter}')- expect(mockNodeReplace).not.toHaveBeenCalled()+ expect(mockSetOutput).not.toHaveBeenCalled()expect(onChange).not.toHaveBeenCalled()expect(mockEditorFocus).not.toHaveBeenCalled()})@@ -372,7 +443,7 @@ describe('AgentOutputBlockComponent', () => {expect(screen.getByText('file')).toBeInTheDocument()})- it('requests the output editor when hovering a committed output block', () => {+ it('requests the output editor when clicking a committed output block', () => {const onEdit = vi.fn()render(@@ -386,7 +457,14 @@ describe('AgentOutputBlockComponent', () => {/>,)- fireEvent.mouseEnter(screen.getByText('qna_report_pdf').parentElement!)+ const outputBlock = screen.getByText('qna_report_pdf').parentElement!++ fireEvent.mouseEnter(outputBlock)++ expect(outputBlock).toHaveClass('cursor-pointer')+ expect(onEdit).not.toHaveBeenCalled()++ fireEvent.click(outputBlock)expect(onEdit).toHaveBeenCalledWith('qna_report_pdf', 'file')})diff --git a/web/app/components/base/prompt-editor/plugins/agent-output-block/__tests__/node.spec.tsx b/web/app/components/base/prompt-editor/plugins/agent-output-block/__tests__/node.spec.tsxindex 95f71afc67a..47e487eb463 100644--- a/web/app/components/base/prompt-editor/plugins/agent-output-block/__tests__/node.spec.tsx+++ b/web/app/components/base/prompt-editor/plugins/agent-output-block/__tests__/node.spec.tsx@@ -12,7 +12,6 @@ import {import {extractAgentOutputNames,getAgentOutputToken,- inferAgentOutputType,parseAgentOutputToken,replaceAgentOutputName,} from '../utils'@@ -40,26 +39,16 @@ describe('AgentOutputBlockNode', () => {})})- it('should persist and parse file-name output tokens', () => {+ it('should select the output name only for newly inserted editing nodes', () => {runInEditor(() => {- const node = $createAgentOutputBlockNode('qna_report.pdf', 'file')+ const newEditingNode = $createAgentOutputBlockNode('output', 'string', true)+ const existingEditingNode = $createAgentOutputBlockNode('summary', 'string', true, [], undefined, undefined, false)+ const typeSelectingNode = $createAgentOutputBlockNode('summary', 'string', true, [], undefined, undefined, false, true)- expect(node.getTextContent()).toBe('[§output:qna_report.pdf:qna_report.pdf§]')- expect(getAgentOutputToken('qna_report.pdf')).toBe('[§output:qna_report.pdf:qna_report.pdf§]')+ expect(newEditingNode.shouldSelectNameOnEdit()).toBe(true)+ expect(existingEditingNode.shouldSelectNameOnEdit()).toBe(false)+ expect(typeSelectingNode.shouldOpenTypeSelectOnEdit()).toBe(true)})-- expect(parseAgentOutputToken('Use [§output:qna_report.pdf:qna_report.pdf§]')).toEqual({- name: 'qna_report.pdf',- start: 4,- end: 44,- })- })-- it('should infer file type only for whitelisted file extensions', () => {- expect(inferAgentOutputType('qna_report.pdf', 'string')).toBe('file')- expect(inferAgentOutputType('QNA_REPORT.PDF', 'string')).toBe('file')- expect(inferAgentOutputType('report.customext', 'string')).toBe('string')- expect(inferAgentOutputType('report.customext', 'object')).toBe('object')})it('should parse bracketed output tokens and legacy bare tokens', () => {@@ -77,9 +66,9 @@ describe('AgentOutputBlockNode', () => {})it('should extract output names from bracketed and legacy tokens', () => {- expect([...extractAgentOutputNames('A [§output:summary:summary§] B §output:qna_report.pdf:qna_report.pdf§')]).toEqual([+ expect([...extractAgentOutputNames('A [§output:summary:summary§] B §output:final_summary:final_summary§')]).toEqual(['summary',- 'qna_report.pdf',+ 'final_summary',])})@@ -89,6 +78,11 @@ describe('AgentOutputBlockNode', () => {'summary','final_summary',)).toBe('Use [§output:final_summary:final_summary§] and §output:other:other§')+ expect(replaceAgentOutputName(+ 'Generate [§output:output:output§] and §output:output:output§',+ 'output',+ 'summary',+ )).toBe('Generate [§output:summary:summary§] and §output:summary:summary§')})it('should create node with helper and support type guard checks', () => {diff --git a/web/app/components/base/prompt-editor/plugins/agent-output-block/component.tsx b/web/app/components/base/prompt-editor/plugins/agent-output-block/component.tsxindex 2305cf817c9..e27b05a781e 100644--- a/web/app/components/base/prompt-editor/plugins/agent-output-block/component.tsx+++ b/web/app/components/base/prompt-editor/plugins/agent-output-block/component.tsx@@ -11,15 +11,15 @@ import {} from '@langgenius/dify-ui/select'import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'import { $getNodeByKey, $getRoot } from 'lexical'-import { memo, useRef, useState } from 'react'+import { memo, useEffect, useRef, useState } from 'react'import { useTranslation } from 'react-i18next'-import { $createAgentOutputBlockNode, $isAgentOutputBlockNode } from './node'+import { $isAgentOutputBlockNode } from './node'import {AGENT_OUTPUT_NAME_PATTERN,AGENT_OUTPUT_TYPE_OPTIONS,createAgentOutputConfig,getAgentOutputTypeOption,- inferAgentOutputType,+ replaceAgentOutputName,} from './utils'type AgentOutputBlockComponentProps = {@@ -27,6 +27,8 @@ type AgentOutputBlockComponentProps = {name: stringoutputType: AgentOutputTypeOptionValueisEditing: boolean+ selectNameOnEdit?: boolean+ openTypeSelectOnEdit?: booleanoutputs: DeclaredOutputConfig[]onChange?: (outputs: DeclaredOutputConfig[], prompt?: string) => voidonEdit?: (name: string, outputType: AgentOutputTypeOptionValue) => void@@ -42,13 +44,12 @@ function upsertOutput(if (!AGENT_OUTPUT_NAME_PATTERN.test(trimmedName))return null- const nextOutputType = inferAgentOutputType(trimmedName, outputType)const existingIndex = outputs.findIndex(output => output.name === oldName)const duplicateIndex = outputs.findIndex(output => output.name === trimmedName && output.name !== oldName)if (duplicateIndex >= 0)return null- const nextOutput = createAgentOutputConfig(trimmedName, nextOutputType)+ const nextOutput = createAgentOutputConfig(trimmedName, outputType)if (existingIndex >= 0)return outputs.map((output, index) => index === existingIndex ? nextOutput : output)@@ -60,6 +61,8 @@ const AgentOutputBlockComponent = ({name,outputType,isEditing,+ selectNameOnEdit = isEditing,+ openTypeSelectOnEdit = false,outputs,onChange,onEdit,@@ -69,8 +72,30 @@ const AgentOutputBlockComponent = ({const selected = getAgentOutputTypeOption(outputType)const [draftName, setDraftName] = useState(name)const [lastNodeName, setLastNodeName] = useState(name)+ const [typeSelectOpen, setTypeSelectOpen] = useState(openTypeSelectOnEdit)+ const nameInputRef = useRef<HTMLInputElement>(null)const skipNextBlurCommitRef = useRef(false)const latestDraftNameRef = useRef(name)+ const skipNameFocusRef = useRef(false)++ useEffect(() => {+ if (!isEditing)+ return+ if (skipNameFocusRef.current) {+ skipNameFocusRef.current = false+ return+ }++ const input = nameInputRef.current+ if (!input)+ return++ input.focus()+ if (selectNameOnEdit)+ input.setSelectionRange(0, input.value.length)+ else+ input.setSelectionRange(input.value.length, input.value.length)+ }, [isEditing, selectNameOnEdit])if (name !== lastNodeName) {setLastNodeName(name)@@ -78,7 +103,20 @@ const AgentOutputBlockComponent = ({latestDraftNameRef.current = name}- const commitOutput = (nextName: string, nextType: AgentOutputTypeOptionValue, selectAfterCommit = false) => {+ const commitOutput = (+ nextName: string,+ nextType: AgentOutputTypeOptionValue,+ options: {+ keepEditing?: boolean+ openTypeSelectOnEdit?: boolean+ selectAfterCommit?: boolean+ } = {},+ ) => {+ const {+ keepEditing = false,+ openTypeSelectOnEdit = false,+ selectAfterCommit = false,+ } = optionsconst trimmedName = nextName.trim()const nextOutputs = upsertOutput(outputs, name, trimmedName, nextType)if (!nextOutputs) {@@ -93,11 +131,11 @@ const AgentOutputBlockComponent = ({if (!$isAgentOutputBlockNode(node))return- const nextOutputType = inferAgentOutputType(trimmedName, nextType)- const nextNode = node.replace($createAgentOutputBlockNode(trimmedName, nextOutputType, false, nextOutputs, onChange, onEdit))+ const currentPrompt = $getRoot().getChildren().map(node => node.getTextContent()).join('\n')+ node.setOutput(trimmedName, nextType, keepEditing, nextOutputs, onChange, onEdit, false, openTypeSelectOnEdit)if (selectAfterCommit)- nextNode.selectNext()- nextPrompt = $getRoot().getChildren().map(node => node.getTextContent()).join('\n')+ node.selectNext()+ nextPrompt = replaceAgentOutputName(currentPrompt, name, trimmedName)didCommit = true})@@ -105,16 +143,44 @@ const AgentOutputBlockComponent = ({return falseonChange?.(nextOutputs, nextPrompt)+ setDraftName(trimmedName)+ latestDraftNameRef.current = trimmedNamereturn true}+ const handleTypeSelectOpenChange = (open: boolean) => {+ setTypeSelectOpen(open)+ if (!open) {+ skipNextBlurCommitRef.current = false+ editor.update(() => {+ const node = $getNodeByKey(nodeKey)+ if ($isAgentOutputBlockNode(node))+ node.setOpenTypeSelectOnEdit(false)+ })+ }+ }++ const handleEditRequest = () => {+ onEdit?.(name, outputType)+ }+if (!isEditing) {return (<span+ role="button"+ tabIndex={0}+ aria-label={t('nodes.agent.outputVars.edit', { ns: 'workflow', name })}contentEditable={false}- className="group/agent-output inline-flex min-w-[18px] items-center gap-1 rounded-[5px] border border-util-colors-violet-violet-100 bg-util-colors-violet-violet-50 px-1 py-0.5 align-middle shadow-xs"- onMouseEnter={() => onEdit?.(name, outputType)}+ className="group/agent-output inline-flex min-w-[18px] cursor-pointer items-center gap-1 rounded-[5px] border border-util-colors-violet-violet-100 bg-util-colors-violet-violet-50 px-1 py-0.5 align-middle shadow-xs"+ onClick={handleEditRequest}+ onKeyDown={(event) => {+ if (event.key !== 'Enter' && event.key !== ' ')+ return++ event.preventDefault()+ handleEditRequest()+ }}><span aria-hidden="true" className="i-custom-vender-workflow-variable-x size-3.5 shrink-0 text-util-colors-violet-violet-700 group-hover/agent-output:hidden" /><span aria-hidden="true" className="i-ri-edit-2-line hidden size-3.5 shrink-0 text-util-colors-violet-violet-700 group-hover/agent-output:inline-block" />@@ -136,6 +202,7 @@ const AgentOutputBlockComponent = ({<span className="flex min-w-0 items-center gap-0.5 pl-0.5"><span aria-hidden="true" className="i-custom-vender-workflow-variable-x size-3.5 shrink-0 text-util-colors-violet-violet-700" /><input+ ref={nameInputRef}aria-label={t('nodes.agent.outputVars.nameLabel', { ns: 'workflow' })}value={draftName}className="h-4 max-w-28 min-w-5 border-0 bg-transparent p-0 text-center system-xs-regular text-util-colors-violet-violet-700 outline-hidden placeholder:text-util-colors-violet-violet-700/50 focus:w-24"@@ -145,15 +212,28 @@ const AgentOutputBlockComponent = ({onKeyDown={(event) => {event.stopPropagation()event.nativeEvent.stopImmediatePropagation?.()- if (event.key === 'Enter') {+ if (event.key === 'Enter' || event.key === 'Tab') {event.preventDefault()skipNextBlurCommitRef.current = true- const didCommit = commitOutput(event.currentTarget.value, outputType, true)+ const isTabCommit = event.key === 'Tab'+ const didCommit = commitOutput(event.currentTarget.value, outputType, {+ keepEditing: isTabCommit,+ openTypeSelectOnEdit: isTabCommit,+ selectAfterCommit: !isTabCommit,+ })if (!didCommit) {skipNextBlurCommitRef.current = falsereturn}+ if (isTabCommit) {+ skipNameFocusRef.current = true+ event.currentTarget.setSelectionRange(event.currentTarget.value.length, event.currentTarget.value.length)+ event.currentTarget.blur()+ setTypeSelectOpen(true)+ return+ }+queueMicrotask(() => {editor.focus()})@@ -179,9 +259,12 @@ const AgentOutputBlockComponent = ({/></span><Select<AgentOutputTypeOptionValue>+ open={typeSelectOpen}+ onOpenChange={handleTypeSelectOpenChange}value={outputType}onValueChange={(nextType) => {skipNextBlurCommitRef.current = false+ setTypeSelectOpen(false)if (nextType)commitOutput(latestDraftNameRef.current, nextType)}}diff --git a/web/app/components/base/prompt-editor/plugins/agent-output-block/index.tsx b/web/app/components/base/prompt-editor/plugins/agent-output-block/index.tsxindex 51d3f6ad34d..ff221d5aa69 100644--- a/web/app/components/base/prompt-editor/plugins/agent-output-block/index.tsx+++ b/web/app/components/base/prompt-editor/plugins/agent-output-block/index.tsx@@ -18,14 +18,13 @@ import {createAgentOutputConfig,getAgentOutputTypeOptionValue,getUniqueAgentOutputName,- inferAgentOutputType,parseAgentOutputToken,} from './utils'function getAgentOutputBlockNodeType(name: string, outputs: NonNullable<AgentOutputBlockType['outputs']>) {const output = outputs.find(item => item.name === name)- return inferAgentOutputType(name, output ? getAgentOutputTypeOptionValue(output) : 'string')+ return output ? getAgentOutputTypeOptionValue(output) : 'string'}const AgentOutputBlock = memo(({@@ -120,7 +119,16 @@ const AgentOutputBlockReplacementBlock = memo(({|| child.getOnChange() !== onChange|| child.getOnEdit() !== onEdit) {- child.replace($createAgentOutputBlockNode(name, outputType, child.isEditing(), outputs, onChange, onEdit))+ child.replace($createAgentOutputBlockNode(+ name,+ outputType,+ child.isEditing(),+ outputs,+ onChange,+ onEdit,+ child.shouldSelectNameOnEdit(),+ child.shouldOpenTypeSelectOnEdit(),+ ))}return}diff --git a/web/app/components/base/prompt-editor/plugins/agent-output-block/node.tsx b/web/app/components/base/prompt-editor/plugins/agent-output-block/node.tsxindex ecf8d53e1c6..0655f8a3106 100644--- a/web/app/components/base/prompt-editor/plugins/agent-output-block/node.tsx+++ b/web/app/components/base/prompt-editor/plugins/agent-output-block/node.tsx@@ -14,6 +14,8 @@ export class AgentOutputBlockNode extends DecoratorNode<React.JSX.Element> {__name: string__outputType: AgentOutputTypeOptionValue__isEditing: boolean+ __selectNameOnEdit: boolean+ __openTypeSelectOnEdit: boolean__outputs: DeclaredOutputConfig[]__onChange?: (outputs: DeclaredOutputConfig[], prompt?: string) => void__onEdit?: (name: string, outputType: AgentOutputTypeOptionValue) => void@@ -27,6 +29,8 @@ export class AgentOutputBlockNode extends DecoratorNode<React.JSX.Element> {node.__name,node.__outputType,node.__isEditing,+ node.__selectNameOnEdit,+ node.__openTypeSelectOnEdit,node.__outputs,node.__onChange,node.__onEdit,@@ -42,6 +46,8 @@ export class AgentOutputBlockNode extends DecoratorNode<React.JSX.Element> {name: string,outputType: AgentOutputTypeOptionValue,isEditing = false,+ selectNameOnEdit = isEditing,+ openTypeSelectOnEdit = false,outputs: DeclaredOutputConfig[] = [],onChange?: (outputs: DeclaredOutputConfig[], prompt?: string) => void,onEdit?: (name: string, outputType: AgentOutputTypeOptionValue) => void,@@ -52,6 +58,8 @@ export class AgentOutputBlockNode extends DecoratorNode<React.JSX.Element> {this.__name = namethis.__outputType = outputTypethis.__isEditing = isEditing+ this.__selectNameOnEdit = selectNameOnEdit+ this.__openTypeSelectOnEdit = openTypeSelectOnEditthis.__outputs = outputsthis.__onChange = onChangethis.__onEdit = onEdit@@ -74,6 +82,8 @@ export class AgentOutputBlockNode extends DecoratorNode<React.JSX.Element> {name={this.getName()}outputType={this.getOutputType()}isEditing={this.isEditing()}+ selectNameOnEdit={this.shouldSelectNameOnEdit()}+ openTypeSelectOnEdit={this.shouldOpenTypeSelectOnEdit()}outputs={this.getOutputs()}onChange={this.getOnChange()}onEdit={this.getOnEdit()}@@ -106,6 +116,14 @@ export class AgentOutputBlockNode extends DecoratorNode<React.JSX.Element> {return this.getLatest().__isEditing}+ shouldSelectNameOnEdit(): boolean {+ return this.getLatest().__selectNameOnEdit+ }++ shouldOpenTypeSelectOnEdit(): boolean {+ return this.getLatest().__openTypeSelectOnEdit+ }+getOutputs(): DeclaredOutputConfig[] {return this.getLatest().__outputs}@@ -118,6 +136,34 @@ export class AgentOutputBlockNode extends DecoratorNode<React.JSX.Element> {return this.getLatest().__onEdit}+ setOutput(+ name: string,+ outputType: AgentOutputTypeOptionValue,+ isEditing: boolean,+ outputs: DeclaredOutputConfig[],+ onChange?: (outputs: DeclaredOutputConfig[], prompt?: string) => void,+ onEdit?: (name: string, outputType: AgentOutputTypeOptionValue) => void,+ selectNameOnEdit = false,+ openTypeSelectOnEdit = false,+ ): this {+ const writable = this.getWritable()+ writable.__name = name+ writable.__outputType = outputType+ writable.__isEditing = isEditing+ writable.__selectNameOnEdit = selectNameOnEdit+ writable.__openTypeSelectOnEdit = openTypeSelectOnEdit+ writable.__outputs = outputs+ writable.__onChange = onChange+ writable.__onEdit = onEdit+ return writable+ }++ setOpenTypeSelectOnEdit(openTypeSelectOnEdit: boolean): this {+ const writable = this.getWritable()+ writable.__openTypeSelectOnEdit = openTypeSelectOnEdit+ return writable+ }+override getTextContent(): string {return getAgentOutputToken(this.getName())}@@ -130,8 +176,10 @@ export function $createAgentOutputBlockNode(outputs: DeclaredOutputConfig[] = [],onChange?: (outputs: DeclaredOutputConfig[], prompt?: string) => void,onEdit?: (name: string, outputType: AgentOutputTypeOptionValue) => void,+ selectNameOnEdit = isEditing,+ openTypeSelectOnEdit = false,): AgentOutputBlockNode {- return new AgentOutputBlockNode(name, outputType, isEditing, outputs, onChange, onEdit)+ return new AgentOutputBlockNode(name, outputType, isEditing, selectNameOnEdit, openTypeSelectOnEdit, outputs, onChange, onEdit)}export function $isAgentOutputBlockNode(diff --git a/web/app/components/base/prompt-editor/plugins/agent-output-block/utils.ts b/web/app/components/base/prompt-editor/plugins/agent-output-block/utils.tsindex a45152d4f2b..d8bb73aae49 100644--- a/web/app/components/base/prompt-editor/plugins/agent-output-block/utils.ts+++ b/web/app/components/base/prompt-editor/plugins/agent-output-block/utils.ts@@ -17,42 +17,7 @@ export type AgentOutputTypeOption = {const AGENT_OUTPUT_TOKEN_REGEX = /\[§output:([^:§\]]+):([^:§\]]+)§\]/const LEGACY_AGENT_OUTPUT_TOKEN_REGEX = /§output:([^:§\]]+):([^:§\]]+)§/-export const AGENT_OUTPUT_NAME_PATTERN = /^[a-z_][\w.-]*$/i-const AGENT_OUTPUT_FILE_NAME_PATTERN = /^[^.][^/\\:*?"<>|\n\r]*\.([a-z0-9]{1,16})$/i-const AGENT_OUTPUT_FILE_EXTENSION_WHITELIST = new Set([- 'amr',- 'csv',- 'doc',- 'docx',- 'eml',- 'epub',- 'gif',- 'html',- 'jpeg',- 'jpg',- 'm4a',- 'markdown',- 'md',- 'mdx',- 'mov',- 'mp3',- 'mp4',- 'mpeg',- 'mpga',- 'msg',- 'pdf',- 'png',- 'ppt',- 'pptx',- 'svg',- 'txt',- 'wav',- 'webm',- 'webp',- 'xls',- 'xlsx',- 'xml',-])+export const AGENT_OUTPUT_NAME_PATTERN = /^[a-z_]\w*$/iexport function getAgentOutputToken(name: string) {return `[§output:${name}:${name}§]`@@ -85,11 +50,13 @@ export function extractAgentOutputNames(text: string) {}export function replaceAgentOutputName(text: string, oldName: string, nextName: string) {- const replaceTokenName = (match: string, name: string, mirrorName: string) => {+ const replaceTokenName = (match: string, name: string, _mirrorName: string) => {if (name !== oldName)return match- return match.replace(`${name}:${mirrorName}`, `${nextName}:${nextName}`)+ return match.startsWith('[')+ ? getAgentOutputToken(nextName)+ : `§output:${nextName}:${nextName}§`}return text@@ -114,21 +81,6 @@ export function getAgentOutputTypeOption(value: AgentOutputTypeOptionValue) {return AGENT_OUTPUT_TYPE_OPTIONS.find(option => option.value === value) || AGENT_OUTPUT_TYPE_OPTIONS[0]!}-function isSupportedAgentOutputFileName(name: string) {- const match = AGENT_OUTPUT_FILE_NAME_PATTERN.exec(name.trim())- if (!match)- return false-- return AGENT_OUTPUT_FILE_EXTENSION_WHITELIST.has(match[1]!.toLowerCase())-}--export function inferAgentOutputType(name: string, fallbackType: AgentOutputTypeOptionValue): AgentOutputTypeOptionValue {- if (isSupportedAgentOutputFileName(name))- return 'file'-- return fallbackType-}-export function getAgentOutputTypeOptionValue(output: DeclaredOutputConfig): AgentOutputTypeOptionValue {if (output.type !== 'array')return output.typediff --git a/web/app/components/base/prompt-editor/prompt-editor-content.tsx b/web/app/components/base/prompt-editor/prompt-editor-content.tsxindex f193d897201..323334ee478 100644--- a/web/app/components/base/prompt-editor/prompt-editor-content.tsx+++ b/web/app/components/base/prompt-editor/prompt-editor-content.tsx@@ -80,7 +80,7 @@ type ShortcutPopup = {Popup: React.ComponentType<{ onClose: () => void, onInsert: ShortcutPopupInsertHandler }>}-type PromptEditorContentAriaProps = Pick<React.AriaAttributes, 'aria-label' | 'aria-labelledby'>+type PromptEditorContentAriaProps = Pick<React.AriaAttributes, 'aria-controls' | 'aria-haspopup' | 'aria-label' | 'aria-labelledby'>type PromptEditorContentProps = PromptEditorContentAriaProps & {compact?: boolean@@ -112,7 +112,22 @@ type PromptEditorContentProps = PromptEditorContentAriaProps & {onEditorChange: (editorState: EditorState) => void}+const getShortcutPopupKey = (+ hotkey: Hotkey,+ displayMode: ShortcutPopupDisplayMode | undefined,+ Popup: React.ComponentType<{ onClose: () => void, onInsert: ShortcutPopupInsertHandler }>,+) => {+ const hotkeyKey = typeof hotkey === 'function'+ ? hotkey.name || 'custom'+ : JSON.stringify(hotkey)+ const popupKey = Popup.displayName ?? Popup.name ?? 'Popup'++ return `${popupKey}:${displayMode ?? 'default'}:${hotkeyKey}`+}+const PromptEditorContent: FC<PromptEditorContentProps> = ({+ 'aria-controls': ariaControls,+ 'aria-haspopup': ariaHasPopup,'aria-label': ariaLabel,'aria-labelledby': ariaLabelledBy,compact,@@ -148,6 +163,8 @@ const PromptEditorContent: FC<PromptEditorContentProps> = ({<RichTextPlugincontentEditable={(<ContentEditable+ aria-controls={ariaControls}+ aria-haspopup={ariaHasPopup}aria-label={ariaLabel}aria-labelledby={ariaLabelledBy}className={cn(@@ -167,8 +184,8 @@ const PromptEditorContent: FC<PromptEditorContentProps> = ({)}ErrorBoundary={LexicalErrorBoundary}/>- {shortcutPopups.map(({ hotkey, displayMode, Popup }, idx) => (- <ShortcutsPopupPlugin key={idx} hotkey={hotkey} displayMode={displayMode}>+ {shortcutPopups.map(({ hotkey, displayMode, Popup }) => (+ <ShortcutsPopupPlugin key={getShortcutPopupKey(hotkey, displayMode, Popup)} hotkey={hotkey} displayMode={displayMode}>{(closePortal, onInsert) => <Popup onClose={closePortal} onInsert={onInsert} />}</ShortcutsPopupPlugin>))}diff --git a/web/app/components/workflow/nodes/agent-v2/__tests__/panel.spec.tsx b/web/app/components/workflow/nodes/agent-v2/__tests__/panel.spec.tsxindex 6710f730f66..3a9dd081d02 100644--- a/web/app/components/workflow/nodes/agent-v2/__tests__/panel.spec.tsx+++ b/web/app/components/workflow/nodes/agent-v2/__tests__/panel.spec.tsx@@ -13,6 +13,7 @@ const {mockHandleNodeDataUpdateWithSyncDraft,mockInsertNodes,mockOrchestratePanelContentProps,+ mockOutputVarsProps,mockPromptEditorProps,mockCopyFromRosterMutate,mockCopyFromRosterState,@@ -36,6 +37,10 @@ const {nodeId: stringopen: boolean}>,+ mockOutputVarsProps: [] as Array<{+ collapsed?: boolean+ onCollapse?: (collapsed: boolean) => void+ }>,mockPromptEditorProps: [] as PromptEditorProps[],mockCopyFromRosterMutate: vi.fn(),mockCopyFromRosterState: {@@ -56,7 +61,19 @@ const {vi.mock('../../_base/components/output-vars', () => ({__esModule: true,- default: ({ children }: { children: ReactNode }) => <div>{children}</div>,+ default: ({+ children,+ collapsed,+ onCollapse,+ }: {+ children: ReactNode+ collapsed?: boolean+ onCollapse?: (collapsed: boolean) => void+ }) => {+ mockOutputVarsProps.push({ collapsed, onCollapse })++ return <div>{children}</div>+ },VarItem: ({ name, type, description }: { name: string, type: string, description?: string }) => (<div>{`${name}:${type}:${description || ''}`}</div>),@@ -307,6 +324,7 @@ describe('agent/panel', () => {vi.clearAllMocks()mockPromptEditorProps.length = 0mockOrchestratePanelContentProps.length = 0+ mockOutputVarsProps.length = 0mockStoreState.appId = 'app-1'mockStoreState.openInlineAgentPanelNodeId = undefinedmockCopyFromRosterState.isPending = false@@ -1054,10 +1072,33 @@ describe('agent/panel', () => {mockPromptEditorProps[0]?.agentOutputBlock?.onEdit?.('summary', 'string')})+ expect(mockOutputVarsProps.at(-1)?.collapsed).toBe(false)expect(screen.getByRole('form', { name: 'workflow.nodes.agent.outputVars.editorLabel' })).toBeInTheDocument()expect(screen.getByRole('textbox', { name: 'workflow.nodes.agent.outputVars.nameLabel' })).toHaveValue('summary')})+ it('expands output variables when an agent task output token changes declared outputs', () => {+ render(+ <AgentV2Panel+ id="agent-node"+ data={createData()}+ panelProps={panelProps}+ />,+ )++ expect(mockOutputVarsProps.at(-1)?.collapsed).toBe(true)++ act(() => {+ mockPromptEditorProps[0]?.agentOutputBlock?.onChange?.([{+ name: 'summary',+ type: 'string',+ required: false,+ }], 'Generate [§output:summary:summary§]')+ })++ expect(mockOutputVarsProps.at(-1)?.collapsed).toBe(false)+ })+it('opens the output variable editor for a prompt token missing from declared outputs', () => {render(<AgentV2Paneldiff --git a/web/app/components/workflow/nodes/agent-v2/components/__tests__/agent-orchestrate-panel-content.spec.tsx b/web/app/components/workflow/nodes/agent-v2/components/__tests__/agent-orchestrate-panel-content.spec.tsxindex ecfdf41932e..8a6fa0106ed 100644--- a/web/app/components/workflow/nodes/agent-v2/components/__tests__/agent-orchestrate-panel-content.spec.tsx+++ b/web/app/components/workflow/nodes/agent-v2/components/__tests__/agent-orchestrate-panel-content.spec.tsx@@ -14,6 +14,8 @@ const mocks = vi.hoisted(() => ({saveBuildDraft: vi.fn(),saveAgentSoulConfig: vi.fn(),saveDraft: vi.fn(),+ uploadAgentSandboxFile: vi.fn(),+ uploadWorkflowSandboxFile: vi.fn(),}))vi.mock('@/app/components/header/account-setting/model-provider-page/hooks', () => ({@@ -135,6 +137,38 @@ vi.mock('@/app/components/workflow/nodes/agent-v2/agent-soul-config', () => ({}))vi.mock('@/service/client', () => ({+ consoleClient: {+ agent: {+ byAgentId: {+ sandbox: {+ files: {+ upload: {+ post: mocks.uploadAgentSandboxFile,+ },+ },+ },+ },+ },+ apps: {+ byAppId: {+ workflowRuns: {+ byWorkflowRunId: {+ agentNodes: {+ byNodeId: {+ sandbox: {+ files: {+ upload: {+ post: mocks.uploadWorkflowSandboxFile,+ },+ },+ },+ },+ },+ },+ },+ },+ },+ },consoleQuery: {agent: {byAgentId: {@@ -225,6 +259,11 @@ vi.mock('@/service/client', () => ({}),},},+ upload: {+ post: {+ mutationOptions: () => ({ mutationFn: mocks.uploadAgentSandboxFile }),+ },+ },},},},@@ -260,6 +299,11 @@ vi.mock('@/service/client', () => ({}),},},+ upload: {+ post: {+ mutationOptions: () => ({ mutationFn: mocks.uploadWorkflowSandboxFile }),+ },+ },},},},@@ -368,6 +412,8 @@ describe('WorkflowInlineAgentConfigureWorkspace', () => {})mocks.saveDraft.mockResolvedValue(createInlineComposerState())mocks.saveAgentSoulConfig.mockResolvedValue(createInlineComposerState())+ mocks.uploadAgentSandboxFile.mockResolvedValue({ url: 'https://example.com/agent-sandbox-file' })+ mocks.uploadWorkflowSandboxFile.mockResolvedValue({ url: 'https://example.com/workflow-sandbox-file' })})afterEach(() => {@@ -394,6 +440,19 @@ describe('WorkflowInlineAgentConfigureWorkspace', () => {)}+ async function restartCurrentChat() {+ fireEvent.click(screen.getByRole('button', {+ name: 'agentV2.agentDetail.configure.preview.restart',+ }))++ const confirmDialog = await screen.findByRole('alertdialog', {+ name: 'agentV2.agentDetail.configure.clearSessionConfirm.title',+ })+ expect(confirmDialog).toBeInTheDocument()++ fireEvent.click(screen.getByRole('button', { name: 'common.operation.confirm' }))+ }+describe('Working Directory', () => {it('should show save-to-roster in the configure header menu without rendering the old action bar', async () => {renderWorkspace({@@ -613,9 +672,7 @@ describe('WorkflowInlineAgentConfigureWorkspace', () => {})expect(await screen.findByRole('region', { name: 'build-chat' })).toHaveTextContent('build:inline-debug-conversation-1')- fireEvent.click(screen.getByRole('button', {- name: 'agentV2.agentDetail.configure.preview.restart',- }))+ await restartCurrentChat()await waitFor(() => expect(mocks.refreshDebugConversation).toHaveBeenCalledWith({params: {@@ -726,9 +783,7 @@ describe('WorkflowInlineAgentConfigureWorkspace', () => {await waitFor(() => expect(screen.getByRole('region', { name: 'build-chat' })).toHaveTextContent('build:build-conversation-new'))fireEvent.click(screen.getByRole('button', { name: 'fail build conversation' }))- fireEvent.click(screen.getByRole('button', {- name: 'agentV2.agentDetail.configure.preview.restart',- }))+ await restartCurrentChat()await waitFor(() => expect(mocks.deleteBuildDraft).toHaveBeenCalledWith({params: {diff --git a/web/app/components/workflow/nodes/agent-v2/components/agent-output-variables/__tests__/index.spec.tsx b/web/app/components/workflow/nodes/agent-v2/components/agent-output-variables/__tests__/index.spec.tsxindex 2772d850f06..114cfb1a0e6 100644--- a/web/app/components/workflow/nodes/agent-v2/components/agent-output-variables/__tests__/index.spec.tsx+++ b/web/app/components/workflow/nodes/agent-v2/components/agent-output-variables/__tests__/index.spec.tsx@@ -181,4 +181,23 @@ describe('AgentOutputVariables', () => {}],}])})++ it('should reject editing an output name with dots', async () => {+ const user = userEvent.setup()+ const onChange = vi.fn()+ const outputs: DeclaredOutputConfig[] = [{+ name: 'summary',+ type: 'string',+ required: true,+ }]++ render(<AgentOutputVariables outputs={outputs} onChange={onChange} />)++ await expandOutputVars(user)+ await user.click(getEditButton('summary'))+ await confirmEditorName(user, 'report.summary')++ expect(screen.getByText('workflow.nodes.agent.outputVars.nameInvalid')).toBeInTheDocument()+ expect(onChange).not.toHaveBeenCalled()+ })})diff --git a/web/app/components/workflow/nodes/agent-v2/components/agent-output-variables/index.tsx b/web/app/components/workflow/nodes/agent-v2/components/agent-output-variables/index.tsxindex 35676cfbc76..5f832a961ec 100644--- a/web/app/components/workflow/nodes/agent-v2/components/agent-output-variables/index.tsx+++ b/web/app/components/workflow/nodes/agent-v2/components/agent-output-variables/index.tsx@@ -109,10 +109,14 @@ function ChildOutputFrame({ children, depth }: { children: ReactNode, depth: numexport function AgentOutputVariables({outputs,onChange,+ collapsed,+ onCollapse,}: AgentOutputVariablesProps) {const { t } = useTranslation()const [editingState, setEditingState] = useState<EditingState | null>(null)- const [collapsed, setCollapsed] = useState(true)+ const [internalCollapsed, setInternalCollapsed] = useState(true)+ const isCollapsed = collapsed ?? internalCollapsed+ const handleCollapseChange = onCollapse ?? setInternalCollapsedfunction handleNewOutput() {setEditingState({ draft: createDraft() })}@@ -214,7 +218,7 @@ export function AgentOutputVariables({)}return (- <OutputVars collapsed={collapsed} onCollapse={setCollapsed}>+ <OutputVars collapsed={isCollapsed} onCollapse={handleCollapseChange}><div className="pb-2"><div className="flex flex-col">{outputs.map((output, index) => {diff --git a/web/app/components/workflow/nodes/agent-v2/components/agent-output-variables/utils.ts b/web/app/components/workflow/nodes/agent-v2/components/agent-output-variables/utils.tsindex 4d21da3e7c3..5e2695a4a3d 100644--- a/web/app/components/workflow/nodes/agent-v2/components/agent-output-variables/utils.ts+++ b/web/app/components/workflow/nodes/agent-v2/components/agent-output-variables/utils.ts@@ -40,6 +40,8 @@ export type EditingState = {export type AgentOutputVariablesProps = {outputs: DeclaredOutputConfig[]onChange: (outputs: DeclaredOutputConfig[]) => void+ collapsed?: boolean+ onCollapse?: (collapsed: boolean) => void}export const OUTPUT_NAME_PATTERN = /^[a-z_]\w*$/idiff --git a/web/app/components/workflow/nodes/agent-v2/panel.tsx b/web/app/components/workflow/nodes/agent-v2/panel.tsxindex e30121e7cab..48637fb4aa2 100644--- a/web/app/components/workflow/nodes/agent-v2/panel.tsx+++ b/web/app/components/workflow/nodes/agent-v2/panel.tsx@@ -62,7 +62,7 @@ function FloatingOutputEditor({return createPortal(<div- className="fixed z-60 w-[400px]"+ className="fixed z-50 w-[400px]"style={{left: position.left,top: position.top,@@ -106,6 +106,7 @@ export function AgentV2Panel({const [isInlineAgentPanelOpenedFromTrigger, setIsInlineAgentPanelOpenedFromTrigger] = useState(false)const [isSaveToRosterDialogOpen, setIsSaveToRosterDialogOpen] = useState(false)const [editingOutputFromTask, setEditingOutputFromTask] = useState<{ name: string, outputType: AgentOutputTypeOptionValue, position: { left: number, top: number }, requestKey: number } | null>(null)+ const [isOutputVariablesCollapsed, setIsOutputVariablesCollapsed] = useState(true)const [saveToRosterSessionKey, setSaveToRosterSessionKey] = useState(0)const { handleNodeDataUpdate, handleNodeDataUpdateWithSyncDraft } = useNodeDataUpdate()const openInlineAgentPanelNodeId = useStore(state => state.openInlineAgentPanelNodeId)@@ -401,6 +402,7 @@ export function AgentV2Panel({}, [createInlineAgentBinding, handleInlineAgentBindingCreated, id, inlineAgentQuery, isCreatingInlineAgent, isInlineAgentPending, isInlineAgentReady, setOpenInlineAgentPanelNodeId])const handleDeclaredOutputsChange = useCallback((outputs: ReturnType<typeof getAgentV2DeclaredOutputs>, agentTask?: string) => {+ setIsOutputVariablesCollapsed(false)const previousOutputs = getAgentV2DeclaredOutputs(inputsRef.current)let nextAgentTask = agentTasklet nextOutputs = outputs@@ -457,6 +459,7 @@ export function AgentV2Panel({}, [handleNodeDataUpdateWithSyncDraft, id])const handleEditTaskOutput = useCallback((name: string, outputType: AgentOutputTypeOptionValue) => {+ setIsOutputVariablesCollapsed(false)const panelRect = drawerPortalContainerRef.current?.getBoundingClientRect()const editorWidth = 400const gap = 24@@ -557,7 +560,9 @@ export function AgentV2Panel({<AgentAdvancedSettings /><div><AgentOutputVariables+ collapsed={isOutputVariablesCollapsed}outputs={declaredOutputs}+ onCollapse={setIsOutputVariablesCollapsed}onChange={handleDeclaredOutputsChange}/></div>diff --git a/web/features/agent-v2/AGENTS.md b/web/features/agent-v2/AGENTS.mdnew file mode 100644index 00000000000..c5069673066--- /dev/null+++ b/web/features/agent-v2/AGENTS.md@@ -0,0 +1,3 @@+## Agent V2 Frontend++- Keep Agent V2 separate from legacy workflow Agent. Use `web/features/agent-v2`, `web/app/components/workflow/nodes/agent-v2`, the `agent_node_kind: 'dify_agent'` and `version: '2'` payload discriminator, and `BlockEnum.AgentV2` where the graph type is already migrated. Do not bridge Agent V2 to legacy `agent_strategy_*` behavior or data shapes.diff --git a/web/features/agent-v2/agent-detail/__tests__/navigation.spec.tsx b/web/features/agent-v2/agent-detail/__tests__/navigation.spec.tsxindex acc67ea7389..f3e63cd4c0a 100644--- a/web/features/agent-v2/agent-detail/__tests__/navigation.spec.tsx+++ b/web/features/agent-v2/agent-detail/__tests__/navigation.spec.tsx@@ -1,5 +1,7 @@import type { AgentAppDetailWithSite } from '@dify/contracts/api/console/agent/types.gen'+import { QueryClient, QueryClientProvider } from '@tanstack/react-query'import { render, screen } from '@testing-library/react'+import userEvent from '@testing-library/user-event'import { AgentDetailSection, AgentDetailTop } from '../navigation'const mocks = vi.hoisted(() => ({@@ -34,6 +36,36 @@ vi.mock('@/app/components/base/divider', () => ({default: () => <div data-testid="divider" />,}))+vi.mock('@/service/client', () => ({+ consoleQuery: {+ agent: {+ byAgentId: {+ get: {+ queryKey: ({ input }: { input: { params: { agent_id: string } } }) => ['agent-detail', input.params.agent_id],+ queryOptions: () => ({ queryKey: ['agent-detail'] }),+ },+ copy: {+ post: {+ mutationOptions: () => ({+ mutationFn: vi.fn(),+ }),+ },+ },+ delete: {+ mutationOptions: () => ({+ mutationFn: vi.fn(),+ }),+ },+ put: {+ mutationOptions: () => ({+ mutationFn: vi.fn(),+ }),+ },+ },+ },+ },+}))+const createAgent = (overrides: Partial<AgentAppDetailWithSite> = {}): AgentAppDetailWithSite => ({description: 'Find and summarize market materials.',enable_api: true,@@ -49,6 +81,16 @@ const createAgent = (overrides: Partial<AgentAppDetailWithSite> = {}): AgentAppD...overrides,})+function renderAgentDetailSection(expand = true) {+ const queryClient = new QueryClient()++ return render(+ <QueryClientProvider client={queryClient}>+ <AgentDetailSection expand={expand} />+ </QueryClientProvider>,+ )+}+describe('AgentDetailSection', () => {beforeEach(() => {mocks.pathname = '/roster/agent/agent-1/configure'@@ -56,7 +98,7 @@ describe('AgentDetailSection', () => {})it('renders the current agent avatar, name, and role', () => {- const { container } = render(<AgentDetailSection />)+ const { container } = renderAgentDetailSection()const agentName = screen.getByText('Research Agent')const agentAvatar = container.querySelector('em-emoji')?.parentElement@@ -67,8 +109,29 @@ describe('AgentDetailSection', () => {expect(container.querySelector('em-emoji')).toHaveAttribute('id', '🧪')expect(agentAvatar).toHaveClass('h-10', 'w-10', 'rounded-full')expect(agentAvatar?.parentElement?.parentElement).toHaveClass('mr-2')- expect(agentName.parentElement).toHaveClass('h-10')- expect(agentName.parentElement?.parentElement).toHaveClass('h-13', 'py-1.5', 'pl-1.5', 'pr-2')+ expect(agentName.parentElement?.parentElement).toHaveClass('h-10')+ expect(agentName.parentElement?.parentElement?.parentElement).toHaveClass('h-13', 'py-1.5', 'pl-1.5', 'pr-2')+ })++ it('renders compact more actions beside the expanded sidebar agent identity', async () => {+ const user = userEvent.setup()+ renderAgentDetailSection()++ const trigger = screen.getByRole('button', { name: /agentV2\.roster\.moreActions/ })+ expect(trigger).toHaveClass('size-6')+ expect(trigger).toHaveClass('hover:bg-state-base-hover')++ await user.click(trigger)++ expect(screen.getByRole('menuitem', { name: 'agentV2.roster.editInfo' })).toBeInTheDocument()+ expect(screen.getByRole('menuitem', { name: 'common.operation.duplicate' })).toBeInTheDocument()+ expect(screen.getByRole('menuitem', { name: 'common.operation.delete' })).toBeInTheDocument()+ })++ it('does not render more actions in collapsed sidebar mode', () => {+ renderAgentDetailSection(false)++ expect(screen.queryByRole('button', { name: /agentV2\.roster\.moreActions/ })).not.toBeInTheDocument()})})diff --git a/web/features/agent-v2/agent-detail/access/components/__tests__/access-surface-cards.spec.tsx b/web/features/agent-v2/agent-detail/access/components/__tests__/access-surface-cards.spec.tsxindex fabf9a736ea..9af16c2a58f 100644--- a/web/features/agent-v2/agent-detail/access/components/__tests__/access-surface-cards.spec.tsx+++ b/web/features/agent-v2/agent-detail/access/components/__tests__/access-surface-cards.spec.tsx@@ -295,7 +295,12 @@ describe('Agent access surface cards', () => {it('should save settings through the backing app id and update the agent detail cache', async () => {const user = userEvent.setup()- const agent = createAgent()+ const agent = createAgent({+ site: {+ ...createAgent().site!,+ icon_url: 'https://files.example.test/old-icon.png',+ },+ })mocks.siteMutation.mockResolvedValueOnce({app_id: 'app-1',code: 'new-site-token',@@ -349,12 +354,65 @@ describe('Agent access surface cards', () => {access_token: 'new-site-token',chat_color_theme: '#123456',description: 'Updated web description.',+ icon_url: null,title: 'Support Portal',},})expect(invalidateSpy).toHaveBeenCalledWith({ queryKey: ['agent-detail', 'agent-1'] })})+ it('should fall back to the Agent icon tuple when WebApp site icon data is missing', async () => {+ const user = userEvent.setup()+ const agent = createAgent({+ icon: 'agent-image-file-id',+ icon_background: null,+ icon_type: 'image',+ icon_url: 'https://files.example.test/agent-icon.png',+ site: {+ ...createAgent().site!,+ icon: null,+ icon_background: null,+ icon_type: null,+ icon_url: null,+ },+ })+ mocks.siteMutation.mockResolvedValueOnce({+ app_id: 'app-1',+ code: 'site-token',+ copyright: '',+ custom_disclaimer: '',+ customize_domain: null,+ customize_token_strategy: 'allow',+ default_language: 'en-US',+ description: 'Support Agent',+ icon: 'agent-image-file-id',+ icon_background: null,+ privacy_policy: '',+ prompt_public: false,+ show_workflow_steps: false,+ title: 'Support Agent',+ use_icon_as_answer_icon: false,+ })++ renderWithQueryClient(+ <WebAppAccessCard agent={agent} agentId="agent-1" isLoading={false} />,+ )++ await user.click(screen.getByRole('button', { name: 'agentV2.agentDetail.access.webApp.actions.settings' }))+ const dialog = await screen.findByRole('dialog', { name: 'appOverview.overview.appInfo.settings.title' })+ expect(within(dialog).getByAltText('app icon')).toHaveAttribute('src', 'https://files.example.test/agent-icon.png')++ await user.click(within(dialog).getByRole('button', { name: 'common.operation.save' }))++ await waitFor(() => {+ expect(mocks.siteMutation.mock.calls[0]?.[0].body).toEqual(expect.objectContaining({+ icon: 'agent-image-file-id',+ icon_background: undefined,+ icon_type: 'image',+ }))+ })+ })+it('should keep embedded disabled until the backing app id and web app token are available', () => {renderWithQueryClient(<WebAppAccessCarddiff --git a/web/features/agent-v2/agent-detail/access/components/web-app-access-card.tsx b/web/features/agent-v2/agent-detail/access/components/web-app-access-card.tsxindex 60b4b2d6241..8086075fd2b 100644--- a/web/features/agent-v2/agent-detail/access/components/web-app-access-card.tsx+++ b/web/features/agent-v2/agent-detail/access/components/web-app-access-card.tsx@@ -3,6 +3,7 @@import type { AgentAppDetailWithSite } from '@dify/contracts/api/console/agent/types.gen'import type { AppSiteUpdatePayload } from '@dify/contracts/api/console/apps/types.gen'import type { ConfigParams, SettingsAppInfo } from '@/app/components/app/overview/settings'+import type { AppIconType } from '@/types/app'import { Button } from '@langgenius/dify-ui/button'import { toast } from '@langgenius/dify-ui/toast'import { useMutation, useQueryClient } from '@tanstack/react-query'@@ -156,7 +157,7 @@ export function WebAppAccessCard({access_token: updatedSite.code ?? agentDetail.site?.access_token ?? agentDetail.site?.code ?? null,code: updatedSite.code ?? agentDetail.site?.code ?? agentDetail.site?.access_token ?? null,app_base_url: agentDetail.site?.app_base_url ?? site?.app_base_url ?? null,- icon_url: agentDetail.site?.icon_url ?? null,+ icon_url: null,},}: agentDetail,@@ -287,6 +288,7 @@ function createSettingsAppInfo(agent: AgentAppDetailWithSite): SettingsAppInfo |const appId = agent.app_idif (!site || !appId)return null+ const icon = getSettingsIcon(agent)return {id: appId,@@ -301,18 +303,50 @@ function createSettingsAppInfo(agent: AgentAppDetailWithSite): SettingsAppInfo |privacy_policy: site.privacy_policy ?? '',custom_disclaimer: site.custom_disclaimer ?? '',input_placeholder: site.input_placeholder ?? '',- icon_type: site.icon_type === 'image' || site.icon_type === 'emoji' || site.icon_type === 'link'- ? site.icon_type- : 'emoji',- icon: site.icon ?? agent.icon ?? '',- icon_background: site.icon_background ?? agent.icon_background ?? null,- icon_url: site.icon_url ?? null,+ icon_type: icon.icon_type,+ icon: icon.icon,+ icon_background: icon.icon_background,+ icon_url: icon.icon_url,show_workflow_steps: site.show_workflow_steps ?? false,use_icon_as_answer_icon: site.use_icon_as_answer_icon ?? false,},}}+function isAppIconType(iconType: unknown): iconType is AppIconType {+ return iconType === 'image' || iconType === 'emoji' || iconType === 'link'+}++function getSettingsIcon(agent: AgentAppDetailWithSite) {+ const site = agent.site+ if (site && isAppIconType(site.icon_type) && site.icon) {+ return {+ icon_type: site.icon_type,+ icon: site.icon,+ icon_background: site.icon_background ?? null,+ icon_url: site.icon_url ?? null,+ }+ }++ if (isAppIconType(agent.icon_type) && agent.icon) {+ return {+ icon_type: agent.icon_type,+ icon: agent.icon,+ icon_background: agent.icon_background ?? null,+ icon_url: agent.icon_type === 'image' || agent.icon_type === 'link'+ ? agent.icon_url+ : null,+ }+ }++ return {+ icon_type: 'emoji' as const,+ icon: '',+ icon_background: null,+ icon_url: null,+ }+}+function getAgentWebAppUrl(agent?: AgentAppDetailWithSite) {const site = agent?.siteconst token = site?.access_token ?? site?.codediff --git a/web/features/agent-v2/agent-detail/configure/__tests__/model-compatibility.spec.ts b/web/features/agent-v2/agent-detail/configure/__tests__/model-compatibility.spec.tsindex 75f9e827220..1a17dd2e773 100644--- a/web/features/agent-v2/agent-detail/configure/__tests__/model-compatibility.spec.ts+++ b/web/features/agent-v2/agent-detail/configure/__tests__/model-compatibility.spec.ts@@ -146,7 +146,7 @@ describe('isAgentSuggestedModel', () => {expect(isAgentSuggestedModel(provider, createModelItem('Claude Opus 4.8'))).toBe(true)expect(isAgentSuggestedModel(provider, createModelItem('opus-4.7'))).toBe(true)expect(isAgentSuggestedModel(provider, createModelItem('Claude Sonnet 4.6'))).toBe(true)- expect(isAgentSuggestedModel(provider, createModelItem('Gemini 3.1 Pro Preview'))).toBe(true)+ expect(isAgentSuggestedModel(provider, createModelItem('Gemini 3.1 Pro Preview'))).toBe(false)expect(isAgentSuggestedModel(provider, createModelItem('Gemini 3.1 Pro Preview 001'))).toBe(false)expect(isAgentSuggestedModel(provider, createModelItem('grok-4.3'))).toBe(true)expect(isAgentSuggestedModel(provider, createModelItem('deepseek-v4-pro'))).toBe(true)diff --git a/web/features/agent-v2/agent-detail/configure/components/__tests__/agent-prompt-editor.spec.tsx b/web/features/agent-v2/agent-detail/configure/components/__tests__/agent-prompt-editor.spec.tsxindex cff644ef134..9ee09398606 100644--- a/web/features/agent-v2/agent-detail/configure/components/__tests__/agent-prompt-editor.spec.tsx+++ b/web/features/agent-v2/agent-detail/configure/components/__tests__/agent-prompt-editor.spec.tsx@@ -2,6 +2,7 @@ import type { ReactNode } from 'react'import type { PromptEditorProps } from '@/app/components/base/prompt-editor'import type { AgentTool } from '@/features/agent-v2/agent-composer/form-state'import { fireEvent, render, screen, waitFor } from '@testing-library/react'+import userEvent from '@testing-library/user-event'import { createStore, Provider as JotaiProvider } from 'jotai'import { API_PREFIX } from '@/config'import { defaultAgentSoulConfigFormState } from '@/features/agent-v2/agent-composer/form-state'@@ -97,7 +98,15 @@ vi.mock('@/app/components/base/prompt-editor', () => ({return (<div>- <div role="textbox" aria-label={String(props.placeholder)} />+ <div+ role="textbox"+ aria-controls={props['aria-controls']}+ aria-haspopup={props['aria-haspopup']}+ aria-label={String(props.placeholder)}+ tabIndex={0}+ >+ {String(props.value ?? '')}+ </div>{props.children}</div>)@@ -235,9 +244,20 @@ const renderAgentPromptEditor = (}}+const syncSlashMenuFromEditor = (textbox = screen.getByRole('textbox')) => {+ fireEvent.keyDown(textbox, { key: '/' })+ fireEvent.keyUp(textbox, { key: '/' })+}++const openSlashMenuFromEditor = async (textbox = screen.getByRole('textbox')) => {+ syncSlashMenuFromEditor(textbox)+ return screen.findByRole('dialog', { name: /agentDetail\.configure\.prompt\.insert\.label/i })+}+describe('AgentPromptEditor', () => {beforeEach(() => {vi.clearAllMocks()+ window.getSelection()?.removeAllRanges()mockConfigFiles.current = []mockLexical.selection = nullmockLexical.rootChildren = []@@ -404,7 +424,7 @@ describe('AgentPromptEditor', () => {// Prompt slash commands should use the Agent Roster category menu and replace it with submenus.describe('Slash Commands', () => {it('should open category menu, show skill submenu, and append the selected reference', async () => {- const { store, rerenderWithValue } = renderAgentPromptEditor('Review these tenders')+ const { store, rerenderWithValue, container } = renderAgentPromptEditor('Review these tenders')expect(mockPromptEditor).toHaveBeenCalledWith(expect.objectContaining({disableBracePicker: true,@@ -414,8 +434,9 @@ describe('AgentPromptEditor', () => {}),}))- expect(fireEvent.keyDown(screen.getByRole('textbox'), { key: '/' })).toBe(true)rerenderWithValue('Review these tenders/')+ await openSlashMenuFromEditor()+ expect(container).toContainElement(screen.getByRole('dialog', { name: /agentDetail\.configure\.prompt\.insert\.label/i }))expect(screen.getByRole('button', { name: /agentDetail\.configure\.skills\.label/i })).toBeInTheDocument()fireEvent.click(screen.getByRole('button', { name: /agentDetail\.configure\.skills\.label/i }))@@ -429,6 +450,149 @@ describe('AgentPromptEditor', () => {})})+ it('should support keyboard navigation and selection in the slash menu', async () => {+ const user = userEvent.setup()+ const { store } = renderAgentPromptEditor('Review these tenders/')+ const textbox = screen.getByRole('textbox')++ textbox.focus()+ await openSlashMenuFromEditor(textbox)++ const skillsCategory = screen.getByRole('button', { name: /agentDetail\.configure\.skills\.label/i })+ const filesCategory = screen.getByRole('button', { name: /agentDetail\.configure\.files\.label/i })+ await waitFor(() => {+ expect(textbox).toHaveFocus()+ expect(textbox).toHaveAttribute('aria-controls', 'agent-configure-prompt-slash-menu')+ expect(textbox).toHaveAttribute('aria-haspopup', 'dialog')+ })++ await user.keyboard('{ArrowDown}')+ await waitFor(() => {+ expect(textbox).toHaveFocus()+ expect(skillsCategory).toHaveAttribute('data-agent-prompt-menu-active')+ })+ await user.keyboard('{ArrowDown}')+ await waitFor(() => {+ expect(textbox).toHaveFocus()+ expect(filesCategory).toHaveAttribute('data-agent-prompt-menu-active')+ })+ await user.keyboard('{ArrowRight}')+ await waitFor(() => {+ expect(textbox).toHaveFocus()+ expect(screen.getByRole('button', { name: /agentDetail\.configure\.files\.label/i })).toHaveAttribute('data-agent-prompt-menu-active')+ })+ await user.keyboard('{ArrowLeft}')+ await waitFor(() => {+ expect(textbox).toHaveFocus()+ expect(screen.getByRole('button', { name: /agentDetail\.configure\.files\.label/i })).toHaveAttribute('data-agent-prompt-menu-active')+ expect(screen.getByRole('button', { name: /agentDetail\.configure\.skills\.label/i })).not.toHaveAttribute('data-agent-prompt-menu-active')+ })+ await user.keyboard('{ArrowUp}')+ await waitFor(() => {+ expect(textbox).toHaveFocus()+ expect(screen.getByRole('button', { name: /agentDetail\.configure\.skills\.label/i })).toHaveAttribute('data-agent-prompt-menu-active')+ })+ await user.keyboard('{ArrowRight}')+ await waitFor(() => {+ expect(textbox).toHaveFocus()+ expect(screen.getByRole('button', { name: /agentDetail\.configure\.skills\.label/i })).toHaveAttribute('data-agent-prompt-menu-active')+ })++ await user.keyboard('{ArrowDown}')+ await waitFor(() => {+ expect(textbox).toHaveFocus()+ expect(screen.getByRole('button', { name: /Playwright/i })).toHaveAttribute('data-agent-prompt-menu-active')+ })+ await user.keyboard('{Enter}')++ expect(store.get(agentComposerPromptAtom)).toBe('Review these tenders [§skill:playwright:Playwright§]')+ await waitFor(() => {+ expect(screen.queryByRole('dialog', { name: /agentDetail\.configure\.prompt\.insert\.label/i })).not.toBeInTheDocument()+ })+ })++ it('should keep editor focus when selecting slash menu items with a pointer', async () => {+ const user = userEvent.setup()+ const { store } = renderAgentPromptEditor('Review these tenders/')+ const textbox = screen.getByRole('textbox')++ textbox.focus()+ await openSlashMenuFromEditor(textbox)++ await user.click(screen.getByRole('button', { name: /agentDetail\.configure\.skills\.label/i }))+ await waitFor(() => {+ expect(textbox).toHaveFocus()+ expect(screen.getByRole('button', { name: /Playwright/i })).toBeInTheDocument()+ })++ await user.click(screen.getByRole('button', { name: /Playwright/i }))++ expect(store.get(agentComposerPromptAtom)).toBe('Review these tenders [§skill:playwright:Playwright§]')+ await waitFor(() => {+ expect(screen.queryByRole('dialog', { name: /agentDetail\.configure\.prompt\.insert\.label/i })).not.toBeInTheDocument()+ })+ })++ it('should close the slash menu with Escape and restore focus to the editor', async () => {+ renderAgentPromptEditor('Review/')+ const textbox = screen.getByRole('textbox')++ textbox.focus()+ await openSlashMenuFromEditor(textbox)++ await waitFor(() => {+ expect(textbox).toHaveFocus()+ })++ fireEvent.keyDown(textbox, { key: 'Escape' })++ await waitFor(() => {+ expect(screen.queryByRole('dialog', { name: /agentDetail\.configure\.prompt\.insert\.label/i })).not.toBeInTheDocument()+ })+ await waitFor(() => {+ expect(textbox).toHaveFocus()+ })+ })++ it('should keep focus in the editor and position the menu from the typed slash', async () => {+ const getClientRectsSpy = vi.spyOn(Range.prototype, 'getClientRects').mockImplementation(function (this: Range) {+ const rect = this.collapsed+ ? DOMRect.fromRect({ x: 480, y: 76, width: 0, height: 18 })+ : DOMRect.fromRect({ x: 82, y: 76, width: 8, height: 18 })+ return [rect] as unknown as DOMRectList+ })+ const getBoundingClientRectSpy = vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation(() => (+ DOMRect.fromRect({ x: 10, y: 50, width: 500, height: 240 })+ ))++ try {+ renderAgentPromptEditor('Review/')+ const textbox = screen.getByRole('textbox')+ const textNode = textbox.firstChild+ expect(textNode).not.toBeNull()++ const range = document.createRange()+ range.setStart(textNode!, 'Review/'.length)+ range.setEnd(textNode!, 'Review/'.length)+ const selection = window.getSelection()+ selection?.removeAllRanges()+ selection?.addRange(range)++ textbox.focus()+ const slashMenu = await openSlashMenuFromEditor(textbox)+ expect(textbox).toHaveFocus()+ expect(slashMenu).toHaveStyle({+ left: '80px',+ top: '48px',+ })+ }+ finally {+ window.getSelection()?.removeAllRanges()+ getClientRectsSpy.mockRestore()+ getBoundingClientRectSpy.mockRestore()+ }+ })+it('should replace the slash at the current lexical selection instead of appending', async () => {const textNode = {__text: true as const,@@ -447,8 +611,15 @@ describe('AgentPromptEditor', () => {},}const { store } = renderAgentPromptEditor('Review / now')-- fireEvent.keyDown(screen.getByRole('textbox'), { key: '/' })+ const textbox = screen.getByRole('textbox')+ const range = document.createRange()+ range.setStart(textbox.firstChild!, 'Review /'.length)+ range.setEnd(textbox.firstChild!, 'Review /'.length)+ window.getSelection()?.removeAllRanges()+ window.getSelection()?.addRange(range)+ textbox.focus()++ await openSlashMenuFromEditor(textbox)fireEvent.click(screen.getByRole('button', { name: /agentDetail\.configure\.skills\.label/i }))fireEvent.click(screen.getByRole('button', { name: /Playwright/i }))@@ -473,7 +644,7 @@ describe('AgentPromptEditor', () => {})it('should insert references after prompt add actions create skills, files, or knowledge retrievals', () => {- const onSelect = vi.fn()+ const onInsertToken = vi.fn()const categories = [{ key: 'skills' as const, label: 'Skills', icon: 'i-ri-box-3-line' },{ key: 'files' as const, label: 'Files', icon: 'i-ri-file-line' },@@ -487,17 +658,17 @@ describe('AgentPromptEditor', () => {categories={categories}skills={[]}files={[]}- tools={[]}+ configuredTools={[]}onAddProviderTools={vi.fn()}onAddSkill={options => options?.onAdded?.({ id: 'skill-1', name: 'Skill One' })}- retrievals={[]}+ knowledgeRetrievals={[]}onBack={vi.fn()}onOpenCategory={vi.fn()}- onSelect={onSelect}+ onInsertToken={onInsertToken}/>,)fireEvent.click(screen.getByRole('button', { name: /agentDetail\.configure\.skills\.add/i }))- expect(onSelect).toHaveBeenCalledWith('[§skill:skill-1:Skill One§]')+ expect(onInsertToken).toHaveBeenCalledWith('[§skill:skill-1:Skill One§]')rerender(<AgentPromptSlashMenu@@ -505,17 +676,17 @@ describe('AgentPromptEditor', () => {categories={categories}skills={[]}files={[]}- tools={[]}+ configuredTools={[]}onAddProviderTools={vi.fn()}onAddFile={options => options?.onAdded?.({ id: 'file-1', name: 'Guide.md', icon: 'markdown', configName: 'Guide.md' })}- retrievals={[]}+ knowledgeRetrievals={[]}onBack={vi.fn()}onOpenCategory={vi.fn()}- onSelect={onSelect}+ onInsertToken={onInsertToken}/>,)fireEvent.click(screen.getByRole('button', { name: /agentDetail\.configure\.files\.add/i }))- expect(onSelect).toHaveBeenCalledWith('[§file:Guide.md:Guide.md§]')+ expect(onInsertToken).toHaveBeenCalledWith('[§file:Guide.md:Guide.md§]')rerender(<AgentPromptSlashMenu@@ -523,17 +694,17 @@ describe('AgentPromptEditor', () => {categories={categories}skills={[]}files={[]}- tools={[]}+ configuredTools={[]}onAddProviderTools={vi.fn()}onAddKnowledge={options => options?.onAdded?.({ id: 'retrieval-1', name: 'Retrieval One', queryMode: 'agent' })}- retrievals={[]}+ knowledgeRetrievals={[]}onBack={vi.fn()}onOpenCategory={vi.fn()}- onSelect={onSelect}+ onInsertToken={onInsertToken}/>,)fireEvent.click(screen.getByRole('button', { name: /agentDetail\.configure\.knowledgeRetrieval\.add/i }))- expect(onSelect).toHaveBeenCalledWith('[§knowledge:retrieval-1:Retrieval One§]')+ expect(onInsertToken).toHaveBeenCalledWith('[§knowledge:retrieval-1:Retrieval One§]')rerender(<AgentPromptSlashMenu@@ -541,24 +712,24 @@ describe('AgentPromptEditor', () => {categories={categories}skills={[]}files={[]}- tools={[]}+ configuredTools={[]}onAddProviderTools={vi.fn()}onAddCliTool={options => options?.onAdded?.({ id: 'cli-1', kind: 'cli', name: 'Lark CLI' })}- retrievals={[]}+ knowledgeRetrievals={[]}onBack={vi.fn()}onOpenCategory={vi.fn()}- onSelect={onSelect}+ onInsertToken={onInsertToken}/>,)expect(screen.queryByRole('button', { name: /agentDetail\.configure\.tools\.cliDialog\.title/i })).not.toBeInTheDocument()expect(screen.queryByRole('button', { name: /agentDetail\.configure\.tools\.toolTabs\.cli/i })).not.toBeInTheDocument()})- it('should append available provider tool references and add missing tools to the configuration', () => {+ it('should append available provider tool references and add missing tools to the configuration', async () => {const { store, rerenderWithValue } = renderAgentPromptEditor('Research/', { tools: [] })const expectedProviderIcon = `${API_PREFIX}/workspaces/current/plugin/icon?tenant_id=workspace-123&filename=duckduckgo.svg`- fireEvent.keyDown(screen.getByRole('textbox'), { key: '/' })+ await openSlashMenuFromEditor()fireEvent.click(screen.getByRole('button', { name: /agentDetail\.configure\.tools\.label/i }))const providerButton = screen.getByRole('button', { name: /DuckDuckGo.*agentDetail\.configure\.tools\.toolTabs\.plugins/i })const providerIcon = Array.from(providerButton.querySelectorAll<HTMLElement>('[style]'))@@ -582,7 +753,7 @@ describe('AgentPromptEditor', () => {])rerenderWithValue('Research/')- fireEvent.keyDown(screen.getByRole('textbox'), { key: '/' })+ await openSlashMenuFromEditor()fireEvent.click(screen.getByRole('button', { name: /agentDetail\.configure\.tools\.label/i }))fireEvent.click(screen.getByRole('button', { name: /DuckDuckGo.*agentDetail\.configure\.tools\.toolTabs\.plugins/i }))@@ -601,7 +772,7 @@ describe('AgentPromptEditor', () => {it('should close slash menu when slash is deleted or the user clicks outside', async () => {const { rerenderWithValue } = renderAgentPromptEditor('Review/')- fireEvent.keyDown(screen.getByRole('textbox'), { key: '/' })+ await openSlashMenuFromEditor()expect(screen.getByRole('button', { name: /agentDetail\.configure\.skills\.label/i })).toBeInTheDocument()rerenderWithValue('Review')@@ -612,7 +783,7 @@ describe('AgentPromptEditor', () => {})rerenderWithValue('Review/')- fireEvent.keyDown(screen.getByRole('textbox'), { key: '/' })+ await openSlashMenuFromEditor()expect(screen.getByRole('button', { name: /agentDetail\.configure\.skills\.label/i })).toBeInTheDocument()fireEvent.pointerDown(document.body)@@ -622,6 +793,27 @@ describe('AgentPromptEditor', () => {})})+ it('should close the slash menu when focus moves outside the prompt editor', async () => {+ const outsideButton = document.createElement('button')+ document.body.append(outsideButton)++ try {+ renderAgentPromptEditor('Review/')++ await openSlashMenuFromEditor()+ expect(screen.getByRole('button', { name: /agentDetail\.configure\.skills\.label/i })).toBeInTheDocument()++ fireEvent.focusIn(outsideButton)++ await waitFor(() => {+ expect(screen.queryByRole('dialog', { name: /agentDetail\.configure\.prompt\.insert\.label/i })).not.toBeInTheDocument()+ })+ }+ finally {+ outsideButton.remove()+ }+ })+it('should reopen slash menu when the cursor is positioned after slash', async () => {renderAgentPromptEditor('Review/')diff --git a/web/features/agent-v2/agent-detail/configure/components/confirm-clear-session-dialog.tsx b/web/features/agent-v2/agent-detail/configure/components/confirm-clear-session-dialog.tsxnew file mode 100644index 00000000000..5c4350d7d54--- /dev/null+++ b/web/features/agent-v2/agent-detail/configure/components/confirm-clear-session-dialog.tsx@@ -0,0 +1,58 @@+'use client'++import type { ReactElement } from 'react'+import {+ AlertDialog,+ AlertDialogActions,+ AlertDialogCancelButton,+ AlertDialogConfirmButton,+ AlertDialogContent,+ AlertDialogDescription,+ AlertDialogTitle,+ AlertDialogTrigger,+} from '@langgenius/dify-ui/alert-dialog'+import { useState } from 'react'+import { useTranslation } from 'react-i18next'++export function AgentConfigureClearSessionConfirmDialog({+ children,+ confirmDisabled = false,+ onConfirm,+}: {+ children: ReactElement+ confirmDisabled?: boolean+ onConfirm: () => void+}) {+ const { t } = useTranslation('agentV2')+ const { t: tCommon } = useTranslation('common')+ const [open, setOpen] = useState(false)++ const handleConfirm = () => {+ onConfirm()+ setOpen(false)+ }++ return (+ <AlertDialog open={open} onOpenChange={setOpen}>+ <AlertDialogTrigger render={children} />+ <AlertDialogContent className="w-100">+ <div className="flex flex-col gap-1 p-6 pb-0">+ <AlertDialogTitle className="title-md-semi-bold text-text-primary">+ {t('agentDetail.configure.clearSessionConfirm.title')}+ </AlertDialogTitle>+ <AlertDialogDescription className="system-sm-regular text-text-tertiary">+ {t('agentDetail.configure.clearSessionConfirm.description')}+ </AlertDialogDescription>+ </div>+ <AlertDialogActions className="pt-6">+ <AlertDialogCancelButton disabled={confirmDisabled}>+ {tCommon('operation.cancel')}+ </AlertDialogCancelButton>+ <AlertDialogConfirmButton disabled={confirmDisabled} onClick={handleConfirm}>+ {tCommon('operation.confirm')}+ </AlertDialogConfirmButton>+ </AlertDialogActions>+ </AlertDialogContent>+ </AlertDialog>+ )+}diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/__tests__/build-draft-bar.spec.tsx b/web/features/agent-v2/agent-detail/configure/components/orchestrate/__tests__/build-draft-bar.spec.tsxindex 2b16ac7456d..7fb42c13134 100644--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/__tests__/build-draft-bar.spec.tsx+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/__tests__/build-draft-bar.spec.tsx@@ -169,6 +169,10 @@ describe('AgentBuildDraftBar', () => {expect(document.querySelector('.text-text-accent')).toHaveClass('i-ri-add-circle-fill')await user.click(screen.getByRole('button', { name: 'agentV2.agentDetail.configure.buildDraft.discard' }))+ expect(onDiscard).not.toHaveBeenCalled()+ expect(screen.getByRole('alertdialog', { name: 'agentV2.agentDetail.configure.clearSessionConfirm.title' })).toBeInTheDocument()++ await user.click(screen.getByRole('button', { name: 'common.operation.confirm' }))await user.click(screen.getByRole('button', { name: 'custom.apply' }))expect(onDiscard).toHaveBeenCalledTimes(1)@@ -197,6 +201,9 @@ describe('AgentBuildDraftBar', () => {expect(applyButton).toBeEnabled()await user.click(discardButton)+ expect(onDiscard).not.toHaveBeenCalled()++ await user.click(screen.getByRole('button', { name: 'common.operation.confirm' }))await user.click(applyButton)expect(onDiscard).toHaveBeenCalledTimes(1)diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/build-draft-bar.tsx b/web/features/agent-v2/agent-detail/configure/components/orchestrate/build-draft-bar.tsxindex c3284e75b1c..e120af8f6ec 100644--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/build-draft-bar.tsx+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/build-draft-bar.tsx@@ -6,6 +6,7 @@ import { CollapsiblePanel, CollapsibleRoot } from '@langgenius/dify-ui/collapsibimport { useId, useRef, useState } from 'react'import { useTranslation } from 'react-i18next'import { AgentBuildGridTexture } from '../build-grid-texture'+import { AgentConfigureClearSessionConfirmDialog } from '../confirm-clear-session-dialog'import { AgentBuildDraftChangesPanel } from './build-draft-changes-panel'type AgentBuildDraftBarProps = {@@ -90,15 +91,19 @@ export function AgentBuildDraftBar({<span aria-hidden className="i-ri-arrow-right-s-line size-4 shrink-0" /></button></div>- <Button- type="button"- variant="secondary"- disabled={discardDisabled}- className="relative z-1 h-8 shrink-0 rounded-lg px-3"- onClick={onDiscard}+ <AgentConfigureClearSessionConfirmDialog+ confirmDisabled={isDiscarding}+ onConfirm={onDiscard}>- {t('agentDetail.configure.buildDraft.discard')}- </Button>+ <Button+ type="button"+ variant="secondary"+ disabled={discardDisabled}+ className="relative z-1 h-8 shrink-0 rounded-lg px-3"+ >+ {t('agentDetail.configure.buildDraft.discard')}+ </Button>+ </AgentConfigureClearSessionConfirmDialog><Buttontype="button"variant="primary"diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/file-icon.ts b/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/file-icon.tsindex cb462055058..296a887d2a2 100644--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/file-icon.ts+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/file-icon.ts@@ -19,6 +19,7 @@ const codeFileExtensions = new Set([])const tableFileExtensions = new Set(['csv', 'xls', 'xlsx'])const archiveFileExtensions = new Set(['7z', 'gz', 'rar', 'tar', 'zip'])+const imageFileExtensions = new Set(['apng', 'avif', 'bmp', 'gif', 'ico', 'jpeg', 'jpg', 'png', 'svg', 'webp'])const driveFileIconTypes = new Set<FileTreeIconType>(['archive','code',@@ -40,7 +41,7 @@ function getFileExtension(fileName: string) {export function getFileIconType(fileName: string, mimeType?: string | null): FileTreeIconType {const extension = getFileExtension(fileName)- if (mimeType?.startsWith('image/'))+ if (mimeType?.startsWith('image/') || imageFileExtensions.has(extension))return 'image'if (mimeType === 'application/pdf' || extension === 'pdf')return 'pdf'diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/prompt-editor/index.tsx b/web/features/agent-v2/agent-detail/configure/components/orchestrate/prompt-editor/index.tsxindex 639ebed2b63..ffd39216212 100644--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/prompt-editor/index.tsx+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/prompt-editor/index.tsx@@ -1,7 +1,7 @@'use client'import type { LexicalNode } from 'lexical'-import type { KeyboardEvent, MouseEvent, PointerEvent as ReactPointerEvent } from 'react'+import type { MouseEvent, KeyboardEvent as ReactKeyboardEvent, PointerEvent as ReactPointerEvent } from 'react'import type { TextRange } from './options'import type { SlashMenuCategory, SlashMenuView } from './slash'import type { RosterReferenceToken } from '@/app/components/base/prompt-editor/plugins/roster-reference-block/utils'@@ -23,8 +23,7 @@ import {COMMAND_PRIORITY_LOW,SELECTION_CHANGE_COMMAND,} from 'lexical'-import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react'-import { createPortal } from 'react-dom'+import { useCallback, useEffect, useMemo, useLayoutEffect as useReactLayoutEffect, useRef, useState } from 'react'import { useTranslation } from 'react-i18next'import { Infotip } from '@/app/components/base/infotip'import PromptEditor from '@/app/components/base/prompt-editor'@@ -45,13 +44,10 @@ import { useAgentPromptToolIconResolver } from './hooks'import { insertTokenAtTextRange, replaceTrailingSlashWithToken } from './options'import { AgentPromptSlashMenu } from './slash'-const subscribeHydrationState = () => () => {}--const useIsHydrated = () => useSyncExternalStore(- subscribeHydrationState,- () => true,- () => false,-)+const noopLayoutEffect: typeof useReactLayoutEffect = () => {}+const useIsoLayoutEffect = typeof document !== 'undefined'+ ? useReactLayoutEffect+ : noopLayoutEffectfunction AgentPromptPlaceholder({insertLabel,@@ -139,7 +135,8 @@ const getLastTextContent = (node: Node): string => {return node.textContent ?? ''const textParts: string[] = []- const walker = document.createTreeWalker(node, NodeFilter.SHOW_TEXT)+ const ownerDocument = node.ownerDocument ?? document+ const walker = ownerDocument.createTreeWalker(node, ownerDocument.defaultView?.NodeFilter.SHOW_TEXT ?? NodeFilter.SHOW_TEXT)let current = walker.nextNode()while (current) {textParts.push(current.textContent ?? '')@@ -153,7 +150,7 @@ const isSelectionAfterSlash = (rootElement: HTMLElement | null, fallbackValue: sif (!rootElement)return fallbackValue.endsWith('/')- const selection = window.getSelection()+ const selection = rootElement.ownerDocument.getSelection()if (!selection || !selection.isCollapsed || selection.rangeCount === 0)return fallbackValue.endsWith('/')@@ -287,14 +284,72 @@ type SelectionRestoreRequest = {type SlashMenuPosition = {left: numbertop: number+ containerWidth: number}const slashMenuViewportPadding = 8const slashMenuMainWidth = 200const slashMenuSubmenuWidth = 360+const agentPromptSlashMenuId = 'agent-configure-prompt-slash-menu'++const getRangeRect = (range: Range) => {+ const rects = range.getClientRects()+ if (rects.length)+ return rects[rects.length - 1]!++ return range.getBoundingClientRect()+}++const getLastTextNode = (node: Node): Text | null => {+ if (node.nodeType === Node.TEXT_NODE)+ return node as Text++ for (let index = node.childNodes.length - 1; index >= 0; index--) {+ const textNode = getLastTextNode(node.childNodes.item(index))+ if (textNode)+ return textNode+ }-const getSlashMenuPosition = (editorElement: HTMLElement): SlashMenuPosition | null => {- const selection = window.getSelection()+ return null+}++const getSlashAnchorRange = (selection: Selection, editorElement: HTMLElement) => {+ const anchorNode = selection.anchorNode+ if (!anchorNode || !editorElement.contains(anchorNode))+ return null++ const ownerDocument = editorElement.ownerDocument++ if (anchorNode.nodeType === Node.TEXT_NODE) {+ const text = anchorNode.textContent ?? ''+ if (selection.anchorOffset > 0 && text[selection.anchorOffset - 1] === '/') {+ const range = ownerDocument.createRange()+ range.setStart(anchorNode, selection.anchorOffset - 1)+ range.setEnd(anchorNode, selection.anchorOffset)+ return range+ }+ }++ if (anchorNode.nodeType !== Node.ELEMENT_NODE)+ return null++ const previousChild = anchorNode.childNodes.item(selection.anchorOffset - 1)+ if (!previousChild)+ return null++ const textNode = getLastTextNode(previousChild)+ const text = textNode?.textContent ?? ''+ if (!textNode || !text.endsWith('/'))+ return null++ const range = ownerDocument.createRange()+ range.setStart(textNode, text.length - 1)+ range.setEnd(textNode, text.length)+ return range+}++const getSlashMenuPosition = (rootElement: HTMLElement, editorElement: HTMLElement): SlashMenuPosition | null => {+ const selection = editorElement.ownerDocument.getSelection()if (!selection || !selection.isCollapsed || selection.rangeCount === 0)return null@@ -302,39 +357,43 @@ const getSlashMenuPosition = (editorElement: HTMLElement): SlashMenuPosition | nif (!anchorNode || !editorElement.contains(anchorNode))return null- const range = selection.getRangeAt(0).cloneRange()- let rect: DOMRect | null = null- const rects = range.getClientRects()- if (rects.length)- rect = rects[rects.length - 1]!- else- rect = range.getBoundingClientRect()+ const slashRange = getSlashAnchorRange(selection, editorElement)+ const caretRange = selection.getRangeAt(0).cloneRange()+ const rect = slashRange ? getRangeRect(slashRange) : getRangeRect(caretRange)if (!rect || (rect.top === 0 && rect.left === 0 && rect.width === 0 && rect.height === 0)) {- const node = anchorNode.nodeType === Node.ELEMENT_NODE- ? anchorNode as Element- : anchorNode.parentElement+ const editorRect = editorElement.getBoundingClientRect()+ const rootRect = rootElement.getBoundingClientRect()- rect = node?.getBoundingClientRect() ?? editorElement.getBoundingClientRect()+ return {+ left: editorRect.left - rootRect.left + slashMenuViewportPadding,+ top: editorRect.top - rootRect.top + 24,+ containerWidth: rootRect.width,+ }}const editorRect = editorElement.getBoundingClientRect()if (!rect || rect.bottom < editorRect.top || rect.top > editorRect.bottom)return null+ const rootRect = rootElement.getBoundingClientRect()+return {- left: rect.right,- top: rect.bottom + 4,+ left: rect.right - rootRect.left,+ top: rect.bottom - rootRect.top + 4,+ containerWidth: rootRect.width,}}const getSlashMenuLeft = (position: SlashMenuPosition, width: number) => {- if (typeof window === 'undefined')- return position.left+ const maxLeft = Math.max(+ slashMenuViewportPadding,+ position.containerWidth - width - slashMenuViewportPadding,+ )return Math.max(slashMenuViewportPadding,- Math.min(position.left, window.innerWidth - width - slashMenuViewportPadding),+ Math.min(position.left, maxLeft),)}/* v8 ignore stop */@@ -398,7 +457,6 @@ export function AgentPromptEditor() {const { getConfiguredToolIcon } = useAgentPromptToolIconResolver()const retrievals = useAtomValue(agentComposerKnowledgeRetrievalsAtom)const addActions = useAgentOrchestrateAddActions()- const isHydrated = useIsHydrated()const promptTip = t('agentDetail.configure.prompt.tip')const promptPlaceholder = (<AgentPromptPlaceholder@@ -416,9 +474,20 @@ export function AgentPromptEditor() {const [isSlashMenuOpen, setIsSlashMenuOpen] = useState(false)const [slashMenuPosition, setSlashMenuPosition] = useState<SlashMenuPosition | null>(null)const [selectionRestoreRequest, setSelectionRestoreRequest] = useState<SelectionRestoreRequest | null>(null)- const rootRef = useRef<HTMLDivElement>(null)- const editorRef = useRef<HTMLDivElement>(null)- const slashInsertRangeRef = useRef<TextRange | null>(null)++ const positioningRootRef = useRef<HTMLDivElement>(null)+ const promptEditorHostRef = useRef<HTMLDivElement>(null)+ const slashMenuElementRef = useRef<HTMLDivElement>(null)+ const slashMenuLiveRegionRef = useRef<HTMLSpanElement>(null)++ const pendingSlashInsertRangeRef = useRef<TextRange | null>(null)+ const shouldFocusSlashMenuRef = useRef(false)+ const shouldKeepEditorFocusRef = useRef(false)+ const activeSlashMenuItemIndexRef = useRef(-1)+ const parentSlashMenuItemIndexRef = useRef(-1)+ const handledEditorMenuKeyRef = useRef(false)+ const slashMenuSyncFrameIdRef = useRef<number | null>(null)+ const slashMenuSyncOwnerWindowRef = useRef<Window | null>(null)const selectionRestoreRequestIdRef = useRef(0)const configuredReferenceIds = useMemo(() => {const skillIds = new Set<string>()@@ -453,67 +522,204 @@ export function AgentPromptEditor() {void copy(value)}, [copy, value])- const closeSlashMenu = () => {+ const closeSlashMenu = useCallback(() => {setIsSlashMenuOpen(false)setSlashMenuPosition(null)+ if (slashMenuLiveRegionRef.current)+ slashMenuLiveRegionRef.current.textContent = ''setSlashMenuView('main')- }+ shouldFocusSlashMenuRef.current = false+ shouldKeepEditorFocusRef.current = false+ activeSlashMenuItemIndexRef.current = -1+ parentSlashMenuItemIndexRef.current = -1+ handledEditorMenuKeyRef.current = false+ }, [])const updateSlashMenuPosition = useCallback(() => {- const editorElement = editorRef.current- if (!editorElement)+ const rootElement = positioningRootRef.current+ const editorElement = promptEditorHostRef.current+ if (!rootElement || !editorElement)return- const position = getSlashMenuPosition(editorElement)+ const position = getSlashMenuPosition(rootElement, editorElement)if (!position)returnsetSlashMenuPosition(position)}, [])- const openSlashMenu = useCallback(() => {+ const openSlashMenu = useCallback((options: { autoFocus: boolean }) => {+ shouldFocusSlashMenuRef.current = options.autoFocus+ shouldKeepEditorFocusRef.current = !options.autoFocus+ activeSlashMenuItemIndexRef.current = options.autoFocus ? 0 : -1+ parentSlashMenuItemIndexRef.current = -1+ if (slashMenuLiveRegionRef.current)+ slashMenuLiveRegionRef.current.textContent = ''setSlashMenuView('main')updateSlashMenuPosition()setIsSlashMenuOpen(true)}, [updateSlashMenuPosition])const syncSlashMenuWithSelection = useCallback(() => {- if (!isHydrated || readOnly)+ if (readOnly)return- if (isSelectionAfterSlash(editorRef.current, value)) {+ if (isSelectionAfterSlash(promptEditorHostRef.current, value)) {updateSlashMenuPosition()- openSlashMenu()+ openSlashMenu({ autoFocus: false })}else {- slashInsertRangeRef.current = null+ pendingSlashInsertRangeRef.current = nullcloseSlashMenu()}- }, [isHydrated, openSlashMenu, readOnly, updateSlashMenuPosition, value])+ }, [closeSlashMenu, openSlashMenu, readOnly, updateSlashMenuPosition, value])++ const scheduleSlashMenuSync = useCallback(() => {+ const ownerWindow = promptEditorHostRef.current?.ownerDocument.defaultView ?? window+ if (slashMenuSyncFrameIdRef.current !== null)+ (slashMenuSyncOwnerWindowRef.current ?? ownerWindow).cancelAnimationFrame(slashMenuSyncFrameIdRef.current)++ slashMenuSyncOwnerWindowRef.current = ownerWindow+ slashMenuSyncFrameIdRef.current = ownerWindow.requestAnimationFrame(() => {+ slashMenuSyncFrameIdRef.current = null+ slashMenuSyncOwnerWindowRef.current = null+ syncSlashMenuWithSelection()+ })+ }, [syncSlashMenuWithSelection])++ useEffect(() => {+ return () => {+ if (slashMenuSyncFrameIdRef.current !== null)+ (slashMenuSyncOwnerWindowRef.current ?? window).cancelAnimationFrame(slashMenuSyncFrameIdRef.current)+ }+ }, [])const handleSlashRangeChange = useCallback((range: TextRange | null) => {if (range)- slashInsertRangeRef.current = range+ pendingSlashInsertRangeRef.current = range+ }, [])++ const focusPromptEditor = useCallback(() => {+ const editable = promptEditorHostRef.current?.querySelector<HTMLElement>('[contenteditable="true"], [role="textbox"]')+ editable?.focus({ preventScroll: true })+ }, [])++ const getSlashMenuItems = useCallback(() => Array.from(slashMenuElementRef.current?.querySelectorAll<HTMLElement>('[data-agent-prompt-menu-item]') ?? [])+ .filter(item => !item.hasAttribute('disabled') && item.getAttribute('aria-disabled') !== 'true'), [])++ const setActiveSlashMenuItem = useCallback((menuItems: HTMLElement[], index: number) => {+ activeSlashMenuItemIndexRef.current = index+ menuItems.forEach((item, itemIndex) => {+ item.toggleAttribute('data-agent-prompt-menu-active', itemIndex === index)+ })+ const announcement = index >= 0+ ? menuItems[index]?.textContent?.replace(/\s+/g, ' ').trim() ?? ''+ : ''+ if (slashMenuLiveRegionRef.current && slashMenuLiveRegionRef.current.textContent !== announcement)+ slashMenuLiveRegionRef.current.textContent = announcement+ }, [])++ const activateSlashMenuItem = useCallback((item: HTMLElement | undefined) => {+ if (!item)+ return++ if (item.hasAttribute('data-agent-prompt-menu-category')) {+ const itemIndex = getSlashMenuItems().indexOf(item)+ parentSlashMenuItemIndexRef.current = itemIndex >= 0+ ? itemIndex+ : Math.max(0, activeSlashMenuItemIndexRef.current)+ activeSlashMenuItemIndexRef.current = 0+ }++ item.click()+ }, [getSlashMenuItems])++ const returnToSlashMenuMain = useCallback(() => {+ activeSlashMenuItemIndexRef.current = Math.max(0, parentSlashMenuItemIndexRef.current)+ setSlashMenuView('main')}, [])- const handleEditorKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {- if (!isHydrated || readOnly)+ const handleEditorKeyDown = (event: ReactKeyboardEvent<HTMLDivElement>) => {+ handledEditorMenuKeyRef.current = false++ if (readOnly)returnif (event.key === 'Escape' && isSlashMenuOpen) {event.preventDefault()+ handledEditorMenuKeyRef.current = truecloseSlashMenu()return}- if (event.key !== '/' || event.metaKey || event.ctrlKey || event.altKey)+ if (!isSlashMenuOpen)+ return++ const menuItems = getSlashMenuItems()+ if (!menuItems.length)return- openSlashMenu()+ if (event.key === 'ArrowLeft' && slashMenuView !== 'main') {+ event.preventDefault()+ event.stopPropagation()+ handledEditorMenuKeyRef.current = true+ returnToSlashMenuMain()+ return+ }++ if (event.key === 'ArrowRight' && activeSlashMenuItemIndexRef.current >= 0) {+ const activeItem = menuItems[activeSlashMenuItemIndexRef.current]+ if (!activeItem?.hasAttribute('data-agent-prompt-menu-category') && !activeItem?.hasAttribute('aria-expanded'))+ return++ event.preventDefault()+ event.stopPropagation()+ handledEditorMenuKeyRef.current = true+ activateSlashMenuItem(activeItem)+ return+ }++ if ((event.key === 'Enter' || event.key === ' ') && activeSlashMenuItemIndexRef.current >= 0) {+ const activeItem = menuItems[activeSlashMenuItemIndexRef.current]+ event.preventDefault()+ event.stopPropagation()+ handledEditorMenuKeyRef.current = true+ activateSlashMenuItem(activeItem)+ return+ }++ if (event.key !== 'ArrowDown' && event.key !== 'ArrowUp' && event.key !== 'Home' && event.key !== 'End')+ return++ event.preventDefault()+ event.stopPropagation()+ handledEditorMenuKeyRef.current = true++ if (event.key === 'Home') {+ setActiveSlashMenuItem(menuItems, 0)+ return+ }++ if (event.key === 'End') {+ setActiveSlashMenuItem(menuItems, menuItems.length - 1)+ return+ }++ const activeIndex = activeSlashMenuItemIndexRef.current+ const nextIndex = activeIndex === -1+ ? event.key === 'ArrowUp' ? menuItems.length - 1 : 0+ : (activeIndex + (event.key === 'ArrowDown' ? 1 : -1) + menuItems.length) % menuItems.length++ setActiveSlashMenuItem(menuItems, nextIndex)}const handleEditorKeyUp = () => {- window.requestAnimationFrame(syncSlashMenuWithSelection)+ if (handledEditorMenuKeyRef.current) {+ handledEditorMenuKeyRef.current = false+ return+ }++ scheduleSlashMenuSync()}const handleEditorPointerUp = (event: ReactPointerEvent<HTMLDivElement>) => {@@ -525,7 +731,17 @@ export function AgentPromptEditor() {return}- window.requestAnimationFrame(syncSlashMenuWithSelection)+ scheduleSlashMenuSync()+ }++ const handleSlashMenuPointerDownCapture = (event: ReactPointerEvent<HTMLDivElement>) => {+ if (shouldKeepEditorFocusRef.current)+ event.preventDefault()+ }++ const handleSlashMenuMouseDownCapture = (event: MouseEvent<HTMLDivElement>) => {+ if (shouldKeepEditorFocusRef.current)+ event.preventDefault()}const handleRootPointerDown = (event: MouseEvent<HTMLDivElement>) => {@@ -533,7 +749,7 @@ export function AgentPromptEditor() {if (!(target instanceof Node))return- if (editorRef.current?.contains(target))+ if (promptEditorHostRef.current?.contains(target))returnif (@@ -550,7 +766,7 @@ export function AgentPromptEditor() {}const handleSlashSelect = (token: string) => {- const slashRange = slashInsertRangeRef.current+ const slashRange = pendingSlashInsertRangeRef.currentlet insertionResultif (slashRange) {insertionResult = insertTokenAtTextRange(value, slashRange, token)@@ -563,7 +779,7 @@ export function AgentPromptEditor() {}}setValue(insertionResult.value)- slashInsertRangeRef.current = null+ pendingSlashInsertRangeRef.current = nullselectionRestoreRequestIdRef.current += 1setSelectionRestoreRequest({id: selectionRestoreRequestIdRef.current,@@ -574,7 +790,7 @@ export function AgentPromptEditor() {const handleInsertSlash = () => {setValue(`${value}/`)- openSlashMenu()+ openSlashMenu({ autoFocus: true })}const renderRosterReferenceIcon = useCallback((token: RosterReferenceToken) => {@@ -619,6 +835,11 @@ export function AgentPromptEditor() {if (!isSlashMenuOpen)return+ const rootElement = positioningRootRef.current+ if (!rootElement)+ return+ const ownerDocument = rootElement.ownerDocument+const handlePointerDown = (event: PointerEvent) => {const target = event.targetif (!(target instanceof Node))@@ -631,15 +852,128 @@ export function AgentPromptEditor() {return}- if (!rootRef.current?.contains(target))+ if (!rootElement.contains(target))+ closeSlashMenu()+ }++ const handleFocusIn = (event: FocusEvent) => {+ const target = event.target+ if (target instanceof Node && !rootElement.contains(target))+ closeSlashMenu()+ }++ ownerDocument.addEventListener('pointerdown', handlePointerDown)+ ownerDocument.addEventListener('focusin', handleFocusIn)+ return () => {+ ownerDocument.removeEventListener('pointerdown', handlePointerDown)+ ownerDocument.removeEventListener('focusin', handleFocusIn)+ }+ }, [closeSlashMenu, isSlashMenuOpen])++ useIsoLayoutEffect(() => {+ if (!isSlashMenuOpen)+ return++ const menuElement = slashMenuElementRef.current+ if (!menuElement)+ return++ const handleKeyDown = (event: globalThis.KeyboardEvent) => {+ const activeElement = menuElement.ownerDocument.activeElement+ if (!menuElement.contains(activeElement))+ return++ if (event.key === 'Escape') {+ event.preventDefault()+ event.stopPropagation()closeSlashMenu()+ focusPromptEditor()+ return+ }++ if (event.key === 'ArrowLeft' && slashMenuView !== 'main') {+ event.preventDefault()+ event.stopPropagation()+ returnToSlashMenuMain()+ return+ }++ const menuItems = getSlashMenuItems()+ if (!menuItems.length)+ return++ const currentIndex = menuItems.findIndex(item => item === activeElement)++ if (event.key === 'ArrowRight') {+ const currentItem = menuItems[currentIndex]+ if (currentItem?.hasAttribute('data-agent-prompt-menu-category') || currentItem?.hasAttribute('aria-expanded')) {+ event.preventDefault()+ event.stopPropagation()+ activateSlashMenuItem(currentItem)+ }++ return+ }++ if (event.key !== 'ArrowDown' && event.key !== 'ArrowUp' && event.key !== 'Home' && event.key !== 'End')+ return++ event.preventDefault()+ event.stopPropagation()++ if (event.key === 'Home') {+ setActiveSlashMenuItem(menuItems, 0)+ menuItems[0]?.focus()+ return+ }++ if (event.key === 'End') {+ setActiveSlashMenuItem(menuItems, menuItems.length - 1)+ menuItems[menuItems.length - 1]?.focus()+ return+ }++ const direction = event.key === 'ArrowDown' ? 1 : -1+ const nextIndex = currentIndex === -1+ ? direction === 1 ? 0 : menuItems.length - 1+ : (currentIndex + direction + menuItems.length) % menuItems.length++ setActiveSlashMenuItem(menuItems, nextIndex)+ menuItems[nextIndex]?.focus()}- document.addEventListener('pointerdown', handlePointerDown)+ menuElement.addEventListener('keydown', handleKeyDown)return () => {- document.removeEventListener('pointerdown', handlePointerDown)+ menuElement.removeEventListener('keydown', handleKeyDown)}- }, [isSlashMenuOpen])+ }, [activateSlashMenuItem, closeSlashMenu, focusPromptEditor, getSlashMenuItems, isSlashMenuOpen, returnToSlashMenuMain, setActiveSlashMenuItem, slashMenuView])++ useIsoLayoutEffect(() => {+ if (!isSlashMenuOpen)+ return++ const menuItems = getSlashMenuItems()+ if (!menuItems.length)+ return++ if (shouldKeepEditorFocusRef.current) {+ const activeIndex = activeSlashMenuItemIndexRef.current < 0+ ? -1+ : Math.min(activeSlashMenuItemIndexRef.current, menuItems.length - 1)+ setActiveSlashMenuItem(menuItems, activeIndex)+ return+ }++ if (!shouldFocusSlashMenuRef.current && slashMenuView === 'main')+ return++ shouldFocusSlashMenuRef.current = true+ const activeIndex = activeSlashMenuItemIndexRef.current < 0+ ? 0+ : Math.min(activeSlashMenuItemIndexRef.current, menuItems.length - 1)+ setActiveSlashMenuItem(menuItems, activeIndex)+ menuItems[activeIndex]?.focus({ preventScroll: true })+ }, [getSlashMenuItems, isSlashMenuOpen, setActiveSlashMenuItem, slashMenuView])const slashMenuCategories: SlashMenuCategory[] = [{@@ -663,12 +997,27 @@ export function AgentPromptEditor() {icon: 'i-ri-book-open-line',},]+ const handleOpenSlashMenuCategory = (view: Exclude<SlashMenuView, 'main'>) => {+ parentSlashMenuItemIndexRef.current = Math.max(+ 0,+ slashMenuCategories.findIndex(category => category.key === view),+ )+ activeSlashMenuItemIndexRef.current = 0+ setSlashMenuView(view)+ }const slashMenuWidth = slashMenuView === 'main' ? slashMenuMainWidth : slashMenuSubmenuWidth- const slashMenu = isHydrated && !readOnly && isSlashMenuOpen- ? createPortal(+ const slashMenu = !readOnly && isSlashMenuOpen+ ? (<div+ id={agentPromptSlashMenuId}+ ref={slashMenuElementRef}data-agent-prompt-slash-menu- className="fixed z-60"+ role="dialog"+ aria-label={t('agentDetail.configure.prompt.insert.label')}+ tabIndex={-1}+ className="absolute z-30"+ onPointerDownCapture={handleSlashMenuPointerDownCapture}+ onMouseDownCapture={handleSlashMenuMouseDownCapture}style={{left: slashMenuPosition ? `${getSlashMenuLeft(slashMenuPosition, slashMenuWidth)}px` : '12px',top: slashMenuPosition ? `${slashMenuPosition.top}px` : '36px',@@ -679,19 +1028,18 @@ export function AgentPromptEditor() {categories={slashMenuCategories}skills={skills}files={files}- tools={tools}+ configuredTools={tools}onAddProviderTools={addProviderTools}- onAddCliTool={ENABLE_AGENT_CLI_TOOLS ? addActions.cli : undefined}+ onAddCliTool={addActions.cli}onAddFile={addActions.files}onAddKnowledge={addActions.knowledge}onAddSkill={addActions.skills}- retrievals={retrievals}- onBack={() => setSlashMenuView('main')}- onOpenCategory={setSlashMenuView}- onSelect={handleSlashSelect}+ knowledgeRetrievals={retrievals}+ onBack={returnToSlashMenuMain}+ onOpenCategory={handleOpenSlashMenuCategory}+ onInsertToken={handleSlashSelect}/>- </div>,- document.body,+ </div>): null@@ -729,7 +1077,7 @@ export function AgentPromptEditor() {</div><div- ref={rootRef}+ ref={positioningRootRef}className="relative"onPointerDownCapture={handleRootPointerDown}>@@ -739,9 +1087,11 @@ export function AgentPromptEditor() {onKeyUpCapture={handleEditorKeyUp}onPointerUpCapture={handleEditorPointerUp}>- <div ref={editorRef} className="min-h-[104px] overflow-y-auto px-3 pt-0.5">+ <div ref={promptEditorHostRef} className="min-h-[104px] overflow-y-auto px-3 pt-0.5"><PromptEditorinstanceId="agent-configure-prompt-editor"+ aria-controls={isSlashMenuOpen ? agentPromptSlashMenuId : undefined}+ aria-haspopup="dialog"aria-labelledby="agent-configure-prompt-label"compactwrapperClassName="min-h-[104px]"@@ -767,6 +1117,7 @@ export function AgentPromptEditor() {onSlashRangeChange={handleSlashRangeChange}/></PromptEditor>+ <span ref={slashMenuLiveRegionRef} className="sr-only" aria-live="polite" /></div>{!readOnly && (<div@@ -776,6 +1127,9 @@ export function AgentPromptEditor() {<div className="flex min-w-0 items-center gap-3"><buttontype="button"+ aria-haspopup="dialog"+ aria-expanded={isSlashMenuOpen}+ aria-controls={isSlashMenuOpen ? agentPromptSlashMenuId : undefined}className="flex items-center gap-1 system-xs-medium hover:text-text-secondary focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden"onClick={handleInsertSlash}>diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/prompt-editor/slash.tsx b/web/features/agent-v2/agent-detail/configure/components/orchestrate/prompt-editor/slash.tsxindex 40e2df9babb..a9f13616bff 100644--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/prompt-editor/slash.tsx+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/prompt-editor/slash.tsx@@ -40,18 +40,22 @@ type AgentPromptSlashMenuProps = {categories: SlashMenuCategory[]skills: AgentSkill[]files: AgentFileNode[]- tools: AgentTool[]+ configuredTools: AgentTool[]onAddProviderTools: (tools: AgentProviderToolDefaultValue[]) => voidonAddCliTool?: AgentOrchestrateAddActiononAddFile?: AgentOrchestrateAddActiononAddKnowledge?: AgentOrchestrateAddActiononAddSkill?: AgentOrchestrateAddAction- retrievals: AgentKnowledgeRetrievalItem[]+ knowledgeRetrievals: AgentKnowledgeRetrievalItem[]onBack: () => voidonOpenCategory: (view: Exclude<SlashMenuView, 'main'>) => void- onSelect: (token: string) => void+ onInsertToken: (token: string) => void}+const agentPromptSlashMenuItemProps = {+ 'data-agent-prompt-menu-item': '',+} as const+const createReferenceToken = (kind: string, id: string, label?: string) => (`[§${kind}:${id}${label ? `:${label}` : ''}§]`)@@ -81,16 +85,16 @@ export function AgentPromptSlashMenu({categories,skills,files,- tools,+ configuredTools,onAddProviderTools,onAddCliTool,onAddFile,onAddKnowledge,onAddSkill,- retrievals,+ knowledgeRetrievals,onBack,onOpenCategory,- onSelect,+ onInsertToken,}: AgentPromptSlashMenuProps) {const { t } = useTranslation('agentV2')const title = categories.find(category => category.key === view)?.label@@ -99,7 +103,7 @@ export function AgentPromptSlashMenu({onAddSkill?.({onAdded: (item) => {if (isPromptReferenceItem(item))- onSelect(createConfigReferenceToken('skill', item.id, item.name))+ onInsertToken(createConfigReferenceToken('skill', item.id, item.name))},})return@@ -109,7 +113,7 @@ export function AgentPromptSlashMenu({onAddFile?.({onAdded: (item) => {if (isAgentFileNode(item))- onSelect(createConfigReferenceToken('file', item.configName ?? item.id, item.name))+ onInsertToken(createConfigReferenceToken('file', item.configName ?? item.id, item.name))},})return@@ -119,7 +123,7 @@ export function AgentPromptSlashMenu({onAddKnowledge?.({onAdded: (item) => {if (isKnowledgeRetrievalItem(item))- onSelect(createReferenceToken('knowledge', item.id, getKnowledgeRetrievalName(item, t)))+ onInsertToken(createReferenceToken('knowledge', item.id, getKnowledgeRetrievalName(item, t)))},})}@@ -133,7 +137,9 @@ export function AgentPromptSlashMenu({<buttonkey={category.key}type="button"- className="flex h-6 w-full items-center gap-1 rounded-md pr-2 pl-3 text-left hover:bg-state-base-hover focus-visible:bg-state-base-hover focus-visible:outline-hidden"+ {...agentPromptSlashMenuItemProps}+ data-agent-prompt-menu-category={category.key}+ className="flex h-6 w-full items-center gap-1 rounded-md pr-2 pl-3 text-left hover:bg-state-base-hover focus-visible:bg-state-base-hover focus-visible:outline-hidden data-[agent-prompt-menu-active]:bg-state-base-hover"onClick={() => onOpenCategory(category.key)}><span aria-hidden className={`${category.icon} size-4 shrink-0 text-text-secondary`} />@@ -151,27 +157,29 @@ export function AgentPromptSlashMenu({<div className="flex flex-col p-1"><buttontype="button"- className="flex h-6 w-full items-center gap-1 rounded-md pr-2 pl-3 text-left text-text-tertiary hover:bg-state-base-hover focus-visible:bg-state-base-hover focus-visible:outline-hidden"+ {...agentPromptSlashMenuItemProps}+ data-agent-prompt-menu-back=""+ className="flex h-6 w-full items-center gap-1 rounded-md pr-2 pl-3 text-left text-text-tertiary hover:bg-state-base-hover focus-visible:bg-state-base-hover focus-visible:outline-hidden data-[agent-prompt-menu-active]:bg-state-base-hover"onClick={onBack}><span aria-hidden className="i-ri-arrow-left-line size-4 shrink-0" /><span className="min-w-0 flex-1 truncate system-xs-medium-uppercase">{title}</span></button>{view === 'skills' && (- <AgentPromptSkillRows skills={skills} onSelect={onSelect} />+ <AgentPromptSkillRows skills={skills} onInsertToken={onInsertToken} />)}{view === 'files' && (- <AgentPromptFileRows files={files} onSelect={onSelect} />+ <AgentPromptFileRows files={files} onInsertToken={onInsertToken} />)}{view === 'tools' && (<AgentPromptToolRows- configuredTools={tools}+ configuredTools={configuredTools}onAddProviderTools={onAddProviderTools}- onSelect={onSelect}+ onInsertToken={onInsertToken}/>)}{view === 'knowledge' && (- <AgentPromptKnowledgeRows retrievals={retrievals} onSelect={onSelect} />+ <AgentPromptKnowledgeRows knowledgeRetrievals={knowledgeRetrievals} onInsertToken={onInsertToken} />)}</div>{view === 'tools'@@ -182,7 +190,7 @@ export function AgentPromptSlashMenu({onAddCliTool?.({onAdded: (item) => {if (isCliToolItem(item))- onSelect(createReferenceToken('cli_tool', item.id, item.name))+ onInsertToken(createReferenceToken('cli_tool', item.id, item.name))},})}@@ -193,7 +201,8 @@ export function AgentPromptSlashMenu({<div className="border-t border-divider-subtle p-1"><buttontype="button"- className="flex h-6 w-full items-center gap-1 rounded-md pr-2 pl-3 text-left hover:bg-state-base-hover focus-visible:bg-state-base-hover focus-visible:outline-hidden"+ {...agentPromptSlashMenuItemProps}+ className="flex h-6 w-full items-center gap-1 rounded-md pr-2 pl-3 text-left hover:bg-state-base-hover focus-visible:bg-state-base-hover focus-visible:outline-hidden data-[agent-prompt-menu-active]:bg-state-base-hover"onClick={handleAddFromFooter}><span aria-hidden className="i-ri-add-line size-4 shrink-0 text-text-secondary" />@@ -225,10 +234,10 @@ function AgentPromptSlashPanel({function AgentPromptSkillRows({skills,- onSelect,+ onInsertToken,}: {skills: AgentSkill[]- onSelect: (token: string) => void+ onInsertToken: (token: string) => void}) {return (<>@@ -237,7 +246,7 @@ function AgentPromptSkillRows({key={skill.id}icon="i-ri-box-3-line"label={skill.name}- onClick={() => onSelect(createConfigReferenceToken('skill', skill.id, skill.name))}+ onClick={() => onInsertToken(createConfigReferenceToken('skill', skill.id, skill.name))}/>))}</>@@ -247,11 +256,11 @@ function AgentPromptSkillRows({function AgentPromptFileRows({files,depth = 0,- onSelect,+ onInsertToken,}: {files: AgentFileNode[]depth?: number- onSelect: (token: string) => void+ onInsertToken: (token: string) => void}) {return (<>@@ -264,11 +273,11 @@ function AgentPromptFileRows({hasChildren={!!file.children?.length}onClick={() => {if (!file.children?.length)- onSelect(createConfigReferenceToken('file', file.configName ?? file.id, file.name))+ onInsertToken(createConfigReferenceToken('file', file.configName ?? file.id, file.name))}}/>{!!file.children?.length && (- <AgentPromptFileRows files={file.children} depth={depth + 1} onSelect={onSelect} />+ <AgentPromptFileRows files={file.children} depth={depth + 1} onInsertToken={onInsertToken} />)}</div>))}@@ -279,11 +288,11 @@ function AgentPromptFileRows({function AgentPromptToolRows({configuredTools,onAddProviderTools,- onSelect,+ onInsertToken,}: {configuredTools: AgentTool[]onAddProviderTools: (tools: AgentProviderToolDefaultValue[]) => void- onSelect: (token: string) => void+ onInsertToken: (token: string) => void}) {const { t } = useTranslation('agentV2')const language = useGetLanguage()@@ -346,14 +355,14 @@ function AgentPromptToolRows({const handleSelectProvider = (provider: ToolWithProvider) => {const { icon, iconDark } = getProviderIcons(provider)selectTools(provider.tools.map(tool => toToolDefaultValue(provider, tool, language, icon, iconDark)))- onSelect(createReferenceToken('tool', `${provider.id}/*`, getProviderLabel(provider, language)))+ onInsertToken(createReferenceToken('tool', `${provider.id}/*`, getProviderLabel(provider, language)))}const handleSelectTool = (provider: ToolWithProvider, tool: Tool) => {const { icon, iconDark } = getProviderIcons(provider)const selectedTool = toToolDefaultValue(provider, tool, language, icon, iconDark)selectTools([selectedTool])- onSelect(createReferenceToken('tool', `${provider.id}/${tool.name}`, selectedTool.tool_label))+ onInsertToken(createReferenceToken('tool', `${provider.id}/${tool.name}`, selectedTool.tool_label))}return (@@ -363,6 +372,7 @@ function AgentPromptToolRows({<buttonkey={tab.key}type="button"+ {...agentPromptSlashMenuItemProps}className={cn('flex h-6 shrink-0 items-center rounded-md px-2 system-xs-medium text-text-tertiary hover:bg-state-base-hover focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden',activeTab === tab.key && 'bg-state-base-active system-xs-semibold text-text-primary',@@ -379,7 +389,7 @@ function AgentPromptToolRows({<AgentPromptCliToolRowkey={tool.id}tool={tool}- onClick={() => onSelect(createReferenceToken('cli_tool', tool.id, tool.name))}+ onClick={() => onInsertToken(createReferenceToken('cli_tool', tool.id, tool.name))}/>)): availableProviders.filter(provider => provider.tools.length > 0).map(provider => (@@ -524,7 +534,8 @@ function AgentPromptProviderToolRow({<div className="group flex h-7 w-full items-center gap-px overflow-hidden rounded-md"><buttontype="button"- className="flex min-w-0 flex-1 items-center gap-1.5 rounded-l-md py-1 pr-1 pl-2 text-left group-hover:bg-state-base-hover focus-visible:bg-state-base-hover focus-visible:outline-hidden"+ {...agentPromptSlashMenuItemProps}+ className="flex min-w-0 flex-1 items-center gap-1.5 rounded-l-md py-1 pr-1 pl-2 text-left group-hover:bg-state-base-hover focus-visible:bg-state-base-hover focus-visible:outline-hidden data-[agent-prompt-menu-active]:bg-state-base-hover"onClick={onClick}><AgentPromptProviderIcon provider={provider} getProviderIcon={getProviderIcon} />@@ -540,8 +551,10 @@ function AgentPromptProviderToolRow({</button><buttontype="button"+ {...agentPromptSlashMenuItemProps}aria-label={providerLabel}- className="flex size-7 shrink-0 items-center justify-center rounded-r-md text-text-tertiary group-hover:bg-state-base-hover hover:bg-state-base-hover focus-visible:bg-state-base-hover focus-visible:outline-hidden"+ aria-expanded={isExpanded}+ className="flex size-7 shrink-0 items-center justify-center rounded-r-md text-text-tertiary group-hover:bg-state-base-hover hover:bg-state-base-hover focus-visible:bg-state-base-hover focus-visible:outline-hidden data-[agent-prompt-menu-active]:bg-state-base-hover"onClick={onToggle}><span aria-hidden className={`${isExpanded ? 'i-ri-arrow-down-s-line' : 'i-ri-arrow-right-s-line'} size-4`} />@@ -582,7 +595,8 @@ function AgentPromptToolFooter({href={getMarketplaceCategoryUrl(PluginCategoryEnum.tool)}target="_blank"rel="noreferrer"- className="flex h-7 w-full items-center gap-1.5 rounded-md px-2 text-left hover:bg-state-base-hover focus-visible:bg-state-base-hover focus-visible:outline-hidden"+ {...agentPromptSlashMenuItemProps}+ className="flex h-7 w-full items-center gap-1.5 rounded-md px-2 text-left hover:bg-state-base-hover focus-visible:bg-state-base-hover focus-visible:outline-hidden data-[agent-prompt-menu-active]:bg-state-base-hover"><span aria-hidden className="i-ri-store-2-line size-4 shrink-0 text-text-secondary" /><span className="system-sm-regular text-text-secondary">{t('findMoreInMarketplace', { ns: 'plugin' })}</span>@@ -590,7 +604,8 @@ function AgentPromptToolFooter({{onAddCliTool && (<buttontype="button"- className="flex h-7 w-full items-center gap-1.5 rounded-md px-2 text-left hover:bg-state-base-hover focus-visible:bg-state-base-hover focus-visible:outline-hidden"+ {...agentPromptSlashMenuItemProps}+ className="flex h-7 w-full items-center gap-1.5 rounded-md px-2 text-left hover:bg-state-base-hover focus-visible:bg-state-base-hover focus-visible:outline-hidden data-[agent-prompt-menu-active]:bg-state-base-hover"onClick={onAddCliTool}><span aria-hidden className="i-ri-add-line size-4 shrink-0 text-text-secondary" />@@ -613,7 +628,8 @@ function AgentPromptProviderToolActionRow({return (<buttontype="button"- className="flex h-6 w-full items-center gap-1 rounded-md text-left hover:bg-state-base-hover focus-visible:bg-state-base-hover focus-visible:outline-hidden"+ {...agentPromptSlashMenuItemProps}+ className="flex h-6 w-full items-center gap-1 rounded-md text-left hover:bg-state-base-hover focus-visible:bg-state-base-hover focus-visible:outline-hidden data-[agent-prompt-menu-active]:bg-state-base-hover"onClick={onClick}><span className="ml-4 h-full w-px shrink-0 bg-divider-subtle" />@@ -638,7 +654,8 @@ function AgentPromptCliToolRow({return (<buttontype="button"- className="flex h-7 w-full items-center gap-1 rounded-md text-left hover:bg-state-base-hover focus-visible:bg-state-base-hover focus-visible:outline-hidden"+ {...agentPromptSlashMenuItemProps}+ className="flex h-7 w-full items-center gap-1 rounded-md text-left hover:bg-state-base-hover focus-visible:bg-state-base-hover focus-visible:outline-hidden data-[agent-prompt-menu-active]:bg-state-base-hover"onClick={onClick}><span className="flex min-w-0 flex-1 items-center gap-1.5 py-1 pr-8 pl-2">@@ -655,22 +672,22 @@ function AgentPromptCliToolRow({}function AgentPromptKnowledgeRows({- retrievals,- onSelect,+ knowledgeRetrievals,+ onInsertToken,}: {- retrievals: AgentKnowledgeRetrievalItem[]- onSelect: (token: string) => void+ knowledgeRetrievals: AgentKnowledgeRetrievalItem[]+ onInsertToken: (token: string) => void}) {const { t } = useTranslation('agentV2')return (<>- {retrievals.map(retrieval => (+ {knowledgeRetrievals.map(retrieval => (<AgentPromptSubmenuRowkey={retrieval.id}icon="i-ri-book-open-line"label={getKnowledgeRetrievalName(retrieval, t)}- onClick={() => onSelect(createReferenceToken('knowledge', retrieval.id, getKnowledgeRetrievalName(retrieval, t)))}+ onClick={() => onInsertToken(createReferenceToken('knowledge', retrieval.id, getKnowledgeRetrievalName(retrieval, t)))}/>))}</>@@ -702,7 +719,8 @@ function AgentPromptSubmenuRow({return (<buttontype="button"- className="flex h-6 w-full items-center gap-1 rounded-md text-left hover:bg-state-base-hover focus-visible:bg-state-base-hover focus-visible:outline-hidden"+ {...agentPromptSlashMenuItemProps}+ className="flex h-6 w-full items-center gap-1 rounded-md text-left hover:bg-state-base-hover focus-visible:bg-state-base-hover focus-visible:outline-hidden data-[agent-prompt-menu-active]:bg-state-base-hover"onClick={onClick}><span className={`flex min-w-0 flex-1 items-center gap-1 ${indent} pr-2`}>diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/detail-dialog.tsx b/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/detail-dialog.tsxindex 4275689c69d..b531ee9f63e 100644--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/detail-dialog.tsx+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/detail-dialog.tsx@@ -24,6 +24,8 @@ type AgentSkillDetailSection = {items?: string[]}+export type AgentSkillDetailDownloadAction = 'header' | 'preview'+export type AgentSkillDetail = {description: stringfileCount?: number@@ -38,6 +40,7 @@ export type AgentSkillDetail = {filePreview?: {binary?: booleancontent?: string+ downloadActionLoadingTarget?: AgentSkillDetailDownloadAction | nulldownloadUrl?: stringfileName?: stringisDownloadError?: boolean@@ -48,7 +51,7 @@ export type AgentSkillDetail = {}onFolderOpenChange?: (context: { file: AgentSkillFileNode, depth: number, open: boolean }) => voidonFolderDoubleClick?: (context: { file: AgentSkillFileNode, depth: number }) => void- onDownloadFile?: () => void+ onDownloadFile?: (action: AgentSkillDetailDownloadAction) => voidonSelectFile?: (file: AgentSkillFileNode) => voidrenderFolderSuffix?: (context: { file: AgentSkillFileNode, depth: number }) => ReactNodeselectedFileId?: string@@ -161,6 +164,7 @@ function AgentSkillDetailSectionBlock({function AgentFilePreviewContent({binary,content,+ downloadActionLoadingTarget,downloadUrl,fileName,isDownloadError,@@ -168,9 +172,11 @@ function AgentFilePreviewContent({isError,isImage,isLoading,+ onDownloadFile,}: {binary?: booleancontent?: string+ downloadActionLoadingTarget?: AgentSkillDetailDownloadAction | nulldownloadUrl?: stringfileName?: stringisDownloadError?: boolean@@ -178,9 +184,11 @@ function AgentFilePreviewContent({isError?: booleanisImage?: booleanisLoading?: boolean+ onDownloadFile?: (action: AgentSkillDetailDownloadAction) => void}) {const { t } = useTranslation('agentV2')const { t: tCommon } = useTranslation('common')+ const isPreviewDownloadLoading = downloadActionLoadingTarget === 'preview'if (isLoading || isDownloadLoading) {return (@@ -218,16 +226,31 @@ function AgentFilePreviewContent({</span><ahref={downloadUrl || '#'}+ aria-disabled={isPreviewDownloadLoading}onClick={(event) => {- if (!downloadUrl)+ if (isPreviewDownloadLoading) {+ event.preventDefault()+ return+ }+ if (!downloadUrl) {event.preventDefault()+ onDownloadFile?.('preview')+ }}}target="_blank"rel="noreferrer"className="inline-flex min-w-0 items-center gap-1 rounded-md px-2 py-1 system-sm-medium text-text-accent outline-hidden hover:bg-state-base-hover focus-visible:ring-2 focus-visible:ring-state-accent-solid">- <span aria-hidden className="i-ri-download-2-line size-4 shrink-0" />- <span className="shrink-0">{tCommon('operation.download')}</span>+ <span+ aria-hidden+ className={cn(+ 'size-4 shrink-0',+ isPreviewDownloadLoading ? 'i-ri-loader-2-line animate-spin motion-reduce:animate-none' : 'i-ri-download-2-line',+ )}+ />+ <span className="shrink-0">+ {isPreviewDownloadLoading ? tCommon('operation.downloading') : tCommon('operation.download')}+ </span></a></div>)@@ -276,6 +299,7 @@ export function AgentSkillDetailDialog({const { t } = useTranslation('agentV2')const { t: tCommon } = useTranslation('common')const previewTitle = detail.filePreview?.fileName+ const isHeaderDownloadLoading = detail.filePreview?.downloadActionLoadingTarget === 'header'return (<DialogContent backdropProps={{ forceRender: true }} backdropClassName="fixed" className="flex h-[min(720px,calc(100dvh-2rem))] max-h-none w-[min(960px,calc(100vw-2rem))] flex-row overflow-hidden rounded-2xl p-0">@@ -316,11 +340,18 @@ export function AgentSkillDetailDialog({{detail.onDownloadFile && previewTitle && (<buttontype="button"- aria-label={`${tCommon('operation.download')} ${previewTitle}`}- onClick={detail.onDownloadFile}+ aria-label={`${isHeaderDownloadLoading ? tCommon('operation.downloading') : tCommon('operation.download')} ${previewTitle}`}+ onClick={() => detail.onDownloadFile?.('header')}+ disabled={isHeaderDownloadLoading}className="flex size-7 shrink-0 items-center justify-center rounded-md text-text-tertiary outline-hidden hover:bg-state-base-hover hover:text-text-secondary focus-visible:bg-state-base-hover focus-visible:text-text-secondary focus-visible:ring-2 focus-visible:ring-state-accent-solid">- <span aria-hidden className="i-ri-download-line size-4" />+ <span+ aria-hidden+ className={cn(+ 'size-4',+ isHeaderDownloadLoading ? 'i-ri-loader-2-line animate-spin motion-reduce:animate-none' : 'i-ri-download-line',+ )}+ /></button>)}<DialogCloseButton className="static size-7 shrink-0 rounded-md" />@@ -338,6 +369,7 @@ export function AgentSkillDetailDialog({<AgentFilePreviewContentbinary={detail.filePreview.binary}content={detail.filePreview.content}+ downloadActionLoadingTarget={detail.filePreview.downloadActionLoadingTarget}downloadUrl={detail.filePreview.downloadUrl}fileName={detail.filePreview.fileName}isDownloadError={detail.filePreview.isDownloadError}@@ -345,6 +377,7 @@ export function AgentSkillDetailDialog({isError={detail.filePreview.isError}isImage={detail.filePreview.isImage}isLoading={detail.filePreview.isLoading}+ onDownloadFile={detail.onDownloadFile}/>)}{detail.sections.map(section => (diff --git a/web/features/agent-v2/agent-detail/configure/components/preview/__tests__/chat.spec.tsx b/web/features/agent-v2/agent-detail/configure/components/preview/__tests__/chat.spec.tsxindex 5dfb1e80108..bfb02eb0168 100644--- a/web/features/agent-v2/agent-detail/configure/components/preview/__tests__/chat.spec.tsx+++ b/web/features/agent-v2/agent-detail/configure/components/preview/__tests__/chat.spec.tsx@@ -358,6 +358,7 @@ describe('AgentPreviewChat', () => {false,expect.any(Function),'debug-conversation-1',+ { isNewAgent: true },)})diff --git a/web/features/agent-v2/agent-detail/configure/components/preview/__tests__/header.spec.tsx b/web/features/agent-v2/agent-detail/configure/components/preview/__tests__/header.spec.tsxindex cdecdc3d8ff..cefdf559f8b 100644--- a/web/features/agent-v2/agent-detail/configure/components/preview/__tests__/header.spec.tsx+++ b/web/features/agent-v2/agent-detail/configure/components/preview/__tests__/header.spec.tsx@@ -41,13 +41,18 @@ describe('AgentPreviewHeader', () => {vi.clearAllMocks()})- it('should emit refresh from the restart button', async () => {+ it('should confirm before emitting refresh from the restart button', async () => {const user = userEvent.setup()const onRefresh = vi.fn()renderHeader({ mode: 'build', onRefresh })await user.click(screen.getByRole('button', { name: 'agentV2.agentDetail.configure.preview.restart' }))+ expect(onRefresh).not.toHaveBeenCalled()+ expect(screen.getByRole('alertdialog', { name: 'agentV2.agentDetail.configure.clearSessionConfirm.title' })).toBeInTheDocument()++ await user.click(screen.getByRole('button', { name: 'common.operation.confirm' }))+expect(onRefresh).toHaveBeenCalledTimes(1)})diff --git a/web/features/agent-v2/agent-detail/configure/components/preview/__tests__/working-directory-panel.spec.tsx b/web/features/agent-v2/agent-detail/configure/components/preview/__tests__/working-directory-panel.spec.tsxindex 788cbf81c79..9cb15a9171d 100644--- a/web/features/agent-v2/agent-detail/configure/components/preview/__tests__/working-directory-panel.spec.tsx+++ b/web/features/agent-v2/agent-detail/configure/components/preview/__tests__/working-directory-panel.spec.tsx@@ -1,3 +1,4 @@+import { toast } from '@langgenius/dify-ui/toast'import { QueryClient, QueryClientProvider } from '@tanstack/react-query'import { render, screen, waitFor } from '@testing-library/react'import userEvent from '@testing-library/user-event'@@ -16,16 +17,57 @@ const mocks = vi.hoisted(() => ({sandboxInfoQueryOptions: vi.fn(),sandboxFilesQueryOptions: vi.fn(),sandboxFileReadQueryOptions: vi.fn(),+ sandboxFileUploadMutationFn: vi.fn(async (_input: unknown) => ({+ url: 'https://example.com/sandbox-file',+ })),workflowSandboxFilesQueryOptions: vi.fn(),workflowSandboxFileReadQueryOptions: vi.fn(),- downloadBlob: vi.fn(),-}))--vi.mock('@/utils/download', () => ({- downloadBlob: mocks.downloadBlob,+ workflowSandboxFileUploadMutationFn: vi.fn(async (_input: unknown) => ({+ url: 'https://example.com/workflow-sandbox-file',+ })),+ sandboxFileUploadClientPost: vi.fn(async (_input: unknown) => ({+ url: 'https://example.com/chart.png',+ })),+ workflowSandboxFileUploadClientPost: vi.fn(async (_input: unknown) => ({+ url: 'https://example.com/workflow-chart.png',+ })),+ downloadUrl: vi.fn(),+ toastSuccess: vi.fn(),}))vi.mock('@/service/client', () => ({+ consoleClient: {+ agent: {+ byAgentId: {+ sandbox: {+ files: {+ upload: {+ post: mocks.sandboxFileUploadClientPost,+ },+ },+ },+ },+ },+ apps: {+ byAppId: {+ workflowRuns: {+ byWorkflowRunId: {+ agentNodes: {+ byNodeId: {+ sandbox: {+ files: {+ upload: {+ post: mocks.workflowSandboxFileUploadClientPost,+ },+ },+ },+ },+ },+ },+ },+ },+ },+ },consoleQuery: {agent: {byAgentId: {@@ -42,6 +84,11 @@ vi.mock('@/service/client', () => ({queryOptions: mocks.sandboxFileReadQueryOptions,},},+ upload: {+ post: {+ mutationOptions: () => ({ mutationFn: mocks.sandboxFileUploadMutationFn }),+ },+ },},},},@@ -62,6 +109,11 @@ vi.mock('@/service/client', () => ({queryOptions: mocks.workflowSandboxFileReadQueryOptions,},},+ upload: {+ post: {+ mutationOptions: () => ({ mutationFn: mocks.workflowSandboxFileUploadMutationFn }),+ },+ },},},},@@ -73,6 +125,24 @@ vi.mock('@/service/client', () => ({},}))+vi.mock('@/utils/download', () => ({+ downloadUrl: mocks.downloadUrl,+}))++vi.mock('@langgenius/dify-ui/toast', () => ({+ toast: {+ success: mocks.toastSuccess,+ },+}))++function createDeferred<T>() {+ let resolve!: (value: T) => void+ const promise = new Promise<T>((promiseResolve) => {+ resolve = promiseResolve+ })+ return { promise, resolve }+}+function renderWorkingDirectoryPanel() {const queryClient = new QueryClient({defaultOptions: {@@ -112,22 +182,25 @@ describe('AgentWorkingDirectoryPanel', () => {{ name: 'workspace/report.md', type: 'file' },{ name: 'workspace/notes.md', type: 'file' },{ name: 'workspace/chart.png', type: 'file' },+ { name: 'workspace/model.bin', type: 'file' },],}),}))mocks.sandboxFileReadQueryOptions.mockImplementation(({ input }: QueryOptionsInput) => ({queryKey: ['sandbox-file-read', input],queryFn: async () => ({- binary: input.query?.path?.endsWith('chart.png') ?? false,+ binary: input.query?.path?.endsWith('model.bin') ?? false,path: input.query?.path ?? '',- text: input.query?.path?.endsWith('chart.png') ? null : `Content for ${input.query?.path}`,+ text: input.query?.path?.endsWith('model.bin') ? null : `Content for ${input.query?.path}`,truncated: false,}),}))})- it('should download the selected working directory file from the preview header action', async () => {+ it('should download the selected working directory file from the preview header download action', async () => {const user = userEvent.setup()+ const upload = createDeferred<{ url: string }>()+ mocks.sandboxFileUploadMutationFn.mockReturnValueOnce(upload.promise)renderWorkingDirectoryPanel()await user.click(await screen.findByText('notes.md'))@@ -135,25 +208,92 @@ describe('AgentWorkingDirectoryPanel', () => {name: /common\.operation\.download.*notes\.md/i,}))+ const downloadingButton = await screen.findByRole('button', {+ name: /common\.operation\.downloading.*notes\.md/i,+ })+ expect(downloadingButton.querySelector('.animate-spin')).toBeInTheDocument()++ upload.resolve({ url: 'https://example.com/sandbox-file' })+await waitFor(() => {- expect(mocks.downloadBlob).toHaveBeenCalledWith({- data: expect.any(Blob),+ expect(mocks.sandboxFileUploadMutationFn).toHaveBeenCalled()+ expect(mocks.sandboxFileUploadMutationFn.mock.calls[0]?.[0]).toEqual({+ params: {+ agent_id: 'agent-1',+ },+ body: {+ conversation_id: 'conversation-1',+ path: '~/workspace/notes.md',+ },+ })+ expect(mocks.downloadUrl).toHaveBeenCalledWith({+ url: 'https://example.com/sandbox-file',fileName: 'notes.md',})+ expect(toast.success).toHaveBeenCalledWith('common.operation.downloadSuccess')})- const blob = mocks.downloadBlob.mock.calls[0]?.[0].data as Blob- await expect(blob.text()).resolves.toBe('Content for ~/workspace/notes.md')})- it('should show an unsupported preview download placeholder for binary working directory files', async () => {+ it('should download binary working directory files from the unsupported preview download link', async () => {const user = userEvent.setup()+ const upload = createDeferred<{ url: string }>()+ mocks.sandboxFileUploadMutationFn.mockReturnValueOnce(upload.promise)renderWorkingDirectoryPanel()- await user.click(await screen.findByText('chart.png'))+ await user.click(await screen.findByText('model.bin'))expect(await screen.findByText('agentV2.agentDetail.configure.files.preview.unsupported')).toBeInTheDocument()- expect(screen.getByRole('link', { name: /common\.operation\.download/i })).toHaveAttribute('href', '#')- expect(screen.queryByRole('button', { name: /common\.operation\.download.*chart\.png/i })).not.toBeInTheDocument()- expect(mocks.downloadBlob).not.toHaveBeenCalled()+ await user.click(screen.getByRole('link', { name: /common\.operation\.download/i }))++ const downloadingLink = await screen.findByRole('link', { name: /common\.operation\.downloading/i })+ expect(downloadingLink.querySelector('.animate-spin')).toBeInTheDocument()+ const headerDownloadButton = screen.getByRole('button', {+ name: /common\.operation\.download.*model\.bin/i,+ })+ expect(headerDownloadButton.querySelector('.animate-spin')).not.toBeInTheDocument()++ upload.resolve({ url: 'https://example.com/sandbox-file' })++ await waitFor(() => {+ expect(mocks.sandboxFileUploadMutationFn).toHaveBeenCalled()+ expect(mocks.sandboxFileUploadMutationFn.mock.calls[0]?.[0]).toEqual({+ params: {+ agent_id: 'agent-1',+ },+ body: {+ conversation_id: 'conversation-1',+ path: '~/workspace/model.bin',+ },+ })+ expect(mocks.downloadUrl).toHaveBeenCalledWith({+ url: 'https://example.com/sandbox-file',+ fileName: 'model.bin',+ })+ expect(toast.success).toHaveBeenCalledWith('common.operation.downloadSuccess')+ })+ })++ it('should preview sandbox images with the uploaded file url', async () => {+ const user = userEvent.setup()+ renderWorkingDirectoryPanel()++ await user.click(await screen.findByText('chart.png'))++ await waitFor(() => {+ expect(mocks.sandboxFileUploadClientPost).toHaveBeenCalled()+ })+ const image = await screen.findByAltText('chart.png')+ expect(image).toHaveAttribute('src', 'https://example.com/chart.png')+ expect(mocks.sandboxFileUploadClientPost).toHaveBeenCalledWith({+ params: {+ agent_id: 'agent-1',+ },+ body: {+ conversation_id: 'conversation-1',+ path: '~/workspace/chart.png',+ },+ })+ expect(screen.queryByText('agentV2.agentDetail.configure.files.preview.unsupported')).not.toBeInTheDocument()+ expect(mocks.downloadUrl).not.toHaveBeenCalled()})})diff --git a/web/features/agent-v2/agent-detail/configure/components/preview/build-chat.tsx b/web/features/agent-v2/agent-detail/configure/components/preview/build-chat.tsxindex c4b0f6e1eef..c4aefc8475f 100644--- a/web/features/agent-v2/agent-detail/configure/components/preview/build-chat.tsx+++ b/web/features/agent-v2/agent-detail/configure/components/preview/build-chat.tsx@@ -87,6 +87,7 @@ export function AgentBuildChat(props: AgentBuildChatProps) {<AgentChatRuntime{...props}inputPlaceholder={t('agentDetail.configure.build.inputPlaceholder')}+ inputAutoFocus={false}sendButtonLabel={t('agentDetail.configure.build.startBuild')}renderEmptyState={(emptyStateProps: AgentChatRuntimeEmptyStateProps) => (<AgentBuildChatEmptyState {...emptyStateProps} />diff --git a/web/features/agent-v2/agent-detail/configure/components/preview/chat-runtime.tsx b/web/features/agent-v2/agent-detail/configure/components/preview/chat-runtime.tsxindex a8067af7625..d035f52e0ed 100644--- a/web/features/agent-v2/agent-detail/configure/components/preview/chat-runtime.tsx+++ b/web/features/agent-v2/agent-detail/configure/components/preview/chat-runtime.tsx@@ -25,6 +25,7 @@ import { skipToken, useQuery, useQueryClient } from '@tanstack/react-query'import { useAtomValue } from 'jotai'import { useCallback, useEffect, useMemo, useRef, useState } from 'react'import { useTranslation } from 'react-i18next'+import { AgentRosterResponseContent } from '@/app/components/base/chat/chat/answer/agent-roster-response-content'import ChatInputArea from '@/app/components/base/chat/chat/chat-input-area'import { useChat } from '@/app/components/base/chat/chat/hooks'import { buildChatItemTree, getLastAnswer, isValidGeneratedAnswer } from '@/app/components/base/chat/utils'@@ -449,6 +450,7 @@ export type AgentChatRuntimeProps = {conversationId?: string | nulldraftType?: 'debug_build'inputPlaceholder: string+ inputAutoFocus?: booleansendButtonLabel?: stringrenderEmptyState: (props: AgentChatRuntimeEmptyStateProps) => ReactNodeonClearChatListChange: (clearChatList: boolean) => void@@ -470,6 +472,7 @@ export function AgentChatRuntime({conversationId,draftType,inputPlaceholder,+ inputAutoFocus,sendButtonLabel,renderEmptyState,onClearChatListChange,@@ -534,6 +537,7 @@ export function AgentChatRuntime({draftType={draftType}initialChatTree={initialChatTree}inputPlaceholder={inputPlaceholder}+ inputAutoFocus={inputAutoFocus}sendButtonLabel={sendButtonLabel}renderEmptyState={renderEmptyState}onClearChatListChange={handleClearChatListChange}@@ -558,6 +562,7 @@ function AgentPreviewChatSession({draftType,initialChatTree,inputPlaceholder,+ inputAutoFocus,sendButtonLabel,renderEmptyState,onClearChatListChange,@@ -578,6 +583,7 @@ function AgentPreviewChatSession({draftType?: 'debug_build'initialChatTree: ChatItemInTree[]inputPlaceholder: string+ inputAutoFocus?: booleansendButtonLabel?: stringrenderEmptyState: (props: AgentChatRuntimeEmptyStateProps) => ReactNodeonClearChatListChange: (clearChatList: boolean) => void@@ -634,6 +640,7 @@ function AgentPreviewChatSession({clearChatList,onClearChatListChange,conversationId ?? undefined,+ { isNewAgent: true },)const doSend: OnSend = useCallback(async (message, files, isRegenerate = false, parentAnswer: ChatItem | null = null) => {@@ -754,6 +761,9 @@ function AgentPreviewChatSession({botName={agentName || 'Agent'}customPlaceholder={inputPlaceholder}disabled={isResponding}+ // Build chat opts out so it does not steal focus from the configure editor.+ // eslint-disable-next-line jsx-a11y/no-autofocus+ autoFocus={inputAutoFocus}sendButtonLoading={sendButtonLoading}showFileUpload={false}visionConfig={config.file_upload}@@ -804,6 +814,7 @@ function AgentPreviewChatSession({onAnnotationEdited={handleAnnotationEdited}onAnnotationAdded={handleAnnotationAdded}onAnnotationRemoved={handleAnnotationRemoved}+ renderAgentContent={AgentRosterResponseContent}noSpacing/>)diff --git a/web/features/agent-v2/agent-detail/configure/components/preview/header.tsx b/web/features/agent-v2/agent-detail/configure/components/preview/header.tsxindex baaf14c7115..290349052dd 100644--- a/web/features/agent-v2/agent-detail/configure/components/preview/header.tsx+++ b/web/features/agent-v2/agent-detail/configure/components/preview/header.tsx@@ -4,6 +4,7 @@ import { Popover, PopoverContent, PopoverTrigger } from '@langgenius/dify-ui/popimport { SegmentedControl, SegmentedControlDivider, SegmentedControlItem } from '@langgenius/dify-ui/segmented-control'import { useTranslation } from 'react-i18next'import { useDocLink } from '@/context/i18n'+import { AgentConfigureClearSessionConfirmDialog } from '../confirm-clear-session-dialog'type AgentConfigureRightPanelMode = 'build' | 'preview'@@ -186,15 +187,16 @@ export function AgentPreviewHeader({</div><div className="flex shrink-0 items-center"><div className="flex items-center gap-2">- <button- type="button"- onClick={onRefresh}- disabled={refreshDisabled}- className="flex size-6 items-center justify-center rounded-md p-0.5 text-text-tertiary hover:bg-state-base-hover hover:text-text-secondary focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50"- aria-label={t('agentDetail.configure.preview.restart')}- >- <span aria-hidden className="i-custom-vender-other-replay-line size-4" />- </button>+ <AgentConfigureClearSessionConfirmDialog onConfirm={onRefresh}>+ <button+ type="button"+ disabled={refreshDisabled}+ className="flex size-6 items-center justify-center rounded-md p-0.5 text-text-tertiary hover:bg-state-base-hover hover:text-text-secondary focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50"+ aria-label={t('agentDetail.configure.preview.restart')}+ >+ <span aria-hidden className="i-custom-vender-other-replay-line size-4" />+ </button>+ </AgentConfigureClearSessionConfirmDialog>{mode === 'build' && showWorkingDirectoryAction && (<buttontype="button"diff --git a/web/features/agent-v2/agent-detail/configure/components/preview/working-directory-panel.tsx b/web/features/agent-v2/agent-detail/configure/components/preview/working-directory-panel.tsxindex 3599a6958b5..0875e062217 100644--- a/web/features/agent-v2/agent-detail/configure/components/preview/working-directory-panel.tsx+++ b/web/features/agent-v2/agent-detail/configure/components/preview/working-directory-panel.tsx@@ -1,15 +1,17 @@'use client'import type { SandboxFileEntryResponse, SandboxListResponse, SandboxReadResponse } from '@dify/contracts/api/console/agent/types.gen'+import type { AgentSkillDetailDownloadAction } from '../orchestrate/skills/detail-dialog'import type { AgentWorkingDirectoryPath } from './working-directory-breadcrumb'import type { AgentFileNode } from '@/features/agent-v2/agent-composer/form-state'import { Dialog } from '@langgenius/dify-ui/dialog'+import { toast } from '@langgenius/dify-ui/toast'import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/tooltip'-import { skipToken, useQueries, useQuery } from '@tanstack/react-query'+import { skipToken, useMutation, useQueries, useQuery } from '@tanstack/react-query'import { useCallback, useState } from 'react'import { useTranslation } from 'react-i18next'-import { consoleQuery } from '@/service/client'-import { downloadBlob } from '@/utils/download'+import { consoleClient, consoleQuery } from '@/service/client'+import { downloadUrl } from '@/utils/download'import { getFileIconType } from '../orchestrate/files/file-icon'import { AgentSkillDetailDialog } from '../orchestrate/skills/detail-dialog'import { AgentWorkingDirectoryBreadcrumb } from './working-directory-breadcrumb'@@ -242,6 +244,7 @@ export function AgentWorkingDirectoryPanel({const [loadedFolderPaths, setLoadedFolderPaths] = useState<string[]>([])const [openFolderPaths, setOpenFolderPaths] = useState<string[]>([])const [pendingOpenFolderPaths, setPendingOpenFolderPaths] = useState<string[]>([])+ const [downloadActionLoadingTarget, setDownloadActionLoadingTarget] = useState<AgentSkillDetailDownloadAction | null>(null)const workflowNodeRunId = source.type === 'workflow-node'? (source.workflowRunId ?? source.conversationId): undefined@@ -411,7 +414,7 @@ export function AgentWorkingDirectoryPanel({})const fileReadQuery = useQuery({...fileReadQueryOptions,- enabled: open && !!selectedWorkingDirectoryFile,+ enabled: open && !!selectedWorkingDirectoryFile && selectedWorkingDirectoryFile.icon !== 'image',queryFn: async (context): Promise<SandboxReadResponse> => {try {return await fileReadQueryOptions.queryFn(context)@@ -431,21 +434,110 @@ export function AgentWorkingDirectoryPanel({},retry: false,})- const isFileReadLoading = !!selectedWorkingDirectoryFile && fileReadQuery.isPending- const { data: fileReadData, refetch: refetchFileRead } = fileReadQuery- const handleDownloadFile = useCallback(async () => {- if (!selectedWorkingDirectoryFile)+ const agentSandboxUploadMutation = useMutation(consoleQuery.agent.byAgentId.sandbox.files.upload.post.mutationOptions())+ const workflowSandboxUploadMutation = useMutation(consoleQuery.apps.byAppId.workflowRuns.byWorkflowRunId.agentNodes.byNodeId.sandbox.files.upload.post.mutationOptions())+ const { mutateAsync: uploadAgentSandboxFile } = agentSandboxUploadMutation+ const isImagePreviewFile = selectedWorkingDirectoryFile?.icon === 'image'+ const selectedWorkingDirectoryFilePath = selectedWorkingDirectoryFile?.id+ const { mutateAsync: uploadWorkflowSandboxFile } = workflowSandboxUploadMutation+ const isFileDownloadPending = agentSandboxUploadMutation.isPending || workflowSandboxUploadMutation.isPending+ const isFileReadLoading = !!selectedWorkingDirectoryFile && !isImagePreviewFile && fileReadQuery.isPending+ const imagePreviewQuery = useQuery({+ queryKey: [+ 'agent-v2',+ 'working-directory',+ 'image-preview',+ source.type,+ source.type === 'agent' ? source.agentId : source.appId,+ source.type === 'agent' ? source.conversationId : workflowNodeRunId,+ source.type === 'workflow-node' ? source.nodeId : undefined,+ selectedWorkingDirectoryFilePath,+ ],+ queryFn: async () => {+ if (!selectedWorkingDirectoryFilePath)+ throw new Error('Missing selected working directory file')++ if (source.type === 'agent') {+ if (!source.conversationId)+ throw new Error('Missing agent sandbox conversation ID')++ return consoleClient.agent.byAgentId.sandbox.files.upload.post({+ params: {+ agent_id: source.agentId,+ },+ body: {+ conversation_id: source.conversationId,+ path: toSandboxApiPath(selectedWorkingDirectoryFilePath),+ },+ })+ }++ if (!source.appId || !workflowNodeRunId)+ throw new Error('Missing workflow sandbox source')++ return consoleClient.apps.byAppId.workflowRuns.byWorkflowRunId.agentNodes.byNodeId.sandbox.files.upload.post({+ params: {+ app_id: source.appId,+ workflow_run_id: workflowNodeRunId,+ node_id: source.nodeId,+ },+ body: {+ path: toSandboxApiPath(selectedWorkingDirectoryFilePath),+ },+ })+ },+ enabled: open && !!selectedWorkingDirectoryFile && isImagePreviewFile && hasWorkingDirectorySource,+ })+ const handleDownloadFile = useCallback(async (action: AgentSkillDetailDownloadAction) => {+ if (!selectedWorkingDirectoryFile || isFileDownloadPending)return- const readResult = fileReadData ?? (await refetchFileRead()).data- if (readResult?.binary || readResult?.text === undefined || readResult.text === null)+ if (source.type === 'agent') {+ if (!source.conversationId)+ return++ setDownloadActionLoadingTarget(action)+ try {+ const result = await uploadAgentSandboxFile({+ params: {+ agent_id: source.agentId,+ },+ body: {+ conversation_id: source.conversationId,+ path: toSandboxApiPath(selectedWorkingDirectoryFile.id),+ },+ })+ downloadUrl({ url: result.url, fileName: selectedWorkingDirectoryFile.name })+ toast.success(tCommon('operation.downloadSuccess'))+ }+ finally {+ setDownloadActionLoadingTarget(null)+ }+ return+ }++ if (!source.appId || !workflowNodeRunId)return- downloadBlob({- data: new Blob([readResult.text], { type: 'text/plain;charset=utf-8' }),- fileName: selectedWorkingDirectoryFile.name,- })- }, [fileReadData, refetchFileRead, selectedWorkingDirectoryFile])+ setDownloadActionLoadingTarget(action)+ try {+ const result = await uploadWorkflowSandboxFile({+ params: {+ app_id: source.appId,+ workflow_run_id: workflowNodeRunId,+ node_id: source.nodeId,+ },+ body: {+ path: toSandboxApiPath(selectedWorkingDirectoryFile.id),+ },+ })+ downloadUrl({ url: result.url, fileName: selectedWorkingDirectoryFile.name })+ toast.success(tCommon('operation.downloadSuccess'))+ }+ finally {+ setDownloadActionLoadingTarget(null)+ }+ }, [isFileDownloadPending, selectedWorkingDirectoryFile, source, tCommon, uploadAgentSandboxFile, uploadWorkflowSandboxFile, workflowNodeRunId])return (<Dialog open={open} onOpenChange={onOpenChange}>@@ -496,13 +588,16 @@ export function AgentWorkingDirectoryPanel({filePreview: {binary: fileReadQuery.data?.binary,content: fileReadQuery.data?.text ?? undefined,+ downloadActionLoadingTarget,+ downloadUrl: imagePreviewQuery.data?.url,fileName: isFileListLoading ? '' : selectedWorkingDirectoryFile?.name,+ isDownloadError: imagePreviewQuery.isError,+ isDownloadLoading: !!isImagePreviewFile && imagePreviewQuery.isPending,isError: fileListQuery.isError || fileReadQuery.isError,+ isImage: isImagePreviewFile,isLoading: isFileListLoading || isFileReadLoading,},- onDownloadFile: selectedWorkingDirectoryFile && !fileReadQuery.data?.binary- ? handleDownloadFile- : undefined,+ onDownloadFile: selectedWorkingDirectoryFile ? handleDownloadFile : undefined,folderOpenState: ({ file }) => {const queryIndex = loadedFolderPathIndexes.get(file.id)const folderLoaded = queryIndex !== undefined && expandedFolderQueries[queryIndex]?.isSuccessdiff --git a/web/features/agent-v2/agent-detail/configure/model-compatibility.ts b/web/features/agent-v2/agent-detail/configure/model-compatibility.tsindex e4fa261c80f..39747570efc 100644--- a/web/features/agent-v2/agent-detail/configure/model-compatibility.ts+++ b/web/features/agent-v2/agent-detail/configure/model-compatibility.ts@@ -67,8 +67,8 @@ const agentSuggestedModelPatterns: RegExp[] = [/^(?:claude[ .-])?opus[ .-]4\.7$/i,/^(?:claude[ .-])?sonnet[ .-]4\.6$/i,- // gemini- /^gemini 3\.1 pro preview$/i,+ // The Gemini model plugin quality is not strong enough yet, so do not recommend it for now.+ // /^gemini 3\.1 pro preview$/i,// x/^grok[ .-]4\.3$/i,diff --git a/web/features/agent-v2/agent-detail/logs/__tests__/page.spec.tsx b/web/features/agent-v2/agent-detail/logs/__tests__/page.spec.tsxindex 4b60e27366a..344535420f0 100644--- a/web/features/agent-v2/agent-detail/logs/__tests__/page.spec.tsx+++ b/web/features/agent-v2/agent-detail/logs/__tests__/page.spec.tsx@@ -301,11 +301,16 @@ describe('AgentLogsPage', () => {expect(getLatestLogsQueryInput().input.query).toEqual(expect.objectContaining({sources: ['webapp:webapp-app-id'],}))+ expect(mocks.logsQueryFn).toHaveBeenCalledTimes(2)})expect(screen.getByText('Previous conversation')).toBeInTheDocument()resolveNextLogs(emptyLogsResponse)++ await waitFor(() => {+ expect(screen.queryByText('Previous conversation')).not.toBeInTheDocument()+ })})it('should open chatbot-style log detail drawer with generated messages contract when a row is clicked', async () => {diff --git a/web/features/agent-v2/agent-detail/navigation.tsx b/web/features/agent-v2/agent-detail/navigation.tsxindex 714bbc57e94..78a884cc1d7 100644--- a/web/features/agent-v2/agent-detail/navigation.tsx+++ b/web/features/agent-v2/agent-detail/navigation.tsx@@ -20,6 +20,7 @@ import Link from '@/next/link'import { usePathname } from '@/next/navigation'import { consoleQuery } from '@/service/client'import { getAgentDetailPath, getAgentIdFromPathname } from './routes'+import { AgentDetailSidebarActions } from './sidebar-actions'type AgentDetailTopProps = {expand?: boolean@@ -214,13 +215,16 @@ export function AgentDetailSection({/></span></div>- <div className={cn('flex h-10 min-w-0 flex-1 flex-col justify-center', !expand && 'hidden')}>- <div className="truncate system-md-semibold text-text-secondary">- {agent?.name ?? t('agentDetail.title')}- </div>- <div className="truncate system-2xs-medium-uppercase text-text-tertiary">- {agent?.role ?? t('agentDetail.type')}+ <div className={cn('flex h-10 min-w-0 flex-1 items-center gap-2', !expand && 'hidden')}>+ <div className="flex min-w-0 flex-1 flex-col justify-center">+ <div className="truncate system-md-semibold text-text-secondary">+ {agent?.name ?? t('agentDetail.title')}+ </div>+ <div className="truncate system-2xs-medium-uppercase text-text-tertiary">+ {agent?.role ?? t('agentDetail.type')}+ </div></div>+ {agent && expand && <AgentDetailSidebarActions agent={agent} />}</div></div></div>diff --git a/web/features/agent-v2/agent-detail/sidebar-actions.tsx b/web/features/agent-v2/agent-detail/sidebar-actions.tsxnew file mode 100644index 00000000000..4e86c2b631b--- /dev/null+++ b/web/features/agent-v2/agent-detail/sidebar-actions.tsx@@ -0,0 +1,111 @@+'use client'++import type { AgentAppPartial } from '@dify/contracts/api/console/agent/types.gen'+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuSeparator,+ DropdownMenuTrigger,+} from '@langgenius/dify-ui/dropdown-menu'+import { useState } from 'react'+import { useTranslation } from 'react-i18next'+import { DeleteAgentDialog } from '@/features/agent-v2/roster/components/delete-agent-dialog'+import { DuplicateAgentDialog } from '@/features/agent-v2/roster/components/duplicate-agent-dialog'+import { EditAgentDialog } from '@/features/agent-v2/roster/components/edit-agent-dialog'++type AgentDetailSidebarActionAgent = Pick<+ AgentAppPartial,+ | 'description'+ | 'icon'+ | 'icon_background'+ | 'icon_type'+ | 'icon_url'+ | 'id'+ | 'mode'+ | 'name'+ | 'role'+>++export function AgentDetailSidebarActions({+ agent,+}: {+ agent: AgentDetailSidebarActionAgent+}) {+ const { t } = useTranslation('agentV2')+ const { t: tCommon } = useTranslation('common')+ const [isEditOpen, setIsEditOpen] = useState(false)+ const [editSessionKey, setEditSessionKey] = useState(0)+ const [isDuplicateOpen, setIsDuplicateOpen] = useState(false)+ const [duplicateSessionKey, setDuplicateSessionKey] = useState(0)+ const [isDeleteOpen, setIsDeleteOpen] = useState(false)+ const dialogAgent: AgentAppPartial = {+ description: agent.description,+ icon: agent.icon,+ icon_background: agent.icon_background,+ icon_type: agent.icon_type,+ icon_url: agent.icon_url,+ id: agent.id,+ mode: agent.mode,+ name: agent.name,+ role: agent.role,+ }++ const handleEditOpen = () => {+ setEditSessionKey(key => key + 1)+ setIsEditOpen(true)+ }++ const handleDuplicateOpen = () => {+ setDuplicateSessionKey(key => key + 1)+ setIsDuplicateOpen(true)+ }++ return (+ <>+ <DropdownMenu>+ <DropdownMenuTrigger+ aria-label={t('roster.moreActions', { name: agent.name })}+ className="flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-text-tertiary hover:bg-state-base-hover hover:text-text-secondary focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden data-popup-open:bg-state-base-hover data-popup-open:text-text-secondary"+ >+ <span aria-hidden className="i-ri-more-fill size-4" />+ </DropdownMenuTrigger>+ <DropdownMenuContent placement="bottom-end" sideOffset={4} popupClassName="w-40">+ <DropdownMenuItem className="gap-2" onClick={handleEditOpen}>+ <span aria-hidden className="i-ri-edit-line size-4 shrink-0 text-text-tertiary" />+ <span>{t('roster.editInfo')}</span>+ </DropdownMenuItem>+ <DropdownMenuItem+ className="gap-2"+ onClick={handleDuplicateOpen}+ >+ <span aria-hidden className="i-ri-file-copy-line size-4 shrink-0 text-text-tertiary" />+ <span>{tCommon('operation.duplicate')}</span>+ </DropdownMenuItem>+ <DropdownMenuSeparator />+ <DropdownMenuItem+ variant="destructive"+ className="gap-2"+ onClick={() => setIsDeleteOpen(true)}+ >+ <span aria-hidden className="i-ri-delete-bin-line size-4 shrink-0" />+ <span>{tCommon('operation.delete')}</span>+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ <EditAgentDialog+ agent={dialogAgent}+ formKey={editSessionKey}+ open={isEditOpen}+ onOpenChange={setIsEditOpen}+ />+ <DuplicateAgentDialog+ agent={dialogAgent}+ formKey={duplicateSessionKey}+ open={isDuplicateOpen}+ onOpenChange={setIsDuplicateOpen}+ />+ <DeleteAgentDialog agentId={agent.id} agentName={agent.name} open={isDeleteOpen} onOpenChange={setIsDeleteOpen} />+ </>+ )+}diff --git a/web/features/agent-v2/roster/page.tsx b/web/features/agent-v2/roster/page.tsxindex 7a63dd1a6d7..5f4a85e7ae7 100644--- a/web/features/agent-v2/roster/page.tsx+++ b/web/features/agent-v2/roster/page.tsx@@ -9,7 +9,6 @@ import {ScrollAreaThumb,ScrollAreaViewport,} from '@langgenius/dify-ui/scroll-area'-import { Tabs, TabsList, TabsPanel, TabsTab } from '@langgenius/dify-ui/tabs'import { keepPreviousData, useInfiniteQuery } from '@tanstack/react-query'import { useDebounce } from 'ahooks'import { useQueryState } from 'nuqs'@@ -28,7 +27,6 @@ import {const ROSTER_PAGE_SIZE = 30const isAgentPublished = (agent: AgentAppPartial) => agent.active_config_is_published === true-const rosterTabClassName = 'pt-0 pb-2 system-xl-semibold data-active:border-transparent data-disabled:opacity-100'const getFilteredRosterItems = (agents: AgentAppPartial[],@@ -90,58 +88,51 @@ export default function RosterPage() {return (<div className="flex h-0 min-w-0 grow flex-col overflow-hidden bg-background-body">- <Tabs defaultValue="agent" className="flex min-h-0 flex-1 flex-col">- <div className="h-25.5 shrink-0 bg-background-body px-8 pt-4 pb-4">- <div className="flex min-w-0 items-center justify-between gap-4">- <TabsList aria-label={t('roster.tabsLabel')}>- <TabsTab value="agent" className={rosterTabClassName}>- {t('roster.tabs.agent')}- </TabsTab>- <TabsTab value="human" disabled className={rosterTabClassName}>- {t('roster.tabs.human')}- </TabsTab>- </TabsList>- <a- href="https://docs.dify.ai/"- target="_blank"- rel="noreferrer"- className="hidden shrink-0 items-center gap-0.5 rounded-md system-xs-regular text-text-tertiary hover:text-text-secondary focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden sm:inline-flex"- >- {t('roster.learnMore')}- <span aria-hidden className="i-ri-external-link-line size-3" />- </a>- </div>- <div className="mt-3.5">- <RosterToolbar- draftAgents={draftAgents}- publishedAgents={publishedAgents}- />- </div>+ <div className="shrink-0 bg-background-body px-8 pt-4 pb-2">+ <div className="flex h-6 min-w-0 items-center justify-between gap-4">+ <h1 className="min-w-0 flex-1 truncate text-[18px]/[21.6px] font-semibold text-text-primary">+ {tCommon('menus.roster')}+ </h1>+ <a+ href="https://docs.dify.ai/"+ target="_blank"+ rel="noreferrer"+ className="hidden shrink-0 items-center gap-0.5 rounded-md system-xs-regular text-text-tertiary hover:text-text-secondary focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden sm:inline-flex"+ >+ {t('roster.learnMore')}+ <span aria-hidden className="i-ri-external-link-line size-3" />+ </a></div>+ <div className="mt-3.5">+ <RosterToolbar+ draftAgents={draftAgents}+ publishedAgents={publishedAgents}+ />+ </div>+ </div>- <TabsPanel value="agent" tabIndex={-1} className="min-h-0 flex-1">- <ScrollAreaRoot className="relative h-full min-h-0 min-w-0 overflow-hidden">- <ScrollAreaViewport tabIndex={-1} className="overscroll-contain">- <ScrollAreaContent className="min-h-full px-8 pt-2 pb-8">- <AgentRosterList- agents={filteredRosterItems}- hasMore={!!hasNextPage}- isEmptySearch={!!debouncedKeyword || rosterFilter !== 'all'}- isError={!!error}- isFetching={isFetching}- isFetchingNextPage={isFetchingNextPage}- isPending={isPending}- label={t('roster.listLabel')}- onLoadMore={() => fetchNextPage()}- />- </ScrollAreaContent>- </ScrollAreaViewport>- <ScrollAreaScrollbar>- <ScrollAreaThumb />- </ScrollAreaScrollbar>- </ScrollAreaRoot>- </TabsPanel>- </Tabs>+ <div className="min-h-0 flex-1">+ <ScrollAreaRoot className="relative h-full min-h-0 min-w-0 overflow-hidden">+ <ScrollAreaViewport tabIndex={-1} className="overscroll-contain">+ <ScrollAreaContent className="min-h-full px-8 pt-2 pb-8">+ <AgentRosterList+ agents={filteredRosterItems}+ hasMore={!!hasNextPage}+ isEmptySearch={!!debouncedKeyword || rosterFilter !== 'all'}+ isError={!!error}+ isFetching={isFetching}+ isFetchingNextPage={isFetchingNextPage}+ isPending={isPending}+ label={t('roster.listLabel')}+ onLoadMore={() => fetchNextPage()}+ />+ </ScrollAreaContent>+ </ScrollAreaViewport>+ <ScrollAreaScrollbar>+ <ScrollAreaThumb />+ </ScrollAreaScrollbar>+ </ScrollAreaRoot>+ </div></div>)}diff --git a/web/i18n/ar-TN/agent-v-2.json b/web/i18n/ar-TN/agent-v-2.jsonindex 56c75195270..0bec3801758 100644--- a/web/i18n/ar-TN/agent-v-2.json+++ b/web/i18n/ar-TN/agent-v-2.json@@ -63,6 +63,11 @@"agentDetail.configure.advancedSettings.envEditor.valuePlaceholder": "Value","agentDetail.configure.advancedSettings.label": "الإعدادات المتقدمة","agentDetail.configure.advancedSettings.toggle": "تبديل الإعدادات المتقدمة",+ "agentDetail.configure.answer.duration.minute": "{{count}} د",+ "agentDetail.configure.answer.duration.second": "{{count}} ث",+ "agentDetail.configure.answer.workFinished": "اكتمل العمل",+ "agentDetail.configure.answer.workedFor": "عمل لمدة {{duration}}",+ "agentDetail.configure.answer.workingFor": "يعمل منذ {{duration}}","agentDetail.configure.build.empty.communityEditionTip": "توفر Community Edition إدارة إصدارات للتكوينات المستخرجة، لكنها لا تدعم إدارة إصدارات نظام الملفات نفسه. كن حذراً في إجراءاتك ضمن وضع Build، لأن التغييرات التي تُجرى على نظام الملفات تحدث في الوقت الفعلي ولا يمكن دائماً التراجع عنها بشكل منظم. Community Edition ليست الخيار المثالي لخدمة جماهير خارجية واسعة.","agentDetail.configure.build.empty.description": "صِف ما تريده وسيتم ملء النموذج على اليسار أثناء المحادثة.","agentDetail.configure.build.empty.title": "ابنِ وكيلك عبر الدردشة",@@ -79,6 +84,8 @@"agentDetail.configure.buildDraft.updated": "تم التحديث","agentDetail.configure.chatFeatures.description": "شكّل تجربة الدردشة للمستخدم النهائي على Web app وأسطح الدردشة.","agentDetail.configure.chatFeatures.title": "ميزات الدردشة",+ "agentDetail.configure.clearSessionConfirm.description": "سيؤدي هذا إلى مسح الجلسة الحالية والتخلي عن تغييرات إعدادات Agent التي لم يتم تطبيقها بعد.",+ "agentDetail.configure.clearSessionConfirm.title": "مسح الجلسة والتخلي عن التغييرات؟","agentDetail.configure.communityEditionIsolationTip": "لا توفر Community Edition عزلاً صارماً لنظام الملفات بين المستخدمين النهائيين أو بين عمليات التشغيل. لا تعرض وكيل CE نفسه لعدة مستخدمين نهائيين مستقلين عندما يكون عزل البيانات أو الامتثال الصارم مطلوباً.","agentDetail.configure.files.add": "إضافة ملف","agentDetail.configure.files.buildNote.generated": "تم إنشاؤه",@@ -348,7 +355,7 @@"agentDetail.versionHistory.versionName": "الإصدار {{version}}","agentDetail.versionHistory.viewOnly": "عرض فقط","roster.createAgent": "إنشاء وكيل",- "roster.createDialog.description": "أنشئ وكيلاً قابلاً لإعادة الاستخدام في Roster مساحة العمل هذه.",+ "roster.createDialog.description": "أنشئ Agent قابلاً لإعادة الاستخدام في مساحة العمل هذه.","roster.createDialog.title": "إنشاء وكيل","roster.createForm.changeIcon": "تغيير أيقونة الوكيل","roster.createForm.descriptionLabel": "الوصف",@@ -360,16 +367,16 @@"roster.createForm.rolePlaceholder": "مثلاً مساعد بحث","roster.createSuccess": "تم إنشاء الوكيل.","roster.dateTimeFormat": "DD/MM/YYYY HH:mm:ss",- "roster.deleteDialog.description": "ستتم إزالة هذا الوكيل من قائمة Roster النشطة.",+ "roster.deleteDialog.description": "ستتم إزالة هذا Agent من قائمة Agent.","roster.deleteDialog.title": "حذف {{name}}؟","roster.deleteFailed": "فشل حذف الوكيل.","roster.deleteSuccess": "تم حذف الوكيل.",- "roster.duplicateDialog.description": "أنشئ نسخة من {{name}} وخصّص هويته في Roster.",+ "roster.duplicateDialog.description": "أنشئ نسخة من {{name}} وخصّص هوية Agent الخاصة بها.","roster.duplicateDialog.title": "نسخ الوكيل","roster.duplicateForm.changeIcon": "تغيير أيقونة نسخة {{name}}","roster.duplicateSuccess": "تم نسخ الوكيل.","roster.editAgent": "تعديل {{name}}",- "roster.editDialog.description": "حدّث اسم Roster والوصف والدور لهذا الوكيل.",+ "roster.editDialog.description": "حدّث اسم هذا Agent ووصفه ودوره.","roster.editDialog.title": "تعديل الوكيل","roster.editInfo": "تعديل المعلومات","roster.empty": "لا يوجد وكيل بعد",@@ -379,8 +386,8 @@"roster.filters.drafts": "مسودات","roster.filters.label": "مرشحات الوكيل","roster.filters.published": "منشور",- "roster.learnMore": "اعرف المزيد عن Agent Roster",- "roster.listLabel": "قائمة Roster الوكلاء",+ "roster.learnMore": "اعرف المزيد عن Agent",+ "roster.listLabel": "قائمة Agent","roster.loadMore": "تحميل المزيد","roster.loadingError": "فشل تحميل الوكلاء. قم بالتحديث وحاول مرة أخرى.","roster.moreActions": "إجراءات أخرى لـ {{name}}",@@ -392,10 +399,10 @@"roster.references.label": "سير العمل الذي يستخدم {{name}}","roster.references.trigger": "سير العمل الذي يستخدم {{name}}","roster.saveToRoster": "حفظ إلى Agent Console",- "roster.saveToRosterDialog.description": "احفظ هذا الإعداد المضمّن كوكيل Roster قابل لإعادة الاستخدام.",+ "roster.saveToRosterDialog.description": "احفظ هذا الإعداد المضمّن كـ Agent قابل لإعادة الاستخدام.","roster.saveToRosterDialog.title": "حفظ إلى Agent Console",- "roster.saveToRosterForm.changeIcon": "تغيير أيقونة وكيل Roster",- "roster.saveToRosterSuccess": "تم حفظ الوكيل في Roster.",+ "roster.saveToRosterForm.changeIcon": "تغيير أيقونة Agent",+ "roster.saveToRosterSuccess": "تم حفظ Agent.","roster.searchLabel": "البحث عن الوكلاء","roster.searchPlaceholder": "ابحث عن الوكلاء بالاسم…","roster.sort.earliestCreated": "الأقدم إنشاءً",@@ -403,9 +410,6 @@"roster.sort.lastModified": "آخر تعديل","roster.sort.optionsLabel": "خيارات الفرز","roster.sort.recentlyCreated": "الأحدث إنشاءً",- "roster.tabs.agent": "وكيل",- "roster.tabs.human": "جهات الاتصال",- "roster.tabsLabel": "نوع Roster","roster.updateSuccess": "تم تحديث الوكيل.","roster.usageStatus.draft": "مسودة"}diff --git a/web/i18n/ar-TN/app-debug.json b/web/i18n/ar-TN/app-debug.jsonindex b0a47ca5e25..f84011d251f 100644--- a/web/i18n/ar-TN/app-debug.json+++ b/web/i18n/ar-TN/app-debug.json@@ -244,6 +244,9 @@"inputs.run": "تشغيل","inputs.title": "تصحيح ومعاينة","inputs.userInputField": "حقل إدخال المستخدم",+ "legacyAgentBadge.action": "إنشاء Agent",+ "legacyAgentBadge.description": "تم إيقاف نوع تطبيق Agent القديم هذا. للحصول على تجربة أفضل في بناء الوكلاء، أنشئ Agent في Agent Console.",+ "legacyAgentBadge.label": "Agent قديم","manageModels": "إدارة النماذج","modelConfig.modeType.chat": "دردشة","modelConfig.modeType.completion": "إكمال",diff --git a/web/i18n/ar-TN/common.json b/web/i18n/ar-TN/common.jsonindex 74856605669..1ad36b6c7d0 100644--- a/web/i18n/ar-TN/common.json+++ b/web/i18n/ar-TN/common.json@@ -288,7 +288,7 @@"menus.explore": "استكشاف","menus.exploreMarketplace": "استكشاف السوق","menus.plugins": "الإضافات",- "menus.roster": "قائمة الوكلاء",+ "menus.roster": "Agent","menus.status": "بيتا","menus.tools": "الأدوات","model.capabilities": "قدرات متعددة الوسائط",@@ -444,6 +444,7 @@"operation.download": "تنزيل","operation.downloadFailed": "فشل التنزيل. يرجى المحاولة مرة أخرى لاحقًا.","operation.downloadSuccess": "اكتمل التنزيل.",+ "operation.downloading": "جارٍ التنزيل...","operation.duplicate": "تكرار","operation.edit": "تعديل","operation.exporting": "جارٍ التصدير",diff --git a/web/i18n/de-DE/agent-v-2.json b/web/i18n/de-DE/agent-v-2.jsonindex b9c777680ce..47ff00a0010 100644--- a/web/i18n/de-DE/agent-v-2.json+++ b/web/i18n/de-DE/agent-v-2.json@@ -63,6 +63,11 @@"agentDetail.configure.advancedSettings.envEditor.valuePlaceholder": "Value","agentDetail.configure.advancedSettings.label": "Erweiterte Einstellungen","agentDetail.configure.advancedSettings.toggle": "Erweiterte Einstellungen umschalten",+ "agentDetail.configure.answer.duration.minute": "{{count}} Min.",+ "agentDetail.configure.answer.duration.second": "{{count}} s",+ "agentDetail.configure.answer.workFinished": "Arbeit abgeschlossen",+ "agentDetail.configure.answer.workedFor": "Gearbeitet für {{duration}}",+ "agentDetail.configure.answer.workingFor": "Arbeitet seit {{duration}}","agentDetail.configure.build.empty.communityEditionTip": "Community Edition bietet zwar Versionierung für extrahierte Konfigurationen, unterstützt aber keine Versionierung des Dateisystems selbst. Seien Sie bei Aktionen im Build-Modus vorsichtig, da Änderungen am Dateisystem in Echtzeit erfolgen und nicht immer sauber rückgängig gemacht werden können. Community Edition ist nicht die ideale Wahl, um große externe Zielgruppen zu bedienen.","agentDetail.configure.build.empty.description": "Beschreiben Sie, was Sie möchten, und das Formular links wird während des Chats ausgefüllt.","agentDetail.configure.build.empty.title": "Agent per Chat erstellen",@@ -79,6 +84,8 @@"agentDetail.configure.buildDraft.updated": "Aktualisiert","agentDetail.configure.chatFeatures.description": "Gestalten Sie das Chat-Erlebnis für Endnutzer in Ihrer Webapp und in Chat-Oberflächen.","agentDetail.configure.chatFeatures.title": "Chat-Funktionen",+ "agentDetail.configure.clearSessionConfirm.description": "Dadurch wird die aktuelle Sitzung geleert und nicht angewendete Agent-Konfigurationsänderungen werden verworfen.",+ "agentDetail.configure.clearSessionConfirm.title": "Sitzung leeren und Änderungen verwerfen?","agentDetail.configure.communityEditionIsolationTip": "Community Edition bietet keine harte Dateisystemisolierung zwischen Endbenutzern oder Ausführungen. Stellen Sie denselben CE-Agenten nicht mehreren voneinander unabhängigen Endbenutzern bereit, wenn Datenisolierung oder strenge Compliance erforderlich ist.","agentDetail.configure.files.add": "Datei hinzufügen","agentDetail.configure.files.buildNote.generated": "Generiert",@@ -348,7 +355,7 @@"agentDetail.versionHistory.versionName": "Version {{version}}","agentDetail.versionHistory.viewOnly": "Nur anzeigen","roster.createAgent": "Agent erstellen",- "roster.createDialog.description": "Erstellen Sie einen wiederverwendbaren Agenten im Roster dieses Workspaces.",+ "roster.createDialog.description": "Erstellen Sie einen wiederverwendbaren Agent in diesem Workspace.","roster.createDialog.title": "Agent erstellen","roster.createForm.changeIcon": "Agenten-Symbol ändern","roster.createForm.descriptionLabel": "Beschreibung",@@ -360,16 +367,16 @@"roster.createForm.rolePlaceholder": "z. B. Research Assistant","roster.createSuccess": "Agent erstellt.","roster.dateTimeFormat": "DD.MM.YYYY HH:mm:ss",- "roster.deleteDialog.description": "Dieser Agent wird aus der aktiven Roster-Liste entfernt.",+ "roster.deleteDialog.description": "Dieser Agent wird aus der Agent-Liste entfernt.","roster.deleteDialog.title": "{{name}} löschen?","roster.deleteFailed": "Agent konnte nicht gelöscht werden.","roster.deleteSuccess": "Agent gelöscht.",- "roster.duplicateDialog.description": "Erstellen Sie eine Kopie von {{name}} und passen Sie ihre Roster-Identität an.",+ "roster.duplicateDialog.description": "Erstellen Sie eine Kopie von {{name}} und passen Sie ihre Agent-Identität an.","roster.duplicateDialog.title": "Agent duplizieren","roster.duplicateForm.changeIcon": "Symbol des Duplikats für {{name}} ändern","roster.duplicateSuccess": "Agent dupliziert.","roster.editAgent": "{{name}} bearbeiten",- "roster.editDialog.description": "Aktualisieren Sie Roster-Name, Beschreibung und Rolle dieses Agenten.",+ "roster.editDialog.description": "Aktualisieren Sie Name, Beschreibung und Rolle dieses Agent.","roster.editDialog.title": "Agent bearbeiten","roster.editInfo": "Info bearbeiten","roster.empty": "Noch kein Agent",@@ -379,8 +386,8 @@"roster.filters.drafts": "Entwürfe","roster.filters.label": "Agentenfilter","roster.filters.published": "Veröffentlicht",- "roster.learnMore": "Mehr über Agent Roster erfahren",- "roster.listLabel": "Agent-Roster-Liste",+ "roster.learnMore": "Mehr über Agent erfahren",+ "roster.listLabel": "Agent-Liste","roster.loadMore": "Mehr laden","roster.loadingError": "Agenten konnten nicht geladen werden. Bitte aktualisieren und erneut versuchen.","roster.moreActions": "Weitere Aktionen für {{name}}",@@ -392,10 +399,10 @@"roster.references.label": "Workflows, die {{name}} verwenden","roster.references.trigger": "Workflows, die {{name}} verwenden","roster.saveToRoster": "In Agent Console speichern",- "roster.saveToRosterDialog.description": "Speichern Sie diese Inline-Einrichtung als wiederverwendbaren Roster-Agenten.",+ "roster.saveToRosterDialog.description": "Speichern Sie diese Inline-Einrichtung als wiederverwendbaren Agent.","roster.saveToRosterDialog.title": "In Agent Console speichern",- "roster.saveToRosterForm.changeIcon": "Symbol des Roster-Agenten ändern",- "roster.saveToRosterSuccess": "Agent im Roster gespeichert.",+ "roster.saveToRosterForm.changeIcon": "Agent-Symbol ändern",+ "roster.saveToRosterSuccess": "Agent gespeichert.","roster.searchLabel": "Agenten suchen","roster.searchPlaceholder": "Agenten nach Namen suchen…","roster.sort.earliestCreated": "Zuerst erstellt",@@ -403,9 +410,6 @@"roster.sort.lastModified": "Zuletzt geändert","roster.sort.optionsLabel": "Sortieroptionen","roster.sort.recentlyCreated": "Zuletzt erstellt",- "roster.tabs.agent": "Agent",- "roster.tabs.human": "Kontakte",- "roster.tabsLabel": "Roster-Typ","roster.updateSuccess": "Agent aktualisiert.","roster.usageStatus.draft": "Entwurf"}diff --git a/web/i18n/de-DE/app-debug.json b/web/i18n/de-DE/app-debug.jsonindex ca3c212f617..35c1c2d80c5 100644--- a/web/i18n/de-DE/app-debug.json+++ b/web/i18n/de-DE/app-debug.json@@ -244,6 +244,9 @@"inputs.run": "AUSFÜHREN","inputs.title": "Debug und Vorschau","inputs.userInputField": "Benutzereingabefeld",+ "legacyAgentBadge.action": "Agent erstellen",+ "legacyAgentBadge.description": "Dieser alte Agent-App-Typ ist veraltet. Für eine bessere Agent-Erstellung erstelle einen Agent in der Agent Console.",+ "legacyAgentBadge.label": "Legacy Agent","manageModels": "Modelle verwalten","modelConfig.modeType.chat": "Chat","modelConfig.modeType.completion": "Vollständig",diff --git a/web/i18n/de-DE/common.json b/web/i18n/de-DE/common.jsonindex aaa671db3d7..7b5709c692b 100644--- a/web/i18n/de-DE/common.json+++ b/web/i18n/de-DE/common.json@@ -288,7 +288,7 @@"menus.explore": "Erkunden","menus.exploreMarketplace": "Marketplace erkunden","menus.plugins": "Integrationen",- "menus.roster": "Agent-Verzeichnis",+ "menus.roster": "Agent","menus.status": "Beta","menus.tools": "Werkzeuge","model.capabilities": "Multimodale Fähigkeiten",@@ -444,6 +444,7 @@"operation.download": "Herunterladen","operation.downloadFailed": "Download fehlgeschlagen. Bitte versuchen Sie es später erneut.","operation.downloadSuccess": "Download abgeschlossen.",+ "operation.downloading": "Wird heruntergeladen...","operation.duplicate": "Duplikat","operation.edit": "Bearbeiten","operation.exporting": "Exportiere",diff --git a/web/i18n/en-US/agent-v-2.json b/web/i18n/en-US/agent-v-2.jsonindex 59c2e6f2172..92ade8e1046 100644--- a/web/i18n/en-US/agent-v-2.json+++ b/web/i18n/en-US/agent-v-2.json@@ -63,6 +63,11 @@"agentDetail.configure.advancedSettings.envEditor.valuePlaceholder": "Value","agentDetail.configure.advancedSettings.label": "Advanced Settings","agentDetail.configure.advancedSettings.toggle": "Toggle advanced settings",+ "agentDetail.configure.answer.duration.minute": "{{count}}m",+ "agentDetail.configure.answer.duration.second": "{{count}}s",+ "agentDetail.configure.answer.workFinished": "Work finished",+ "agentDetail.configure.answer.workedFor": "Worked for {{duration}}",+ "agentDetail.configure.answer.workingFor": "Working for {{duration}}","agentDetail.configure.build.empty.communityEditionTip": "Community Edition, while offering versioning to the extracted configs, does not support versioning on the file system itself. Be careful with your actions in Build mode, as changes made to the file system happen in real time and cannot always be neatly reverted. Community Edition is not your ideal choice for serving mass external audiences.","agentDetail.configure.build.empty.description": "Describe what you want and it fills in the form on the left as you go.","agentDetail.configure.build.empty.title": "Build your agent by chatting",@@ -79,6 +84,8 @@"agentDetail.configure.buildDraft.updated": "Updated","agentDetail.configure.chatFeatures.description": "Shape the end-user chat experience on your web app and chat surfaces.","agentDetail.configure.chatFeatures.title": "Chat Features",+ "agentDetail.configure.clearSessionConfirm.description": "This will clear the current session and discard unapplied Agent configuration changes.",+ "agentDetail.configure.clearSessionConfirm.title": "Clear session and discard changes?","agentDetail.configure.communityEditionIsolationTip": "Community Edition does not provide hard file system isolation between end users or runs. Do not expose the same CE agent to multiple independent end users where data isolation or strict compliance is required.","agentDetail.configure.files.add": "Add file","agentDetail.configure.files.buildNote.generated": "Generated",@@ -348,7 +355,7 @@"agentDetail.versionHistory.versionName": "Version {{version}}","agentDetail.versionHistory.viewOnly": "View Only","roster.createAgent": "Create agent",- "roster.createDialog.description": "Create a reusable agent in this workspace roster.",+ "roster.createDialog.description": "Create a reusable Agent in this workspace.","roster.createDialog.title": "Create agent","roster.createForm.changeIcon": "Change agent icon","roster.createForm.descriptionLabel": "Description",@@ -360,16 +367,16 @@"roster.createForm.rolePlaceholder": "e.g. Research Assistant","roster.createSuccess": "Agent created.","roster.dateTimeFormat": "MM/DD/YYYY hh:mm:ss A",- "roster.deleteDialog.description": "This agent will be removed from the active roster list.",+ "roster.deleteDialog.description": "This Agent will be removed from the Agent list.","roster.deleteDialog.title": "Delete {{name}}?","roster.deleteFailed": "Failed to delete agent.","roster.deleteSuccess": "Agent deleted.",- "roster.duplicateDialog.description": "Create a copy of {{name}} and customize its roster identity.",+ "roster.duplicateDialog.description": "Create a copy of {{name}} and customize its Agent identity.","roster.duplicateDialog.title": "Duplicate agent","roster.duplicateForm.changeIcon": "Change duplicate icon for {{name}}","roster.duplicateSuccess": "Agent duplicated.","roster.editAgent": "Edit {{name}}",- "roster.editDialog.description": "Update the roster name, description, and role for this agent.",+ "roster.editDialog.description": "Update this Agent's name, description, and role.","roster.editDialog.title": "Edit agent","roster.editInfo": "Edit Info","roster.empty": "No agent yet",@@ -379,8 +386,8 @@"roster.filters.drafts": "Drafts","roster.filters.label": "Agent filters","roster.filters.published": "Published",- "roster.learnMore": "Learn more about Agent Roster",- "roster.listLabel": "Agent roster list",+ "roster.learnMore": "Learn more about Agent",+ "roster.listLabel": "Agent list","roster.loadMore": "Load more","roster.loadingError": "Failed to load agents. Refresh and try again.","roster.moreActions": "More actions for {{name}}",@@ -392,10 +399,10 @@"roster.references.label": "Workflows using {{name}}","roster.references.trigger": "Workflows using {{name}}","roster.saveToRoster": "Save to Agent Console",- "roster.saveToRosterDialog.description": "Save this inline setup as a reusable roster agent.",+ "roster.saveToRosterDialog.description": "Save this inline setup as a reusable Agent.","roster.saveToRosterDialog.title": "Save to Agent Console",- "roster.saveToRosterForm.changeIcon": "Change roster agent icon",- "roster.saveToRosterSuccess": "Agent saved to roster.",+ "roster.saveToRosterForm.changeIcon": "Change Agent icon",+ "roster.saveToRosterSuccess": "Agent saved.","roster.searchLabel": "Search agents","roster.searchPlaceholder": "Search agents by name…","roster.sort.earliestCreated": "Earliest created",@@ -403,9 +410,6 @@"roster.sort.lastModified": "Last modified","roster.sort.optionsLabel": "Sort options","roster.sort.recentlyCreated": "Recently created",- "roster.tabs.agent": "Agent",- "roster.tabs.human": "Contacts",- "roster.tabsLabel": "Roster type","roster.updateSuccess": "Agent updated.","roster.usageStatus.draft": "Draft"}diff --git a/web/i18n/en-US/app-debug.json b/web/i18n/en-US/app-debug.jsonindex df461aa22f4..7275057cb8d 100644--- a/web/i18n/en-US/app-debug.json+++ b/web/i18n/en-US/app-debug.json@@ -244,6 +244,9 @@"inputs.run": "RUN","inputs.title": "Debug & Preview","inputs.userInputField": "User Input Field",+ "legacyAgentBadge.action": "Create Agent",+ "legacyAgentBadge.description": "This legacy Agent app type is deprecated. For a better agent-building experience, create an Agent in Agent Console.",+ "legacyAgentBadge.label": "Legacy Agent","manageModels": "Manage models","modelConfig.modeType.chat": "Chat","modelConfig.modeType.completion": "Complete",diff --git a/web/i18n/en-US/common.json b/web/i18n/en-US/common.jsonindex 968801a2b7e..6a4f3648493 100644--- a/web/i18n/en-US/common.json+++ b/web/i18n/en-US/common.json@@ -288,7 +288,7 @@"menus.explore": "Explore","menus.exploreMarketplace": "Explore Marketplace","menus.plugins": "Integrations",- "menus.roster": "Roster",+ "menus.roster": "Agent","menus.status": "beta","menus.tools": "Tools","model.capabilities": "MultiModal Capabilities",@@ -444,6 +444,7 @@"operation.download": "Download","operation.downloadFailed": "Download failed. Please try again later.","operation.downloadSuccess": "Download Completed.",+ "operation.downloading": "Downloading","operation.duplicate": "Duplicate","operation.edit": "Edit","operation.exporting": "Exporting",diff --git a/web/i18n/es-ES/agent-v-2.json b/web/i18n/es-ES/agent-v-2.jsonindex 9ec0bc588a4..060d5d30f11 100644--- a/web/i18n/es-ES/agent-v-2.json+++ b/web/i18n/es-ES/agent-v-2.json@@ -63,6 +63,11 @@"agentDetail.configure.advancedSettings.envEditor.valuePlaceholder": "Value","agentDetail.configure.advancedSettings.label": "Configuración avanzada","agentDetail.configure.advancedSettings.toggle": "Alternar configuración avanzada",+ "agentDetail.configure.answer.duration.minute": "{{count}} min",+ "agentDetail.configure.answer.duration.second": "{{count}} s",+ "agentDetail.configure.answer.workFinished": "Trabajo finalizado",+ "agentDetail.configure.answer.workedFor": "Trabajó durante {{duration}}",+ "agentDetail.configure.answer.workingFor": "Trabajando durante {{duration}}","agentDetail.configure.build.empty.communityEditionTip": "Community Edition, aunque ofrece versionado para las configuraciones extraídas, no admite versionado del propio sistema de archivos. Ten cuidado con tus acciones en el modo Build, ya que los cambios realizados en el sistema de archivos ocurren en tiempo real y no siempre se pueden revertir limpiamente. Community Edition no es la opción ideal para atender audiencias externas masivas.","agentDetail.configure.build.empty.description": "Describe lo que quieres y se irá completando el formulario de la izquierda mientras avanzas.","agentDetail.configure.build.empty.title": "Crea tu agente chateando",@@ -79,6 +84,8 @@"agentDetail.configure.buildDraft.updated": "Actualizado","agentDetail.configure.chatFeatures.description": "Da forma a la experiencia de chat del usuario final en tu webapp y superficies de chat.","agentDetail.configure.chatFeatures.title": "Funciones de chat",+ "agentDetail.configure.clearSessionConfirm.description": "Esto borrará la sesión actual y descartará los cambios de configuración del Agent que aún no se hayan aplicado.",+ "agentDetail.configure.clearSessionConfirm.title": "¿Borrar la sesión y descartar los cambios?","agentDetail.configure.communityEditionIsolationTip": "Community Edition no proporciona aislamiento estricto del sistema de archivos entre usuarios finales ni entre ejecuciones. No expongas el mismo agente CE a varios usuarios finales independientes cuando se requiera aislamiento de datos o cumplimiento estricto.","agentDetail.configure.files.add": "Agregar archivo","agentDetail.configure.files.buildNote.generated": "Generado",@@ -348,7 +355,7 @@"agentDetail.versionHistory.versionName": "Versión {{version}}","agentDetail.versionHistory.viewOnly": "Solo lectura","roster.createAgent": "Crear agente",- "roster.createDialog.description": "Crea un agente reutilizable en el roster de este workspace.",+ "roster.createDialog.description": "Crea un Agent reutilizable en este espacio de trabajo.","roster.createDialog.title": "Crear agente","roster.createForm.changeIcon": "Cambiar icono del agente","roster.createForm.descriptionLabel": "Descripción",@@ -360,16 +367,16 @@"roster.createForm.rolePlaceholder": "p. ej. Asistente de investigación","roster.createSuccess": "Agente creado.","roster.dateTimeFormat": "DD/MM/YYYY HH:mm:ss",- "roster.deleteDialog.description": "Este agente se eliminará de la lista del roster activo.",+ "roster.deleteDialog.description": "Este Agent se eliminará de la lista de Agent.","roster.deleteDialog.title": "¿Eliminar {{name}}?","roster.deleteFailed": "Error al eliminar el agente.","roster.deleteSuccess": "Agente eliminado.",- "roster.duplicateDialog.description": "Crea una copia de {{name}} y personaliza su identidad en el roster.",+ "roster.duplicateDialog.description": "Crea una copia de {{name}} y personaliza su identidad de Agent.","roster.duplicateDialog.title": "Duplicar agente","roster.duplicateForm.changeIcon": "Cambiar icono del duplicado de {{name}}","roster.duplicateSuccess": "Agente duplicado.","roster.editAgent": "Editar {{name}}",- "roster.editDialog.description": "Actualiza el nombre, la descripción y el rol del roster para este agente.",+ "roster.editDialog.description": "Actualiza el nombre, la descripción y el rol de este Agent.","roster.editDialog.title": "Editar agente","roster.editInfo": "Editar información","roster.empty": "Aún no hay agentes",@@ -379,8 +386,8 @@"roster.filters.drafts": "Borradores","roster.filters.label": "Filtros de agente","roster.filters.published": "Publicados",- "roster.learnMore": "Más información sobre Agent Roster",- "roster.listLabel": "Lista del roster de agentes",+ "roster.learnMore": "Más información sobre Agent",+ "roster.listLabel": "Lista de Agent","roster.loadMore": "Cargar más","roster.loadingError": "Error al cargar los agentes. Actualiza y vuelve a intentarlo.","roster.moreActions": "Más acciones para {{name}}",@@ -392,10 +399,10 @@"roster.references.label": "Flujos de trabajo que usan {{name}}","roster.references.trigger": "Flujos de trabajo que usan {{name}}","roster.saveToRoster": "Guardar en Agent Console",- "roster.saveToRosterDialog.description": "Guarda esta configuración inline como un agente de roster reutilizable.",+ "roster.saveToRosterDialog.description": "Guarda esta configuración inline como un Agent reutilizable.","roster.saveToRosterDialog.title": "Guardar en Agent Console",- "roster.saveToRosterForm.changeIcon": "Cambiar icono del agente de roster",- "roster.saveToRosterSuccess": "Agente guardado en el roster.",+ "roster.saveToRosterForm.changeIcon": "Cambiar icono de Agent",+ "roster.saveToRosterSuccess": "Agent guardado.","roster.searchLabel": "Buscar agentes","roster.searchPlaceholder": "Buscar agentes por nombre…","roster.sort.earliestCreated": "Creados primero",@@ -403,9 +410,6 @@"roster.sort.lastModified": "Última modificación","roster.sort.optionsLabel": "Opciones de ordenación","roster.sort.recentlyCreated": "Creados recientemente",- "roster.tabs.agent": "Agente",- "roster.tabs.human": "Contactos",- "roster.tabsLabel": "Tipo de roster","roster.updateSuccess": "Agente actualizado.","roster.usageStatus.draft": "Borrador"}diff --git a/web/i18n/es-ES/app-debug.json b/web/i18n/es-ES/app-debug.jsonindex 27277dc3c92..510342a1a6a 100644--- a/web/i18n/es-ES/app-debug.json+++ b/web/i18n/es-ES/app-debug.json@@ -244,6 +244,9 @@"inputs.run": "EJECUTAR","inputs.title": "Depurar y Previsualizar","inputs.userInputField": "Campo de Entrada del Usuario",+ "legacyAgentBadge.action": "Crear Agent",+ "legacyAgentBadge.description": "Este tipo de app Agent heredado está obsoleto. Para una mejor experiencia de creación de agentes, crea un Agent en Agent Console.",+ "legacyAgentBadge.label": "Agent heredado","manageModels": "Gestionar modelos","modelConfig.modeType.chat": "Chat","modelConfig.modeType.completion": "Completar",diff --git a/web/i18n/es-ES/common.json b/web/i18n/es-ES/common.jsonindex ce0d0803ba7..33c81767024 100644--- a/web/i18n/es-ES/common.json+++ b/web/i18n/es-ES/common.json@@ -288,7 +288,7 @@"menus.explore": "Explorar","menus.exploreMarketplace": "Explora el mercado","menus.plugins": "Integraciones",- "menus.roster": "Directorio de agentes",+ "menus.roster": "Agent","menus.status": "beta","menus.tools": "Herramientas","model.capabilities": "Capacidades multimodales",@@ -444,6 +444,7 @@"operation.download": "Descargar","operation.downloadFailed": "La descarga ha fallado. Por favor, inténtalo de nuevo más tarde.","operation.downloadSuccess": "Descarga completada.",+ "operation.downloading": "Descargando...","operation.duplicate": "Duplicar","operation.edit": "Editar","operation.exporting": "Exportando",diff --git a/web/i18n/fa-IR/agent-v-2.json b/web/i18n/fa-IR/agent-v-2.jsonindex d8565933495..abe962b35c0 100644--- a/web/i18n/fa-IR/agent-v-2.json+++ b/web/i18n/fa-IR/agent-v-2.json@@ -63,6 +63,11 @@"agentDetail.configure.advancedSettings.envEditor.valuePlaceholder": "Value","agentDetail.configure.advancedSettings.label": "تنظیمات پیشرفته","agentDetail.configure.advancedSettings.toggle": "تغییر تنظیمات پیشرفته",+ "agentDetail.configure.answer.duration.minute": "{{count}} دقیقه",+ "agentDetail.configure.answer.duration.second": "{{count}} ثانیه",+ "agentDetail.configure.answer.workFinished": "کار تمام شد",+ "agentDetail.configure.answer.workedFor": "به مدت {{duration}} کار کرد",+ "agentDetail.configure.answer.workingFor": "در حال کار به مدت {{duration}}","agentDetail.configure.build.empty.communityEditionTip": "Community Edition با اینکه برای پیکربندیهای استخراجشده نسخهبندی ارائه میکند، از نسخهبندی خود سیستم فایل پشتیبانی نمیکند. در حالت Build با اقدامات خود محتاط باشید، زیرا تغییرات روی سیستم فایل بهصورت بلادرنگ انجام میشوند و همیشه نمیتوان آنها را بهصورت تمیز بازگرداند. Community Edition انتخاب ایدهآلی برای خدمترسانی به مخاطبان خارجی گسترده نیست.","agentDetail.configure.build.empty.description": "آنچه میخواهید را توضیح دهید تا فرم سمت چپ در طول گفتگو تکمیل شود.","agentDetail.configure.build.empty.title": "عامل خود را با چت بسازید",@@ -79,6 +84,8 @@"agentDetail.configure.buildDraft.updated": "بهروزرسانی شد","agentDetail.configure.chatFeatures.description": "تجربه چت کاربر نهایی را در Web app و سطوح چت خود شکل دهید.","agentDetail.configure.chatFeatures.title": "ویژگیهای چت",+ "agentDetail.configure.clearSessionConfirm.description": "این کار نشست فعلی را پاک میکند و تغییرات پیکربندی Agent را که هنوز اعمال نشدهاند کنار میگذارد.",+ "agentDetail.configure.clearSessionConfirm.title": "نشست پاک شود و تغییرات کنار گذاشته شوند؟","agentDetail.configure.communityEditionIsolationTip": "Community Edition جداسازی سختگیرانهٔ سیستم فایل را بین کاربران نهایی یا اجراها فراهم نمیکند. در جایی که جداسازی داده یا رعایت الزامات سختگیرانه لازم است، همان عامل CE را در اختیار چند کاربر نهایی مستقل قرار ندهید.","agentDetail.configure.files.add": "افزودن فایل","agentDetail.configure.files.buildNote.generated": "تولید شده",@@ -348,7 +355,7 @@"agentDetail.versionHistory.versionName": "نسخه {{version}}","agentDetail.versionHistory.viewOnly": "فقط نمایش","roster.createAgent": "ایجاد عامل",- "roster.createDialog.description": "یک عامل قابل استفاده مجدد در Roster این فضای کاری ایجاد کنید.",+ "roster.createDialog.description": "یک Agent قابل استفاده مجدد در این فضای کاری ایجاد کنید.","roster.createDialog.title": "ایجاد عامل","roster.createForm.changeIcon": "تغییر آیکون عامل","roster.createForm.descriptionLabel": "توضیحات",@@ -360,16 +367,16 @@"roster.createForm.rolePlaceholder": "مثلاً دستیار پژوهش","roster.createSuccess": "عامل ایجاد شد.","roster.dateTimeFormat": "YYYY/MM/DD HH:mm:ss",- "roster.deleteDialog.description": "این عامل از فهرست Roster فعال حذف خواهد شد.",+ "roster.deleteDialog.description": "این Agent از فهرست Agent حذف خواهد شد.","roster.deleteDialog.title": "حذف {{name}}؟","roster.deleteFailed": "حذف عامل ناموفق بود.","roster.deleteSuccess": "عامل حذف شد.",- "roster.duplicateDialog.description": "یک کپی از {{name}} ایجاد کنید و هویت آن در Roster را سفارشی کنید.",+ "roster.duplicateDialog.description": "یک کپی از {{name}} ایجاد کنید و هویت Agent آن را سفارشی کنید.","roster.duplicateDialog.title": "تکثیر عامل","roster.duplicateForm.changeIcon": "تغییر آیکون کپی برای {{name}}","roster.duplicateSuccess": "عامل تکثیر شد.","roster.editAgent": "ویرایش {{name}}",- "roster.editDialog.description": "نام، توضیحات و نقش Roster این عامل را بهروزرسانی کنید.",+ "roster.editDialog.description": "نام، توضیحات و نقش این Agent را بهروزرسانی کنید.","roster.editDialog.title": "ویرایش عامل","roster.editInfo": "ویرایش اطلاعات","roster.empty": "هنوز عاملی وجود ندارد",@@ -379,8 +386,8 @@"roster.filters.drafts": "پیشنویسها","roster.filters.label": "فیلترهای عامل","roster.filters.published": "منتشر شده",- "roster.learnMore": "اطلاعات بیشتر درباره Agent Roster",- "roster.listLabel": "فهرست Roster عاملها",+ "roster.learnMore": "اطلاعات بیشتر درباره Agent",+ "roster.listLabel": "فهرست Agent","roster.loadMore": "بارگذاری بیشتر","roster.loadingError": "بارگذاری عوامل ناموفق بود. تازهسازی کنید و دوباره امتحان کنید.","roster.moreActions": "اقدامات بیشتر برای {{name}}",@@ -392,10 +399,10 @@"roster.references.label": "گردشهای کار با استفاده از {{name}}","roster.references.trigger": "گردشهای کار با استفاده از {{name}}","roster.saveToRoster": "ذخیره در Agent Console",- "roster.saveToRosterDialog.description": "این پیکربندی درونخطی را بهعنوان یک عامل Roster قابل استفاده مجدد ذخیره کنید.",+ "roster.saveToRosterDialog.description": "این پیکربندی درونخطی را بهعنوان یک Agent قابل استفاده مجدد ذخیره کنید.","roster.saveToRosterDialog.title": "ذخیره در Agent Console",- "roster.saveToRosterForm.changeIcon": "تغییر نماد عامل Roster",- "roster.saveToRosterSuccess": "عامل در Roster ذخیره شد.",+ "roster.saveToRosterForm.changeIcon": "تغییر نماد Agent",+ "roster.saveToRosterSuccess": "Agent ذخیره شد.","roster.searchLabel": "جستجوی عوامل","roster.searchPlaceholder": "جستجوی عوامل بر اساس نام…","roster.sort.earliestCreated": "قدیمیترین ایجاد",@@ -403,9 +410,6 @@"roster.sort.lastModified": "آخرین تغییر","roster.sort.optionsLabel": "گزینههای مرتبسازی","roster.sort.recentlyCreated": "تازهترین ایجاد",- "roster.tabs.agent": "عامل",- "roster.tabs.human": "مخاطبین",- "roster.tabsLabel": "نوع Roster","roster.updateSuccess": "عامل بهروزرسانی شد.","roster.usageStatus.draft": "پیشنویس"}diff --git a/web/i18n/fa-IR/app-debug.json b/web/i18n/fa-IR/app-debug.jsonindex 60f3ba4c2c9..02e3116546d 100644--- a/web/i18n/fa-IR/app-debug.json+++ b/web/i18n/fa-IR/app-debug.json@@ -244,6 +244,9 @@"inputs.run": "اجرا","inputs.title": "اشکال زدایی و پیش نمایش","inputs.userInputField": "فیلد ورودی کاربر",+ "legacyAgentBadge.action": "ایجاد Agent",+ "legacyAgentBadge.description": "این نوع برنامه Agent قدیمی منسوخ شده است. برای تجربه بهتر در ساخت عامل، یک Agent در Agent Console ایجاد کنید.",+ "legacyAgentBadge.label": "Agent قدیمی","manageModels": "مدیریت مدلها","modelConfig.modeType.chat": "چت","modelConfig.modeType.completion": "کامل",diff --git a/web/i18n/fa-IR/common.json b/web/i18n/fa-IR/common.jsonindex 4c9dc6821b9..71089b220cc 100644--- a/web/i18n/fa-IR/common.json+++ b/web/i18n/fa-IR/common.json@@ -288,7 +288,7 @@"menus.explore": "کاوش","menus.exploreMarketplace": "بازار را کاوش کنید","menus.plugins": "یکپارچهسازیها",- "menus.roster": "فهرست عاملها",+ "menus.roster": "Agent","menus.status": "بتا","menus.tools": "ابزارها","model.capabilities": "قابلیت های چند وجهی",@@ -444,6 +444,7 @@"operation.download": "دانلود","operation.downloadFailed": "دانلود ناموفق بود. لطفاً بعداً دوباره تلاش کنید.","operation.downloadSuccess": "دانلود کامل شد.",+ "operation.downloading": "در حال دانلود...","operation.duplicate": "تکرار","operation.edit": "ویرایش","operation.exporting": "در حال خروجی گرفتن",diff --git a/web/i18n/fr-FR/agent-v-2.json b/web/i18n/fr-FR/agent-v-2.jsonindex 1831035a2d0..d2aa970eecc 100644--- a/web/i18n/fr-FR/agent-v-2.json+++ b/web/i18n/fr-FR/agent-v-2.json@@ -63,6 +63,11 @@"agentDetail.configure.advancedSettings.envEditor.valuePlaceholder": "Value","agentDetail.configure.advancedSettings.label": "Paramètres avancés","agentDetail.configure.advancedSettings.toggle": "Basculer les paramètres avancés",+ "agentDetail.configure.answer.duration.minute": "{{count}} min",+ "agentDetail.configure.answer.duration.second": "{{count}} s",+ "agentDetail.configure.answer.workFinished": "Travail terminé",+ "agentDetail.configure.answer.workedFor": "A travaillé pendant {{duration}}",+ "agentDetail.configure.answer.workingFor": "Travaille depuis {{duration}}","agentDetail.configure.build.empty.communityEditionTip": "Community Edition, bien qu’elle offre la gestion des versions pour les configurations extraites, ne prend pas en charge la gestion des versions du système de fichiers lui-même. Soyez prudent avec vos actions en mode Build, car les modifications apportées au système de fichiers se produisent en temps réel et ne peuvent pas toujours être annulées proprement. Community Edition n’est pas le choix idéal pour servir un public externe massif.","agentDetail.configure.build.empty.description": "Décrivez ce que vous voulez et le formulaire de gauche se remplit au fil de la conversation.","agentDetail.configure.build.empty.title": "Créez votre agent par chat",@@ -79,6 +84,8 @@"agentDetail.configure.buildDraft.updated": "Mis à jour","agentDetail.configure.chatFeatures.description": "Façonnez l’expérience de chat de l’utilisateur final sur votre webapp et vos surfaces de chat.","agentDetail.configure.chatFeatures.title": "Fonctionnalités de chat",+ "agentDetail.configure.clearSessionConfirm.description": "Cette action effacera la session actuelle et ignorera les modifications de configuration de l’Agent non encore appliquées.",+ "agentDetail.configure.clearSessionConfirm.title": "Effacer la session et ignorer les modifications ?","agentDetail.configure.communityEditionIsolationTip": "Community Edition ne fournit pas d’isolation stricte du système de fichiers entre les utilisateurs finaux ni entre les exécutions. N’exposez pas le même agent CE à plusieurs utilisateurs finaux indépendants lorsque l’isolation des données ou une conformité stricte est requise.","agentDetail.configure.files.add": "Ajouter un fichier","agentDetail.configure.files.buildNote.generated": "Généré",@@ -348,7 +355,7 @@"agentDetail.versionHistory.versionName": "Version {{version}}","agentDetail.versionHistory.viewOnly": "Lecture seule","roster.createAgent": "Créer un agent",- "roster.createDialog.description": "Créez un agent réutilisable dans le roster de cet espace de travail.",+ "roster.createDialog.description": "Créez un Agent réutilisable dans cet espace de travail.","roster.createDialog.title": "Créer un agent","roster.createForm.changeIcon": "Changer l’icône de l’agent","roster.createForm.descriptionLabel": "Description",@@ -360,16 +367,16 @@"roster.createForm.rolePlaceholder": "p. ex. Assistant de recherche","roster.createSuccess": "Agent créé.","roster.dateTimeFormat": "DD/MM/YYYY HH:mm:ss",- "roster.deleteDialog.description": "Cet agent sera supprimé de la liste du roster actif.",+ "roster.deleteDialog.description": "Cet Agent sera supprimé de la liste Agent.","roster.deleteDialog.title": "Supprimer {{name}} ?","roster.deleteFailed": "Échec de la suppression de l’agent.","roster.deleteSuccess": "Agent supprimé.",- "roster.duplicateDialog.description": "Créez une copie de {{name}} et personnalisez son identité dans le roster.",+ "roster.duplicateDialog.description": "Créez une copie de {{name}} et personnalisez son identité Agent.","roster.duplicateDialog.title": "Dupliquer l’agent","roster.duplicateForm.changeIcon": "Changer l’icône du duplicata pour {{name}}","roster.duplicateSuccess": "Agent dupliqué.","roster.editAgent": "Modifier {{name}}",- "roster.editDialog.description": "Mettez à jour le nom, la description et le rôle de cet agent dans le roster.",+ "roster.editDialog.description": "Mettez à jour le nom, la description et le rôle de cet Agent.","roster.editDialog.title": "Modifier l’agent","roster.editInfo": "Modifier les informations","roster.empty": "Pas encore d’agent",@@ -379,8 +386,8 @@"roster.filters.drafts": "Brouillons","roster.filters.label": "Filtres d’agent","roster.filters.published": "Publiés",- "roster.learnMore": "En savoir plus sur Agent Roster",- "roster.listLabel": "Liste du roster d’agents",+ "roster.learnMore": "En savoir plus sur Agent",+ "roster.listLabel": "Liste Agent","roster.loadMore": "Charger plus","roster.loadingError": "Échec du chargement des agents. Actualisez et réessayez.","roster.moreActions": "Plus d’actions pour {{name}}",@@ -392,10 +399,10 @@"roster.references.label": "Workflows utilisant {{name}}","roster.references.trigger": "Workflows utilisant {{name}}","roster.saveToRoster": "Enregistrer dans Agent Console",- "roster.saveToRosterDialog.description": "Enregistrez cette configuration inline comme un agent roster réutilisable.",+ "roster.saveToRosterDialog.description": "Enregistrez cette configuration inline comme Agent réutilisable.","roster.saveToRosterDialog.title": "Enregistrer dans Agent Console",- "roster.saveToRosterForm.changeIcon": "Changer l’icône de l’agent roster",- "roster.saveToRosterSuccess": "Agent enregistré dans le roster.",+ "roster.saveToRosterForm.changeIcon": "Changer l’icône Agent",+ "roster.saveToRosterSuccess": "Agent enregistré.","roster.searchLabel": "Rechercher des agents","roster.searchPlaceholder": "Rechercher des agents par nom…","roster.sort.earliestCreated": "Créés en premier",@@ -403,9 +410,6 @@"roster.sort.lastModified": "Dernière modification","roster.sort.optionsLabel": "Options de tri","roster.sort.recentlyCreated": "Récemment créés",- "roster.tabs.agent": "Agent",- "roster.tabs.human": "Contacts",- "roster.tabsLabel": "Type de roster","roster.updateSuccess": "Agent mis à jour.","roster.usageStatus.draft": "Brouillon"}diff --git a/web/i18n/fr-FR/app-debug.json b/web/i18n/fr-FR/app-debug.jsonindex 4870605697d..bbe544cd354 100644--- a/web/i18n/fr-FR/app-debug.json+++ b/web/i18n/fr-FR/app-debug.json@@ -244,6 +244,9 @@"inputs.run": "EXÉCUTER","inputs.title": "Déboguer et Aperçu","inputs.userInputField": "Champ de saisie utilisateur",+ "legacyAgentBadge.action": "Créer un Agent",+ "legacyAgentBadge.description": "Ce type d’app Agent hérité est obsolète. Pour une meilleure expérience de création d’agents, créez un Agent dans Agent Console.",+ "legacyAgentBadge.label": "Agent hérité","manageModels": "Gérer les modèles","modelConfig.modeType.chat": "Discussion","modelConfig.modeType.completion": "Complet",diff --git a/web/i18n/fr-FR/common.json b/web/i18n/fr-FR/common.jsonindex 4693c5b88fa..ab8630326fd 100644--- a/web/i18n/fr-FR/common.json+++ b/web/i18n/fr-FR/common.json@@ -288,7 +288,7 @@"menus.explore": "Explorer","menus.exploreMarketplace": "Explorer Marketplace","menus.plugins": "Intégrations",- "menus.roster": "Répertoire des agents",+ "menus.roster": "Agent","menus.status": "bêta","menus.tools": "Outils","model.capabilities": "Capacités multimodales",@@ -444,6 +444,7 @@"operation.download": "Télécharger","operation.downloadFailed": "Échec du téléchargement. Veuillez réessayer plus tard.","operation.downloadSuccess": "Téléchargement terminé.",+ "operation.downloading": "Téléchargement...","operation.duplicate": "Dupliquer","operation.edit": "Modifier","operation.exporting": "Exportation",diff --git a/web/i18n/hi-IN/agent-v-2.json b/web/i18n/hi-IN/agent-v-2.jsonindex e605fab7e8b..e3525a23630 100644--- a/web/i18n/hi-IN/agent-v-2.json+++ b/web/i18n/hi-IN/agent-v-2.json@@ -63,6 +63,11 @@"agentDetail.configure.advancedSettings.envEditor.valuePlaceholder": "Value","agentDetail.configure.advancedSettings.label": "उन्नत सेटिंग्स","agentDetail.configure.advancedSettings.toggle": "उन्नत सेटिंग्स टॉगल करें",+ "agentDetail.configure.answer.duration.minute": "{{count}} मिनट",+ "agentDetail.configure.answer.duration.second": "{{count}} सेकंड",+ "agentDetail.configure.answer.workFinished": "काम पूरा हुआ",+ "agentDetail.configure.answer.workedFor": "{{duration}} तक काम किया",+ "agentDetail.configure.answer.workingFor": "{{duration}} से काम कर रहा है","agentDetail.configure.build.empty.communityEditionTip": "Community Edition निकाले गए कॉन्फ़िगरेशन के लिए वर्शनिंग प्रदान करता है, लेकिन फ़ाइल सिस्टम पर स्वयं वर्शनिंग का समर्थन नहीं करता। Build मोड में अपनी कार्रवाइयों के साथ सावधान रहें, क्योंकि फ़ाइल सिस्टम में किए गए बदलाव वास्तविक समय में होते हैं और हमेशा साफ़-सुथरे ढंग से वापस नहीं किए जा सकते। बड़े पैमाने पर बाहरी दर्शकों को सेवा देने के लिए Community Edition आदर्श विकल्प नहीं है।","agentDetail.configure.build.empty.description": "आप जो चाहते हैं उसका वर्णन करें और बाईं ओर का फ़ॉर्म बातचीत के साथ भरता जाएगा।","agentDetail.configure.build.empty.title": "चैट करके अपना एजेंट बनाएं",@@ -79,6 +84,8 @@"agentDetail.configure.buildDraft.updated": "अपडेट किया गया","agentDetail.configure.chatFeatures.description": "अपने Web app और चैट सतहों पर अंतिम-उपयोगकर्ता चैट अनुभव को आकार दें।","agentDetail.configure.chatFeatures.title": "चैट सुविधाएँ",+ "agentDetail.configure.clearSessionConfirm.description": "यह मौजूदा सेशन साफ़ कर देगा और Agent कॉन्फ़िगरेशन के वे बदलाव छोड़ देगा जो अभी लागू नहीं हुए हैं।",+ "agentDetail.configure.clearSessionConfirm.title": "सेशन साफ़ करके बदलाव छोड़ें?","agentDetail.configure.communityEditionIsolationTip": "Community Edition अंतिम उपयोगकर्ताओं या रन के बीच सख्त फ़ाइल सिस्टम आइसोलेशन प्रदान नहीं करता है। जहाँ डेटा आइसोलेशन या कड़े अनुपालन की आवश्यकता हो, वहाँ एक ही CE एजेंट को कई स्वतंत्र अंतिम उपयोगकर्ताओं के लिए उजागर न करें।","agentDetail.configure.files.add": "फ़ाइल जोड़ें","agentDetail.configure.files.buildNote.generated": "जनरेट किया गया",@@ -348,7 +355,7 @@"agentDetail.versionHistory.versionName": "संस्करण {{version}}","agentDetail.versionHistory.viewOnly": "केवल देखें","roster.createAgent": "एजेंट बनाएँ",- "roster.createDialog.description": "इस कार्यक्षेत्र Roster में एक पुनः उपयोग योग्य एजेंट बनाएँ।",+ "roster.createDialog.description": "इस वर्कस्पेस में एक पुनः उपयोग योग्य Agent बनाएँ।","roster.createDialog.title": "एजेंट बनाएँ","roster.createForm.changeIcon": "एजेंट आइकन बदलें","roster.createForm.descriptionLabel": "विवरण",@@ -360,16 +367,16 @@"roster.createForm.rolePlaceholder": "उदा. शोध सहायक","roster.createSuccess": "एजेंट बन गया।","roster.dateTimeFormat": "DD/MM/YYYY hh:mm:ss A",- "roster.deleteDialog.description": "इस एजेंट को सक्रिय Roster सूची से हटा दिया जाएगा।",+ "roster.deleteDialog.description": "यह Agent, Agent सूची से हटा दिया जाएगा।","roster.deleteDialog.title": "{{name}} हटाएँ?","roster.deleteFailed": "एजेंट हटाने में विफल।","roster.deleteSuccess": "एजेंट हटा दिया गया।",- "roster.duplicateDialog.description": "{{name}} की एक प्रति बनाएँ और उसकी Roster पहचान को अनुकूलित करें।",+ "roster.duplicateDialog.description": "{{name}} की एक प्रति बनाएँ और उसकी Agent पहचान को अनुकूलित करें।","roster.duplicateDialog.title": "एजेंट डुप्लिकेट करें","roster.duplicateForm.changeIcon": "{{name}} के लिए डुप्लिकेट आइकन बदलें","roster.duplicateSuccess": "एजेंट डुप्लिकेट किया गया।","roster.editAgent": "{{name}} संपादित करें",- "roster.editDialog.description": "इस एजेंट का Roster नाम, विवरण और भूमिका अपडेट करें।",+ "roster.editDialog.description": "इस Agent का नाम, विवरण और भूमिका अपडेट करें।","roster.editDialog.title": "एजेंट संपादित करें","roster.editInfo": "जानकारी संपादित करें","roster.empty": "अभी तक कोई एजेंट नहीं",@@ -379,8 +386,8 @@"roster.filters.drafts": "ड्राफ्ट","roster.filters.label": "एजेंट फ़िल्टर","roster.filters.published": "प्रकाशित",- "roster.learnMore": "Agent Roster के बारे में और जानें",- "roster.listLabel": "एजेंट Roster सूची",+ "roster.learnMore": "Agent के बारे में और जानें",+ "roster.listLabel": "Agent सूची","roster.loadMore": "और लोड करें","roster.loadingError": "एजेंट लोड करने में विफल। रीफ़्रेश करें और पुनः प्रयास करें।","roster.moreActions": "{{name}} के लिए और क्रियाएँ",@@ -392,10 +399,10 @@"roster.references.label": "{{name}} का उपयोग करने वाले वर्कफ़्लो","roster.references.trigger": "{{name}} का उपयोग करने वाले वर्कफ़्लो","roster.saveToRoster": "Agent Console में सहेजें",- "roster.saveToRosterDialog.description": "इस इनलाइन सेटअप को एक पुनः उपयोग योग्य Roster एजेंट के रूप में सहेजें।",+ "roster.saveToRosterDialog.description": "इस इनलाइन सेटअप को एक पुनः उपयोग योग्य Agent के रूप में सहेजें।","roster.saveToRosterDialog.title": "Agent Console में सहेजें",- "roster.saveToRosterForm.changeIcon": "Roster एजेंट आइकन बदलें",- "roster.saveToRosterSuccess": "एजेंट Roster में सहेजा गया।",+ "roster.saveToRosterForm.changeIcon": "Agent आइकन बदलें",+ "roster.saveToRosterSuccess": "Agent सहेजा गया।","roster.searchLabel": "एजेंट खोजें","roster.searchPlaceholder": "नाम से एजेंट खोजें…","roster.sort.earliestCreated": "सबसे पहले बनाए गए",@@ -403,9 +410,6 @@"roster.sort.lastModified": "अंतिम संशोधन","roster.sort.optionsLabel": "क्रमबद्ध विकल्प","roster.sort.recentlyCreated": "हाल ही में बनाए गए",- "roster.tabs.agent": "एजेंट",- "roster.tabs.human": "संपर्क",- "roster.tabsLabel": "Roster प्रकार","roster.updateSuccess": "एजेंट अपडेट हो गया।","roster.usageStatus.draft": "ड्राफ्ट"}diff --git a/web/i18n/hi-IN/app-debug.json b/web/i18n/hi-IN/app-debug.jsonindex 0c6a0f703d5..e7e519f4ff2 100644--- a/web/i18n/hi-IN/app-debug.json+++ b/web/i18n/hi-IN/app-debug.json@@ -244,6 +244,9 @@"inputs.run": "चालू करें","inputs.title": "डिबग और पूर्वावलोकन","inputs.userInputField": "उपयोगकर्ता इनपुट फ़ील्ड",+ "legacyAgentBadge.action": "Agent बनाएं",+ "legacyAgentBadge.description": "यह पुराना Agent ऐप प्रकार अब अप्रचलित है। बेहतर एजेंट-बिल्डिंग अनुभव के लिए Agent Console में एक Agent बनाएं।",+ "legacyAgentBadge.label": "लेगेसी Agent","manageModels": "मॉडल प्रबंधित करें","modelConfig.modeType.chat": "चैट","modelConfig.modeType.completion": "पूर्ण",diff --git a/web/i18n/hi-IN/common.json b/web/i18n/hi-IN/common.jsonindex 5a82a70c482..173f6caf7d1 100644--- a/web/i18n/hi-IN/common.json+++ b/web/i18n/hi-IN/common.json@@ -288,7 +288,7 @@"menus.explore": "अन्वेषण करें","menus.exploreMarketplace": "मार्केटप्लेस का अन्वेषण करें","menus.plugins": "एकीकरण",- "menus.roster": "एजेंट सूची",+ "menus.roster": "Agent","menus.status": "बीटा","menus.tools": "उपकरण","model.capabilities": "मल्टीमोडल क्षमताएँ",@@ -444,6 +444,7 @@"operation.download": "डाउनलोड करें","operation.downloadFailed": "डाउनलोड विफल। कृपया बाद में पुनः प्रयास करें।","operation.downloadSuccess": "डाउनलोड पूरा हुआ।",+ "operation.downloading": "डाउनलोड हो रहा है...","operation.duplicate": "डुप्लिकेट","operation.edit": "संपादित करें","operation.exporting": "निर्यात हो रहा है",diff --git a/web/i18n/id-ID/agent-v-2.json b/web/i18n/id-ID/agent-v-2.jsonindex 33e473ead14..35101fa70f6 100644--- a/web/i18n/id-ID/agent-v-2.json+++ b/web/i18n/id-ID/agent-v-2.json@@ -63,6 +63,11 @@"agentDetail.configure.advancedSettings.envEditor.valuePlaceholder": "Value","agentDetail.configure.advancedSettings.label": "Pengaturan Lanjutan","agentDetail.configure.advancedSettings.toggle": "Alihkan pengaturan lanjutan",+ "agentDetail.configure.answer.duration.minute": "{{count}} mnt",+ "agentDetail.configure.answer.duration.second": "{{count}} dtk",+ "agentDetail.configure.answer.workFinished": "Pekerjaan selesai",+ "agentDetail.configure.answer.workedFor": "Bekerja selama {{duration}}",+ "agentDetail.configure.answer.workingFor": "Bekerja selama {{duration}}","agentDetail.configure.build.empty.communityEditionTip": "Community Edition, meskipun menawarkan versioning untuk konfigurasi yang diekstrak, tidak mendukung versioning pada sistem file itu sendiri. Berhati-hatilah dengan tindakan Anda dalam mode Build, karena perubahan pada sistem file terjadi secara real time dan tidak selalu dapat dikembalikan dengan rapi. Community Edition bukan pilihan ideal untuk melayani audiens eksternal dalam skala besar.","agentDetail.configure.build.empty.description": "Jelaskan yang Anda inginkan dan formulir di kiri akan terisi seiring percakapan.","agentDetail.configure.build.empty.title": "Bangun agen Anda lewat chat",@@ -79,6 +84,8 @@"agentDetail.configure.buildDraft.updated": "Diperbarui","agentDetail.configure.chatFeatures.description": "Bentuk pengalaman chat pengguna akhir di Web app dan permukaan chat Anda.","agentDetail.configure.chatFeatures.title": "Fitur Chat",+ "agentDetail.configure.clearSessionConfirm.description": "Tindakan ini akan menghapus sesi saat ini dan membuang perubahan konfigurasi Agent yang belum diterapkan.",+ "agentDetail.configure.clearSessionConfirm.title": "Hapus sesi dan buang perubahan?","agentDetail.configure.communityEditionIsolationTip": "Community Edition tidak menyediakan isolasi sistem file yang ketat antar pengguna akhir atau antar eksekusi. Jangan mengekspos agen CE yang sama kepada beberapa pengguna akhir independen ketika isolasi data atau kepatuhan ketat diperlukan.","agentDetail.configure.files.add": "Tambahkan file","agentDetail.configure.files.buildNote.generated": "Dihasilkan",@@ -348,7 +355,7 @@"agentDetail.versionHistory.versionName": "Versi {{version}}","agentDetail.versionHistory.viewOnly": "Hanya lihat","roster.createAgent": "Buat agen",- "roster.createDialog.description": "Buat agen yang dapat digunakan kembali di Roster ruang kerja ini.",+ "roster.createDialog.description": "Buat Agent yang dapat digunakan kembali di ruang kerja ini.","roster.createDialog.title": "Buat agen","roster.createForm.changeIcon": "Ubah ikon agen","roster.createForm.descriptionLabel": "Deskripsi",@@ -360,16 +367,16 @@"roster.createForm.rolePlaceholder": "mis. Asisten Riset","roster.createSuccess": "Agen dibuat.","roster.dateTimeFormat": "DD/MM/YYYY HH:mm:ss",- "roster.deleteDialog.description": "Agen ini akan dihapus dari daftar Roster aktif.",+ "roster.deleteDialog.description": "Agent ini akan dihapus dari daftar Agent.","roster.deleteDialog.title": "Hapus {{name}}?","roster.deleteFailed": "Gagal menghapus agen.","roster.deleteSuccess": "Agen dihapus.",- "roster.duplicateDialog.description": "Buat salinan {{name}} dan sesuaikan identitas Roster-nya.",+ "roster.duplicateDialog.description": "Buat salinan {{name}} dan sesuaikan identitas Agent-nya.","roster.duplicateDialog.title": "Duplikat agen","roster.duplicateForm.changeIcon": "Ubah ikon duplikat untuk {{name}}","roster.duplicateSuccess": "Agen diduplikasi.","roster.editAgent": "Edit {{name}}",- "roster.editDialog.description": "Perbarui nama, deskripsi, dan peran Roster untuk agen ini.",+ "roster.editDialog.description": "Perbarui nama, deskripsi, dan peran Agent ini.","roster.editDialog.title": "Edit agen","roster.editInfo": "Edit Info","roster.empty": "Belum ada agen",@@ -379,8 +386,8 @@"roster.filters.drafts": "Draf","roster.filters.label": "Filter agen","roster.filters.published": "Diterbitkan",- "roster.learnMore": "Pelajari lebih lanjut tentang Agent Roster",- "roster.listLabel": "Daftar Roster agen",+ "roster.learnMore": "Pelajari lebih lanjut tentang Agent",+ "roster.listLabel": "Daftar Agent","roster.loadMore": "Muat lebih banyak","roster.loadingError": "Gagal memuat agen. Segarkan dan coba lagi.","roster.moreActions": "Tindakan lainnya untuk {{name}}",@@ -392,10 +399,10 @@"roster.references.label": "Alur kerja yang menggunakan {{name}}","roster.references.trigger": "Alur kerja yang menggunakan {{name}}","roster.saveToRoster": "Simpan ke Agent Console",- "roster.saveToRosterDialog.description": "Simpan penyiapan inline ini sebagai agen Roster yang dapat digunakan kembali.",+ "roster.saveToRosterDialog.description": "Simpan penyiapan inline ini sebagai Agent yang dapat digunakan kembali.","roster.saveToRosterDialog.title": "Simpan ke Agent Console",- "roster.saveToRosterForm.changeIcon": "Ubah ikon agen Roster",- "roster.saveToRosterSuccess": "Agen disimpan ke Roster.",+ "roster.saveToRosterForm.changeIcon": "Ubah ikon Agent",+ "roster.saveToRosterSuccess": "Agent disimpan.","roster.searchLabel": "Cari agen","roster.searchPlaceholder": "Cari agen berdasarkan nama…","roster.sort.earliestCreated": "Paling awal dibuat",@@ -403,9 +410,6 @@"roster.sort.lastModified": "Terakhir diubah","roster.sort.optionsLabel": "Opsi pengurutan","roster.sort.recentlyCreated": "Baru dibuat",- "roster.tabs.agent": "Agen",- "roster.tabs.human": "Kontak",- "roster.tabsLabel": "Tipe Roster","roster.updateSuccess": "Agen diperbarui.","roster.usageStatus.draft": "Draf"}diff --git a/web/i18n/id-ID/app-debug.json b/web/i18n/id-ID/app-debug.jsonindex 1e015ad2780..bec251f5477 100644--- a/web/i18n/id-ID/app-debug.json+++ b/web/i18n/id-ID/app-debug.json@@ -244,6 +244,9 @@"inputs.run": "Jalankan","inputs.title": "Debug & Pratinjau","inputs.userInputField": "Bidang Input Pengguna",+ "legacyAgentBadge.action": "Buat Agent",+ "legacyAgentBadge.description": "Jenis aplikasi Agent legacy ini sudah dihentikan. Untuk pengalaman membuat agent yang lebih baik, buat Agent di Agent Console.",+ "legacyAgentBadge.label": "Agent legacy","manageModels": "Kelola model","modelConfig.modeType.chat": "Mengobrol","modelConfig.modeType.completion": "Lengkap",diff --git a/web/i18n/id-ID/common.json b/web/i18n/id-ID/common.jsonindex d37302bae9f..cf0c1c427dc 100644--- a/web/i18n/id-ID/common.json+++ b/web/i18n/id-ID/common.json@@ -288,7 +288,7 @@"menus.explore": "Menjelajahi","menus.exploreMarketplace": "Jelajahi Marketplace","menus.plugins": "Integrasi",- "menus.roster": "Daftar Agen",+ "menus.roster": "Agent","menus.status": "beta","menus.tools": "Perkakas","model.capabilities": "Kemampuan MultiModal",@@ -444,6 +444,7 @@"operation.download": "Mengunduh","operation.downloadFailed": "Unduhan gagal. Silakan coba lagi nanti.","operation.downloadSuccess": "Unduh Selesai.",+ "operation.downloading": "Mengunduh...","operation.duplicate": "Duplikat","operation.edit": "Mengedit","operation.exporting": "Mengekspor",diff --git a/web/i18n/it-IT/agent-v-2.json b/web/i18n/it-IT/agent-v-2.jsonindex d626ac1356e..0d99ffbb5bb 100644--- a/web/i18n/it-IT/agent-v-2.json+++ b/web/i18n/it-IT/agent-v-2.json@@ -63,6 +63,11 @@"agentDetail.configure.advancedSettings.envEditor.valuePlaceholder": "Value","agentDetail.configure.advancedSettings.label": "Impostazioni avanzate","agentDetail.configure.advancedSettings.toggle": "Attiva/disattiva impostazioni avanzate",+ "agentDetail.configure.answer.duration.minute": "{{count}} min",+ "agentDetail.configure.answer.duration.second": "{{count}} s",+ "agentDetail.configure.answer.workFinished": "Lavoro terminato",+ "agentDetail.configure.answer.workedFor": "Ha lavorato per {{duration}}",+ "agentDetail.configure.answer.workingFor": "Sta lavorando da {{duration}}","agentDetail.configure.build.empty.communityEditionTip": "Community Edition, pur offrendo il versionamento delle configurazioni estratte, non supporta il versionamento del file system stesso. Fai attenzione alle azioni in modalità Build, perché le modifiche al file system avvengono in tempo reale e non sempre possono essere annullate in modo pulito. Community Edition non è la scelta ideale per servire un pubblico esterno di massa.","agentDetail.configure.build.empty.description": "Descrivi ciò che vuoi e il modulo a sinistra verrà compilato man mano.","agentDetail.configure.build.empty.title": "Crea il tuo agente con la chat",@@ -79,6 +84,8 @@"agentDetail.configure.buildDraft.updated": "Aggiornato","agentDetail.configure.chatFeatures.description": "Definisci l’esperienza di chat per l’utente finale sulla tua webapp e sulle superfici di chat.","agentDetail.configure.chatFeatures.title": "Funzionalità chat",+ "agentDetail.configure.clearSessionConfirm.description": "Questa operazione cancellerà la sessione corrente e scarterà le modifiche alla configurazione dell’Agent non ancora applicate.",+ "agentDetail.configure.clearSessionConfirm.title": "Cancellare la sessione e scartare le modifiche?","agentDetail.configure.communityEditionIsolationTip": "Community Edition non fornisce un isolamento rigido del file system tra utenti finali o esecuzioni. Non esporre lo stesso agente CE a più utenti finali indipendenti quando sono richiesti isolamento dei dati o conformità rigorosa.","agentDetail.configure.files.add": "Aggiungi file","agentDetail.configure.files.buildNote.generated": "Generato",@@ -348,7 +355,7 @@"agentDetail.versionHistory.versionName": "Versione {{version}}","agentDetail.versionHistory.viewOnly": "Sola lettura","roster.createAgent": "Crea agente",- "roster.createDialog.description": "Crea un agente riutilizzabile nel roster di questo workspace.",+ "roster.createDialog.description": "Crea un Agent riutilizzabile in questo workspace.","roster.createDialog.title": "Crea agente","roster.createForm.changeIcon": "Cambia icona dell’agente","roster.createForm.descriptionLabel": "Descrizione",@@ -360,16 +367,16 @@"roster.createForm.rolePlaceholder": "ad es. Assistente di ricerca","roster.createSuccess": "Agente creato.","roster.dateTimeFormat": "DD/MM/YYYY HH:mm:ss",- "roster.deleteDialog.description": "Questo agente verrà rimosso dall’elenco del roster attivo.",+ "roster.deleteDialog.description": "Questo Agent sarà rimosso dall’elenco Agent.","roster.deleteDialog.title": "Eliminare {{name}}?","roster.deleteFailed": "Impossibile eliminare l’agente.","roster.deleteSuccess": "Agente eliminato.",- "roster.duplicateDialog.description": "Crea una copia di {{name}} e personalizza la sua identità nel roster.",+ "roster.duplicateDialog.description": "Crea una copia di {{name}} e personalizza la sua identità Agent.","roster.duplicateDialog.title": "Duplica agente","roster.duplicateForm.changeIcon": "Cambia icona del duplicato per {{name}}","roster.duplicateSuccess": "Agente duplicato.","roster.editAgent": "Modifica {{name}}",- "roster.editDialog.description": "Aggiorna il nome, la descrizione e il ruolo del roster per questo agente.",+ "roster.editDialog.description": "Aggiorna nome, descrizione e ruolo di questo Agent.","roster.editDialog.title": "Modifica agente","roster.editInfo": "Modifica informazioni","roster.empty": "Nessun agente al momento",@@ -379,8 +386,8 @@"roster.filters.drafts": "Bozze","roster.filters.label": "Filtri agente","roster.filters.published": "Pubblicati",- "roster.learnMore": "Scopri di più su Agent Roster",- "roster.listLabel": "Elenco del roster degli agenti",+ "roster.learnMore": "Scopri di più su Agent",+ "roster.listLabel": "Elenco Agent","roster.loadMore": "Carica altro","roster.loadingError": "Impossibile caricare gli agenti. Aggiorna e riprova.","roster.moreActions": "Altre azioni per {{name}}",@@ -392,10 +399,10 @@"roster.references.label": "Workflow che usano {{name}}","roster.references.trigger": "Workflow che usano {{name}}","roster.saveToRoster": "Salva in Agent Console",- "roster.saveToRosterDialog.description": "Salva questa configurazione inline come agente roster riutilizzabile.",+ "roster.saveToRosterDialog.description": "Salva questa configurazione inline come Agent riutilizzabile.","roster.saveToRosterDialog.title": "Salva in Agent Console",- "roster.saveToRosterForm.changeIcon": "Cambia icona dell’agente roster",- "roster.saveToRosterSuccess": "Agente salvato nel roster.",+ "roster.saveToRosterForm.changeIcon": "Cambia icona Agent",+ "roster.saveToRosterSuccess": "Agent salvato.","roster.searchLabel": "Cerca agenti","roster.searchPlaceholder": "Cerca agenti per nome…","roster.sort.earliestCreated": "Creati per primi",@@ -403,9 +410,6 @@"roster.sort.lastModified": "Ultima modifica","roster.sort.optionsLabel": "Opzioni di ordinamento","roster.sort.recentlyCreated": "Creati di recente",- "roster.tabs.agent": "Agente",- "roster.tabs.human": "Contatti",- "roster.tabsLabel": "Tipo di roster","roster.updateSuccess": "Agente aggiornato.","roster.usageStatus.draft": "Bozza"}diff --git a/web/i18n/it-IT/app-debug.json b/web/i18n/it-IT/app-debug.jsonindex c111977edab..202a86e589d 100644--- a/web/i18n/it-IT/app-debug.json+++ b/web/i18n/it-IT/app-debug.json@@ -244,6 +244,9 @@"inputs.run": "ESEGUI","inputs.title": "Debug e Anteprima","inputs.userInputField": "Campo Input Utente",+ "legacyAgentBadge.action": "Crea Agent",+ "legacyAgentBadge.description": "Questo tipo di app Agent legacy è deprecato. Per una migliore esperienza di creazione degli agenti, crea un Agent in Agent Console.",+ "legacyAgentBadge.label": "Agent legacy","manageModels": "Gestisci modelli","modelConfig.modeType.chat": "Chat","modelConfig.modeType.completion": "Completamento",diff --git a/web/i18n/it-IT/common.json b/web/i18n/it-IT/common.jsonindex b65ce4d48d2..6fe3bf52cc9 100644--- a/web/i18n/it-IT/common.json+++ b/web/i18n/it-IT/common.json@@ -288,7 +288,7 @@"menus.explore": "Esplora","menus.exploreMarketplace": "Esplora il Marketplace","menus.plugins": "Integrazione",- "menus.roster": "Elenco agenti",+ "menus.roster": "Agent","menus.status": "beta","menus.tools": "Strumenti","model.capabilities": "Funzionalità multimodali",@@ -444,6 +444,7 @@"operation.download": "Scarica","operation.downloadFailed": "Download non riuscito. Per favore riprova più tardi.","operation.downloadSuccess": "Download completato.",+ "operation.downloading": "Download in corso...","operation.duplicate": "Duplica","operation.edit": "Modifica","operation.exporting": "Esportazione in corso",diff --git a/web/i18n/ja-JP/agent-v-2.json b/web/i18n/ja-JP/agent-v-2.jsonindex 30279b3121c..2edcdbd684d 100644--- a/web/i18n/ja-JP/agent-v-2.json+++ b/web/i18n/ja-JP/agent-v-2.json@@ -63,6 +63,11 @@"agentDetail.configure.advancedSettings.envEditor.valuePlaceholder": "Value","agentDetail.configure.advancedSettings.label": "詳細設定","agentDetail.configure.advancedSettings.toggle": "詳細設定の表示を切り替え",+ "agentDetail.configure.answer.duration.minute": "{{count}}分",+ "agentDetail.configure.answer.duration.second": "{{count}}秒",+ "agentDetail.configure.answer.workFinished": "作業が完了しました",+ "agentDetail.configure.answer.workedFor": "{{duration}} 実行しました",+ "agentDetail.configure.answer.workingFor": "{{duration}} 実行中","agentDetail.configure.build.empty.communityEditionTip": "Community Edition は抽出された設定のバージョン管理を提供しますが、ファイルシステム自体のバージョン管理には対応していません。Build モードでの操作には注意してください。ファイルシステムへの変更はリアルタイムで発生し、常にきれいに元に戻せるとは限りません。Community Edition は大規模な外部利用者向けサービスには理想的な選択ではありません。","agentDetail.configure.build.empty.description": "やりたいことを説明すると、左側のフォームが会話に合わせて入力されます。","agentDetail.configure.build.empty.title": "チャットでエージェントを作成",@@ -79,6 +84,8 @@"agentDetail.configure.buildDraft.updated": "更新済み","agentDetail.configure.chatFeatures.description": "Web app やチャット画面でのエンドユーザー向けチャット体験を設定します。","agentDetail.configure.chatFeatures.title": "チャット機能",+ "agentDetail.configure.clearSessionConfirm.description": "現在のセッションをクリアし、まだ適用されていない Agent の設定変更を破棄します。",+ "agentDetail.configure.clearSessionConfirm.title": "セッションをクリアして変更を破棄しますか?","agentDetail.configure.communityEditionIsolationTip": "Community Edition では、エンドユーザー間または実行間で厳密なファイルシステム分離は提供されません。データ分離や厳格なコンプライアンスが必要な場合は、同じ CE エージェントを複数の独立したエンドユーザーに公開しないでください。","agentDetail.configure.files.add": "ファイルを追加","agentDetail.configure.files.buildNote.generated": "生成済み",@@ -348,7 +355,7 @@"agentDetail.versionHistory.versionName": "バージョン {{version}}","agentDetail.versionHistory.viewOnly": "表示のみ","roster.createAgent": "エージェントを作成",- "roster.createDialog.description": "このワークスペース Roster に再利用可能なエージェントを作成します。",+ "roster.createDialog.description": "このワークスペースに再利用可能な Agent を作成します。","roster.createDialog.title": "エージェントを作成","roster.createForm.changeIcon": "エージェントアイコンを変更","roster.createForm.descriptionLabel": "説明",@@ -360,16 +367,16 @@"roster.createForm.rolePlaceholder": "例: リサーチアシスタント","roster.createSuccess": "エージェントを作成しました。","roster.dateTimeFormat": "YYYY/MM/DD HH:mm:ss",- "roster.deleteDialog.description": "このエージェントはアクティブな Roster リストから削除されます。",+ "roster.deleteDialog.description": "この Agent は Agent リストから削除されます。","roster.deleteDialog.title": "{{name}} を削除しますか?","roster.deleteFailed": "エージェントの削除に失敗しました。","roster.deleteSuccess": "エージェントを削除しました。",- "roster.duplicateDialog.description": "{{name}} のコピーを作成し、その Roster での識別情報をカスタマイズします。",+ "roster.duplicateDialog.description": "{{name}} のコピーを作成し、その Agent ID 情報をカスタマイズします。","roster.duplicateDialog.title": "エージェントを複製","roster.duplicateForm.changeIcon": "{{name}} の複製アイコンを変更","roster.duplicateSuccess": "エージェントを複製しました。","roster.editAgent": "{{name}} を編集",- "roster.editDialog.description": "このエージェントの Roster 名、説明、ロールを更新します。",+ "roster.editDialog.description": "この Agent の名前、説明、ロールを更新します。","roster.editDialog.title": "エージェントを編集","roster.editInfo": "情報を編集","roster.empty": "エージェントはまだありません",@@ -379,8 +386,8 @@"roster.filters.drafts": "ドラフト","roster.filters.label": "エージェントフィルター","roster.filters.published": "公開済み",- "roster.learnMore": "Agent Roster について詳しく見る",- "roster.listLabel": "エージェント Roster リスト",+ "roster.learnMore": "Agent について詳しく見る",+ "roster.listLabel": "Agent リスト","roster.loadMore": "さらに読み込む","roster.loadingError": "エージェントの読み込みに失敗しました。更新してもう一度お試しください。","roster.moreActions": "{{name}} のその他の操作",@@ -392,10 +399,10 @@"roster.references.label": "{{name}} を使用するワークフロー","roster.references.trigger": "{{name}} を使用するワークフロー","roster.saveToRoster": "Agent Console に保存",- "roster.saveToRosterDialog.description": "このインライン設定を再利用可能な Roster エージェントとして保存します。",+ "roster.saveToRosterDialog.description": "このインライン設定を再利用可能な Agent として保存します。","roster.saveToRosterDialog.title": "Agent Console に保存",- "roster.saveToRosterForm.changeIcon": "Roster エージェントのアイコンを変更",- "roster.saveToRosterSuccess": "エージェントを Roster に保存しました。",+ "roster.saveToRosterForm.changeIcon": "Agent アイコンを変更",+ "roster.saveToRosterSuccess": "Agent を保存しました。","roster.searchLabel": "エージェントを検索","roster.searchPlaceholder": "エージェントを名前で検索…","roster.sort.earliestCreated": "作成が古い順",@@ -403,9 +410,6 @@"roster.sort.lastModified": "最終更新","roster.sort.optionsLabel": "並び替えオプション","roster.sort.recentlyCreated": "最近作成",- "roster.tabs.agent": "エージェント",- "roster.tabs.human": "連絡先",- "roster.tabsLabel": "Roster タイプ","roster.updateSuccess": "エージェントを更新しました。","roster.usageStatus.draft": "ドラフト"}diff --git a/web/i18n/ja-JP/app-debug.json b/web/i18n/ja-JP/app-debug.jsonindex f4c58ea5a4c..9f022b5acbc 100644--- a/web/i18n/ja-JP/app-debug.json+++ b/web/i18n/ja-JP/app-debug.json@@ -244,6 +244,9 @@"inputs.run": "実行","inputs.title": "デバッグとプレビュー","inputs.userInputField": "ユーザー入力フィールド",+ "legacyAgentBadge.action": "Agent を作成",+ "legacyAgentBadge.description": "この従来の Agent アプリタイプは非推奨です。より良いエージェント作成体験のため、Agent Console で Agent を作成してください。",+ "legacyAgentBadge.label": "レガシー Agent","manageModels": "モデルを管理","modelConfig.modeType.chat": "チャット","modelConfig.modeType.completion": "完成",diff --git a/web/i18n/ja-JP/common.json b/web/i18n/ja-JP/common.jsonindex 3758341f94c..88ddcfbd6ae 100644--- a/web/i18n/ja-JP/common.json+++ b/web/i18n/ja-JP/common.json@@ -288,7 +288,7 @@"menus.explore": "探索","menus.exploreMarketplace": "マーケットプレイスを探索する","menus.plugins": "インテグレーション",- "menus.roster": "エージェント名簿",+ "menus.roster": "Agent","menus.status": "ベータ版","menus.tools": "ツール","model.capabilities": "マルチモーダル機能",@@ -444,6 +444,7 @@"operation.download": "ダウンロード","operation.downloadFailed": "ダウンロードに失敗しました、後で再試行してください。","operation.downloadSuccess": "ダウンロード完了",+ "operation.downloading": "ダウンロード中...","operation.duplicate": "複製","operation.edit": "編集","operation.exporting": "エクスポート中",diff --git a/web/i18n/ko-KR/agent-v-2.json b/web/i18n/ko-KR/agent-v-2.jsonindex 4f0ba8d8151..d6306ba4bbf 100644--- a/web/i18n/ko-KR/agent-v-2.json+++ b/web/i18n/ko-KR/agent-v-2.json@@ -63,6 +63,11 @@"agentDetail.configure.advancedSettings.envEditor.valuePlaceholder": "Value","agentDetail.configure.advancedSettings.label": "고급 설정","agentDetail.configure.advancedSettings.toggle": "고급 설정 전환",+ "agentDetail.configure.answer.duration.minute": "{{count}}분",+ "agentDetail.configure.answer.duration.second": "{{count}}초",+ "agentDetail.configure.answer.workFinished": "작업 완료",+ "agentDetail.configure.answer.workedFor": "{{duration}} 동안 작업함",+ "agentDetail.configure.answer.workingFor": "{{duration}} 동안 작업 중","agentDetail.configure.build.empty.communityEditionTip": "Community Edition은 추출된 설정에 대한 버전 관리는 제공하지만 파일 시스템 자체의 버전 관리는 지원하지 않습니다. Build 모드에서의 작업에 주의하세요. 파일 시스템 변경은 실시간으로 발생하며 항상 깔끔하게 되돌릴 수 있는 것은 아닙니다. Community Edition은 대규모 외부 사용자에게 서비스를 제공하기에 이상적인 선택이 아닙니다.","agentDetail.configure.build.empty.description": "원하는 내용을 설명하면 대화에 맞춰 왼쪽 양식이 채워집니다.","agentDetail.configure.build.empty.title": "채팅으로 에이전트 만들기",@@ -79,6 +84,8 @@"agentDetail.configure.buildDraft.updated": "업데이트됨","agentDetail.configure.chatFeatures.description": "Web app 및 채팅 화면에서의 최종 사용자 채팅 경험을 구성합니다.","agentDetail.configure.chatFeatures.title": "채팅 기능",+ "agentDetail.configure.clearSessionConfirm.description": "현재 세션이 지워지고 아직 적용되지 않은 Agent 구성 변경 사항이 폐기됩니다.",+ "agentDetail.configure.clearSessionConfirm.title": "세션을 지우고 변경 사항을 폐기할까요?","agentDetail.configure.communityEditionIsolationTip": "Community Edition은 최종 사용자 간 또는 실행 간에 강력한 파일 시스템 격리를 제공하지 않습니다. 데이터 격리나 엄격한 규정 준수가 필요한 경우 동일한 CE 에이전트를 여러 독립 최종 사용자에게 노출하지 마세요.","agentDetail.configure.files.add": "파일 추가","agentDetail.configure.files.buildNote.generated": "생성됨",@@ -348,7 +355,7 @@"agentDetail.versionHistory.versionName": "버전 {{version}}","agentDetail.versionHistory.viewOnly": "보기 전용","roster.createAgent": "에이전트 만들기",- "roster.createDialog.description": "이 워크스페이스 Roster 에 재사용 가능한 에이전트를 만듭니다.",+ "roster.createDialog.description": "이 워크스페이스에 재사용 가능한 Agent 를 만듭니다.","roster.createDialog.title": "에이전트 만들기","roster.createForm.changeIcon": "에이전트 아이콘 변경","roster.createForm.descriptionLabel": "설명",@@ -360,16 +367,16 @@"roster.createForm.rolePlaceholder": "예: 리서치 어시스턴트","roster.createSuccess": "에이전트가 생성되었습니다.","roster.dateTimeFormat": "YYYY-MM-DD HH:mm:ss",- "roster.deleteDialog.description": "이 에이전트가 활성 Roster 목록에서 제거됩니다.",+ "roster.deleteDialog.description": "이 Agent 가 Agent 목록에서 제거됩니다.","roster.deleteDialog.title": "{{name}}을(를) 삭제하시겠습니까?","roster.deleteFailed": "에이전트 삭제에 실패했습니다.","roster.deleteSuccess": "에이전트가 삭제되었습니다.",- "roster.duplicateDialog.description": "{{name}} 의 사본을 만들고 Roster 신원을 사용자 지정합니다.",+ "roster.duplicateDialog.description": "{{name}} 의 사본을 만들고 Agent ID 정보를 사용자 지정합니다.","roster.duplicateDialog.title": "에이전트 복제","roster.duplicateForm.changeIcon": "{{name}} 의 복제본 아이콘 변경","roster.duplicateSuccess": "에이전트가 복제되었습니다.","roster.editAgent": "{{name}} 편집",- "roster.editDialog.description": "이 에이전트의 Roster 이름, 설명 및 역할을 업데이트합니다.",+ "roster.editDialog.description": "이 Agent 의 이름, 설명 및 역할을 업데이트합니다.","roster.editDialog.title": "에이전트 편집","roster.editInfo": "정보 편집","roster.empty": "아직 에이전트가 없습니다",@@ -379,8 +386,8 @@"roster.filters.drafts": "초안","roster.filters.label": "에이전트 필터","roster.filters.published": "게시됨",- "roster.learnMore": "Agent Roster에 대해 자세히 알아보기",- "roster.listLabel": "에이전트 Roster 목록",+ "roster.learnMore": "Agent 자세히 알아보기",+ "roster.listLabel": "Agent 목록","roster.loadMore": "더 보기","roster.loadingError": "에이전트 로딩에 실패했습니다. 새로 고침 후 다시 시도하세요.","roster.moreActions": "{{name}}의 추가 작업",@@ -392,10 +399,10 @@"roster.references.label": "{{name}}을(를) 사용하는 워크플로","roster.references.trigger": "{{name}}을(를) 사용하는 워크플로","roster.saveToRoster": "Agent Console에 저장",- "roster.saveToRosterDialog.description": "이 인라인 설정을 재사용 가능한 Roster 에이전트로 저장합니다.",+ "roster.saveToRosterDialog.description": "이 인라인 설정을 재사용 가능한 Agent 로 저장합니다.","roster.saveToRosterDialog.title": "Agent Console에 저장",- "roster.saveToRosterForm.changeIcon": "Roster 에이전트 아이콘 변경",- "roster.saveToRosterSuccess": "에이전트가 Roster에 저장되었습니다.",+ "roster.saveToRosterForm.changeIcon": "Agent 아이콘 변경",+ "roster.saveToRosterSuccess": "Agent 가 저장되었습니다.","roster.searchLabel": "에이전트 검색","roster.searchPlaceholder": "이름으로 에이전트 검색…","roster.sort.earliestCreated": "오래된 생성순",@@ -403,9 +410,6 @@"roster.sort.lastModified": "마지막 수정","roster.sort.optionsLabel": "정렬 옵션","roster.sort.recentlyCreated": "최근 생성",- "roster.tabs.agent": "에이전트",- "roster.tabs.human": "연락처",- "roster.tabsLabel": "Roster 유형","roster.updateSuccess": "에이전트가 업데이트되었습니다.","roster.usageStatus.draft": "초안"}diff --git a/web/i18n/ko-KR/app-debug.json b/web/i18n/ko-KR/app-debug.jsonindex 620c16f243d..5890dc3f97b 100644--- a/web/i18n/ko-KR/app-debug.json+++ b/web/i18n/ko-KR/app-debug.json@@ -244,6 +244,9 @@"inputs.run": "실행","inputs.title": "디버그 및 미리보기","inputs.userInputField": "사용자 입력 필드",+ "legacyAgentBadge.action": "Agent 만들기",+ "legacyAgentBadge.description": "이 레거시 Agent 앱 유형은 더 이상 권장되지 않습니다. 더 나은 에이전트 제작 경험을 위해 Agent Console에서 Agent를 생성하세요.",+ "legacyAgentBadge.label": "레거시 Agent","manageModels": "모델 관리","modelConfig.modeType.chat": "채팅","modelConfig.modeType.completion": "완료",diff --git a/web/i18n/ko-KR/common.json b/web/i18n/ko-KR/common.jsonindex a0040398bfe..f6c607b5632 100644--- a/web/i18n/ko-KR/common.json+++ b/web/i18n/ko-KR/common.json@@ -288,7 +288,7 @@"menus.explore": "탐색","menus.exploreMarketplace": "Marketplace 둘러보기","menus.plugins": "통합",- "menus.roster": "에이전트 명단",+ "menus.roster": "Agent","menus.status": "베타 버전","menus.tools": "도구","model.capabilities": "멀티모달 기능",@@ -444,6 +444,7 @@"operation.download": "다운로드","operation.downloadFailed": "다운로드 실패했습니다. 나중에 다시 시도하십시오.","operation.downloadSuccess": "다운로드 완료.",+ "operation.downloading": "다운로드 중...","operation.duplicate": "중복","operation.edit": "편집","operation.exporting": "내보내는 중",diff --git a/web/i18n/nl-NL/agent-v-2.json b/web/i18n/nl-NL/agent-v-2.jsonindex 5fe85b681df..92475f2a180 100644--- a/web/i18n/nl-NL/agent-v-2.json+++ b/web/i18n/nl-NL/agent-v-2.json@@ -63,6 +63,11 @@"agentDetail.configure.advancedSettings.envEditor.valuePlaceholder": "Value","agentDetail.configure.advancedSettings.label": "Geavanceerde instellingen","agentDetail.configure.advancedSettings.toggle": "Geavanceerde instellingen in/uit",+ "agentDetail.configure.answer.duration.minute": "{{count}} min",+ "agentDetail.configure.answer.duration.second": "{{count}} s",+ "agentDetail.configure.answer.workFinished": "Werk voltooid",+ "agentDetail.configure.answer.workedFor": "Gewerkt gedurende {{duration}}",+ "agentDetail.configure.answer.workingFor": "Bezig gedurende {{duration}}","agentDetail.configure.build.empty.communityEditionTip": "Community Edition biedt wel versiebeheer voor geëxtraheerde configuraties, maar ondersteunt geen versiebeheer van het bestandssysteem zelf. Wees voorzichtig met je acties in de Build-modus, omdat wijzigingen aan het bestandssysteem in realtime plaatsvinden en niet altijd netjes kunnen worden teruggedraaid. Community Edition is niet de ideale keuze voor het bedienen van grote externe doelgroepen.","agentDetail.configure.build.empty.description": "Beschrijf wat je wilt en het formulier links wordt gaandeweg ingevuld.","agentDetail.configure.build.empty.title": "Bouw je agent via chat",@@ -79,6 +84,8 @@"agentDetail.configure.buildDraft.updated": "Bijgewerkt","agentDetail.configure.chatFeatures.description": "Geef vorm aan de chatervaring voor eindgebruikers in je webapp en chatoppervlakken.","agentDetail.configure.chatFeatures.title": "Chatfuncties",+ "agentDetail.configure.clearSessionConfirm.description": "Dit wist de huidige sessie en negeert nog niet toegepaste configuratiewijzigingen van de Agent.",+ "agentDetail.configure.clearSessionConfirm.title": "Sessie wissen en wijzigingen negeren?","agentDetail.configure.communityEditionIsolationTip": "Community Edition biedt geen harde bestandssysteemisolatie tussen eindgebruikers of runs. Stel dezelfde CE-agent niet beschikbaar aan meerdere onafhankelijke eindgebruikers wanneer gegevensisolatie of strikte compliance vereist is.","agentDetail.configure.files.add": "Bestand toevoegen","agentDetail.configure.files.buildNote.generated": "Gegenereerd",@@ -348,7 +355,7 @@"agentDetail.versionHistory.versionName": "Versie {{version}}","agentDetail.versionHistory.viewOnly": "Alleen bekijken","roster.createAgent": "Agent aanmaken",- "roster.createDialog.description": "Maak een herbruikbare agent in het roster van deze werkruimte.",+ "roster.createDialog.description": "Maak een herbruikbare Agent in deze workspace.","roster.createDialog.title": "Agent aanmaken","roster.createForm.changeIcon": "Agentpictogram wijzigen","roster.createForm.descriptionLabel": "Beschrijving",@@ -360,16 +367,16 @@"roster.createForm.rolePlaceholder": "bv. Research Assistant","roster.createSuccess": "Agent aangemaakt.","roster.dateTimeFormat": "DD-MM-YYYY HH:mm:ss",- "roster.deleteDialog.description": "Deze agent wordt uit de actieve rosterlijst verwijderd.",+ "roster.deleteDialog.description": "Deze Agent wordt verwijderd uit de Agent-lijst.","roster.deleteDialog.title": "{{name}} verwijderen?","roster.deleteFailed": "Verwijderen van agent mislukt.","roster.deleteSuccess": "Agent verwijderd.",- "roster.duplicateDialog.description": "Maak een kopie van {{name}} en pas de roster-identiteit aan.",+ "roster.duplicateDialog.description": "Maak een kopie van {{name}} en pas de Agent-identiteit aan.","roster.duplicateDialog.title": "Agent dupliceren","roster.duplicateForm.changeIcon": "Duplicaatpictogram voor {{name}} wijzigen","roster.duplicateSuccess": "Agent gedupliceerd.","roster.editAgent": "{{name}} bewerken",- "roster.editDialog.description": "Werk de rosternaam, beschrijving en rol van deze agent bij.",+ "roster.editDialog.description": "Werk de naam, beschrijving en rol van deze Agent bij.","roster.editDialog.title": "Agent bewerken","roster.editInfo": "Info bewerken","roster.empty": "Nog geen agent",@@ -379,8 +386,8 @@"roster.filters.drafts": "Concepten","roster.filters.label": "Agentfilters","roster.filters.published": "Gepubliceerd",- "roster.learnMore": "Meer over Agent Roster",- "roster.listLabel": "Agent Roster-lijst",+ "roster.learnMore": "Meer over Agent",+ "roster.listLabel": "Agent-lijst","roster.loadMore": "Meer laden","roster.loadingError": "Laden van agents mislukt. Vernieuw en probeer het opnieuw.","roster.moreActions": "Meer acties voor {{name}}",@@ -392,10 +399,10 @@"roster.references.label": "Workflows die {{name}} gebruiken","roster.references.trigger": "Workflows die {{name}} gebruiken","roster.saveToRoster": "Opslaan in Agent Console",- "roster.saveToRosterDialog.description": "Sla deze inline-configuratie op als een herbruikbare roster-agent.",+ "roster.saveToRosterDialog.description": "Sla deze inline-instelling op als herbruikbare Agent.","roster.saveToRosterDialog.title": "Opslaan in Agent Console",- "roster.saveToRosterForm.changeIcon": "Pictogram van roster-agent wijzigen",- "roster.saveToRosterSuccess": "Agent opgeslagen in roster.",+ "roster.saveToRosterForm.changeIcon": "Agent-pictogram wijzigen",+ "roster.saveToRosterSuccess": "Agent opgeslagen.","roster.searchLabel": "Agents zoeken","roster.searchPlaceholder": "Agents op naam zoeken…","roster.sort.earliestCreated": "Eerst aangemaakt",@@ -403,9 +410,6 @@"roster.sort.lastModified": "Laatst gewijzigd","roster.sort.optionsLabel": "Sorteeropties","roster.sort.recentlyCreated": "Recent aangemaakt",- "roster.tabs.agent": "Agent",- "roster.tabs.human": "Contacten",- "roster.tabsLabel": "Rostertype","roster.updateSuccess": "Agent bijgewerkt.","roster.usageStatus.draft": "Concept"}diff --git a/web/i18n/nl-NL/app-debug.json b/web/i18n/nl-NL/app-debug.jsonindex b6af12c3a1c..6caeceb17bd 100644--- a/web/i18n/nl-NL/app-debug.json+++ b/web/i18n/nl-NL/app-debug.json@@ -244,6 +244,9 @@"inputs.run": "RUN","inputs.title": "Debug & Preview","inputs.userInputField": "User Input Field",+ "legacyAgentBadge.action": "Agent maken",+ "legacyAgentBadge.description": "Dit legacy Agent-app-type is verouderd. Maak voor een betere ervaring met het bouwen van agents een Agent in Agent Console.",+ "legacyAgentBadge.label": "Legacy Agent","manageModels": "Modellen beheren","modelConfig.modeType.chat": "Chat","modelConfig.modeType.completion": "Complete",diff --git a/web/i18n/nl-NL/common.json b/web/i18n/nl-NL/common.jsonindex 272157a52b6..1b7f32701b3 100644--- a/web/i18n/nl-NL/common.json+++ b/web/i18n/nl-NL/common.json@@ -288,7 +288,7 @@"menus.explore": "Explore","menus.exploreMarketplace": "Explore Marketplace","menus.plugins": "Integraties",- "menus.roster": "Agentenoverzicht",+ "menus.roster": "Agent","menus.status": "beta","menus.tools": "Tools","model.capabilities": "MultiModal Capabilities",@@ -444,6 +444,7 @@"operation.download": "Download","operation.downloadFailed": "Download failed. Please try again later.","operation.downloadSuccess": "Download Completed.",+ "operation.downloading": "Downloaden...","operation.duplicate": "Duplicate","operation.edit": "Edit","operation.exporting": "Exporteren",diff --git a/web/i18n/pl-PL/agent-v-2.json b/web/i18n/pl-PL/agent-v-2.jsonindex 5492b29fcf9..f9bdad9b6f3 100644--- a/web/i18n/pl-PL/agent-v-2.json+++ b/web/i18n/pl-PL/agent-v-2.json@@ -63,6 +63,11 @@"agentDetail.configure.advancedSettings.envEditor.valuePlaceholder": "Value","agentDetail.configure.advancedSettings.label": "Ustawienia zaawansowane","agentDetail.configure.advancedSettings.toggle": "Przełącz ustawienia zaawansowane",+ "agentDetail.configure.answer.duration.minute": "{{count}} min",+ "agentDetail.configure.answer.duration.second": "{{count}} s",+ "agentDetail.configure.answer.workFinished": "Praca zakończona",+ "agentDetail.configure.answer.workedFor": "Pracował przez {{duration}}",+ "agentDetail.configure.answer.workingFor": "Pracuje od {{duration}}","agentDetail.configure.build.empty.communityEditionTip": "Community Edition oferuje wersjonowanie wyodrębnionych konfiguracji, ale nie obsługuje wersjonowania samego systemu plików. Zachowaj ostrożność podczas działań w trybie Build, ponieważ zmiany w systemie plików zachodzą w czasie rzeczywistym i nie zawsze można je czysto cofnąć. Community Edition nie jest idealnym wyborem do obsługi masowej publiczności zewnętrznej.","agentDetail.configure.build.empty.description": "Opisz, czego chcesz, a formularz po lewej będzie wypełniany w trakcie rozmowy.","agentDetail.configure.build.empty.title": "Buduj agenta przez czat",@@ -79,6 +84,8 @@"agentDetail.configure.buildDraft.updated": "Zaktualizowano","agentDetail.configure.chatFeatures.description": "Ukształtuj doświadczenie czatu użytkownika końcowego w aplikacji webowej i powierzchniach czatu.","agentDetail.configure.chatFeatures.title": "Funkcje czatu",+ "agentDetail.configure.clearSessionConfirm.description": "Spowoduje to wyczyszczenie bieżącej sesji i odrzucenie niezastosowanych zmian konfiguracji Agent.",+ "agentDetail.configure.clearSessionConfirm.title": "Wyczyścić sesję i odrzucić zmiany?","agentDetail.configure.communityEditionIsolationTip": "Community Edition nie zapewnia twardej izolacji systemu plików między użytkownikami końcowymi ani uruchomieniami. Nie udostępniaj tego samego agenta CE wielu niezależnym użytkownikom końcowym, gdy wymagana jest izolacja danych lub ścisła zgodność.","agentDetail.configure.files.add": "Dodaj plik","agentDetail.configure.files.buildNote.generated": "Wygenerowano",@@ -348,7 +355,7 @@"agentDetail.versionHistory.versionName": "Wersja {{version}}","agentDetail.versionHistory.viewOnly": "Tylko podgląd","roster.createAgent": "Utwórz agenta",- "roster.createDialog.description": "Utwórz reużywalnego agenta w Roster tego workspace.",+ "roster.createDialog.description": "Utwórz wielokrotnego użytku Agent w tym workspace.","roster.createDialog.title": "Utwórz agenta","roster.createForm.changeIcon": "Zmień ikonę agenta","roster.createForm.descriptionLabel": "Opis",@@ -360,16 +367,16 @@"roster.createForm.rolePlaceholder": "np. Asystent badawczy","roster.createSuccess": "Agent utworzony.","roster.dateTimeFormat": "DD.MM.YYYY HH:mm:ss",- "roster.deleteDialog.description": "Ten agent zostanie usunięty z aktywnej listy Roster.",+ "roster.deleteDialog.description": "Ten Agent zostanie usunięty z listy Agent.","roster.deleteDialog.title": "Usunąć {{name}}?","roster.deleteFailed": "Nie udało się usunąć agenta.","roster.deleteSuccess": "Agent usunięty.",- "roster.duplicateDialog.description": "Utwórz kopię {{name}} i dostosuj jego tożsamość w Roster.",+ "roster.duplicateDialog.description": "Utwórz kopię {{name}} i dostosuj jej tożsamość Agent.","roster.duplicateDialog.title": "Duplikuj agenta","roster.duplicateForm.changeIcon": "Zmień ikonę duplikatu dla {{name}}","roster.duplicateSuccess": "Agent zduplikowany.","roster.editAgent": "Edytuj {{name}}",- "roster.editDialog.description": "Zaktualizuj nazwę w Roster, opis i rolę tego agenta.",+ "roster.editDialog.description": "Zaktualizuj nazwę, opis i rolę tego Agent.","roster.editDialog.title": "Edytuj agenta","roster.editInfo": "Edytuj informacje","roster.empty": "Brak agentów",@@ -379,8 +386,8 @@"roster.filters.drafts": "Wersje robocze","roster.filters.label": "Filtry agentów","roster.filters.published": "Opublikowani",- "roster.learnMore": "Dowiedz się więcej o Agent Roster",- "roster.listLabel": "Lista Roster agentów",+ "roster.learnMore": "Dowiedz się więcej o Agent",+ "roster.listLabel": "Lista Agent","roster.loadMore": "Załaduj więcej","roster.loadingError": "Nie udało się załadować agentów. Odśwież i spróbuj ponownie.","roster.moreActions": "Więcej akcji dla {{name}}",@@ -392,10 +399,10 @@"roster.references.label": "Workflow używające {{name}}","roster.references.trigger": "Workflow używające {{name}}","roster.saveToRoster": "Zapisz w Agent Console",- "roster.saveToRosterDialog.description": "Zapisz tę konfigurację inline jako reużywalnego agenta Roster.",+ "roster.saveToRosterDialog.description": "Zapisz tę konfigurację inline jako wielokrotnego użytku Agent.","roster.saveToRosterDialog.title": "Zapisz w Agent Console",- "roster.saveToRosterForm.changeIcon": "Zmień ikonę agenta Roster",- "roster.saveToRosterSuccess": "Agent zapisany w Roster.",+ "roster.saveToRosterForm.changeIcon": "Zmień ikonę Agent",+ "roster.saveToRosterSuccess": "Agent zapisany.","roster.searchLabel": "Szukaj agentów","roster.searchPlaceholder": "Wyszukaj agentów po nazwie…","roster.sort.earliestCreated": "Najwcześniej utworzone",@@ -403,9 +410,6 @@"roster.sort.lastModified": "Ostatnio zmodyfikowane","roster.sort.optionsLabel": "Opcje sortowania","roster.sort.recentlyCreated": "Ostatnio utworzone",- "roster.tabs.agent": "Agent",- "roster.tabs.human": "Kontakty",- "roster.tabsLabel": "Typ Roster","roster.updateSuccess": "Agent zaktualizowany.","roster.usageStatus.draft": "Wersja robocza"}diff --git a/web/i18n/pl-PL/app-debug.json b/web/i18n/pl-PL/app-debug.jsonindex aad66ea9f8c..dbd7763ace7 100644--- a/web/i18n/pl-PL/app-debug.json+++ b/web/i18n/pl-PL/app-debug.json@@ -244,6 +244,9 @@"inputs.run": "URUCHOM","inputs.title": "Debugowanie i podgląd","inputs.userInputField": "Pole wejściowe użytkownika",+ "legacyAgentBadge.action": "Utwórz Agent",+ "legacyAgentBadge.description": "Ten starszy typ aplikacji Agent jest przestarzały. Aby uzyskać lepsze środowisko tworzenia agentów, utwórz Agent w Agent Console.",+ "legacyAgentBadge.label": "Starszy Agent","manageModels": "Zarządzaj modelami","modelConfig.modeType.chat": "Czat","modelConfig.modeType.completion": "Uzupełnienie",diff --git a/web/i18n/pl-PL/common.json b/web/i18n/pl-PL/common.jsonindex 3943bd38479..51f944de3fd 100644--- a/web/i18n/pl-PL/common.json+++ b/web/i18n/pl-PL/common.json@@ -288,7 +288,7 @@"menus.explore": "Eksploruj","menus.exploreMarketplace": "Zapoznaj się z Marketplace","menus.plugins": "Integracjay",- "menus.roster": "Lista agentów",+ "menus.roster": "Agent","menus.status": "beta","menus.tools": "Narzędzia","model.capabilities": "Możliwości multimodalne",@@ -444,6 +444,7 @@"operation.download": "Pobierz","operation.downloadFailed": "Pobieranie nie powiodło się. Proszę spróbować ponownie później.","operation.downloadSuccess": "Pobieranie zakończone.",+ "operation.downloading": "Pobieranie...","operation.duplicate": "Duplikuj","operation.edit": "Edytuj","operation.exporting": "Eksportowanie",diff --git a/web/i18n/pt-BR/agent-v-2.json b/web/i18n/pt-BR/agent-v-2.jsonindex 867ef4b8e6b..cd508231240 100644--- a/web/i18n/pt-BR/agent-v-2.json+++ b/web/i18n/pt-BR/agent-v-2.json@@ -63,6 +63,11 @@"agentDetail.configure.advancedSettings.envEditor.valuePlaceholder": "Value","agentDetail.configure.advancedSettings.label": "Configurações avançadas","agentDetail.configure.advancedSettings.toggle": "Alternar configurações avançadas",+ "agentDetail.configure.answer.duration.minute": "{{count}} min",+ "agentDetail.configure.answer.duration.second": "{{count}} s",+ "agentDetail.configure.answer.workFinished": "Trabalho concluído",+ "agentDetail.configure.answer.workedFor": "Trabalhou por {{duration}}",+ "agentDetail.configure.answer.workingFor": "Trabalhando há {{duration}}","agentDetail.configure.build.empty.communityEditionTip": "A Community Edition, embora ofereça versionamento para as configurações extraídas, não oferece suporte a versionamento do próprio sistema de arquivos. Tenha cuidado com suas ações no modo Build, pois as alterações feitas no sistema de arquivos acontecem em tempo real e nem sempre podem ser revertidas de forma limpa. A Community Edition não é a escolha ideal para atender grandes públicos externos.","agentDetail.configure.build.empty.description": "Descreva o que você quer e o formulário à esquerda será preenchido conforme a conversa avança.","agentDetail.configure.build.empty.title": "Crie seu agente conversando",@@ -79,6 +84,8 @@"agentDetail.configure.buildDraft.updated": "Atualizado","agentDetail.configure.chatFeatures.description": "Modele a experiência de chat do usuário final no seu webapp e superfícies de chat.","agentDetail.configure.chatFeatures.title": "Recursos de chat",+ "agentDetail.configure.clearSessionConfirm.description": "Isso limpará a sessão atual e descartará as alterações de configuração do Agent que ainda não foram aplicadas.",+ "agentDetail.configure.clearSessionConfirm.title": "Limpar a sessão e descartar alterações?","agentDetail.configure.communityEditionIsolationTip": "A Community Edition não fornece isolamento rígido do sistema de arquivos entre usuários finais ou execuções. Não exponha o mesmo agente CE a vários usuários finais independentes quando isolamento de dados ou conformidade rigorosa forem necessários.","agentDetail.configure.files.add": "Adicionar arquivo","agentDetail.configure.files.buildNote.generated": "Gerado",@@ -348,7 +355,7 @@"agentDetail.versionHistory.versionName": "Versão {{version}}","agentDetail.versionHistory.viewOnly": "Somente leitura","roster.createAgent": "Criar agente",- "roster.createDialog.description": "Crie um agente reutilizável no roster deste workspace.",+ "roster.createDialog.description": "Crie um Agent reutilizável neste workspace.","roster.createDialog.title": "Criar agente","roster.createForm.changeIcon": "Alterar ícone do agente","roster.createForm.descriptionLabel": "Descrição",@@ -360,16 +367,16 @@"roster.createForm.rolePlaceholder": "ex.: Assistente de pesquisa","roster.createSuccess": "Agente criado.","roster.dateTimeFormat": "DD/MM/YYYY HH:mm:ss",- "roster.deleteDialog.description": "Este agente será removido da lista do roster ativo.",+ "roster.deleteDialog.description": "Este Agent será removido da lista de Agent.","roster.deleteDialog.title": "Excluir {{name}}?","roster.deleteFailed": "Falha ao excluir o agente.","roster.deleteSuccess": "Agente excluído.",- "roster.duplicateDialog.description": "Crie uma cópia de {{name}} e personalize sua identidade no roster.",+ "roster.duplicateDialog.description": "Crie uma cópia de {{name}} e personalize sua identidade de Agent.","roster.duplicateDialog.title": "Duplicar agente","roster.duplicateForm.changeIcon": "Alterar ícone da duplicata de {{name}}","roster.duplicateSuccess": "Agente duplicado.","roster.editAgent": "Editar {{name}}",- "roster.editDialog.description": "Atualize o nome, a descrição e a função deste agente no roster.",+ "roster.editDialog.description": "Atualize o nome, a descrição e a função deste Agent.","roster.editDialog.title": "Editar agente","roster.editInfo": "Editar informações","roster.empty": "Ainda não há agente",@@ -379,8 +386,8 @@"roster.filters.drafts": "Rascunhos","roster.filters.label": "Filtros de agente","roster.filters.published": "Publicados",- "roster.learnMore": "Saiba mais sobre o Agent Roster",- "roster.listLabel": "Lista do roster de agentes",+ "roster.learnMore": "Saiba mais sobre Agent",+ "roster.listLabel": "Lista de Agent","roster.loadMore": "Carregar mais","roster.loadingError": "Falha ao carregar agentes. Atualize e tente novamente.","roster.moreActions": "Mais ações para {{name}}",@@ -392,10 +399,10 @@"roster.references.label": "Workflows que usam {{name}}","roster.references.trigger": "Workflows que usam {{name}}","roster.saveToRoster": "Salvar no Agent Console",- "roster.saveToRosterDialog.description": "Salve esta configuração inline como um agente de roster reutilizável.",+ "roster.saveToRosterDialog.description": "Salve esta configuração inline como um Agent reutilizável.","roster.saveToRosterDialog.title": "Salvar no Agent Console",- "roster.saveToRosterForm.changeIcon": "Alterar ícone do agente de roster",- "roster.saveToRosterSuccess": "Agente salvo no roster.",+ "roster.saveToRosterForm.changeIcon": "Alterar ícone do Agent",+ "roster.saveToRosterSuccess": "Agent salvo.","roster.searchLabel": "Pesquisar agentes","roster.searchPlaceholder": "Pesquisar agentes pelo nome…","roster.sort.earliestCreated": "Criados primeiro",@@ -403,9 +410,6 @@"roster.sort.lastModified": "Última modificação","roster.sort.optionsLabel": "Opções de ordenação","roster.sort.recentlyCreated": "Criados recentemente",- "roster.tabs.agent": "Agente",- "roster.tabs.human": "Contatos",- "roster.tabsLabel": "Tipo de roster","roster.updateSuccess": "Agente atualizado.","roster.usageStatus.draft": "Rascunho"}diff --git a/web/i18n/pt-BR/app-debug.json b/web/i18n/pt-BR/app-debug.jsonindex 595c55d2ca0..4650bd0d131 100644--- a/web/i18n/pt-BR/app-debug.json+++ b/web/i18n/pt-BR/app-debug.json@@ -244,6 +244,9 @@"inputs.run": "EXECUTAR","inputs.title": "Depuração e Visualização","inputs.userInputField": "Campo de Entrada do Usuário",+ "legacyAgentBadge.action": "Criar Agent",+ "legacyAgentBadge.description": "Este tipo de app Agent legado foi descontinuado. Para uma experiência melhor de criação de agentes, crie um Agent no Agent Console.",+ "legacyAgentBadge.label": "Agent legado","manageModels": "Gerenciar modelos","modelConfig.modeType.chat": "Chat","modelConfig.modeType.completion": "Completar",diff --git a/web/i18n/pt-BR/common.json b/web/i18n/pt-BR/common.jsonindex 3fb45b62ccd..efd6074cf9d 100644--- a/web/i18n/pt-BR/common.json+++ b/web/i18n/pt-BR/common.json@@ -288,7 +288,7 @@"menus.explore": "Explorar","menus.exploreMarketplace": "Explorar Mercado","menus.plugins": "Integrações",- "menus.roster": "Lista de agentes",+ "menus.roster": "Agent","menus.status": "beta","menus.tools": "Ferramentas","model.capabilities": "Recursos multimodais",@@ -444,6 +444,7 @@"operation.download": "Baixar","operation.downloadFailed": "Download falhou. Por favor, tente novamente mais tarde.","operation.downloadSuccess": "Download concluído.",+ "operation.downloading": "Baixando...","operation.duplicate": "Duplicada","operation.edit": "Editar","operation.exporting": "Exportando",diff --git a/web/i18n/ro-RO/agent-v-2.json b/web/i18n/ro-RO/agent-v-2.jsonindex d56d9c17b33..e69a96f1bc6 100644--- a/web/i18n/ro-RO/agent-v-2.json+++ b/web/i18n/ro-RO/agent-v-2.json@@ -63,6 +63,11 @@"agentDetail.configure.advancedSettings.envEditor.valuePlaceholder": "Value","agentDetail.configure.advancedSettings.label": "Setări avansate","agentDetail.configure.advancedSettings.toggle": "Comută setările avansate",+ "agentDetail.configure.answer.duration.minute": "{{count}} min",+ "agentDetail.configure.answer.duration.second": "{{count}} s",+ "agentDetail.configure.answer.workFinished": "Lucrare finalizată",+ "agentDetail.configure.answer.workedFor": "A lucrat timp de {{duration}}",+ "agentDetail.configure.answer.workingFor": "Lucrează de {{duration}}","agentDetail.configure.build.empty.communityEditionTip": "Community Edition, deși oferă versionare pentru configurațiile extrase, nu acceptă versionarea sistemului de fișiere în sine. Fii atent la acțiunile din modul Build, deoarece modificările făcute în sistemul de fișiere au loc în timp real și nu pot fi întotdeauna anulate curat. Community Edition nu este alegerea ideală pentru servirea unor audiențe externe numeroase.","agentDetail.configure.build.empty.description": "Descrie ce dorești, iar formularul din stânga se completează pe măsură ce avansezi.","agentDetail.configure.build.empty.title": "Construiește agentul prin chat",@@ -79,6 +84,8 @@"agentDetail.configure.buildDraft.updated": "Actualizat","agentDetail.configure.chatFeatures.description": "Modelează experiența de chat a utilizatorului final pe webapp-ul tău și pe suprafețele de chat.","agentDetail.configure.chatFeatures.title": "Funcții de chat",+ "agentDetail.configure.clearSessionConfirm.description": "Această acțiune va goli sesiunea curentă și va renunța la modificările neaplicate ale configurării Agent.",+ "agentDetail.configure.clearSessionConfirm.title": "Golești sesiunea și renunți la modificări?","agentDetail.configure.communityEditionIsolationTip": "Community Edition nu oferă izolare strictă a sistemului de fișiere între utilizatorii finali sau între rulări. Nu expune același agent CE către mai mulți utilizatori finali independenți atunci când este necesară izolarea datelor sau conformitatea strictă.","agentDetail.configure.files.add": "Adaugă fișier","agentDetail.configure.files.buildNote.generated": "Generat",@@ -348,7 +355,7 @@"agentDetail.versionHistory.versionName": "Versiunea {{version}}","agentDetail.versionHistory.viewOnly": "Doar vizualizare","roster.createAgent": "Creează agent",- "roster.createDialog.description": "Creați un agent reutilizabil în roster-ul acestui workspace.",+ "roster.createDialog.description": "Creați un Agent reutilizabil în acest workspace.","roster.createDialog.title": "Creează agent","roster.createForm.changeIcon": "Schimbă pictograma agentului","roster.createForm.descriptionLabel": "Descriere",@@ -360,16 +367,16 @@"roster.createForm.rolePlaceholder": "de ex. Asistent de cercetare","roster.createSuccess": "Agent creat.","roster.dateTimeFormat": "DD.MM.YYYY HH:mm:ss",- "roster.deleteDialog.description": "Acest agent va fi eliminat din lista activă a roster-ului.",+ "roster.deleteDialog.description": "Acest Agent va fi eliminat din lista Agent.","roster.deleteDialog.title": "Ștergeți {{name}}?","roster.deleteFailed": "Ștergerea agentului a eșuat.","roster.deleteSuccess": "Agent șters.",- "roster.duplicateDialog.description": "Creați o copie a {{name}} și personalizați identitatea sa în roster.",+ "roster.duplicateDialog.description": "Creați o copie a {{name}} și personalizați-i identitatea Agent.","roster.duplicateDialog.title": "Duplică agentul","roster.duplicateForm.changeIcon": "Schimbă pictograma duplicatului pentru {{name}}","roster.duplicateSuccess": "Agent duplicat.","roster.editAgent": "Editați {{name}}",- "roster.editDialog.description": "Actualizați numele, descrierea și rolul din roster pentru acest agent.",+ "roster.editDialog.description": "Actualizați numele, descrierea și rolul acestui Agent.","roster.editDialog.title": "Editați agentul","roster.editInfo": "Editați informațiile","roster.empty": "Niciun agent încă",@@ -379,8 +386,8 @@"roster.filters.drafts": "Ciorne","roster.filters.label": "Filtre agent","roster.filters.published": "Publicați",- "roster.learnMore": "Aflați mai multe despre Agent Roster",- "roster.listLabel": "Listă roster de agenți",+ "roster.learnMore": "Aflați mai multe despre Agent",+ "roster.listLabel": "Listă Agent","roster.loadMore": "Încarcă mai mult","roster.loadingError": "Încărcarea agenților a eșuat. Reîmprospătați și încercați din nou.","roster.moreActions": "Mai multe acțiuni pentru {{name}}",@@ -392,10 +399,10 @@"roster.references.label": "Workflow-uri care folosesc {{name}}","roster.references.trigger": "Workflow-uri care folosesc {{name}}","roster.saveToRoster": "Salvează în Agent Console",- "roster.saveToRosterDialog.description": "Salvează această configurație inline ca agent roster reutilizabil.",+ "roster.saveToRosterDialog.description": "Salvați această configurare inline ca Agent reutilizabil.","roster.saveToRosterDialog.title": "Salvează în Agent Console",- "roster.saveToRosterForm.changeIcon": "Schimbă pictograma agentului roster",- "roster.saveToRosterSuccess": "Agent salvat în roster.",+ "roster.saveToRosterForm.changeIcon": "Schimbați pictograma Agent",+ "roster.saveToRosterSuccess": "Agent salvat.","roster.searchLabel": "Căutați agenți","roster.searchPlaceholder": "Căutați agenți după nume…","roster.sort.earliestCreated": "Create mai întâi",@@ -403,9 +410,6 @@"roster.sort.lastModified": "Ultima modificare","roster.sort.optionsLabel": "Opțiuni de sortare","roster.sort.recentlyCreated": "Create recent",- "roster.tabs.agent": "Agent",- "roster.tabs.human": "Contacte",- "roster.tabsLabel": "Tip de roster","roster.updateSuccess": "Agent actualizat.","roster.usageStatus.draft": "Ciornă"}diff --git a/web/i18n/ro-RO/app-debug.json b/web/i18n/ro-RO/app-debug.jsonindex e295d3a813c..53d86b54b75 100644--- a/web/i18n/ro-RO/app-debug.json+++ b/web/i18n/ro-RO/app-debug.json@@ -244,6 +244,9 @@"inputs.run": "RULARE","inputs.title": "Depanare și previzualizare","inputs.userInputField": "Câmp de intrare utilizator",+ "legacyAgentBadge.action": "Creează Agent",+ "legacyAgentBadge.description": "Acest tip vechi de aplicație Agent este depreciat. Pentru o experiență mai bună de creare a agenților, creează un Agent în Agent Console.",+ "legacyAgentBadge.label": "Agent moștenit","manageModels": "Gestionare modele","modelConfig.modeType.chat": "Chat","modelConfig.modeType.completion": "Completare",diff --git a/web/i18n/ro-RO/common.json b/web/i18n/ro-RO/common.jsonindex 8e070517325..79bd7f63cc7 100644--- a/web/i18n/ro-RO/common.json+++ b/web/i18n/ro-RO/common.json@@ -288,7 +288,7 @@"menus.explore": "Explorează","menus.exploreMarketplace": "Explorați Marketplace","menus.plugins": "Integrare-uri",- "menus.roster": "Listă agenți",+ "menus.roster": "Agent","menus.status": "beta","menus.tools": "Instrumente","model.capabilities": "Capacități multimodale",@@ -444,6 +444,7 @@"operation.download": "Descarcă","operation.downloadFailed": "Descărcarea a eșuat. Vă rugăm să încercați din nou mai târziu.","operation.downloadSuccess": "Descărcarea a fost finalizată.",+ "operation.downloading": "Se descarcă...","operation.duplicate": "Duplică","operation.edit": "Editează","operation.exporting": "Se exportă",diff --git a/web/i18n/ru-RU/agent-v-2.json b/web/i18n/ru-RU/agent-v-2.jsonindex 62ff29d2d05..a0d64ba94a4 100644--- a/web/i18n/ru-RU/agent-v-2.json+++ b/web/i18n/ru-RU/agent-v-2.json@@ -63,6 +63,11 @@"agentDetail.configure.advancedSettings.envEditor.valuePlaceholder": "Value","agentDetail.configure.advancedSettings.label": "Расширенные настройки","agentDetail.configure.advancedSettings.toggle": "Переключить расширенные настройки",+ "agentDetail.configure.answer.duration.minute": "{{count}} мин",+ "agentDetail.configure.answer.duration.second": "{{count}} с",+ "agentDetail.configure.answer.workFinished": "Работа завершена",+ "agentDetail.configure.answer.workedFor": "Работал {{duration}}",+ "agentDetail.configure.answer.workingFor": "Работает {{duration}}","agentDetail.configure.build.empty.communityEditionTip": "Community Edition предоставляет версионирование извлеченных конфигураций, но не поддерживает версионирование самой файловой системы. Будьте осторожны с действиями в режиме Build: изменения файловой системы происходят в реальном времени и не всегда могут быть аккуратно отменены. Community Edition не является идеальным выбором для обслуживания массовой внешней аудитории.","agentDetail.configure.build.empty.description": "Опишите, что вам нужно, и форма слева будет заполняться по ходу диалога.","agentDetail.configure.build.empty.title": "Создайте агента в чате",@@ -79,6 +84,8 @@"agentDetail.configure.buildDraft.updated": "Обновлено","agentDetail.configure.chatFeatures.description": "Настройте чат-опыт конечного пользователя в вашем веб-приложении и чат-поверхностях.","agentDetail.configure.chatFeatures.title": "Функции чата",+ "agentDetail.configure.clearSessionConfirm.description": "Это очистит текущий сеанс и отменит непримененные изменения конфигурации Agent.",+ "agentDetail.configure.clearSessionConfirm.title": "Очистить сеанс и отменить изменения?","agentDetail.configure.communityEditionIsolationTip": "Community Edition не обеспечивает жесткую изоляцию файловой системы между конечными пользователями или запусками. Не предоставляйте один и тот же CE-агент нескольким независимым конечным пользователям, если требуется изоляция данных или строгое соответствие требованиям.","agentDetail.configure.files.add": "Добавить файл","agentDetail.configure.files.buildNote.generated": "Сгенерировано",@@ -348,7 +355,7 @@"agentDetail.versionHistory.versionName": "Версия {{version}}","agentDetail.versionHistory.viewOnly": "Только просмотр","roster.createAgent": "Создать агента",- "roster.createDialog.description": "Создайте переиспользуемого агента в Roster этого рабочего пространства.",+ "roster.createDialog.description": "Создайте переиспользуемый Agent в этом workspace.","roster.createDialog.title": "Создать агента","roster.createForm.changeIcon": "Сменить иконку агента","roster.createForm.descriptionLabel": "Описание",@@ -360,16 +367,16 @@"roster.createForm.rolePlaceholder": "напр. Помощник по исследованиям","roster.createSuccess": "Агент создан.","roster.dateTimeFormat": "DD.MM.YYYY HH:mm:ss",- "roster.deleteDialog.description": "Этот агент будет удалён из активного списка Roster.",+ "roster.deleteDialog.description": "Этот Agent будет удалён из списка Agent.","roster.deleteDialog.title": "Удалить {{name}}?","roster.deleteFailed": "Не удалось удалить агента.","roster.deleteSuccess": "Агент удалён.",- "roster.duplicateDialog.description": "Создайте копию {{name}} и настройте его идентичность в Roster.",+ "roster.duplicateDialog.description": "Создайте копию {{name}} и настройте её идентичность Agent.","roster.duplicateDialog.title": "Дублировать агента","roster.duplicateForm.changeIcon": "Сменить иконку копии для {{name}}","roster.duplicateSuccess": "Агент продублирован.","roster.editAgent": "Редактировать {{name}}",- "roster.editDialog.description": "Обновите имя в Roster, описание и роль этого агента.",+ "roster.editDialog.description": "Обновите имя, описание и роль этого Agent.","roster.editDialog.title": "Редактировать агента","roster.editInfo": "Редактировать информацию","roster.empty": "Агентов пока нет",@@ -379,8 +386,8 @@"roster.filters.drafts": "Черновики","roster.filters.label": "Фильтры агентов","roster.filters.published": "Опубликованные",- "roster.learnMore": "Подробнее об Agent Roster",- "roster.listLabel": "Список Roster агентов",+ "roster.learnMore": "Подробнее об Agent",+ "roster.listLabel": "Список Agent","roster.loadMore": "Загрузить ещё","roster.loadingError": "Не удалось загрузить агентов. Обновите и попробуйте снова.","roster.moreActions": "Дополнительные действия для {{name}}",@@ -392,10 +399,10 @@"roster.references.label": "Рабочие процессы, использующие {{name}}","roster.references.trigger": "Рабочие процессы, использующие {{name}}","roster.saveToRoster": "Сохранить в Agent Console",- "roster.saveToRosterDialog.description": "Сохраните эту встроенную настройку как переиспользуемого агента Roster.",+ "roster.saveToRosterDialog.description": "Сохраните эту inline-настройку как переиспользуемый Agent.","roster.saveToRosterDialog.title": "Сохранить в Agent Console",- "roster.saveToRosterForm.changeIcon": "Изменить значок агента Roster",- "roster.saveToRosterSuccess": "Агент сохранён в Roster.",+ "roster.saveToRosterForm.changeIcon": "Изменить значок Agent",+ "roster.saveToRosterSuccess": "Agent сохранён.","roster.searchLabel": "Поиск агентов","roster.searchPlaceholder": "Поиск агентов по имени…","roster.sort.earliestCreated": "Сначала созданные",@@ -403,9 +410,6 @@"roster.sort.lastModified": "Последнее изменение","roster.sort.optionsLabel": "Параметры сортировки","roster.sort.recentlyCreated": "Недавно созданные",- "roster.tabs.agent": "Агент",- "roster.tabs.human": "Контакты",- "roster.tabsLabel": "Тип Roster","roster.updateSuccess": "Агент обновлён.","roster.usageStatus.draft": "Черновик"}diff --git a/web/i18n/ru-RU/app-debug.json b/web/i18n/ru-RU/app-debug.jsonindex 858c9949389..8f0dea9a7bc 100644--- a/web/i18n/ru-RU/app-debug.json+++ b/web/i18n/ru-RU/app-debug.json@@ -244,6 +244,9 @@"inputs.run": "ЗАПУСТИТЬ","inputs.title": "Отладка и предварительный просмотр","inputs.userInputField": "Поле пользовательского ввода",+ "legacyAgentBadge.action": "Создать Agent",+ "legacyAgentBadge.description": "Этот устаревший тип приложения Agent больше не рекомендуется. Для лучшего опыта создания агентов создайте Agent в Agent Console.",+ "legacyAgentBadge.label": "Устаревший Agent","manageModels": "Управление моделями","modelConfig.modeType.chat": "Чат","modelConfig.modeType.completion": "Завершение",diff --git a/web/i18n/ru-RU/common.json b/web/i18n/ru-RU/common.jsonindex edb825318d8..4e026c6ccf2 100644--- a/web/i18n/ru-RU/common.json+++ b/web/i18n/ru-RU/common.json@@ -288,7 +288,7 @@"menus.explore": "Исследовать","menus.exploreMarketplace": "Подробнее о Marketplace","menus.plugins": "Интеграции",- "menus.roster": "Список агентов",+ "menus.roster": "Agent","menus.status": "бета","menus.tools": "Инструменты","model.capabilities": "Мультимодальные возможности",@@ -444,6 +444,7 @@"operation.download": "Скачать","operation.downloadFailed": "Скачивание не удалось. Пожалуйста, попробуйте еще раз позже.","operation.downloadSuccess": "Загрузка завершена.",+ "operation.downloading": "Скачивание...","operation.duplicate": "Дублировать","operation.edit": "Редактировать","operation.exporting": "Экспорт",diff --git a/web/i18n/sl-SI/agent-v-2.json b/web/i18n/sl-SI/agent-v-2.jsonindex 900a6ed6075..620e846dd3b 100644--- a/web/i18n/sl-SI/agent-v-2.json+++ b/web/i18n/sl-SI/agent-v-2.json@@ -63,6 +63,11 @@"agentDetail.configure.advancedSettings.envEditor.valuePlaceholder": "Value","agentDetail.configure.advancedSettings.label": "Napredne nastavitve","agentDetail.configure.advancedSettings.toggle": "Preklopi napredne nastavitve",+ "agentDetail.configure.answer.duration.minute": "{{count}} min",+ "agentDetail.configure.answer.duration.second": "{{count}} s",+ "agentDetail.configure.answer.workFinished": "Delo končano",+ "agentDetail.configure.answer.workedFor": "Delal {{duration}}",+ "agentDetail.configure.answer.workingFor": "Dela {{duration}}","agentDetail.configure.build.empty.communityEditionTip": "Community Edition sicer ponuja različice za izvlečene konfiguracije, vendar ne podpira različic samega datotečnega sistema. Pri dejanjih v načinu Build bodite previdni, saj se spremembe datotečnega sistema zgodijo v realnem času in jih ni vedno mogoče lepo razveljaviti. Community Edition ni idealna izbira za množično zunanjo publiko.","agentDetail.configure.build.empty.description": "Opišite, kaj želite, in obrazec na levi se bo sproti izpolnjeval.","agentDetail.configure.build.empty.title": "Izdelajte agenta s klepetom",@@ -79,6 +84,8 @@"agentDetail.configure.buildDraft.updated": "Posodobljeno","agentDetail.configure.chatFeatures.description": "Oblikujte uporabniško izkušnjo klepeta v vaši spletni aplikaciji in klepetalnih površinah.","agentDetail.configure.chatFeatures.title": "Funkcije klepeta",+ "agentDetail.configure.clearSessionConfirm.description": "To bo počistilo trenutno sejo in zavrglo še neuveljavljene spremembe konfiguracije Agent.",+ "agentDetail.configure.clearSessionConfirm.title": "Počisti sejo in zavrzi spremembe?","agentDetail.configure.communityEditionIsolationTip": "Community Edition ne zagotavlja stroge izolacije datotečnega sistema med končnimi uporabniki ali zagoni. Istega agenta CE ne izpostavljajte več neodvisnim končnim uporabnikom, kadar sta potrebni izolacija podatkov ali stroga skladnost.","agentDetail.configure.files.add": "Dodaj datoteko","agentDetail.configure.files.buildNote.generated": "Ustvarjeno",@@ -348,7 +355,7 @@"agentDetail.versionHistory.versionName": "Različica {{version}}","agentDetail.versionHistory.viewOnly": "Samo ogled","roster.createAgent": "Ustvari agenta",- "roster.createDialog.description": "Ustvarite ponovno uporabnega agenta v Roster tega delovnega prostora.",+ "roster.createDialog.description": "Ustvarite ponovno uporabnega Agent v tem workspace.","roster.createDialog.title": "Ustvari agenta","roster.createForm.changeIcon": "Spremeni ikono agenta","roster.createForm.descriptionLabel": "Opis",@@ -360,16 +367,16 @@"roster.createForm.rolePlaceholder": "npr. Raziskovalni asistent","roster.createSuccess": "Agent ustvarjen.","roster.dateTimeFormat": "DD. MM. YYYY HH:mm:ss",- "roster.deleteDialog.description": "Ta agent bo odstranjen iz aktivnega seznama Roster.",+ "roster.deleteDialog.description": "Ta Agent bo odstranjen s seznama Agent.","roster.deleteDialog.title": "Izbrišem {{name}}?","roster.deleteFailed": "Agenta ni bilo mogoče izbrisati.","roster.deleteSuccess": "Agent izbrisan.",- "roster.duplicateDialog.description": "Ustvarite kopijo agenta {{name}} in prilagodite njegovo identiteto v Roster.",+ "roster.duplicateDialog.description": "Ustvarite kopijo {{name}} in prilagodite njeno identiteto Agent.","roster.duplicateDialog.title": "Podvoji agenta","roster.duplicateForm.changeIcon": "Spremeni ikono kopije za {{name}}","roster.duplicateSuccess": "Agent podvojen.","roster.editAgent": "Uredi {{name}}",- "roster.editDialog.description": "Posodobite ime v Roster, opis in vlogo za tega agenta.",+ "roster.editDialog.description": "Posodobite ime, opis in vlogo tega Agent.","roster.editDialog.title": "Uredi agenta","roster.editInfo": "Uredi informacije","roster.empty": "Še ni agentov",@@ -379,8 +386,8 @@"roster.filters.drafts": "Osnutki","roster.filters.label": "Filtri agentov","roster.filters.published": "Objavljeni",- "roster.learnMore": "Več o Agent Roster",- "roster.listLabel": "Seznam Roster agentov",+ "roster.learnMore": "Več o Agent",+ "roster.listLabel": "Seznam Agent","roster.loadMore": "Naloži več","roster.loadingError": "Agentov ni bilo mogoče naložiti. Osvežite in poskusite znova.","roster.moreActions": "Več dejanj za {{name}}",@@ -392,10 +399,10 @@"roster.references.label": "Poteki dela, ki uporabljajo {{name}}","roster.references.trigger": "Poteki dela, ki uporabljajo {{name}}","roster.saveToRoster": "Shrani v Agent Console",- "roster.saveToRosterDialog.description": "Shranite to vgrajeno nastavitev kot ponovno uporabnega agenta Roster.",+ "roster.saveToRosterDialog.description": "Shranite to inline nastavitev kot ponovno uporabnega Agent.","roster.saveToRosterDialog.title": "Shrani v Agent Console",- "roster.saveToRosterForm.changeIcon": "Spremeni ikono agenta Roster",- "roster.saveToRosterSuccess": "Agent shranjen v Roster.",+ "roster.saveToRosterForm.changeIcon": "Spremeni ikono Agent",+ "roster.saveToRosterSuccess": "Agent shranjen.","roster.searchLabel": "Iskanje agentov","roster.searchPlaceholder": "Iskanje agentov po imenu…","roster.sort.earliestCreated": "Najprej ustvarjeno",@@ -403,9 +410,6 @@"roster.sort.lastModified": "Nazadnje spremenjeno","roster.sort.optionsLabel": "Možnosti razvrščanja","roster.sort.recentlyCreated": "Nedavno ustvarjeno",- "roster.tabs.agent": "Agent",- "roster.tabs.human": "Stiki",- "roster.tabsLabel": "Tip Roster","roster.updateSuccess": "Agent posodobljen.","roster.usageStatus.draft": "Osnutek"}diff --git a/web/i18n/sl-SI/app-debug.json b/web/i18n/sl-SI/app-debug.jsonindex 5fee642be5f..b172eb562ac 100644--- a/web/i18n/sl-SI/app-debug.json+++ b/web/i18n/sl-SI/app-debug.json@@ -244,6 +244,9 @@"inputs.run": "TEČI","inputs.title": "Odpravljanje napak in predogled","inputs.userInputField": "Uporabniško polje za vnos",+ "legacyAgentBadge.action": "Ustvari Agent",+ "legacyAgentBadge.description": "Ta podedovana vrsta aplikacije Agent je zastarela. Za boljšo izkušnjo ustvarjanja agentov ustvarite Agent v Agent Console.",+ "legacyAgentBadge.label": "Podedovani Agent","manageModels": "Upravljanje modelov","modelConfig.modeType.chat": "Chat","modelConfig.modeType.completion": "Dokončati",diff --git a/web/i18n/sl-SI/common.json b/web/i18n/sl-SI/common.jsonindex a51dd2cd160..bba579d8c50 100644--- a/web/i18n/sl-SI/common.json+++ b/web/i18n/sl-SI/common.json@@ -288,7 +288,7 @@"menus.explore": "Raziskuj","menus.exploreMarketplace": "Raziščite Marketplace","menus.plugins": "Integracije",- "menus.roster": "Seznam agentov",+ "menus.roster": "Agent","menus.status": "beta","menus.tools": "Orodja","model.capabilities": "Multimodalne zmogljivosti",@@ -444,6 +444,7 @@"operation.download": "Prenesi","operation.downloadFailed": "Prenos ni uspel. Prosim, poskusite znova pozneje.","operation.downloadSuccess": "Prenos končan.",+ "operation.downloading": "Prenašanje...","operation.duplicate": "Podvoji","operation.edit": "Uredi","operation.exporting": "Izvažanje",diff --git a/web/i18n/th-TH/agent-v-2.json b/web/i18n/th-TH/agent-v-2.jsonindex 1042946c10a..5fa77e6ad06 100644--- a/web/i18n/th-TH/agent-v-2.json+++ b/web/i18n/th-TH/agent-v-2.json@@ -63,6 +63,11 @@"agentDetail.configure.advancedSettings.envEditor.valuePlaceholder": "Value","agentDetail.configure.advancedSettings.label": "การตั้งค่าขั้นสูง","agentDetail.configure.advancedSettings.toggle": "สลับการตั้งค่าขั้นสูง",+ "agentDetail.configure.answer.duration.minute": "{{count}} นาที",+ "agentDetail.configure.answer.duration.second": "{{count}} วินาที",+ "agentDetail.configure.answer.workFinished": "งานเสร็จสิ้น",+ "agentDetail.configure.answer.workedFor": "ทำงานเป็นเวลา {{duration}}",+ "agentDetail.configure.answer.workingFor": "กำลังทำงานเป็นเวลา {{duration}}","agentDetail.configure.build.empty.communityEditionTip": "Community Edition แม้จะมีการจัดการเวอร์ชันสำหรับการกำหนดค่าที่แยกออกมา แต่ไม่รองรับการจัดการเวอร์ชันของระบบไฟล์เอง โปรดระมัดระวังการดำเนินการในโหมด Build เนื่องจากการเปลี่ยนแปลงระบบไฟล์เกิดขึ้นแบบเรียลไทม์และอาจไม่สามารถย้อนกลับได้อย่างเรียบร้อยเสมอไป Community Edition ไม่ใช่ตัวเลือกที่เหมาะสมที่สุดสำหรับการให้บริการผู้ชมภายนอกจำนวนมาก","agentDetail.configure.build.empty.description": "อธิบายสิ่งที่คุณต้องการ แล้วแบบฟอร์มด้านซ้ายจะถูกกรอกไปพร้อมกับการสนทนา","agentDetail.configure.build.empty.title": "สร้างเอเจนต์ของคุณด้วยการแชท",@@ -79,6 +84,8 @@"agentDetail.configure.buildDraft.updated": "อัปเดตแล้ว","agentDetail.configure.chatFeatures.description": "กำหนดประสบการณ์การแชทของผู้ใช้ปลายทางบน Web app และหน้าจอแชท","agentDetail.configure.chatFeatures.title": "ฟีเจอร์แชท",+ "agentDetail.configure.clearSessionConfirm.description": "การดำเนินการนี้จะล้างเซสชันปัจจุบันและทิ้งการเปลี่ยนแปลงการกำหนดค่าของ Agent ที่ยังไม่ได้ใช้",+ "agentDetail.configure.clearSessionConfirm.title": "ล้างเซสชันและทิ้งการเปลี่ยนแปลงหรือไม่?","agentDetail.configure.communityEditionIsolationTip": "Community Edition ไม่มีการแยกระบบไฟล์อย่างเข้มงวดระหว่างผู้ใช้ปลายทางหรือระหว่างการรัน อย่าเปิดเผยเอเจนต์ CE ตัวเดียวกันให้กับผู้ใช้ปลายทางอิสระหลายรายเมื่อจำเป็นต้องมีการแยกข้อมูลหรือการปฏิบัติตามข้อกำหนดอย่างเข้มงวด","agentDetail.configure.files.add": "เพิ่มไฟล์","agentDetail.configure.files.buildNote.generated": "สร้างแล้ว",@@ -348,7 +355,7 @@"agentDetail.versionHistory.versionName": "เวอร์ชัน {{version}}","agentDetail.versionHistory.viewOnly": "ดูเท่านั้น","roster.createAgent": "สร้างตัวแทน",- "roster.createDialog.description": "สร้างตัวแทนที่นำกลับมาใช้ใหม่ได้ใน Roster ของเวิร์กสเปซนี้",+ "roster.createDialog.description": "สร้าง Agent ที่นำกลับมาใช้ใหม่ได้ในเวิร์กสเปซนี้","roster.createDialog.title": "สร้างตัวแทน","roster.createForm.changeIcon": "เปลี่ยนไอคอนตัวแทน","roster.createForm.descriptionLabel": "คำอธิบาย",@@ -360,16 +367,16 @@"roster.createForm.rolePlaceholder": "เช่น ผู้ช่วยวิจัย","roster.createSuccess": "สร้างตัวแทนแล้ว","roster.dateTimeFormat": "DD/MM/YYYY HH:mm:ss",- "roster.deleteDialog.description": "ตัวแทนนี้จะถูกลบออกจากรายการ Roster ที่ใช้งานอยู่",+ "roster.deleteDialog.description": "Agent นี้จะถูกลบออกจากรายการ Agent","roster.deleteDialog.title": "ลบ {{name}} หรือไม่","roster.deleteFailed": "ลบตัวแทนไม่สำเร็จ","roster.deleteSuccess": "ลบตัวแทนแล้ว",- "roster.duplicateDialog.description": "สร้างสำเนาของ {{name}} และปรับแต่งข้อมูลระบุตัวตนใน Roster",+ "roster.duplicateDialog.description": "สร้างสำเนาของ {{name}} และปรับแต่งข้อมูลระบุตัวตนของ Agent","roster.duplicateDialog.title": "ทำสำเนาตัวแทน","roster.duplicateForm.changeIcon": "เปลี่ยนไอคอนสำเนาสำหรับ {{name}}","roster.duplicateSuccess": "ทำสำเนาตัวแทนแล้ว","roster.editAgent": "แก้ไข {{name}}",- "roster.editDialog.description": "อัปเดตชื่อ คำอธิบาย และบทบาทใน Roster สำหรับตัวแทนนี้",+ "roster.editDialog.description": "อัปเดตชื่อ คำอธิบาย และบทบาทของ Agent นี้","roster.editDialog.title": "แก้ไขตัวแทน","roster.editInfo": "แก้ไขข้อมูล","roster.empty": "ยังไม่มีตัวแทน",@@ -379,8 +386,8 @@"roster.filters.drafts": "ฉบับร่าง","roster.filters.label": "ตัวกรองตัวแทน","roster.filters.published": "เผยแพร่แล้ว",- "roster.learnMore": "เรียนรู้เพิ่มเติมเกี่ยวกับ Agent Roster",- "roster.listLabel": "รายชื่อ Roster ตัวแทน",+ "roster.learnMore": "เรียนรู้เพิ่มเติมเกี่ยวกับ Agent",+ "roster.listLabel": "รายการ Agent","roster.loadMore": "โหลดเพิ่มเติม","roster.loadingError": "โหลดตัวแทนไม่สำเร็จ รีเฟรชและลองอีกครั้ง","roster.moreActions": "การกระทำเพิ่มเติมสำหรับ {{name}}",@@ -392,10 +399,10 @@"roster.references.label": "เวิร์กโฟลว์ที่ใช้ {{name}}","roster.references.trigger": "เวิร์กโฟลว์ที่ใช้ {{name}}","roster.saveToRoster": "บันทึกไปยัง Agent Console",- "roster.saveToRosterDialog.description": "บันทึกการตั้งค่าแบบอินไลน์นี้เป็นตัวแทน Roster ที่นำกลับมาใช้ใหม่ได้",+ "roster.saveToRosterDialog.description": "บันทึกการตั้งค่าแบบอินไลน์นี้เป็น Agent ที่นำกลับมาใช้ใหม่ได้","roster.saveToRosterDialog.title": "บันทึกไปยัง Agent Console",- "roster.saveToRosterForm.changeIcon": "เปลี่ยนไอคอนตัวแทน Roster",- "roster.saveToRosterSuccess": "บันทึกตัวแทนไปยัง Roster แล้ว",+ "roster.saveToRosterForm.changeIcon": "เปลี่ยนไอคอน Agent",+ "roster.saveToRosterSuccess": "บันทึก Agent แล้ว","roster.searchLabel": "ค้นหาตัวแทน","roster.searchPlaceholder": "ค้นหาตัวแทนตามชื่อ…","roster.sort.earliestCreated": "สร้างแรกสุด",@@ -403,9 +410,6 @@"roster.sort.lastModified": "แก้ไขล่าสุด","roster.sort.optionsLabel": "ตัวเลือกการเรียง","roster.sort.recentlyCreated": "สร้างล่าสุด",- "roster.tabs.agent": "ตัวแทน",- "roster.tabs.human": "ผู้ติดต่อ",- "roster.tabsLabel": "ประเภท Roster","roster.updateSuccess": "อัปเดตตัวแทนแล้ว","roster.usageStatus.draft": "ฉบับร่าง"}diff --git a/web/i18n/th-TH/app-debug.json b/web/i18n/th-TH/app-debug.jsonindex c7fc48a5e4d..95f37492d6b 100644--- a/web/i18n/th-TH/app-debug.json+++ b/web/i18n/th-TH/app-debug.json@@ -244,6 +244,9 @@"inputs.run": "วิ่ง","inputs.title": "ดีบัก & ดูตัวอย่าง","inputs.userInputField": "ฟิลด์ป้อนข้อมูลของผู้ใช้",+ "legacyAgentBadge.action": "สร้าง Agent",+ "legacyAgentBadge.description": "ประเภทแอป Agent เดิมนี้เลิกใช้งานแล้ว เพื่อประสบการณ์การสร้างเอเจนต์ที่ดีกว่า โปรดสร้าง Agent ใน Agent Console",+ "legacyAgentBadge.label": "Agent เดิม","manageModels": "จัดการโมเดล","modelConfig.modeType.chat": "สนทนา","modelConfig.modeType.completion": "สมบูรณ์",diff --git a/web/i18n/th-TH/common.json b/web/i18n/th-TH/common.jsonindex 12c99d7a0b7..ee755812f4c 100644--- a/web/i18n/th-TH/common.json+++ b/web/i18n/th-TH/common.json@@ -288,7 +288,7 @@"menus.explore": "สํารวจ","menus.exploreMarketplace": "สํารวจ Marketplace","menus.plugins": "การผสานรวม",- "menus.roster": "รายชื่อตัวแทน",+ "menus.roster": "Agent","menus.status": "Beta","menus.tools": "เครื่อง มือ","model.capabilities": "ความสามารถหลายรูปแบบ",@@ -444,6 +444,7 @@"operation.download": "ดาวน์โหลด","operation.downloadFailed": "ดาวน์โหลดล้มเหลว กรุณาลองอีกครั้งในภายหลัง.","operation.downloadSuccess": "ดาวน์โหลดเสร็จสิ้นแล้ว.",+ "operation.downloading": "กำลังดาวน์โหลด...","operation.duplicate": "สำเนา","operation.edit": "แก้ไข","operation.exporting": "กำลังส่งออก",diff --git a/web/i18n/tr-TR/agent-v-2.json b/web/i18n/tr-TR/agent-v-2.jsonindex ea90af5e5d9..d70fce5b44d 100644--- a/web/i18n/tr-TR/agent-v-2.json+++ b/web/i18n/tr-TR/agent-v-2.json@@ -63,6 +63,11 @@"agentDetail.configure.advancedSettings.envEditor.valuePlaceholder": "Value","agentDetail.configure.advancedSettings.label": "Gelişmiş Ayarlar","agentDetail.configure.advancedSettings.toggle": "Gelişmiş ayarları değiştir",+ "agentDetail.configure.answer.duration.minute": "{{count}} dk",+ "agentDetail.configure.answer.duration.second": "{{count}} sn",+ "agentDetail.configure.answer.workFinished": "İş tamamlandı",+ "agentDetail.configure.answer.workedFor": "{{duration}} çalıştı",+ "agentDetail.configure.answer.workingFor": "{{duration}} çalışıyor","agentDetail.configure.build.empty.communityEditionTip": "Community Edition, çıkarılan yapılandırmalar için sürümleme sunsa da dosya sisteminin kendisi için sürümleme desteklemez. Build modundaki işlemlerinizde dikkatli olun; dosya sisteminde yapılan değişiklikler gerçek zamanlı gerçekleşir ve her zaman temiz bir şekilde geri alınamayabilir. Community Edition, kitlesel dış hedef kitlelere hizmet vermek için ideal seçiminiz değildir.","agentDetail.configure.build.empty.description": "Ne istediğinizi açıklayın; soldaki form ilerledikçe doldurulur.","agentDetail.configure.build.empty.title": "Aracınızı sohbet ederek oluşturun",@@ -79,6 +84,8 @@"agentDetail.configure.buildDraft.updated": "Güncellendi","agentDetail.configure.chatFeatures.description": "Web app ve sohbet yüzeylerinizde son kullanıcı sohbet deneyimini şekillendirin.","agentDetail.configure.chatFeatures.title": "Sohbet Özellikleri",+ "agentDetail.configure.clearSessionConfirm.description": "Bu işlem geçerli oturumu temizler ve henüz uygulanmamış Agent yapılandırma değişikliklerini vazgeçer.",+ "agentDetail.configure.clearSessionConfirm.title": "Oturumu temizleyip değişikliklerden vazgeçilsin mi?","agentDetail.configure.communityEditionIsolationTip": "Community Edition, son kullanıcılar veya çalıştırmalar arasında katı dosya sistemi yalıtımı sağlamaz. Veri yalıtımı veya sıkı uyumluluk gerektiğinde aynı CE ajanını birden fazla bağımsız son kullanıcıya açmayın.","agentDetail.configure.files.add": "Dosya ekle","agentDetail.configure.files.buildNote.generated": "Oluşturuldu",@@ -348,7 +355,7 @@"agentDetail.versionHistory.versionName": "Sürüm {{version}}","agentDetail.versionHistory.viewOnly": "Yalnızca görüntüle","roster.createAgent": "Ajan oluştur",- "roster.createDialog.description": "Bu çalışma alanı Roster'ında yeniden kullanılabilir bir ajan oluşturun.",+ "roster.createDialog.description": "Bu workspace içinde yeniden kullanılabilir bir Agent oluşturun.","roster.createDialog.title": "Ajan oluştur","roster.createForm.changeIcon": "Ajan simgesini değiştir","roster.createForm.descriptionLabel": "Açıklama",@@ -360,16 +367,16 @@"roster.createForm.rolePlaceholder": "örn. Araştırma Asistanı","roster.createSuccess": "Ajan oluşturuldu.","roster.dateTimeFormat": "DD/MM/YYYY HH:mm:ss",- "roster.deleteDialog.description": "Bu ajan, aktif Roster listesinden kaldırılacak.",+ "roster.deleteDialog.description": "Bu Agent, Agent listesinden kaldırılacak.","roster.deleteDialog.title": "{{name}} silinsin mi?","roster.deleteFailed": "Ajan silinemedi.","roster.deleteSuccess": "Ajan silindi.",- "roster.duplicateDialog.description": "{{name}} ajanının bir kopyasını oluşturun ve Roster kimliğini özelleştirin.",+ "roster.duplicateDialog.description": "{{name}} kopyasını oluşturun ve Agent kimliğini özelleştirin.","roster.duplicateDialog.title": "Ajanı çoğalt","roster.duplicateForm.changeIcon": "{{name}} için kopya simgesini değiştir","roster.duplicateSuccess": "Ajan çoğaltıldı.","roster.editAgent": "{{name}} düzenle",- "roster.editDialog.description": "Bu ajan için Roster adı, açıklaması ve rolünü güncelleyin.",+ "roster.editDialog.description": "Bu Agent için adı, açıklamayı ve rolü güncelleyin.","roster.editDialog.title": "Ajanı düzenle","roster.editInfo": "Bilgileri Düzenle","roster.empty": "Henüz ajan yok",@@ -379,8 +386,8 @@"roster.filters.drafts": "Taslaklar","roster.filters.label": "Ajan filtreleri","roster.filters.published": "Yayınlandı",- "roster.learnMore": "Agent Roster hakkında daha fazla bilgi",- "roster.listLabel": "Ajan Roster listesi",+ "roster.learnMore": "Agent hakkında daha fazla bilgi",+ "roster.listLabel": "Agent listesi","roster.loadMore": "Daha fazla yükle","roster.loadingError": "Ajanlar yüklenemedi. Yenileyip tekrar deneyin.","roster.moreActions": "{{name}} için daha fazla eylem",@@ -392,10 +399,10 @@"roster.references.label": "{{name}} kullanan iş akışları","roster.references.trigger": "{{name}} kullanan iş akışları","roster.saveToRoster": "Agent Console'a kaydet",- "roster.saveToRosterDialog.description": "Bu satır içi kurulumu yeniden kullanılabilir bir Roster ajanı olarak kaydedin.",+ "roster.saveToRosterDialog.description": "Bu inline kurulumu yeniden kullanılabilir bir Agent olarak kaydedin.","roster.saveToRosterDialog.title": "Agent Console'a kaydet",- "roster.saveToRosterForm.changeIcon": "Roster ajanı simgesini değiştir",- "roster.saveToRosterSuccess": "Ajan Roster'a kaydedildi.",+ "roster.saveToRosterForm.changeIcon": "Agent simgesini değiştir",+ "roster.saveToRosterSuccess": "Agent kaydedildi.","roster.searchLabel": "Ajanları ara","roster.searchPlaceholder": "Ajanları ada göre ara…","roster.sort.earliestCreated": "İlk oluşturulanlar",@@ -403,9 +410,6 @@"roster.sort.lastModified": "Son değiştirilme","roster.sort.optionsLabel": "Sıralama seçenekleri","roster.sort.recentlyCreated": "Yeni oluşturulanlar",- "roster.tabs.agent": "Ajan",- "roster.tabs.human": "Kişiler",- "roster.tabsLabel": "Roster türü","roster.updateSuccess": "Ajan güncellendi.","roster.usageStatus.draft": "Taslak"}diff --git a/web/i18n/tr-TR/app-debug.json b/web/i18n/tr-TR/app-debug.jsonindex 196f7d83203..bc0bde0c1ce 100644--- a/web/i18n/tr-TR/app-debug.json+++ b/web/i18n/tr-TR/app-debug.json@@ -244,6 +244,9 @@"inputs.run": "ÇALIŞTIR","inputs.title": "Hata ayıklama ve Önizleme","inputs.userInputField": "Kullanıcı Giriş Alanı",+ "legacyAgentBadge.action": "Agent oluştur",+ "legacyAgentBadge.description": "Bu eski Agent uygulama türü kullanımdan kaldırıldı. Daha iyi bir agent oluşturma deneyimi için Agent Console içinde bir Agent oluşturun.",+ "legacyAgentBadge.label": "Eski Agent","manageModels": "Modelleri yönet","modelConfig.modeType.chat": "Sohbet","modelConfig.modeType.completion": "Tamamlama",diff --git a/web/i18n/tr-TR/common.json b/web/i18n/tr-TR/common.jsonindex f661f3fd0fd..a7756c3efab 100644--- a/web/i18n/tr-TR/common.json+++ b/web/i18n/tr-TR/common.json@@ -288,7 +288,7 @@"menus.explore": "Keşfet","menus.exploreMarketplace": "Pazar Yeri'ni Keşfedin","menus.plugins": "Entegrasyonlar",- "menus.roster": "Ajan listesi",+ "menus.roster": "Agent","menus.status": "beta","menus.tools": "Araçlar","model.capabilities": "MultiModal Yetenekler",@@ -444,6 +444,7 @@"operation.download": "İndir","operation.downloadFailed": "İndirme başarısız oldu. Lütfen daha sonra tekrar deneyin.","operation.downloadSuccess": "İndirme Tamamlandı.",+ "operation.downloading": "İndiriliyor...","operation.duplicate": "Çoğalt","operation.edit": "Düzenle","operation.exporting": "Dışa aktarılıyor",diff --git a/web/i18n/uk-UA/agent-v-2.json b/web/i18n/uk-UA/agent-v-2.jsonindex 6da2f4e3dde..5be35cbce15 100644--- a/web/i18n/uk-UA/agent-v-2.json+++ b/web/i18n/uk-UA/agent-v-2.json@@ -63,6 +63,11 @@"agentDetail.configure.advancedSettings.envEditor.valuePlaceholder": "Value","agentDetail.configure.advancedSettings.label": "Розширені налаштування","agentDetail.configure.advancedSettings.toggle": "Перемкнути розширені налаштування",+ "agentDetail.configure.answer.duration.minute": "{{count}} хв",+ "agentDetail.configure.answer.duration.second": "{{count}} с",+ "agentDetail.configure.answer.workFinished": "Роботу завершено",+ "agentDetail.configure.answer.workedFor": "Працював {{duration}}",+ "agentDetail.configure.answer.workingFor": "Працює {{duration}}","agentDetail.configure.build.empty.communityEditionTip": "Community Edition, хоча й пропонує версіонування витягнутих конфігурацій, не підтримує версіонування самої файлової системи. Будьте обережні з діями в режимі Build, адже зміни файлової системи відбуваються в реальному часі й не завжди можуть бути чисто скасовані. Community Edition не є ідеальним вибором для обслуговування масової зовнішньої аудиторії.","agentDetail.configure.build.empty.description": "Опишіть, що вам потрібно, і форма ліворуч заповнюватиметься під час розмови.","agentDetail.configure.build.empty.title": "Створіть агента через чат",@@ -79,6 +84,8 @@"agentDetail.configure.buildDraft.updated": "Оновлено","agentDetail.configure.chatFeatures.description": "Налаштуйте чат-досвід кінцевого користувача у вашому веб-застосунку та чат-поверхнях.","agentDetail.configure.chatFeatures.title": "Функції чату",+ "agentDetail.configure.clearSessionConfirm.description": "Ця дія очистить поточний сеанс і відхилить незастосовані зміни конфігурації Agent.",+ "agentDetail.configure.clearSessionConfirm.title": "Очистити сеанс і відхилити зміни?","agentDetail.configure.communityEditionIsolationTip": "Community Edition не забезпечує жорсткої ізоляції файлової системи між кінцевими користувачами або запусками. Не надавайте один і той самий CE-агент кільком незалежним кінцевим користувачам, якщо потрібна ізоляція даних або сувора відповідність вимогам.","agentDetail.configure.files.add": "Додати файл","agentDetail.configure.files.buildNote.generated": "Згенеровано",@@ -348,7 +355,7 @@"agentDetail.versionHistory.versionName": "Версія {{version}}","agentDetail.versionHistory.viewOnly": "Лише перегляд","roster.createAgent": "Створити агента",- "roster.createDialog.description": "Створіть перевикористовного агента в Roster цього робочого простору.",+ "roster.createDialog.description": "Створіть перевикористовний Agent у цьому workspace.","roster.createDialog.title": "Створити агента","roster.createForm.changeIcon": "Змінити іконку агента","roster.createForm.descriptionLabel": "Опис",@@ -360,16 +367,16 @@"roster.createForm.rolePlaceholder": "напр. Помічник з досліджень","roster.createSuccess": "Агента створено.","roster.dateTimeFormat": "DD.MM.YYYY HH:mm:ss",- "roster.deleteDialog.description": "Цього агента буде видалено з активного списку Roster.",+ "roster.deleteDialog.description": "Цей Agent буде видалений зі списку Agent.","roster.deleteDialog.title": "Видалити {{name}}?","roster.deleteFailed": "Не вдалося видалити агента.","roster.deleteSuccess": "Агента видалено.",- "roster.duplicateDialog.description": "Створіть копію {{name}} та налаштуйте його ідентичність у Roster.",+ "roster.duplicateDialog.description": "Створіть копію {{name}} та налаштуйте її ідентичність Agent.","roster.duplicateDialog.title": "Дублювати агента","roster.duplicateForm.changeIcon": "Змінити іконку копії для {{name}}","roster.duplicateSuccess": "Агента продубльовано.","roster.editAgent": "Редагувати {{name}}",- "roster.editDialog.description": "Оновіть ім'я в Roster, опис і роль для цього агента.",+ "roster.editDialog.description": "Оновіть ім’я, опис і роль цього Agent.","roster.editDialog.title": "Редагувати агента","roster.editInfo": "Редагувати інформацію","roster.empty": "Поки що немає агентів",@@ -379,8 +386,8 @@"roster.filters.drafts": "Чернетки","roster.filters.label": "Фільтри агентів","roster.filters.published": "Опубліковані",- "roster.learnMore": "Докладніше про Agent Roster",- "roster.listLabel": "Список Roster агентів",+ "roster.learnMore": "Докладніше про Agent",+ "roster.listLabel": "Список Agent","roster.loadMore": "Завантажити ще","roster.loadingError": "Не вдалося завантажити агентів. Оновіть і спробуйте ще раз.","roster.moreActions": "Більше дій для {{name}}",@@ -392,10 +399,10 @@"roster.references.label": "Робочі процеси, що використовують {{name}}","roster.references.trigger": "Робочі процеси, що використовують {{name}}","roster.saveToRoster": "Зберегти в Agent Console",- "roster.saveToRosterDialog.description": "Збережіть це вбудоване налаштування як перевикористовного агента Roster.",+ "roster.saveToRosterDialog.description": "Збережіть це inline-налаштування як перевикористовний Agent.","roster.saveToRosterDialog.title": "Зберегти в Agent Console",- "roster.saveToRosterForm.changeIcon": "Змінити значок агента Roster",- "roster.saveToRosterSuccess": "Агента збережено в Roster.",+ "roster.saveToRosterForm.changeIcon": "Змінити значок Agent",+ "roster.saveToRosterSuccess": "Agent збережено.","roster.searchLabel": "Пошук агентів","roster.searchPlaceholder": "Пошук агентів за ім'ям…","roster.sort.earliestCreated": "Спочатку створені",@@ -403,9 +410,6 @@"roster.sort.lastModified": "Остання зміна","roster.sort.optionsLabel": "Параметри сортування","roster.sort.recentlyCreated": "Нещодавно створені",- "roster.tabs.agent": "Агент",- "roster.tabs.human": "Контакти",- "roster.tabsLabel": "Тип Roster","roster.updateSuccess": "Агента оновлено.","roster.usageStatus.draft": "Чернетка"}diff --git a/web/i18n/uk-UA/app-debug.json b/web/i18n/uk-UA/app-debug.jsonindex 122319db528..53f3aaacfc3 100644--- a/web/i18n/uk-UA/app-debug.json+++ b/web/i18n/uk-UA/app-debug.json@@ -244,6 +244,9 @@"inputs.run": "ЗАПУСТИТИ","inputs.title": "Налагодження та попередній перегляд","inputs.userInputField": "Поле введення користувача",+ "legacyAgentBadge.action": "Створити Agent",+ "legacyAgentBadge.description": "Цей застарілий тип застосунку Agent більше не рекомендується. Для кращого досвіду створення агентів створіть Agent в Agent Console.",+ "legacyAgentBadge.label": "Застарілий Agent","manageModels": "Керування моделями","modelConfig.modeType.chat": "Чат","modelConfig.modeType.completion": "Завершення",diff --git a/web/i18n/uk-UA/common.json b/web/i18n/uk-UA/common.jsonindex 19db8af712e..0f57dd23b51 100644--- a/web/i18n/uk-UA/common.json+++ b/web/i18n/uk-UA/common.json@@ -288,7 +288,7 @@"menus.explore": "Досліджувати","menus.exploreMarketplace": "Дізнайтеся більше про Marketplace","menus.plugins": "Інтеграції",- "menus.roster": "Список агентів",+ "menus.roster": "Agent","menus.status": "бета","menus.tools": "Інструменти","model.capabilities": "Можливості MultiModal",@@ -444,6 +444,7 @@"operation.download": "Завантажити","operation.downloadFailed": "Не вдалося завантажити. Будь ласка, спробуйте ще раз пізніше.","operation.downloadSuccess": "Завантаження завершено.",+ "operation.downloading": "Завантаження...","operation.duplicate": "дублікат","operation.edit": "Редагувати","operation.exporting": "Експорт",diff --git a/web/i18n/vi-VN/agent-v-2.json b/web/i18n/vi-VN/agent-v-2.jsonindex f3a16a876ad..510e33f83ab 100644--- a/web/i18n/vi-VN/agent-v-2.json+++ b/web/i18n/vi-VN/agent-v-2.json@@ -63,6 +63,11 @@"agentDetail.configure.advancedSettings.envEditor.valuePlaceholder": "Value","agentDetail.configure.advancedSettings.label": "Cài đặt nâng cao","agentDetail.configure.advancedSettings.toggle": "Bật/tắt cài đặt nâng cao",+ "agentDetail.configure.answer.duration.minute": "{{count}} phút",+ "agentDetail.configure.answer.duration.second": "{{count}} giây",+ "agentDetail.configure.answer.workFinished": "Công việc đã hoàn tất",+ "agentDetail.configure.answer.workedFor": "Đã làm việc trong {{duration}}",+ "agentDetail.configure.answer.workingFor": "Đang làm việc trong {{duration}}","agentDetail.configure.build.empty.communityEditionTip": "Community Edition, mặc dù cung cấp phiên bản cho các cấu hình được trích xuất, không hỗ trợ phiên bản cho chính hệ thống tệp. Hãy cẩn thận với các thao tác trong chế độ Build, vì các thay đổi đối với hệ thống tệp diễn ra theo thời gian thực và không phải lúc nào cũng có thể hoàn tác gọn gàng. Community Edition không phải là lựa chọn lý tưởng để phục vụ lượng lớn khán giả bên ngoài.","agentDetail.configure.build.empty.description": "Mô tả điều bạn muốn và biểu mẫu bên trái sẽ được điền dần khi trò chuyện.","agentDetail.configure.build.empty.title": "Xây dựng tác nhân bằng trò chuyện",@@ -79,6 +84,8 @@"agentDetail.configure.buildDraft.updated": "Đã cập nhật","agentDetail.configure.chatFeatures.description": "Định hình trải nghiệm trò chuyện cho người dùng cuối trên Web app và các bề mặt trò chuyện.","agentDetail.configure.chatFeatures.title": "Tính năng trò chuyện",+ "agentDetail.configure.clearSessionConfirm.description": "Thao tác này sẽ xóa phiên hiện tại và hủy các thay đổi cấu hình Agent chưa được áp dụng.",+ "agentDetail.configure.clearSessionConfirm.title": "Xóa phiên và hủy thay đổi?","agentDetail.configure.communityEditionIsolationTip": "Community Edition không cung cấp cách ly hệ thống tệp cứng giữa người dùng cuối hoặc giữa các lần chạy. Không cung cấp cùng một tác nhân CE cho nhiều người dùng cuối độc lập khi cần cách ly dữ liệu hoặc tuân thủ nghiêm ngặt.","agentDetail.configure.files.add": "Thêm tệp","agentDetail.configure.files.buildNote.generated": "Đã tạo",@@ -348,7 +355,7 @@"agentDetail.versionHistory.versionName": "Phiên bản {{version}}","agentDetail.versionHistory.viewOnly": "Chỉ xem","roster.createAgent": "Tạo tác nhân",- "roster.createDialog.description": "Tạo một tác nhân có thể tái sử dụng trong Roster của không gian làm việc này.",+ "roster.createDialog.description": "Tạo một Agent có thể tái sử dụng trong workspace này.","roster.createDialog.title": "Tạo tác nhân","roster.createForm.changeIcon": "Đổi biểu tượng tác nhân","roster.createForm.descriptionLabel": "Mô tả",@@ -360,16 +367,16 @@"roster.createForm.rolePlaceholder": "ví dụ: Trợ lý nghiên cứu","roster.createSuccess": "Đã tạo tác nhân.","roster.dateTimeFormat": "DD/MM/YYYY HH:mm:ss",- "roster.deleteDialog.description": "Tác nhân này sẽ bị xóa khỏi danh sách Roster đang hoạt động.",+ "roster.deleteDialog.description": "Agent này sẽ bị xóa khỏi danh sách Agent.","roster.deleteDialog.title": "Xóa {{name}}?","roster.deleteFailed": "Xóa tác nhân thất bại.","roster.deleteSuccess": "Đã xóa tác nhân.",- "roster.duplicateDialog.description": "Tạo một bản sao của {{name}} và tùy chỉnh danh tính của nó trong Roster.",+ "roster.duplicateDialog.description": "Tạo một bản sao của {{name}} và tùy chỉnh danh tính Agent của nó.","roster.duplicateDialog.title": "Nhân bản tác nhân","roster.duplicateForm.changeIcon": "Đổi biểu tượng bản sao cho {{name}}","roster.duplicateSuccess": "Đã nhân bản tác nhân.","roster.editAgent": "Chỉnh sửa {{name}}",- "roster.editDialog.description": "Cập nhật tên, mô tả và vai trò Roster cho tác nhân này.",+ "roster.editDialog.description": "Cập nhật tên, mô tả và vai trò của Agent này.","roster.editDialog.title": "Chỉnh sửa tác nhân","roster.editInfo": "Chỉnh sửa thông tin","roster.empty": "Chưa có tác nhân nào",@@ -379,8 +386,8 @@"roster.filters.drafts": "Bản nháp","roster.filters.label": "Bộ lọc tác nhân","roster.filters.published": "Đã xuất bản",- "roster.learnMore": "Tìm hiểu thêm về Agent Roster",- "roster.listLabel": "Danh sách Roster tác nhân",+ "roster.learnMore": "Tìm hiểu thêm về Agent",+ "roster.listLabel": "Danh sách Agent","roster.loadMore": "Tải thêm","roster.loadingError": "Tải tác nhân thất bại. Làm mới và thử lại.","roster.moreActions": "Thêm hành động cho {{name}}",@@ -392,10 +399,10 @@"roster.references.label": "Quy trình làm việc đang dùng {{name}}","roster.references.trigger": "Quy trình làm việc đang dùng {{name}}","roster.saveToRoster": "Lưu vào Agent Console",- "roster.saveToRosterDialog.description": "Lưu thiết lập nội tuyến này thành một tác nhân Roster có thể tái sử dụng.",+ "roster.saveToRosterDialog.description": "Lưu thiết lập inline này thành một Agent có thể tái sử dụng.","roster.saveToRosterDialog.title": "Lưu vào Agent Console",- "roster.saveToRosterForm.changeIcon": "Thay đổi biểu tượng tác nhân Roster",- "roster.saveToRosterSuccess": "Đã lưu tác nhân vào Roster.",+ "roster.saveToRosterForm.changeIcon": "Thay đổi biểu tượng Agent",+ "roster.saveToRosterSuccess": "Agent đã được lưu.","roster.searchLabel": "Tìm kiếm tác nhân","roster.searchPlaceholder": "Tìm kiếm tác nhân theo tên…","roster.sort.earliestCreated": "Tạo sớm nhất",@@ -403,9 +410,6 @@"roster.sort.lastModified": "Sửa đổi gần nhất","roster.sort.optionsLabel": "Tùy chọn sắp xếp","roster.sort.recentlyCreated": "Mới tạo gần đây",- "roster.tabs.agent": "Tác nhân",- "roster.tabs.human": "Liên hệ",- "roster.tabsLabel": "Loại Roster","roster.updateSuccess": "Đã cập nhật tác nhân.","roster.usageStatus.draft": "Bản nháp"}diff --git a/web/i18n/vi-VN/app-debug.json b/web/i18n/vi-VN/app-debug.jsonindex 3168648153c..9b386f99d46 100644--- a/web/i18n/vi-VN/app-debug.json+++ b/web/i18n/vi-VN/app-debug.json@@ -244,6 +244,9 @@"inputs.run": "CHẠY","inputs.title": "Gỡ lỗi và xem trước","inputs.userInputField": "Trường nhập liệu người dùng",+ "legacyAgentBadge.action": "Tạo Agent",+ "legacyAgentBadge.description": "Loại ứng dụng Agent cũ này đã ngừng khuyến nghị. Để có trải nghiệm xây dựng agent tốt hơn, hãy tạo Agent trong Agent Console.",+ "legacyAgentBadge.label": "Agent cũ","manageModels": "Quản lý mô hình","modelConfig.modeType.chat": "Trò chuyện","modelConfig.modeType.completion": "Hoàn thành",diff --git a/web/i18n/vi-VN/common.json b/web/i18n/vi-VN/common.jsonindex f705c057dcc..925005fceba 100644--- a/web/i18n/vi-VN/common.json+++ b/web/i18n/vi-VN/common.json@@ -288,7 +288,7 @@"menus.explore": "Khám phá","menus.exploreMarketplace": "Khám phá Marketplace","menus.plugins": "Tích hợp",- "menus.roster": "Danh sách tác nhân",+ "menus.roster": "Agent","menus.status": "beta","menus.tools": "Công cụ","model.capabilities": "Khả năng đa phương thức",@@ -444,6 +444,7 @@"operation.download": "Tải xuống","operation.downloadFailed": "Tải xuống thất bại. Vui lòng thử lại sau.","operation.downloadSuccess": "Tải xuống đã hoàn thành.",+ "operation.downloading": "Đang tải xuống...","operation.duplicate": "Nhân bản","operation.edit": "Chỉnh sửa","operation.exporting": "Đang xuất",diff --git a/web/i18n/zh-Hans/agent-v-2.json b/web/i18n/zh-Hans/agent-v-2.jsonindex 613d125939a..aead5280420 100644--- a/web/i18n/zh-Hans/agent-v-2.json+++ b/web/i18n/zh-Hans/agent-v-2.json@@ -63,6 +63,11 @@"agentDetail.configure.advancedSettings.envEditor.valuePlaceholder": "Value","agentDetail.configure.advancedSettings.label": "高级设置","agentDetail.configure.advancedSettings.toggle": "展开或收起高级设置",+ "agentDetail.configure.answer.duration.minute": "{{count}}分",+ "agentDetail.configure.answer.duration.second": "{{count}}秒",+ "agentDetail.configure.answer.workFinished": "工作已完成",+ "agentDetail.configure.answer.workedFor": "工作了 {{duration}}",+ "agentDetail.configure.answer.workingFor": "工作中 {{duration}}","agentDetail.configure.build.empty.communityEditionTip": "Community Edition 虽然会对提取出的配置提供版本管理,但不支持文件系统本身的版本管理。请谨慎使用 Build 模式,因为对文件系统的更改会实时发生,并且不一定总能干净地回退。Community Edition 并不是面向大量外部受众提供服务的理想选择。","agentDetail.configure.build.empty.description": "描述你的需求,它会随着对话填写左侧表单。","agentDetail.configure.build.empty.title": "通过对话构建 Agent",@@ -79,6 +84,8 @@"agentDetail.configure.buildDraft.updated": "已更新","agentDetail.configure.chatFeatures.description": "配置 Web app 和聊天界面的终端用户聊天体验。","agentDetail.configure.chatFeatures.title": "Chat 功能",+ "agentDetail.configure.clearSessionConfirm.description": "这将清空当前会话,并丢弃尚未应用的 Agent 配置更改。",+ "agentDetail.configure.clearSessionConfirm.title": "清空会话并放弃改动?","agentDetail.configure.communityEditionIsolationTip": "Community Edition 不在最终用户之间或不同运行之间提供严格的文件系统隔离。如果需要数据隔离或严格合规,请勿将同一个 CE Agent 暴露给多个相互独立的最终用户。","agentDetail.configure.files.add": "添加文件","agentDetail.configure.files.buildNote.generated": "已生成",@@ -348,7 +355,7 @@"agentDetail.versionHistory.versionName": "版本 {{version}}","agentDetail.versionHistory.viewOnly": "只读","roster.createAgent": "创建 Agent",- "roster.createDialog.description": "在当前工作区 Roster 中创建一个可复用 Agent。",+ "roster.createDialog.description": "在当前工作区创建一个可复用 Agent。","roster.createDialog.title": "创建 Agent","roster.createForm.changeIcon": "更换 Agent 图标","roster.createForm.descriptionLabel": "描述",@@ -360,16 +367,16 @@"roster.createForm.rolePlaceholder": "例如:研究助理","roster.createSuccess": "Agent 已创建。","roster.dateTimeFormat": "YYYY-MM-DD HH:mm:ss",- "roster.deleteDialog.description": "此 Agent 将从当前活跃 Roster 列表中移除。",+ "roster.deleteDialog.description": "此 Agent 将从 Agent 列表中移除。","roster.deleteDialog.title": "删除 {{name}}?","roster.deleteFailed": "Agent 删除失败。","roster.deleteSuccess": "Agent 已删除。",- "roster.duplicateDialog.description": "创建 {{name}} 的副本,并自定义它在 Roster 中的身份信息。",+ "roster.duplicateDialog.description": "创建 {{name}} 的副本,并自定义它的 Agent 身份信息。","roster.duplicateDialog.title": "复制 Agent","roster.duplicateForm.changeIcon": "更换 {{name}} 副本的图标","roster.duplicateSuccess": "Agent 已复制。","roster.editAgent": "编辑 {{name}}",- "roster.editDialog.description": "更新此 Agent 在 Roster 中的名称、描述和角色。",+ "roster.editDialog.description": "更新此 Agent 的名称、描述和角色。","roster.editDialog.title": "编辑 Agent","roster.editInfo": "编辑信息","roster.empty": "暂无 Agent",@@ -379,8 +386,8 @@"roster.filters.drafts": "草稿","roster.filters.label": "Agent 筛选","roster.filters.published": "已发布",- "roster.learnMore": "了解 Agent 名册",- "roster.listLabel": "Agent 名册列表",+ "roster.learnMore": "了解 Agent",+ "roster.listLabel": "Agent 列表","roster.loadMore": "加载更多","roster.loadingError": "Agent 加载失败。请刷新后重试。","roster.moreActions": "{{name}} 的更多操作",@@ -392,10 +399,10 @@"roster.references.label": "使用 {{name}} 的工作流","roster.references.trigger": "使用 {{name}} 的工作流","roster.saveToRoster": "保存到 Agent Console",- "roster.saveToRosterDialog.description": "将此内联配置保存为可复用的 Roster Agent。",+ "roster.saveToRosterDialog.description": "将此内联配置保存为可复用 Agent。","roster.saveToRosterDialog.title": "保存到 Agent Console",- "roster.saveToRosterForm.changeIcon": "更换 Roster Agent 图标",- "roster.saveToRosterSuccess": "Agent 已保存到 Roster。",+ "roster.saveToRosterForm.changeIcon": "更换 Agent 图标",+ "roster.saveToRosterSuccess": "Agent 已保存。","roster.searchLabel": "搜索 Agent","roster.searchPlaceholder": "按名称搜索 Agent…","roster.sort.earliestCreated": "最早创建",@@ -403,9 +410,6 @@"roster.sort.lastModified": "最后修改","roster.sort.optionsLabel": "排序选项","roster.sort.recentlyCreated": "最近创建",- "roster.tabs.agent": "Agent",- "roster.tabs.human": "联系人",- "roster.tabsLabel": "Roster 类型","roster.updateSuccess": "Agent 已更新。","roster.usageStatus.draft": "草稿"}diff --git a/web/i18n/zh-Hans/app-debug.json b/web/i18n/zh-Hans/app-debug.jsonindex e9eec99bd98..7282f4c54d4 100644--- a/web/i18n/zh-Hans/app-debug.json+++ b/web/i18n/zh-Hans/app-debug.json@@ -244,6 +244,9 @@"inputs.run": "运行","inputs.title": "调试与预览","inputs.userInputField": "用户输入",+ "legacyAgentBadge.action": "创建 Agent",+ "legacyAgentBadge.description": "这类旧版 Agent App 已经废弃。为了获得更好的 Agent 构建体验,请在 Agent Console 中创建 Agent。",+ "legacyAgentBadge.label": "旧版 Agent","manageModels": "管理模型","modelConfig.modeType.chat": "对话型","modelConfig.modeType.completion": "补全型",diff --git a/web/i18n/zh-Hans/common.json b/web/i18n/zh-Hans/common.jsonindex 3f81738d058..7408f744093 100644--- a/web/i18n/zh-Hans/common.json+++ b/web/i18n/zh-Hans/common.json@@ -288,7 +288,7 @@"menus.explore": "探索","menus.exploreMarketplace": "探索 Marketplace","menus.plugins": "集成",- "menus.roster": "名册",+ "menus.roster": "Agent","menus.status": "beta","menus.tools": "工具","model.capabilities": "多模态能力",@@ -444,6 +444,7 @@"operation.download": "下载","operation.downloadFailed": "下载失败,请稍后重试。","operation.downloadSuccess": "下载完毕",+ "operation.downloading": "下载中","operation.duplicate": "复制","operation.edit": "编辑","operation.exporting": "导出中",diff --git a/web/i18n/zh-Hant/agent-v-2.json b/web/i18n/zh-Hant/agent-v-2.jsonindex 2e3e2007894..8b0dcda54d6 100644--- a/web/i18n/zh-Hant/agent-v-2.json+++ b/web/i18n/zh-Hant/agent-v-2.json@@ -63,6 +63,11 @@"agentDetail.configure.advancedSettings.envEditor.valuePlaceholder": "Value","agentDetail.configure.advancedSettings.label": "進階設定","agentDetail.configure.advancedSettings.toggle": "展開或收合進階設定",+ "agentDetail.configure.answer.duration.minute": "{{count}}分",+ "agentDetail.configure.answer.duration.second": "{{count}}秒",+ "agentDetail.configure.answer.workFinished": "工作已完成",+ "agentDetail.configure.answer.workedFor": "工作了 {{duration}}",+ "agentDetail.configure.answer.workingFor": "工作中 {{duration}}","agentDetail.configure.build.empty.communityEditionTip": "Community Edition 雖然會對提取出的設定提供版本管理,但不支援檔案系統本身的版本管理。請謹慎使用 Build 模式,因為對檔案系統的變更會即時發生,且不一定總能乾淨地回復。Community Edition 並不是面向大量外部受眾提供服務的理想選擇。","agentDetail.configure.build.empty.description": "描述你的需求,它會隨著對話填寫左側表單。","agentDetail.configure.build.empty.title": "透過對話建置 Agent",@@ -79,6 +84,8 @@"agentDetail.configure.buildDraft.updated": "已更新","agentDetail.configure.chatFeatures.description": "配置 Web app 和聊天介面的終端使用者聊天體驗。","agentDetail.configure.chatFeatures.title": "Chat 功能",+ "agentDetail.configure.clearSessionConfirm.description": "這會清空目前會話,並丟棄尚未套用的 Agent 設定變更。",+ "agentDetail.configure.clearSessionConfirm.title": "清空會話並放棄變更?","agentDetail.configure.communityEditionIsolationTip": "Community Edition 不會在最終使用者之間或不同執行之間提供嚴格的檔案系統隔離。如果需要資料隔離或嚴格合規,請勿將同一個 CE Agent 暴露給多個相互獨立的最終使用者。","agentDetail.configure.files.add": "新增檔案","agentDetail.configure.files.buildNote.generated": "已生成",@@ -348,7 +355,7 @@"agentDetail.versionHistory.versionName": "版本 {{version}}","agentDetail.versionHistory.viewOnly": "唯讀","roster.createAgent": "建立 Agent",- "roster.createDialog.description": "在目前工作區 Roster 中建立一個可複用 Agent。",+ "roster.createDialog.description": "在目前工作區建立一個可複用 Agent。","roster.createDialog.title": "建立 Agent","roster.createForm.changeIcon": "更換 Agent 圖示","roster.createForm.descriptionLabel": "描述",@@ -360,16 +367,16 @@"roster.createForm.rolePlaceholder": "例如:研究助理","roster.createSuccess": "Agent 已建立。","roster.dateTimeFormat": "YYYY-MM-DD HH:mm:ss",- "roster.deleteDialog.description": "此 Agent 將從目前活躍 Roster 清單中移除。",+ "roster.deleteDialog.description": "此 Agent 將從 Agent 清單中移除。","roster.deleteDialog.title": "刪除 {{name}}?","roster.deleteFailed": "Agent 刪除失敗。","roster.deleteSuccess": "Agent 已刪除。",- "roster.duplicateDialog.description": "建立 {{name}} 的副本,並自訂它在 Roster 中的身份資訊。",+ "roster.duplicateDialog.description": "建立 {{name}} 的副本,並自訂它的 Agent 身份資訊。","roster.duplicateDialog.title": "複製 Agent","roster.duplicateForm.changeIcon": "更換 {{name}} 副本的圖示","roster.duplicateSuccess": "Agent 已複製。","roster.editAgent": "編輯 {{name}}",- "roster.editDialog.description": "更新此 Agent 在 Roster 中的名稱、描述和角色。",+ "roster.editDialog.description": "更新此 Agent 的名稱、描述和角色。","roster.editDialog.title": "編輯 Agent","roster.editInfo": "編輯資訊","roster.empty": "暫無 Agent",@@ -379,8 +386,8 @@"roster.filters.drafts": "草稿","roster.filters.label": "Agent 篩選","roster.filters.published": "已發佈",- "roster.learnMore": "了解 Agent 名冊",- "roster.listLabel": "Agent 名冊清單",+ "roster.learnMore": "了解 Agent",+ "roster.listLabel": "Agent 清單","roster.loadMore": "載入更多","roster.loadingError": "Agent 載入失敗。請重新整理後再試。","roster.moreActions": "{{name}} 的更多操作",@@ -392,10 +399,10 @@"roster.references.label": "使用 {{name}} 的工作流程","roster.references.trigger": "使用 {{name}} 的工作流程","roster.saveToRoster": "儲存到 Agent Console",- "roster.saveToRosterDialog.description": "將此內聯設定儲存為可重用的 Roster Agent。",+ "roster.saveToRosterDialog.description": "將此內聯設定儲存為可重用 Agent。","roster.saveToRosterDialog.title": "儲存到 Agent Console",- "roster.saveToRosterForm.changeIcon": "更換 Roster Agent 圖示",- "roster.saveToRosterSuccess": "Agent 已儲存到 Roster。",+ "roster.saveToRosterForm.changeIcon": "更換 Agent 圖示",+ "roster.saveToRosterSuccess": "Agent 已儲存。","roster.searchLabel": "搜尋 Agent","roster.searchPlaceholder": "依名稱搜尋 Agent…","roster.sort.earliestCreated": "最早建立",@@ -403,9 +410,6 @@"roster.sort.lastModified": "最後修改","roster.sort.optionsLabel": "排序選項","roster.sort.recentlyCreated": "最近建立",- "roster.tabs.agent": "Agent",- "roster.tabs.human": "聯絡人",- "roster.tabsLabel": "Roster 類型","roster.updateSuccess": "Agent 已更新。","roster.usageStatus.draft": "草稿"}diff --git a/web/i18n/zh-Hant/app-debug.json b/web/i18n/zh-Hant/app-debug.jsonindex 35bb03dc967..bcf64325786 100644--- a/web/i18n/zh-Hant/app-debug.json+++ b/web/i18n/zh-Hant/app-debug.json@@ -244,6 +244,9 @@"inputs.run": "執行","inputs.title": "除錯與預覽","inputs.userInputField": "使用者輸入",+ "legacyAgentBadge.action": "建立 Agent",+ "legacyAgentBadge.description": "這類舊版 Agent App 已經廢棄。為了獲得更好的 Agent 建置體驗,請在 Agent Console 中建立 Agent。",+ "legacyAgentBadge.label": "舊版 Agent","manageModels": "管理模型","modelConfig.modeType.chat": "對話型","modelConfig.modeType.completion": "補全型",diff --git a/web/i18n/zh-Hant/common.json b/web/i18n/zh-Hant/common.jsonindex bd5bee143b5..147a0faf55b 100644--- a/web/i18n/zh-Hant/common.json+++ b/web/i18n/zh-Hant/common.json@@ -288,7 +288,7 @@"menus.explore": "探索","menus.exploreMarketplace": "探索 Marketplace","menus.plugins": "集成",- "menus.roster": "名冊",+ "menus.roster": "Agent","menus.status": "beta","menus.tools": "工具","model.capabilities": "多模式功能",@@ -444,6 +444,7 @@"operation.download": "下載","operation.downloadFailed": "下載失敗。請稍後再試。","operation.downloadSuccess": "下載完成。",+ "operation.downloading": "下載中","operation.duplicate": "複製","operation.edit": "編輯","operation.exporting": "匯出中",diff --git a/web/service/base.spec.ts b/web/service/base.spec.tsindex 0b117adbe0e..f448bab096b 100644--- a/web/service/base.spec.ts+++ b/web/service/base.spec.ts@@ -130,6 +130,7 @@ describe('handleStream', () => {await new Promise(resolve => setTimeout(resolve, 50))expect(onData).toHaveBeenCalledWith('Hello world', true, {+ event: 'message',conversationId: 'conv-123',taskId: 'task-456',messageId: 'msg-789',diff --git a/web/service/base.ts b/web/service/base.tsindex 69a4c2b6980..6df3057fd7b 100644--- a/web/service/base.ts+++ b/web/service/base.ts@@ -41,6 +41,7 @@ import { getWebAppPassport } from './webapp-auth'const TIME_OUT = 100000export type IOnDataMoreInfo = {+ event?: stringconversationId?: stringtaskId?: stringmessageId: string@@ -303,6 +304,7 @@ export const handleStream = (if (bufferObj.event === 'message' || bufferObj.event === 'agent_message') {// can not use format here. Because message is splitted.onData(unicodeToChar(bufferObj.answer), isFirstMessage, {+ event: bufferObj.event,conversationId: bufferObj.conversation_id,taskId: bufferObj.task_id,messageId: bufferObj.id,