Docs homeCore ConceptsContext & Variables

Context & Variables

Context Variables are Workspace-level key/value pairs injected into Branch prompts and Bud inputs at execution time. They decouple configuration from workflow logic.

Context Variables are the mechanism by which Workspace-specific configuration is injected into Branch executions without hardcoding values into workflow logic. They are stored at the Workspace level and resolved at execution time when the Branch's prompt and Bud inputs are rendered.

Variable syntax

Variables are referenced using double-brace syntax: {{ variable_name }}. This syntax is used in Branch prompts, Bud input templates, and system configuration fields. At execution time, the platform resolves all occurrences of this syntax before passing values to Buds or models.

Variable names are case-sensitive and must contain only alphanumeric characters and underscores.

Example — Branch prompt before resolution:

{
  "prompt": "Summarize the latest activity for {{ company_name }} ({{ tenant_id }}) in {{ output_language }}."
}

After resolution with Workspace context Variables and execution inputs:

{
  "prompt": "Summarize the latest activity for Gilead Sciences (tenant_8821) in French."
}
⚠️
If a Variable referenced in a Branch prompt cannot be resolved at execution time — because it is missing from both execution inputs and Workspace context Variables — the execution fails immediately before any model call is made. No credits are deducted. The error response lists every unresolved Variable name.

Variable resolution order

When a Branch executes, Variables are resolved in this priority order:

  1. Execution inputs — Values explicitly provided when triggering the Branch (via API, Chat, or scheduled trigger). These take highest priority and override Workspace defaults.
  2. Workspace context Variables — The key/value pairs configured in Workspace settings. Applied when no execution input matches the Variable name.

If a Variable referenced in a Branch prompt or Bud input cannot be resolved from either source, the execution fails immediately with a descriptive error listing the unresolved Variable names.

Common use cases

  • API credentials — Store third-party API keys (Salesforce, HubSpot, Slack tokens) as context Variables. Buds reference them via {{ salesforce_api_key }} without ever hardcoding credentials in workflow logic.
  • Tenant identifiers — Multi-tenant deployments can store a {{ tenant_id }} or {{ company_name }} Variable to scope queries and outputs per Workspace.
  • Configuration values — Thresholds, routing targets, locale settings, and other runtime configuration can be managed as context Variables and changed without modifying the Branch.
  • Prompt personalization — Inject Workspace-specific instructions (tone, terminology, format preferences) into model prompts via Variables like {{ response_tone }} or {{ output_language }}.

BYOK (Bring Your Own Key)

For model Buds, Workspaces can supply their own model provider API keys via context Variables. The bud_context_loader system Bud reads these tokens and passes them to model Buds, enabling Workspaces to use their own model provider accounts and billing while still operating under Stackmint's governance layer.

Variable types

Context Variables are stored and resolved as strings. Type coercion is handled by individual Buds — if a Bud expects an integer and receives a string, the Bud's input validation will catch the mismatch. There is no native type system for context Variables at the platform level.

Security

Context Variables are stored encrypted at rest. Sensitive Variables (API keys, tokens) should be marked as secret in the Workspace UI — secret Variables are redacted from audit log output and execution traces, appearing as [REDACTED].

💡
Mark every API key, token, and password as Secret. Non-secret Variables appear in plaintext in audit logs and execution traces — which are visible to all Workspace Admins and Owners. When in doubt, mark it secret.