revert: add tools for output in agent mode

feat: hide output tools and improve JSON formatting for structured output
feat: hide output tools and improve JSON formatting for structured output
fix: handle prompt template correctly to extract selectors for step run
fix: emit StreamChunkEvent correctly for sandbox agent
chore: better debug message
fix: incorrect output tool runtime selection
fix: type issues
fix: align parameter list
fix: align parameter list
fix: hide internal builtin providers from tool list
vibe: implement file structured output
vibe: implement file structured output
fix: refix parameter for tool
fix: crash
fix: crash
refactor: remove union types
fix: type check
Merge branch 'feat/structured-output-with-sandbox' into feat/support-agent-sandbox
fix: provide json as text
fix: provide json as text
fix: get AgentResult correctly
fix: provides correct prompts, tools and terminal predicates
fix: provides correct prompts, tools and terminal predicates
fix: circular import
feat: support structured output in sandbox and tool mode
This commit is contained in:
Stream
2026-02-04 21:13:07 +08:00
parent 25065a4f2f
commit e0082dbf18
41 changed files with 1014 additions and 1358 deletions

View File

@ -1,5 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none">
<rect x="3" y="3" width="18" height="18" rx="4" stroke="#2F2F2F" stroke-width="1.5"/>
<path d="M7 12h10" stroke="#2F2F2F" stroke-width="1.5" stroke-linecap="round"/>
<path d="M12 7v10" stroke="#2F2F2F" stroke-width="1.5" stroke-linecap="round"/>
</svg>

Before

Width:  |  Height:  |  Size: 332 B

View File

@ -1,8 +0,0 @@
from typing import Any
from core.tools.builtin_tool.provider import BuiltinToolProviderController
class AgentOutputProvider(BuiltinToolProviderController):
def _validate_credentials(self, user_id: str, credentials: dict[str, Any]):
pass

View File

@ -1,10 +0,0 @@
identity:
author: Dify
name: agent_output
label:
en_US: Agent Output
description:
en_US: Internal tools for agent output control.
icon: icon.svg
tags:
- utilities

View File

@ -1,17 +0,0 @@
from collections.abc import Generator
from typing import Any
from core.tools.builtin_tool.tool import BuiltinTool
from core.tools.entities.tool_entities import ToolInvokeMessage
class FinalOutputAnswerTool(BuiltinTool):
def _invoke(
self,
user_id: str,
tool_parameters: dict[str, Any],
conversation_id: str | None = None,
app_id: str | None = None,
message_id: str | None = None,
) -> Generator[ToolInvokeMessage, None, None]:
yield self.create_text_message("Final answer recorded.")

View File

@ -1,18 +0,0 @@
identity:
name: final_output_answer
author: Dify
label:
en_US: Final Output Answer
description:
human:
en_US: Internal tool to deliver the final answer.
llm: Use this tool when you are ready to provide the final answer.
parameters:
- name: text
type: string
required: true
label:
en_US: Text
human_description:
en_US: Final answer text.
form: llm

View File

@ -1,17 +0,0 @@
from collections.abc import Generator
from typing import Any
from core.tools.builtin_tool.tool import BuiltinTool
from core.tools.entities.tool_entities import ToolInvokeMessage
class FinalStructuredOutputTool(BuiltinTool):
def _invoke(
self,
user_id: str,
tool_parameters: dict[str, Any],
conversation_id: str | None = None,
app_id: str | None = None,
message_id: str | None = None,
) -> Generator[ToolInvokeMessage, None, None]:
yield self.create_text_message("Structured output recorded.")

View File

@ -1,18 +0,0 @@
identity:
name: final_structured_output
author: Dify
label:
en_US: Final Structured Output
description:
human:
en_US: Internal tool to deliver structured output.
llm: Use this tool to provide structured output data.
parameters:
- name: data
type: object
required: true
label:
en_US: Data
human_description:
en_US: Structured output data.
form: llm

View File

@ -1,21 +0,0 @@
from collections.abc import Generator
from typing import Any
from core.tools.builtin_tool.tool import BuiltinTool
from core.tools.entities.tool_entities import ToolInvokeMessage
class IllegalOutputTool(BuiltinTool):
def _invoke(
self,
user_id: str,
tool_parameters: dict[str, Any],
conversation_id: str | None = None,
app_id: str | None = None,
message_id: str | None = None,
) -> Generator[ToolInvokeMessage, None, None]:
message = (
"Protocol violation: do not output plain text. "
"Call an output tool and finish with the configured terminal tool."
)
yield self.create_text_message(message)

View File

@ -1,18 +0,0 @@
identity:
name: illegal_output
author: Dify
label:
en_US: Illegal Output
description:
human:
en_US: Internal tool for output protocol violations.
llm: Use this tool to correct output protocol violations.
parameters:
- name: raw
type: string
required: true
label:
en_US: Raw Output
human_description:
en_US: Raw model output that violated the protocol.
form: llm

View File

@ -1,17 +0,0 @@
from collections.abc import Generator
from typing import Any
from core.tools.builtin_tool.tool import BuiltinTool
from core.tools.entities.tool_entities import ToolInvokeMessage
class OutputTextTool(BuiltinTool):
def _invoke(
self,
user_id: str,
tool_parameters: dict[str, Any],
conversation_id: str | None = None,
app_id: str | None = None,
message_id: str | None = None,
) -> Generator[ToolInvokeMessage, None, None]:
yield self.create_text_message("Output recorded.")

View File

@ -1,18 +0,0 @@
identity:
name: output_text
author: Dify
label:
en_US: Output Text
description:
human:
en_US: Internal tool to store intermediate text output.
llm: Use this tool to emit non-final text output.
parameters:
- name: text
type: string
required: true
label:
en_US: Text
human_description:
en_US: Output text.
form: llm