fix: assistant's automation is refused when it leaves out the action type (#35384)

When the assistant created or changed an automation from a chat, the tool told it an action's type was optional and defaulted to a prompt, but an action sent without it was refused with a raw validation error and nothing was saved. An action without a type is now read from what it holds, as a prompt or as code, so the automation is created or updated as the assistant was told it would be.

Fixes #35379
This commit is contained in:
Classic298 authored and GitHub committed 2026-11-30 22:48:05 +04:00
1 parent 3d6a092c76
commit 48d8e2ff1c
1 file changed
+3 -2
+3 -2
View File
@@ -10,7 +10,7 @@ import asyncio
import logging
import ntpath
import time
from typing import Annotated, Any, Literal, Optional, Union
from typing import Any, Literal, Optional, Union
from urllib.parse import unquote
from fastapi import HTTPException, Request
@@ -4451,7 +4451,8 @@ class AutomationCodeForm(BaseModel):
new_chat: bool = Field(False, description='True sends each prompt to a new chat; false sends them to this chat.')
AutomationActionForm = Annotated[Union[AutomationPromptForm, AutomationCodeForm], Field(discriminator='type')]
# Untagged, so an action without a type is read by its fields, as the schema's type defaults promise.
AutomationActionForm = Union[AutomationPromptForm, AutomationCodeForm]
async def _automation_action(action, metadata: dict, user_id: str, saved_tools: list[dict]) -> dict: