Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(workflows): papercut - scope MCP workflows-update to non-graph fields (#73166)

Harley Alexander095421ab0daa
diff --git a/products/workflows/backend/api/hog_flow.py b/products/workflows/backend/api/hog_flow.py
index 44ab362b2333..c863784bab86 100644
--- a/products/workflows/backend/api/hog_flow.py
+++ b/products/workflows/backend/api/hog_flow.py
@@ -1416,6 +1416,13 @@ class HogFlowGraphOperationSerializer(serializers.Serializer):
class HogFlowGraphUpdateSerializer(serializers.Serializer):
+ base_updated_at = serializers.DateTimeField(
+ required=False,
+ help_text=(
+ "Optimistic concurrency: the updated_at (or draft_updated_at) last loaded. If the stored "
+ "graph is newer, the patch is rejected with 409 instead of clobbering a concurrent edit."
+ ),
+ )
operations = serializers.ListField(
child=HogFlowGraphOperationSerializer(),
allow_empty=False,
@@ -1883,6 +1890,16 @@ class HogFlowViewSet(
"workflows-archive — they can't be combined with other field updates."
)
+ # Whole-graph replacement through a plain update wipes any step the payload omits - a
+ # partial actions list has destroyed live graphs. MCP edits the graph exclusively through
+ # the id-addressed patch endpoint; the web builder keeps full-save semantics.
+ if keys & {"actions", "edges"}:
+ raise exceptions.ValidationError(
+ "actions/edges can't be replaced via workflows-update - a partial list silently "
+ "drops every step it omits. Edit the graph with workflows-patch-graph instead; it "
+ "changes steps by id and leaves the rest of the graph untouched."
+ )
+
# Content edits on an active workflow stage a draft when the revisions cycle is on for the
# team; otherwise active workflows stay read-only via MCP. Status-only PATCHes (lifecycle
# tools) pass through either way, and metadata-only edits apply live once the flag is on.
@@ -2077,6 +2094,20 @@ class HogFlowViewSet(
raise exceptions.ValidationError(MCP_ACTIVE_EDIT_REJECTION)
route_to_draft = True
+ # Optimistic concurrency, mirroring perform_update: the graph endpoint is the only MCP
+ # path that writes graph content, so it carries the base_updated_at staleness contract.
+ # Draft edits race against other draft edits, so the baseline is the draft's timestamp
+ # once one exists.
+ base_updated_at_raw = request.data.get("base_updated_at")
+ base_updated_at = parse_datetime(base_updated_at_raw) if base_updated_at_raw else None
+ if base_updated_at is not None and timezone.is_naive(base_updated_at):
+ base_updated_at = timezone.make_aware(base_updated_at)
+ guard_timestamp = locked.updated_at
+ if route_to_draft and locked.draft_updated_at:
+ guard_timestamp = locked.draft_updated_at
+ if base_updated_at and guard_timestamp and guard_timestamp > base_updated_at:
+ raise StaleWorkflowUpdateError()
+
# Draft edits compose on the staged draft, not on live — a second patch must see the first.
if route_to_draft and locked.draft:
base_actions = list(locked.draft.get("actions") or [])
diff --git a/products/workflows/backend/api/test/test_hog_flow.py b/products/workflows/backend/api/test/test_hog_flow.py
index 22bd99b8619d..36e97c9d3f6f 100644
--- a/products/workflows/backend/api/test/test_hog_flow.py
+++ b/products/workflows/backend/api/test/test_hog_flow.py
@@ -126,6 +126,41 @@ class TestHogFlowAPI(APIBaseTest):
assert "actions" in web_response.json()["results"][0]
assert secret in web_response.content.decode()
+ def test_mcp_update_rejects_graph_replacement(self):
+ # A partial actions list through a plain update silently drops every step it omits -
+ # an agent doing this wiped a live graph in production. MCP graph edits must go
+ # through the id-addressed patch endpoint; the web builder keeps full-save semantics.
+ flow_id = self._create_simple_flow()
+
+ # A structurally valid partial list (trigger only) passes serializer validation and would
+ # silently drop the webhook step - exactly the production wipe.
+ trigger_only = [
+ {
+ "id": "trigger_node",
+ "name": "trigger_1",
+ "type": "trigger",
+ "config": {
+ "type": "event",
+ "filters": {"events": [{"id": "$pageview", "name": "$pageview", "type": "events", "order": 0}]},
+ },
+ }
+ ]
+ response = self.client.patch(
+ f"/api/projects/{self.team.id}/hog_flows/{flow_id}",
+ {"actions": trigger_only},
+ HTTP_X_POSTHOG_CLIENT="mcp",
+ )
+ assert response.status_code == 400, response.json()
+ assert "workflows-patch-graph" in response.json()["detail"]
+
+ # Metadata stays editable over MCP, and the web builder keeps sending full graphs.
+ mcp_rename = self.client.patch(
+ f"/api/projects/{self.team.id}/hog_flows/{flow_id}", {"name": "Renamed"}, HTTP_X_POSTHOG_CLIENT="mcp"
+ )
+ assert mcp_rename.status_code == 200, mcp_rename.json()
+ web_actions = self.client.patch(f"/api/projects/{self.team.id}/hog_flows/{flow_id}", {"actions": trigger_only})
+ assert web_actions.status_code == 200, web_actions.json()
+
def test_invalid_action_input_error_carries_the_field_message(self):
# A programmatic caller sending a broken function input must get back the validator's
# actual message (what is wrong with which field), not a bare code: agents retry blind
diff --git a/products/workflows/backend/api/test/test_hog_flow_draft_publish.py b/products/workflows/backend/api/test/test_hog_flow_draft_publish.py
index 3f35e9e5808c..b7efbef5d34e 100644
--- a/products/workflows/backend/api/test/test_hog_flow_draft_publish.py
+++ b/products/workflows/backend/api/test/test_hog_flow_draft_publish.py
@@ -53,9 +53,19 @@ class TestHogFlowDraftPublish(APIBaseTest):
return flow_id
def _patch_actions_via_mcp(self, flow_id: str, url: str = "https://changed.example.com"):
+ # Graph content edits over MCP go through the surgical graph endpoint (a plain update
+ # rejects actions/edges outright), so drafts are staged the way real agents stage them.
return self.client.patch(
- f"/api/projects/{self.team.id}/hog_flows/{flow_id}",
- {"actions": [_trigger_action(), _webhook_action(url=url)]},
+ f"/api/projects/{self.team.id}/hog_flows/{flow_id}/graph",
+ {
+ "operations": [
+ {
+ "op": "update_action",
+ "id": "action_1",
+ "patch": {"config": {"inputs": {"url": {"value": url}}}},
+ }
+ ]
+ },
HTTP_X_POSTHOG_CLIENT="mcp",
)
@@ -143,9 +153,15 @@ class TestHogFlowDraftPublish(APIBaseTest):
stale = "2020-01-01T00:00:00Z"
response = self.client.patch(
- f"/api/projects/{self.team.id}/hog_flows/{flow_id}",
+ f"/api/projects/{self.team.id}/hog_flows/{flow_id}/graph",
{
- "actions": [_trigger_action(), _webhook_action(url="https://other.example.com")],
+ "operations": [
+ {
+ "op": "update_action",
+ "id": "action_1",
+ "patch": {"config": {"inputs": {"url": {"value": "https://other.example.com"}}}},
+ }
+ ],
"base_updated_at": stale,
},
HTTP_X_POSTHOG_CLIENT="mcp",
@@ -291,8 +307,8 @@ class TestHogFlowDraftPublish(APIBaseTest):
)
flow_id = self._create_active_three_step_flow()
stage = self.client.patch(
- f"/api/projects/{self.team.id}/hog_flows/{flow_id}",
- self._DELETE_ACTION_1_PAYLOAD,
+ f"/api/projects/{self.team.id}/hog_flows/{flow_id}/graph",
+ {"operations": [{"op": "remove_action", "id": "action_1"}]},
HTTP_X_POSTHOG_CLIENT="mcp",
)
assert stage.status_code == 200, stage.json()
@@ -496,8 +512,8 @@ class TestHogFlowDraftPublish(APIBaseTest):
def test_publish_deleting_a_step_persists_its_redirect(self, _flag):
flow_id = self._create_active_three_step_flow()
response = self.client.patch(
- f"/api/projects/{self.team.id}/hog_flows/{flow_id}",
- self._DELETE_ACTION_1_PAYLOAD,
+ f"/api/projects/{self.team.id}/hog_flows/{flow_id}/graph",
+ {"operations": [{"op": "remove_action", "id": "action_1"}]},
HTTP_X_POSTHOG_CLIENT="mcp",
)
assert response.status_code == 200, response.json()
diff --git a/products/workflows/backend/api/test/test_hog_flow_revisions.py b/products/workflows/backend/api/test/test_hog_flow_revisions.py
index 61cdf7d28fb3..b906b712fa9d 100644
--- a/products/workflows/backend/api/test/test_hog_flow_revisions.py
+++ b/products/workflows/backend/api/test/test_hog_flow_revisions.py
@@ -76,9 +76,19 @@ class TestHogFlowRevisions(APIBaseTest):
)
def _stage_draft(self, flow_id: str, url: str = "https://changed.example.com"):
+ # Graph content edits over MCP go through the surgical graph endpoint (a plain update
+ # rejects actions/edges outright), so drafts are staged the way real agents stage them.
response = self.client.patch(
- f"/api/projects/{self.team.id}/hog_flows/{flow_id}",
- {"actions": [_trigger_action(), _webhook_action(url=url)]},
+ f"/api/projects/{self.team.id}/hog_flows/{flow_id}/graph",
+ {
+ "operations": [
+ {
+ "op": "update_action",
+ "id": "action_1",
+ "patch": {"config": {"inputs": {"url": {"value": url}}}},
+ }
+ ]
+ },
HTTP_X_POSTHOG_CLIENT="mcp",
)
assert response.status_code == 200, response.json()
@@ -158,16 +168,32 @@ class TestHogFlowRevisions(APIBaseTest):
@parameterized.expand(
[
- ("draft_staging", {"actions": [_trigger_action(), _webhook_action(url="https://d.example.com")]}, "mcp"),
- ("metadata_only", {"name": "Renamed"}, None),
- ("status_only", {"status": "draft"}, None),
+ # MCP graph edits go through the graph endpoint (a plain update rejects actions/edges)
+ (
+ "draft_staging",
+ "/graph",
+ {
+ "operations": [
+ {
+ "op": "update_action",
+ "id": "action_1",
+ "patch": {"config": {"inputs": {"url": {"value": "https://d.example.com"}}}},
+ }
+ ]
+ },
+ "mcp",
+ ),
+ ("metadata_only", "", {"name": "Renamed"}, None),
+ ("status_only", "", {"status": "draft"}, None),
]
)
- def test_non_content_writes_do_not_append_revisions(self, _name, payload, client_header):
+ def test_non_content_writes_do_not_append_revisions(self, _name, path_suffix, payload, client_header):
flow_id = self._create_active_flow()
with patch(FLAG_PATH, return_value=True):
extra = {"HTTP_X_POSTHOG_CLIENT": client_header} if client_header else {}
- response = self.client.patch(f"/api/projects/{self.team.id}/hog_flows/{flow_id}", payload, **extra)
+ response = self.client.patch(
+ f"/api/projects/{self.team.id}/hog_flows/{flow_id}{path_suffix}", payload, **extra
+ )
assert response.status_code == 200, response.json()
assert self._list_revisions(flow_id) == []
assert response.json()["version"] == 1
@@ -275,11 +301,8 @@ class TestHogFlowRevisions(APIBaseTest):
def _stage_draft_delete_action_1(self, flow_id: str) -> None:
response = self.client.patch(
- f"/api/projects/{self.team.id}/hog_flows/{flow_id}",
- {
- "actions": [_trigger_action(), _webhook_action("action_2")],
- "edges": [{"from": "trigger_node", "to": "action_2", "type": "continue"}],
- },
+ f"/api/projects/{self.team.id}/hog_flows/{flow_id}/graph",
+ {"operations": [{"op": "remove_action", "id": "action_1"}]},
HTTP_X_POSTHOG_CLIENT="mcp",
)
assert response.status_code == 200, response.json()
diff --git a/products/workflows/backend/api/test/test_hog_flow_timing_reschedule.py b/products/workflows/backend/api/test/test_hog_flow_timing_reschedule.py
index b0720da27512..e325d842f081 100644
--- a/products/workflows/backend/api/test/test_hog_flow_timing_reschedule.py
+++ b/products/workflows/backend/api/test/test_hog_flow_timing_reschedule.py
@@ -67,6 +67,19 @@ class TestHogFlowTimingRescheduleTrigger(APIBaseTest):
**extra,
)
+ def _patch_delay_via_mcp(self, flow_id: str, delay_duration: str = "1d"):
+ # Graph content edits over MCP go through the surgical graph endpoint (a plain update
+ # rejects actions/edges outright).
+ return self.client.patch(
+ f"/api/projects/{self.team.id}/hog_flows/{flow_id}/graph",
+ {
+ "operations": [
+ {"op": "update_action", "id": "delay_1", "patch": {"config": {"delay_duration": delay_duration}}}
+ ]
+ },
+ HTTP_X_POSTHOG_CLIENT="mcp",
+ )
+
@patch(TASK_PATH)
@patch(TIMING_FLAG_PATH, return_value=True)
def test_shortened_delay_on_live_save_enqueues_sweep_post_commit(self, _flag, mock_task):
@@ -117,7 +130,7 @@ class TestHogFlowTimingRescheduleTrigger(APIBaseTest):
flow_id = self._create_flow()
with self.captureOnCommitCallbacks(execute=True):
- response = self._patch_actions(flow_id, delay_duration="1d", HTTP_X_POSTHOG_CLIENT="mcp")
+ response = self._patch_delay_via_mcp(flow_id)
assert response.status_code == 200, response.json()
assert HogFlow.objects.get(pk=flow_id).draft is not None
@@ -128,7 +141,7 @@ class TestHogFlowTimingRescheduleTrigger(APIBaseTest):
@patch(REVISIONS_FLAG_PATH, return_value=True)
def test_publish_of_timing_shortening_draft_enqueues_sweep(self, _revisions, _timing, mock_task):
flow_id = self._create_flow()
- response = self._patch_actions(flow_id, delay_duration="1d", HTTP_X_POSTHOG_CLIENT="mcp")
+ response = self._patch_delay_via_mcp(flow_id)
assert response.status_code == 200, response.json()
assert HogFlow.objects.get(pk=flow_id).draft_updated_at is not None
mock_task.delay.assert_not_called()
diff --git a/products/workflows/frontend/generated/api.schemas.ts b/products/workflows/frontend/generated/api.schemas.ts
index 3d1a459c533d..06eb65143923 100644
--- a/products/workflows/frontend/generated/api.schemas.ts
+++ b/products/workflows/frontend/generated/api.schemas.ts
@@ -737,6 +737,8 @@ export interface HogFlowGraphOperationApi {
}
export interface PatchedHogFlowGraphUpdateApi {
+ /** Optimistic concurrency: the updated_at (or draft_updated_at) last loaded. If the stored graph is newer, the patch is rejected with 409 instead of clobbering a concurrent edit. */
+ base_updated_at?: string
/** Ordered graph edits applied atomically to a draft workflow: the stored graph is read, the ops are applied in order, the result is fully validated, and it's saved only if valid — otherwise the workflow is unchanged. Reference nodes/edges by id so you never resend the whole graph. The full updated workflow is returned. */
operations?: HogFlowGraphOperationApi[]
}
diff --git a/products/workflows/frontend/generated/api.zod.ts b/products/workflows/frontend/generated/api.zod.ts
index ec27ae072a86..a23941c931a8 100644
--- a/products/workflows/frontend/generated/api.zod.ts
+++ b/products/workflows/frontend/generated/api.zod.ts
@@ -1403,6 +1403,12 @@ export const HogFlowsBatchJobsCreateBody = /* @__PURE__ */ zod.object({
})
export const HogFlowsGraphPartialUpdateBody = /* @__PURE__ */ zod.object({
+ base_updated_at: zod.iso
+ .datetime({ offset: true })
+ .optional()
+ .describe(
+ 'Optimistic concurrency: the updated_at (or draft_updated_at) last loaded. If the stored graph is newer, the patch is rejected with 409 instead of clobbering a concurrent edit.'
+ ),
operations: zod
.array(
zod.object({
diff --git a/products/workflows/mcp/tools.yaml b/products/workflows/mcp/tools.yaml
index a9a00fad0ba6..f95a225694f8 100644
--- a/products/workflows/mcp/tools.yaml
+++ b/products/workflows/mcp/tools.yaml
@@ -405,15 +405,17 @@ tools:
enrich_url: '{id}/workflow'
title: Update workflow
description: >
- Fallback editor. Prefer workflows-patch-graph for graph changes: it sends only the delta, is structurally
- validated, and returns the full updated graph. Reach for workflows-update for top-level metadata a patch
- can't express (name, description, exit_condition), or as an escape hatch to replace the whole workflow when
- you can't get workflows-patch-graph to land a change. On an active workflow, content fields stage a draft
- (published with workflows-publish) while name/description apply immediately; a rejection saying active
- workflows can't be edited means draft editing isn't enabled for this project yet — then a live change means
- recreating the workflow as a new draft. Status changes go through workflows-enable / workflows-archive.
+ Updates workflow fields a graph patch can't express: name, description, exit_condition, conversion,
+ trigger_masking, variables. Graph content (actions/edges) is rejected here - a partial list would silently
+ drop every step it omits - so all graph edits go through workflows-patch-graph. On an active workflow,
+ content fields stage a draft (published with workflows-publish) while name/description apply immediately; a
+ rejection saying active workflows can't be edited means draft editing isn't enabled for this project yet -
+ then a live change means recreating the workflow as a new draft. Status changes go through workflows-enable
+ / workflows-archive.
exclude_params:
- status
+ - actions
+ - edges
ui_app: workflow
workflows-update-schedule:
operation: hog_flows_schedules_partial_update
diff --git a/products/workflows/skills/building-workflows/SKILL.md b/products/workflows/skills/building-workflows/SKILL.md
index 6864650a9c36..f54f4a945e2f 100644
--- a/products/workflows/skills/building-workflows/SKILL.md
+++ b/products/workflows/skills/building-workflows/SKILL.md
@@ -28,7 +28,7 @@ Full tool catalog, grouped by job: [references/lifecycle-and-debugging.md](refer
**Patch, don't replace.** Edit a draft with `workflows-patch-graph`: a small, ordered list of id-addressed operations (`update_action`, `add_action`, `remove_action`, `add_edge`, `remove_edge`, `replace_action_edges`). `update_action` deep-merges its patch, so changing one email subject is a few lines, not the whole graph. The ops apply atomically server-side (read, apply in order, validate, save only if valid), and the response echoes the **full updated graph**, so you never re-fetch before the next edit. This keeps each round-trip tiny instead of re-transmitting every action and edge.
-`workflows-update` is the fallback, for two cases: top-level metadata a graph patch can't express (for example renaming the workflow), or as an escape hatch when you genuinely can't get `workflows-patch-graph` to land a change (send the whole corrected workflow rather than keep fighting the op list). For everything else, patch.
+`workflows-update` covers only what a graph patch can't express: top-level fields like name, description, exit_condition, conversion, trigger_masking, and variables. It rejects `actions`/`edges` outright - a partial list would silently drop every step it omits - so every graph change goes through `workflows-patch-graph`.
After **any** patch, re-test the path you changed (step 3). A patch that validates structurally can still route the wrong way.
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index b9b785fba9f3..92b7ee01c5f9 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -10722,7 +10722,7 @@
}
},
"workflows-update": {
- "description": "Fallback editor. Prefer workflows-patch-graph for graph changes: it sends only the delta, is structurally validated, and returns the full updated graph. Reach for workflows-update for top-level metadata a patch can't express (name, description, exit_condition), or as an escape hatch to replace the whole workflow when you can't get workflows-patch-graph to land a change. On an active workflow, content fields stage a draft (published with workflows-publish) while name/description apply immediately; a rejection saying active workflows can't be edited means draft editing isn't enabled for this project yet — then a live change means recreating the workflow as a new draft. Status changes go through workflows-enable / workflows-archive.",
+ "description": "Updates workflow fields a graph patch can't express: name, description, exit_condition, conversion, trigger_masking, variables. Graph content (actions/edges) is rejected here - a partial list would silently drop every step it omits - so all graph edits go through workflows-patch-graph. On an active workflow, content fields stage a draft (published with workflows-publish) while name/description apply immediately; a rejection saying active workflows can't be edited means draft editing isn't enabled for this project yet - then a live change means recreating the workflow as a new draft. Status changes go through workflows-enable / workflows-archive.",
"category": "Workflows",
"feature": "workflows",
"summary": "Update workflow",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index b1e19e4d1a55..a60cd1648c49 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -11385,7 +11385,7 @@
}
},
"workflows-update": {
- "description": "Fallback editor. Prefer workflows-patch-graph for graph changes: it sends only the delta, is structurally validated, and returns the full updated graph. Reach for workflows-update for top-level metadata a patch can't express (name, description, exit_condition), or as an escape hatch to replace the whole workflow when you can't get workflows-patch-graph to land a change. On an active workflow, content fields stage a draft (published with workflows-publish) while name/description apply immediately; a rejection saying active workflows can't be edited means draft editing isn't enabled for this project yet — then a live change means recreating the workflow as a new draft. Status changes go through workflows-enable / workflows-archive.",
+ "description": "Updates workflow fields a graph patch can't express: name, description, exit_condition, conversion, trigger_masking, variables. Graph content (actions/edges) is rejected here - a partial list would silently drop every step it omits - so all graph edits go through workflows-patch-graph. On an active workflow, content fields stage a draft (published with workflows-publish) while name/description apply immediately; a rejection saying active workflows can't be edited means draft editing isn't enabled for this project yet - then a live change means recreating the workflow as a new draft. Status changes go through workflows-enable / workflows-archive.",
"category": "Workflows",
"feature": "workflows",
"summary": "Update workflow",
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index ee35b7afeb1b..739389076c67 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -48649,6 +48649,8 @@ export namespace Schemas {
}
export interface PatchedHogFlowGraphUpdate {
+ /** Optimistic concurrency: the updated_at (or draft_updated_at) last loaded. If the stored graph is newer, the patch is rejected with 409 instead of clobbering a concurrent edit. */
+ base_updated_at?: string;
/** Ordered graph edits applied atomically to a draft workflow: the stored graph is read, the ops are applied in order, the result is fully validated, and it's saved only if valid — otherwise the workflow is unchanged. Reference nodes/edges by id so you never resend the whole graph. The full updated workflow is returned. */
operations?: HogFlowGraphOperation[];
}
diff --git a/services/mcp/src/generated/workflows/api.ts b/services/mcp/src/generated/workflows/api.ts
index 1f09745137f6..d4e84b163fd2 100644
--- a/services/mcp/src/generated/workflows/api.ts
+++ b/services/mcp/src/generated/workflows/api.ts
@@ -393,16 +393,6 @@ export const hogFlowsPartialUpdateBodyTriggerMaskingOneTtlMin = 60
export const hogFlowsPartialUpdateBodyTriggerMaskingOneTtlMax = 94608000
export const hogFlowsPartialUpdateBodyConversionOneEventsItemFiltersOneSourceDefault = `events`
-export const hogFlowsPartialUpdateBodyActionsItemIdMax = 200
-
-export const hogFlowsPartialUpdateBodyActionsItemNameMax = 400
-
-export const hogFlowsPartialUpdateBodyActionsItemDescriptionDefault = ``
-export const hogFlowsPartialUpdateBodyActionsItemFiltersOneSourceDefault = `events`
-export const hogFlowsPartialUpdateBodyActionsItemTypeMax = 100
-
-export const hogFlowsPartialUpdateBodyActionsItemConfigTwoConditionFiltersOneSourceDefault = `events`
-export const hogFlowsPartialUpdateBodyActionsItemConfigTwoEventsItemFiltersOneSourceDefault = `events`
export const HogFlowsPartialUpdateBody = /* @__PURE__ */ zod
.object({
@@ -507,202 +497,6 @@ export const HogFlowsPartialUpdateBody = /* @__PURE__ */ zod
.describe(
"exit_only_at_end: only at exit node (default). exit_on_conversion: also on conversion (needs 'conversion'; silent no-op otherwise). exit_on_trigger_not_matched: also when trigger filter stops matching. exit_on_trigger_not_matched_or_conversion: both (needs 'conversion').\n\n\* `exit_on_conversion` - Conversion\n\* `exit_on_trigger_not_matched` - Trigger Not Matched\n\* `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion\n\* `exit_only_at_end` - Only At End"
),
- edges: zod
- .array(
- zod.object({
- to: zod.string().describe('Target action id.'),
- type: zod
- .enum(['continue', 'branch'])
- .describe('\* `continue` - continue\n\* `branch` - branch')
- .describe(
- "continue: fall-through (sequential or the no-match path of conditional_branch). branch: requires 'index' matching config.conditions[index].\n\n\* `continue` - continue\n\* `branch` - branch"
- ),
- index: zod
- .number()
- .optional()
- .describe(
- "Required for type='branch'. conditional_branch: index into config.conditions[index]. wait_until_condition: use index:0 — it advances via the index:0 branch edge when it resolves (a condition match or an events entry firing)."
- ),
- from: zod.string().describe('Source action id.'),
- })
- )
- .optional()
- .describe(
- "Graph edges: [{from, to, type: 'continue'|'branch', index?}]. 'continue' = fall-through (sequential, or no-match path of conditional_branch). 'branch' requires 'index': matches config.conditions[index] on conditional_branch \/ wait_until_condition. Every non-exit action needs a reachable next action ('No next action found' otherwise)."
- ),
- actions: zod
- .array(
- zod.object({
- id: zod
- .string()
- .max(hogFlowsPartialUpdateBodyActionsItemIdMax)
- .describe('Unique node ID within the workflow.'),
- name: zod.string().max(hogFlowsPartialUpdateBodyActionsItemNameMax).describe('Display name.'),
- description: zod
- .string()
- .default(hogFlowsPartialUpdateBodyActionsItemDescriptionDefault)
- .describe('Optional description.'),
- on_error: zod
- .union([
- zod.enum(['continue', 'abort']).describe('\* `continue` - continue\n\* `abort` - abort'),
- zod.null(),
- ])
- .optional()
- .describe(
- 'On failure: continue (skip the action and proceed) or abort (stop the run).\n\n\* `continue` - continue\n\* `abort` - abort'
- ),
- created_at: zod.number().optional().describe('Created at (epoch ms). Frontend-managed.'),
- updated_at: zod.number().optional().describe('Updated at (epoch ms). Frontend-managed.'),
- filters: zod
- .union([
- zod.object({
- source: zod
- .enum(['events', 'person-updates', 'data-warehouse-table'])
- .describe(
- '\* `events` - events\n\* `person-updates` - person-updates\n\* `data-warehouse-table` - data-warehouse-table'
- )
- .default(hogFlowsPartialUpdateBodyActionsItemFiltersOneSourceDefault),
- actions: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
- events: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
- data_warehouse: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
- properties: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
- bytecode: zod.unknown().optional(),
- transpiled: zod.unknown().optional(),
- filter_test_accounts: zod.boolean().optional(),
- bytecode_error: zod.string().optional(),
- }),
- zod.null(),
- ])
- .optional()
- .describe('Property filters gating this action.'),
- type: zod
- .string()
- .max(hogFlowsPartialUpdateBodyActionsItemTypeMax)
- .describe(
- 'trigger | function | function_email | function_sms | delay | conditional_branch | wait_until_condition | wait_until_time_window | random_cohort_branch | exit.'
- ),
- config: zod
- .union([
- zod
- .record(zod.string(), zod.unknown())
- .describe(
- 'Config for every action type except wait_until_condition — see the field description for per-type shapes.'
- ),
- zod
- .object({
- condition: zod
- .object({
- filters: zod
- .union([
- zod.object({
- source: zod
- .enum(['events', 'person-updates', 'data-warehouse-table'])
- .describe(
- '\* `events` - events\n\* `person-updates` - person-updates\n\* `data-warehouse-table` - data-warehouse-table'
- )
- .default(
- hogFlowsPartialUpdateBodyActionsItemConfigTwoConditionFiltersOneSourceDefault
- ),
- actions: zod
- .array(zod.record(zod.string(), zod.unknown()))
- .optional(),
- events: zod
- .array(zod.record(zod.string(), zod.unknown()))
- .optional(),
- data_warehouse: zod
- .array(zod.record(zod.string(), zod.unknown()))
- .optional(),
- properties: zod
- .array(zod.record(zod.string(), zod.unknown()))
- .optional(),
- bytecode: zod.unknown().optional(),
- transpiled: zod.unknown().optional(),
- filter_test_accounts: zod.boolean().optional(),
- bytecode_error: zod.string().optional(),
- }),
- zod.null(),
- ])
- .optional()
- .describe(
- 'Property conditions, e.g. {properties: [{key, value, operator, type}]}.'
- ),
- name: zod.string().optional().describe('Optional display name.'),
- })
- .optional()
- .describe(
- "Property-based wait condition; continues when the person matches. A condition with no property filters is ignored — the wait then relies on 'events' and the max_wait_duration timeout."
- ),
- events: zod
- .array(
- zod.object({
- filters: zod
- .union([
- zod.object({
- source: zod
- .enum([
- 'events',
- 'person-updates',
- 'data-warehouse-table',
- ])
- .describe(
- '\* `events` - events\n\* `person-updates` - person-updates\n\* `data-warehouse-table` - data-warehouse-table'
- )
- .default(
- hogFlowsPartialUpdateBodyActionsItemConfigTwoEventsItemFiltersOneSourceDefault
- ),
- actions: zod
- .array(zod.record(zod.string(), zod.unknown()))
- .optional(),
- events: zod
- .array(zod.record(zod.string(), zod.unknown()))
- .optional(),
- data_warehouse: zod
- .array(zod.record(zod.string(), zod.unknown()))
- .optional(),
- properties: zod
- .array(zod.record(zod.string(), zod.unknown()))
- .optional(),
- bytecode: zod.unknown().optional(),
- transpiled: zod.unknown().optional(),
- filter_test_accounts: zod.boolean().optional(),
- bytecode_error: zod.string().optional(),
- }),
- zod.null(),
- ])
- .optional()
- .describe(
- 'Event\/action filters; the workflow wakes when a matching event fires. Must target at least one event or action (entries targeting neither are dropped).'
- ),
- name: zod.string().optional().describe('Optional display name.'),
- })
- )
- .optional()
- .describe(
- "Events to wait for: continues when ANY entry fires (OR'd with 'condition'). Each entry: {filters: {events: [{id, name, type: 'events'}], actions?: [...]}, name?}."
- ),
- max_wait_duration: zod
- .string()
- .describe(
- "'<number><unit>' with unit m|h|d, e.g. '30m' (same rules as delay)."
- ),
- })
- .describe(
- "Config for type='wait_until_condition'. Provide 'condition' and\/or 'events' — an events-only wait (no condition) is valid."
- ),
- ])
- .describe(
- "Type-specific config keyed by action type. trigger: {type: event|webhook|manual|batch|schedule|tracking_pixel, filters?}. filters shape: {events: [{id, name, type:'events', properties:[<cond>]}], properties:[<cond>], actions:[...], filter_test_accounts:<bool>}. <cond>: {key, value, operator, type: event|person|group}. function\*: {template_id, inputs: {<key>: {value: <str>}}}. Wrap values in {value:...} to enable hog templating ({person.x}, {event.x}); flat strings won't interpolate. Dictionary input values are template strings too — write booleans\/numbers as single-expression templates ('{true}', '{42}'), which evaluate to the typed value. delay: {delay_duration: '<number><unit>'} where unit is m|h|d. Fractions OK ('0.5m'=30s; seconds unsupported). Per-unit max m<=60, h<=24, d<=30; values above are SILENTLY CLAMPED. Max 30d. conditional_branch: {conditions: [{filters}, ...]}. Index N matches the 'branch' edge with index:N. wait_until_condition: {condition: {filters}, events?: [{filters: {events: [{id, name, type: 'events'}], actions?: [...]}, name?}], max_wait_duration: <duration>} (same rules as delay). Continues when condition.filters match OR any events entry fires; each events entry must target at least one event or action. On resolution (a condition match or any events entry firing) it advances via the 'branch' edge with index:0; the max_wait_duration timeout falls through the 'continue' edge. exit: {reason}."
- ),
- output_variable: zod
- .unknown()
- .optional()
- .describe(
- 'Output variable for downstream actions: {key, result_path?, spread?, label?} or a list of those.'
- ),
- })
- )
- .optional()
- .describe("Ordered action nodes. Exactly one type='trigger' required. Typically one type='exit' too."),
variables: zod
.array(
zod
@@ -742,6 +536,12 @@ export const HogFlowsGraphPartialUpdateParams = /* @__PURE__ */ zod.object({
})
export const HogFlowsGraphPartialUpdateBody = /* @__PURE__ */ zod.object({
+ base_updated_at: zod.iso
+ .datetime({ offset: true })
+ .optional()
+ .describe(
+ 'Optimistic concurrency: the updated_at (or draft_updated_at) last loaded. If the stored graph is newer, the patch is rejected with 409 instead of clobbering a concurrent edit.'
+ ),
operations: zod
.array(
zod.object({
diff --git a/services/mcp/src/tools/generated/workflows.ts b/services/mcp/src/tools/generated/workflows.ts
index c3a031fba4c4..fe8ef041728e 100644
--- a/services/mcp/src/tools/generated/workflows.ts
+++ b/services/mcp/src/tools/generated/workflows.ts
@@ -434,12 +434,6 @@ const workflowsUpdate = (): ToolBase<typeof WorkflowsUpdateSchema, WithPostHogUr
if (params.exit_condition !== undefined) {
body['exit_condition'] = params.exit_condition
}
- if (params.edges !== undefined) {
- body['edges'] = params.edges
- }
- if (params.actions !== undefined) {
- body['actions'] = params.actions
- }
if (params.variables !== undefined) {
body['variables'] = params.variables
}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-update.json
index 45270262b279..204da23fb654 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-update.json
@@ -1,316 +1,6 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
- "actions": {
- "description": "Ordered action nodes. Exactly one type='trigger' required. Typically one type='exit' too.",
- "items": {
- "properties": {
- "config": {
- "anyOf": [
- {
- "additionalProperties": {},
- "description": "Config for every action type except wait_until_condition — see the field description for per-type shapes.",
- "propertyNames": {
- "type": "string"
- },
- "type": "object"
- },
- {
- "description": "Config for type='wait_until_condition'. Provide 'condition' and/or 'events' — an events-only wait (no condition) is valid.",
- "properties": {
- "condition": {
- "description": "Property-based wait condition; continues when the person matches. A condition with no property filters is ignored — the wait then relies on 'events' and the max_wait_duration timeout.",
- "properties": {
- "filters": {
- "anyOf": [
- {
- "properties": {
- "actions": {
- "items": {
- "additionalProperties": {},
- "propertyNames": {
- "type": "string"
- },
- "type": "object"
- },
- "type": "array"
- },
- "bytecode": {},
- "bytecode_error": {
- "type": "string"
- },
- "data_warehouse": {
- "items": {
- "additionalProperties": {},
- "propertyNames": {
- "type": "string"
- },
- "type": "object"
- },
- "type": "array"
- },
- "events": {
- "items": {
- "additionalProperties": {},
- "propertyNames": {
- "type": "string"
- },
- "type": "object"
- },
- "type": "array"
- },
- "filter_test_accounts": {
- "type": "boolean"
- },
- "properties": {
- "items": {
- "additionalProperties": {},
- "propertyNames": {
- "type": "string"
- },
- "type": "object"
- },
- "type": "array"
- },
- "source": {
- "default": "events",
- "description": "* `events` - events\n* `person-updates` - person-updates\n* `data-warehouse-table` - data-warehouse-table",
- "enum": [
- "events",
- "person-updates",
- "data-warehouse-table"
- ],
- "type": "string"
- },
- "transpiled": {}
- },
- "type": "object"
- },
- {
- "type": "null"
- }
- ],
- "description": "Property conditions, e.g. {properties: [{key, value, operator, type}]}."
- },
- "name": {
- "description": "Optional display name.",
- "type": "string"
- }
- },
- "type": "object"
- },
- "events": {
- "description": "Events to wait for: continues when ANY entry fires (OR'd with 'condition'). Each entry: {filters: {events: [{id, name, type: 'events'}], actions?: [...]}, name?}.",
- "items": {
- "properties": {
- "filters": {
- "anyOf": [
- {
- "properties": {
- "actions": {
- "items": {
- "additionalProperties": {},
- "propertyNames": {
- "type": "string"
- },
- "type": "object"
- },
- "type": "array"
- },
- "bytecode": {},
- "bytecode_error": {
- "type": "string"
- },
- "data_warehouse": {
- "items": {
- "additionalProperties": {},
- "propertyNames": {
- "type": "string"
- },
- "type": "object"
- },
- "type": "array"
- },
- "events": {
- "items": {
- "additionalProperties": {},
- "propertyNames": {
- "type": "string"
- },
- "type": "object"
- },
- "type": "array"
- },
- "filter_test_accounts": {
- "type": "boolean"
- },
- "properties": {
- "items": {
- "additionalProperties": {},
- "propertyNames": {
- "type": "string"
- },
- "type": "object"
- },
- "type": "array"
- },
- "source": {
- "default": "events",
- "description": "* `events` - events\n* `person-updates` - person-updates\n* `data-warehouse-table` - data-warehouse-table",
- "enum": [
- "events",
- "person-updates",
- "data-warehouse-table"
- ],
- "type": "string"
- },
- "transpiled": {}
- },
- "type": "object"
- },
- {
- "type": "null"
- }
- ],
- "description": "Event/action filters; the workflow wakes when a matching event fires. Must target at least one event or action (entries targeting neither are dropped)."
- },
- "name": {
- "description": "Optional display name.",
- "type": "string"
- }
- },
- "type": "object"
- },
- "type": "array"
- },
- "max_wait_duration": {
- "description": "'<number><unit>' with unit m|h|d, e.g. '30m' (same rules as delay).",
- "type": "string"
- }
- },
- "required": ["max_wait_duration"],
- "type": "object"
- }
- ],
- "description": "Type-specific config keyed by action type. trigger: {type: event|webhook|manual|batch|schedule|tracking_pixel, filters?}. filters shape: {events: [{id, name, type:'events', properties:[<cond>]}], properties:[<cond>], actions:[...], filter_test_accounts:<bool>}. <cond>: {key, value, operator, type: event|person|group}. function*: {template_id, inputs: {<key>: {value: <str>}}}. Wrap values in {value:...} to enable hog templating ({person.x}, {event.x}); flat strings won't interpolate. Dictionary input values are template strings too — write booleans/numbers as single-expression templates ('{true}', '{42}'), which evaluate to the typed value. delay: {delay_duration: '<number><unit>'} where unit is m|h|d. Fractions OK ('0.5m'=30s; seconds unsupported). Per-unit max m<=60, h<=24, d<=30; values above are SILENTLY CLAMPED. Max 30d. conditional_branch: {conditions: [{filters}, ...]}. Index N matches the 'branch' edge with index:N. wait_until_condition: {condition: {filters}, events?: [{filters: {events: [{id, name, type: 'events'}], actions?: [...]}, name?}], max_wait_duration: <duration>} (same rules as delay). Continues when condition.filters match OR any events entry fires; each events entry must target at least one event or action. On resolution (a condition match or any events entry firing) it advances via the 'branch' edge with index:0; the max_wait_duration timeout falls through the 'continue' edge. exit: {reason}."
- },
- "created_at": {
- "description": "Created at (epoch ms). Frontend-managed.",
- "type": "number"
- },
- "description": {
- "default": "",
- "description": "Optional description.",
- "type": "string"
- },
- "filters": {
- "anyOf": [
- {
- "properties": {
- "actions": {
- "items": {
- "additionalProperties": {},
- "propertyNames": {
- "type": "string"
- },
- "type": "object"
- },
- "type": "array"
- },
- "bytecode": {},
- "bytecode_error": {
- "type": "string"
- },
- "data_warehouse": {
- "items": {
- "additionalProperties": {},
- "propertyNames": {
- "type": "string"
- },
- "type": "object"
- },
- "type": "array"
- },
- "events": {
- "items": {
- "additionalProperties": {},
- "propertyNames": {
- "type": "string"
- },
- "type": "object"
- },
- "type": "array"
- },
- "filter_test_accounts": {
- "type": "boolean"
- },
- "properties": {
- "items": {
- "additionalProperties": {},
- "propertyNames": {
- "type": "string"
- },
- "type": "object"
- },
- "type": "array"
- },
- "source": {
- "default": "events",
- "description": "* `events` - events\n* `person-updates` - person-updates\n* `data-warehouse-table` - data-warehouse-table",
- "enum": ["events", "person-updates", "data-warehouse-table"],
- "type": "string"
- },
- "transpiled": {}
- },
- "type": "object"
- },
- {
- "type": "null"
- }
- ],
- "description": "Property filters gating this action."
- },
- "id": {
- "description": "Unique node ID within the workflow.",
- "maxLength": 200,
- "type": "string"
- },
- "name": {
- "description": "Display name.",
- "maxLength": 400,
- "type": "string"
- },
- "on_error": {
- "anyOf": [
- {
- "description": "* `continue` - continue\n* `abort` - abort",
- "enum": ["continue", "abort"],
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "description": "On failure: continue (skip the action and proceed) or abort (stop the run).\n\n* `continue` - continue\n* `abort` - abort"
- },
- "output_variable": {
- "description": "Output variable for downstream actions: {key, result_path?, spread?, label?} or a list of those."
- },
- "type": {
- "description": "trigger | function | function_email | function_sms | delay | conditional_branch | wait_until_condition | wait_until_time_window | random_cohort_branch | exit.",
- "maxLength": 100,
- "type": "string"
- },
- "updated_at": {
- "description": "Updated at (epoch ms). Frontend-managed.",
- "type": "number"
- }
- },
- "required": ["id", "name", "type", "config"],
- "type": "object"
- },
- "type": "array"
- },
"conversion": {
"anyOf": [
{
@@ -423,33 +113,6 @@
"description": "Optional description.",
"type": "string"
},
- "edges": {
- "description": "Graph edges: [{from, to, type: 'continue'|'branch', index?}]. 'continue' = fall-through (sequential, or no-match path of conditional_branch). 'branch' requires 'index': matches config.conditions[index] on conditional_branch / wait_until_condition. Every non-exit action needs a reachable next action ('No next action found' otherwise).",
- "items": {
- "properties": {
- "from": {
- "description": "Source action id.",
- "type": "string"
- },
- "index": {
- "description": "Required for type='branch'. conditional_branch: index into config.conditions[index]. wait_until_condition: use index:0 — it advances via the index:0 branch edge when it resolves (a condition match or an events entry firing).",
- "type": "number"
- },
- "to": {
- "description": "Target action id.",
- "type": "string"
- },
- "type": {
- "description": "continue: fall-through (sequential or the no-match path of conditional_branch). branch: requires 'index' matching config.conditions[index].\n\n* `continue` - continue\n* `branch` - branch",
- "enum": ["continue", "branch"],
- "type": "string"
- }
- },
- "required": ["to", "type", "from"],
- "type": "object"
- },
- "type": "array"
- },
"exit_condition": {
"description": "exit_only_at_end: only at exit node (default). exit_on_conversion: also on conversion (needs 'conversion'; silent no-op otherwise). exit_on_trigger_not_matched: also when trigger filter stops matching. exit_on_trigger_not_matched_or_conversion: both (needs 'conversion').\n\n* `exit_on_conversion` - Conversion\n* `exit_on_trigger_not_matched` - Trigger Not Matched\n* `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion\n* `exit_only_at_end` - Only At End",
"enum": [