Kaizen

Workspace Stats

Track per-user stats (e.g. completions, skips) in the workspace and use them in workflows

Workspace Stats let you track numeric values per user in a workspace (e.g. completions, skips). Stats are defined in the workspace Stats schema (workflow custom metadata) and updated or read by blocks. The user is always the run's user (no extra configuration).

Block Types

  • kaizen_get_workspace_stats - Retrieve the current user's stats
  • kaizen_update_workspace_stat - Set, increment, or decrement a stat for the current user

Defining Stat Keys

In the workspace Overview page, open the Stats schema section (admin only). Add rows for each stat key (e.g. completions, skips) with an optional label and default value. Save to apply. These keys can then be used in Update Workspace Stat and Get Workspace Stats blocks.

Get Workspace Stats

Retrieves the current user's stats for the workspace.

Input Fields

FieldTypeRequiredDescription
keystringNoIf provided, the value output will contain this key's value. If omitted, returns all stats.

Outputs

OutputTypeDescription
successbooleanWhether the operation succeeded
statsobjectAll stats for the current user: { [statKey]: number }
valuenumberWhen key was provided, the value for that key

Update Workspace Stat

Sets, increments, or decrements a stat for the current user.

Input Fields

FieldTypeRequiredDescription
keystringYesStat key (e.g. completions, skips). Must start with a letter or underscore.
operationdropdownYesSet – set to a value; Increment – add; Decrement – subtract
valuenumberFor Set: yes. For Increment/Decrement: no (default 1)Value to set, or amount to add/subtract

Outputs

OutputTypeDescription
successbooleanWhether the operation succeeded
keystringThe stat key
valuenumberThe new value after the operation
previousValuenumberThe previous value (if it existed)

Conditional Flow Example

Use a Condition block with two Update Workspace Stat blocks to record completions vs skips:

# Condition block: e.g. <some_block.completed> === true
# True branch:
Update Workspace Stat:
  key: "completions"
  operation: "Increment"
  value: 1

# False branch:
Update Workspace Stat:
  key: "skips"
  operation: "Increment"
  value: 1

Each run updates the current user's stats. No need to pass user ID; it comes from the execution context.

Common Use Cases

Completions and Skips

# Define "completions" and "skips" in the workspace Stats schema, then:

Condition:
  # e.g. todo was completed
  condition: "<kaizen_todos.completedCount> > 0"

# True: increment completions
Update Workspace Stat:
  key: "completions"
  operation: "Increment"

# False: increment skips
Update Workspace Stat:
  key: "skips"
  operation: "Increment"

Read Stats Downstream

Get Workspace Stats:
  # leave key empty to get all stats

# Use in another block, e.g. display or condition
# Reference: <kaizen_get_workspace_stats.stats.completions>

Set a Stat Explicitly

Update Workspace Stat:
  key: "streak"
  operation: "Set"
  value: "0"

Stats are stored per (workspace, user, statKey). The same key can have different values for different users. User is always taken from the workflow run context.

Best Practices

  • Define keys in the Stats schema so they appear in the workspace and stay consistent across workflows.
  • Use Condition + two Update blocks for binary outcomes (e.g. completions vs skips) instead of a single block with complex logic.
  • Keys must be valid identifiers: start with a letter or underscore, then letters, numbers, and underscores only.
On this page

On this page

Start building today
Trusted by over 60,000 builders.
Build Agentic workflows visually on a drag-and-drop canvas or with natural language.
Get started