<@ULVA73B9P> I want to pass details about flow run...
# marvin-ai
r
@Marvin I want to pass details about flow run A which triggers an automation, to flow B started by the automation. I tried using jinja template {{ flow_run }} but it seems that the flow B receives a string instead of a structured variable. Is there another way how to pass structured parameters to flow B?
m
thought for 97.2 seconds
Yes —
{{ flow_run }}
in an automation parameter is typically rendered as a string, not passed through as a native dict/object. If you want Flow B to receive structured data, the supported pattern is to wrap the Jinja output in Prefect's JSON hydration format:
Copy code
{
  "__prefect_kind": "json",
  "value": {
    "__prefect_kind": "jinja",
    "template": "{{ flow_run | tojson }}"
  }
}
That does two things: 1.
{{ flow_run | tojson }}
serializes the triggering flow run to JSON 2.
__prefect_kind: "json"
tells Prefect to parse that JSON back into a structured parameter So in your automation's
RunDeployment
action, you'd do something like:
Copy code
parameters={
  "upstream_flow_run": {
    "__prefect_kind": "json",
    "value": {
      "__prefect_kind": "jinja",
      "template": "{{ flow_run | tojson }}"
    }
  }
}
Then Flow B can accept:
Copy code
@flow
def flow_b(upstream_flow_run: dict):
    print(upstream_flow_run["id"])
Recommended approach: instead of passing the entire
flow_run
object, pass only the fields you actually need:
Copy code
parameters={
  "trigger_info": {
    "__prefect_kind": "json",
    "value": {
      "__prefect_kind": "jinja",
      "template": "{{ {'id': flow_run.id, 'name': flow_run.name, 'parameters': flow_run.parameters} | tojson }}"
    }
  }
}
That tends to be more stable and easier to work with. A few notes: - Simple scalar values can use plain Jinja:
Copy code
"name": {
    "__prefect_kind": "jinja",
    "template": "{{ flow_run.name }}"
  }
- For dicts/lists/bools/numbers where you want native types preserved, use the
json
+
jinja
+
tojson
pattern -
flow_run
here refers to the run that triggered the automation If you want, I can also show you a complete automation example for either: - Python SDK automations, or - deployment trigger configuration in YAML/UI.