Skip to main content

Flow Metadata

flow.meta() exposes request-scoped metadata about the current execution. It replaces the deprecated metadata: TaskMetadata parameter on processTask.

async processTask(command: any, _metadata: TaskMetadata, flow: Flow) {
const userId = flow.meta().userId();
const tier = flow.meta().userSubscriptionTier();
// ...
}
MethodReturnsDescription
command()TaskCommandThe incoming task command.
taskId()stringCurrent task id.
userId()string | undefinedCaller's user id. undefined for anonymous requests.
userSubscriptionTier()SubscriptionTier | undefinedFREE / PLUS / PRO / GOLD_OLD. Not propagated by default — must be enabled (today via the Gateway).
platform()stringClient platform (e.g. WEBSITE, APPLE, ANDROID).
touchpoint()stringThe touchpoint/surface that submitted the task.
countryCode()stringISO country code from the request.
submittedAt()DateTime the task was submitted.
addProcessedUnit(unit, options?)voidRecord vendor usage for cost attribution. See Expense Tracking.
configureNotification(overrides)voidOverride notification text for this execution. See Notifications.
setLabels(labels)voidAttach runtime labels to this execution for filtering logs and metrics. See Dynamic labels.
baggage(key?)Record<string, any> or T | undefinedRead arbitrary data carried from the preflight options() phase (or supplied by the caller). See Baggage.

Dynamic labels

Dynamic labels let you tag the current execution with runtime values, so the access log and Datadog metrics can be filtered and grouped by attributes that aren't fixed at the task level (e.g. the model used).

flow.meta().setLabels({ model: 'gpt-4o' });
  • Only keys defined in DynamicLabels are accepted; unknown keys are silently dropped.
  • Values longer than 100 chars are silently dropped.
  • Each call replaces the full set — there is no merge.

Requires @picsart/pa-pluggable-workers-core 7.1.0 or higher.

Baggage

flow.meta().baggage() reads arbitrary data carried into this execution from the preflight options() phase, letting you reuse work done there instead of recomputing it.

const faces = flow.meta().baggage<Face[]>('faces'); // one key, typed
const all = flow.meta().baggage(); // the whole bag

See Runtime Options → Baggage for more info.