From 297e20ce8dd53e70f8153668e4165048391ac132 Mon Sep 17 00:00:00 2001 From: Roberto Musso Date: Wed, 18 Mar 2026 00:04:29 +0100 Subject: [PATCH] Fix 422 on agent trigger: accept plural data type names AgentTriggerRequest.what_to_extract now accepts list[str] instead of strict Literal values. _to_data_types normalises all FE variants (tasks/task, notes/note, timelines/timeline/timelineEvents, projects/project) to the canonical plural form the runner expects, with deduplication. Co-Authored-By: Claude Sonnet 4.6 --- app/api/routes/agents.py | 17 ++++++++++++----- app/schemas.py | 7 ++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/api/routes/agents.py b/app/api/routes/agents.py index 65844de..fbb8cc0 100644 --- a/app/api/routes/agents.py +++ b/app/api/routes/agents.py @@ -49,12 +49,19 @@ def _dt_ms_opt(dt: datetime | None) -> int | None: def _to_data_types(values: list[str]) -> list[str]: normalize = { - "task": "tasks", - "note": "notes", - "timeline": "timelines", - "project": "projects", + "task": "tasks", "tasks": "tasks", + "note": "notes", "notes": "notes", + "timeline": "timelines", "timelines": "timelines", "timelineEvents": "timelines", + "project": "projects", "projects": "projects", } - return [normalize[v] for v in values if v in normalize] + seen: set[str] = set() + result: list[str] = [] + for v in values: + mapped = normalize.get(v) + if mapped and mapped not in seen: + seen.add(mapped) + result.append(mapped) + return result def _to_run_log_response(log: AgentRunLog) -> AgentRunLogResponse: diff --git a/app/schemas.py b/app/schemas.py index e4399ec..3e8a034 100644 --- a/app/schemas.py +++ b/app/schemas.py @@ -295,11 +295,8 @@ class AgentCreationCheckResponse(BaseModel): class AgentTriggerRequest(BaseModel): directory: str = Field(min_length=1) device_id: str = Field(default="") - what_to_extract: list[Literal["task", "note", "timeline", "project"]] = Field(min_length=1) - actions_by_type: dict[ - Literal["task", "note", "timeline", "project"], - list[Literal["add", "update"]], - ] | None = None + what_to_extract: list[str] = Field(min_length=1) + actions_by_type: dict[str, list[str]] | None = None batch_interval: str = Field(min_length=1) custom_agent_prompt: str = Field(min_length=1) active_agents: int = Field(ge=0, default=0)