diff --git a/api/core/app/apps/advanced_chat/generate_task_pipeline.py b/api/core/app/apps/advanced_chat/generate_task_pipeline.py index b695dd0bef..095b2d4650 100644 --- a/api/core/app/apps/advanced_chat/generate_task_pipeline.py +++ b/api/core/app/apps/advanced_chat/generate_task_pipeline.py @@ -138,7 +138,14 @@ class StreamEventBuffer: self._current_reasoning += text self._last_event_type = "thought" - def record_tool_call(self, tool_call_id: str, tool_name: str, tool_arguments: str) -> None: + def record_tool_call( + self, + tool_call_id: str, + tool_name: str, + tool_arguments: str, + tool_icon: str | dict | None = None, + tool_icon_dark: str | dict | None = None, + ) -> None: """Record a tool call event.""" if not tool_call_id: return @@ -161,6 +168,8 @@ class StreamEventBuffer: "arguments": tool_arguments or "", "result": "", "elapsed_time": None, + "icon": tool_icon, + "icon_dark": tool_icon_dark, } self.tool_calls.append(tool_call) idx = len(self.tool_calls) - 1 @@ -542,6 +551,8 @@ class AdvancedChatAppGenerateTaskPipeline(GraphRuntimeStateSupport): tool_call_id=tool_call_id, tool_name=tool_name, tool_arguments=tool_arguments, + tool_icon=tool_icon, + tool_icon_dark=tool_icon_dark, ) case ChunkType.TOOL_RESULT: self._stream_buffer.record_tool_result( diff --git a/api/core/app/entities/llm_generation_entities.py b/api/core/app/entities/llm_generation_entities.py index 33e97e3299..a65fe5de1f 100644 --- a/api/core/app/entities/llm_generation_entities.py +++ b/api/core/app/entities/llm_generation_entities.py @@ -43,6 +43,8 @@ class ToolCallDetail(BaseModel): arguments: str = Field(default="", description="JSON string of tool arguments") result: str = Field(default="", description="Result from the tool execution") elapsed_time: float | None = Field(default=None, description="Elapsed time in seconds") + icon: str | dict | None = Field(default=None, description="Icon of the tool") + icon_dark: str | dict | None = Field(default=None, description="Dark theme icon of the tool") class LLMGenerationDetailData(BaseModel):