Repository navigation
feat(automations): run automations on new activities, with limits, budgets and runs - #462
Merged
Merged
Conversation
…dgets and runs A thread follows the stream for the kinds switched-on automations listen for and runs each one a new activity matches, once, as the person who made it. A run checks that person still may act where it works, its If, its cooldown and hourly limit and the global per-minute limit, and its budgets (held for the person's pick, as routines are), then runs its event workflow and keeps a run with its trace, log and intents. Runs show in the stream as automation.ran; chains stop at max_depth. The API tries an automation (saved or a draft) without keeping anything, runs one now, pages its runs, lists what an activity caused and decides a held run. Settings → Automations switches them off and sets the limits and how long runs are kept. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VCAZ9NEmBJNovqdzxvK3qi
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
Description
Before: automations could be saved and switched on, but nothing ran them.
After: a switched-on automation reacts to new activities in its namespaces. When its If passes it runs its event workflow as the person who made it, within its limits and budgets, and each run is kept with what every node did, its log, its cost and what its actions did, asked or wait to do. Runs appear in the stream as
automation.ran. Over the API you can list an automation's runs, read one, find the runs an activity started, try an automation (saved or a draft) on an activity or a kind's sample without keeping or sending anything, run it now, decide a run held over budget, and see when it runs next. Settings → Automations switches them all off and sets how deep chains may go, how many runs a minute Lens allows and how long runs are kept.How: a thread named
automationsfollows the stream where the notifier and routines run.automations.fire(...)is the one way every trigger starts a run: it checks the person still may act, the If, the automation's cooldown and hourly limit, the minute-wide cap and budgets (automation:<id>is now a budget resource), then runs the graph inside an activity-ledger scope. Activities an automation makes carry their run as the cause, so chains stop atautomations.max_depthand an automation ignores other automations' activities unless a trigger saysfrom_automations. Each (automation, trigger, activity) is claimed once through the event log's claims, so the API and a worker can both follow. An action that asks first becomes an approval in the inbox (approvals.ask, #447, with the activity that caused it) and one that waits becomes a timer (timers.later, #452, its timer and time kept on the intent); both report back throughupdate_intent, and the inbox's Always callsset_policy.approvalsnow reads the run's activity from the fields runs keep (event_ids). Schedule andattriggers run when their timers fire (#450 callsfirewith aclock.tickactivity), a relative trigger's matching activity sets its timer (timers.relative), andGET /automations/{id}/upcominglists what it has waiting. A webhook trigger runs onwebhook.receivedcalls to its own hook (#442), and purging a deleted automation revokes its hooks. The new sourceautomations(app/domain/events_automations.py) emitsautomation.ranandautomation.limited, and a recording's actor names the automation that brought it.Motivation and Context
Workflow studio, module M6 (automation engine), part 3 of 5: the dispatcher, runs, limits and budgets. Next come the MCP and assistant tools, then drafting from a sentence.
Types of changes
!in the title)Checklist:
make hookschecks it on commit).docs/accordingly.## UnreleasedinCHANGELOG.md.Done questions (AGENTS.md)
automations.enabled,max_depth(3),max_runs_per_minute(60) andkeep_runs_days(30) in Settings → Automations.automationsentry point, P-AUTOMATION-ACTOR (acting for its creator) and P-AUTOMATION-LOOP (loop amplification).automation:<id>; budgets on the automation, its workflow and namespaces hold or skip a run; the If is checked before anything is spent.automation_run,automation_intentandautomation_limittables (DEFINE TABLE IF NOT EXISTS, safe to run twice) and four keys added to theautomationssettings section next tocatch_upandapproval_days, with defaults; no existing data changes.tests/domain/test_automation_runs.py, including a schedule's timer firing a real run and re-arming, an approval and a waiting action carried out for real, and a saved variable counting across real runs (feat(automations): saved variables, kept between runs and set by the set_variable action #460);tests/api/test_automations.py), docs (automations, api, budgets, configuration, activity, telemetry) and the generated client (make openapi) updated.docs/automations.md.Checked locally: full backend suite (1321 passed; 1328 with the next two PRs on top), ruff, mypy, the threat model check and
mkdocs build --strict.🤖 Generated with Claude Code
https://claude.ai/code/session_01VCAZ9NEmBJNovqdzxvK3qi
Generated by Claude Code