Skip to main content

State Bag Variables

Complete list of all variables available in prompt templates and workflow expressions.

Spec variable

VariableAvailableDescription
{spec}AlwaysFull content of the spec file passed to gump run

Step output variables

Available after the referenced step has executed.
VariableDescription
{steps.<n>.output}Main output: git patch (diff), JSON (plan), text (artifact), JSON (review)
{steps.<n>.files}Comma-separated list of files changed (diff steps only)
{steps.<n>.status}pass, fail, or fatal
{steps.<n>.duration}Duration in milliseconds
{steps.<n>.cost}Estimated cost in USD
{steps.<n>.turns}Number of cognitive turns
{steps.<n>.retries}Number of retries executed
{steps.<n>.tokens_in}Input tokens consumed
{steps.<n>.tokens_out}Output tokens produced
{steps.<n>.cache_read}Cache read tokens
{steps.<n>.cache_write}Cache write tokens
{steps.<n>.session_id}Agent session ID (provider-specific)
{steps.<n>.check_result}Gate result: pass, fail, or none

Sub-workflow variables

After a workflow: step completes, its state bag is accessible recursively:
VariableDescription
{steps.<n>.steps.<m>.output}Output of step m inside sub-workflow n
{steps.<n>.steps.<m>.*}Any metric from the sub-workflow’s step
{steps.<n>.run.cost}Total cost of the sub-workflow run

Item variables (foreach)

Available inside a foreach block, for the current item.
VariableDescription
{item.name}Item name (from the plan JSON)
{item.description}Item description
{item.files}Item blast radius (file list)

Run-level variables

Aggregate metrics for the entire run. Updated after each step.
VariableDescription
{run.cost}Total cost so far (USD)
{run.duration}Elapsed time (ms)
{run.tokens_in}Total input tokens
{run.tokens_out}Total output tokens
{run.retries}Total retries across all steps
{run.status}running, pass, fatal, aborted

Retry variables

Available when a step is retried (attempt > 1).
VariableDescription
{error}Stderr from the failed gate or guard reason (truncated to 2000 chars)
{diff}Git diff from the failed attempt (truncated to 3000 chars)

Resolution order

Variables resolve by proximity: same group first, then parent, then root. If {steps.impl.output} exists both in the current group and a parent group, the current group’s version wins. Use --dry-run to check for ambiguity — Gump will reject workflows with ambiguous variable references.

Template escaping

SyntaxResult
{variable}Resolved from the state bag
{{Literal { character
}}Literal } character
Variables that resolve to an empty string cause the entire line to be removed from the prompt (if the variable is the only content on that line). This enables conditional prompt sections — a line with {steps.review.output} disappears cleanly on the first iteration when no review has run yet.