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();
// ...
}
| Method | Returns | Description |
|---|---|---|
command() | TaskCommand | The incoming task command. |
taskId() | string | Current task id. |
userId() | string | undefined | Caller's user id. undefined for anonymous requests. |
userSubscriptionTier() | SubscriptionTier | undefined | FREE / PLUS / PRO / GOLD_OLD. Not propagated by default — must be enabled (today via the Gateway). |
platform() | string | Client platform (e.g. WEBSITE, APPLE, ANDROID). |
touchpoint() | string | The touchpoint/surface that submitted the task. |
countryCode() | string | ISO country code from the request. |
submittedAt() | Date | Time the task was submitted. |
addProcessedUnit(unit, options?) | void | Record vendor usage for cost attribution. See Expense Tracking. |
configureNotification(overrides) | void | Override notification text for this execution. See Notifications. |
setLabels(labels) | void | Attach runtime labels to this execution for filtering logs and metrics. See Dynamic labels. |
baggage(key?) | Record<string, any> or T | undefined | Read 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
DynamicLabelsare 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.