Repository navigation
feat(automations): saved variables, kept between runs and set by the set_variable action - #460
Merged
Merged
Conversation
…set_variable action An automation's own variables and its namespace's, read as vars in the run context; the set_variable action (set, increment, append to the last 100, clear) with writes that race read the value again; the API and the automation_vars and set_automation_vars MCP tools. A variable set from a template reading outside text stays marked in later runs' prompts. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JZDyxMfCBYNRw12CHqE9ss
This was referenced Oct 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Adeel · project thread
Workflow studio M9, part 2 of 3 (variables and templates): saved variables. Part 1 (#454, templates) is merged; the variable picker's catalog and preview come next.
Description
Before:
varsin the run context was always empty. An automation had no way to keep a value between runs, such as a counter or when it last alerted.After:
automation_var): an automation's own, or its namespace's, which every automation working there reads. A run reads them asvars.<name>, and the automation's own win on a name.set_variableaction (group Run, effectself, so routine) canset,increment(default 1),append(keeping the last 100) orclear. Values are JSON up to 16 KB, and a scope holds at most 100 variables. Two runs writing at once both count, because a write that loses the race (CAS onrev) reads the value again. Namespace scope needs the automation's person to be an editor there.untrusted. Later runs' prompts wrap it as outside text, and an action reading it counts as reading outside text. Other variables stay as written. This replaces part 1's default of marking every variable.GET/PUT /api/v1/automations/{id}/vars: for admins and whoever may change the automation; 404 otherwise.GET/PUT /api/v1/namespaces/{name}/automation-vars: readers read, editors change.PUTtakes{"vars": {name: value}}, where null clears one, and audits the change.automation_vars(read-only) andset_automation_vars(write scope). They are split like the other read and set tools, so clients can treat reading as safe.Motivation and Context
Workflow studio, module M9 (brief
workflow-studio/briefs/M9.md, item 4). It makes counters, "last alert at" values and lists shared between runs possible:{"action": "set_variable", "params": {"name": "door_opened", "op": "increment"}}, then{{ steps.count.value }}.Defaults taken (reversible):
automationrow directly until M6's API lands.x/set_xpairs.Types of changes
!in the title)Checklist:
make hookschecks it on commit).tests/api/test_automation_vars.py, the MCP tool list intests/api/test_mcp.py).docs/accordingly:docs/automations.md(Saved variables, a counter example),docs/api.md,docs/mcp.mdanddocs/database.md. I also fixed table cells whose\|pipes showed a backslash.## UnreleasedinCHANGELOG.md. (n/a)Done questions (AGENTS.md)
automation_varsandset_automation_varsMCP tools, the REST API, and theset_variableaction that agents can put in automations.IF NOT EXISTS).P-INJECTION-EGRESSin the threat model.make openapi.docs/automations.md: secrets, typed declarations, an activity when a person changes one, finer marking, and removing an automation's variables when it is deleted (M6).🤖 Generated with Claude Code
https://claude.ai/code/session_01JZDyxMfCBYNRw12CHqE9ss
Generated by Claude Code