8000 feat(automations): draft an automation from a sentence by adeelahmad · Pull Request #464 · adeelahmad/lense · GitHub
[go: up one dir, main page]

Skip to content

feat(automations): draft an automation from a sentence - #464

Merged
adeelahmad merged 1 commit into
mainfrom
claude/project-thread-sxrerj
Oct 16, 2026
Merged

adeelahmad merged 1 commit into
mainfrom
claude/project-thread-sxrerj

Conversation

@adeelahmad
Copy link
Copy Markdown
Owner

Requested by Adeel · project thread

Description

Before: making an automation meant writing its triggers, If and graph as JSON.

After: POST /api/v1/automations/draft {"text": "when a new email from the school comes in, tell me", "spaces": [...]} asks the model once and gives back a draft automation to try and save, with what didn't fit (dropped) and what it couldn't express yet (unmapped, such as "when both arrive" while joins are planned). A draft may listen for activities, a webhook (its address comes when it is saved), a schedule, a time or a time in an activity (#450's triggers, in UTC unless the sentence names a zone), or a person running it. Nothing is saved.

How: app/domain/automation_draft.py gives the model the vocabulary Lens has (the kinds with their fields, the If operators and the actions catalog) and a JSON schema, is told about triggers in time only once the timers that run them are there, then maps what comes back onto real triggers, a match tree and a chain of action nodes, dropping anything unknown and checking the result with the same checks as saving. The call goes through the activity ledger and is refused when a budget for the person's account or the chosen namespaces is used up, or no model is set up.

Motivation and Context

Workflow studio, module M6 (automation engine), part 5 of 5: drafting from a sentence, so the builder (M11) and agents can start from words.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change; ! in the title)

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project (make hooks checks it on commit).
  • I added or updated tests.
  • My change requires documentation updates, and I have updated docs/ accordingly.
  • Users need more than the title to understand it, so I wrote it under ## Unreleased in CHANGELOG.md.

Done questions (AGENTS.md)

  • Goal: the last part of M6's brief; merged on green CI.
  • Agents: an API route usable with an API key; agents can also write the draft themselves with save_automation.
  • Zero setup: uses the model already configured; says so plainly when none is.
  • Fewest clicks and keystrokes: one sentence instead of a JSON body.
  • Configurable: n/a, no new setting (the model comes from Settings).
  • Light: one model call per draft; no new dependency.
  • Private and secure: only people who can edit a namespace draft; the sentence goes to the configured model like any assistant turn; threat model entry point updated.
  • Cost: one call, in the activity ledger, refused over budget.
  • User decides: a draft is never saved; the person tries and saves it.
  • Upgrades: no stored-data change.
  • Honest: docs label drafting built and name what it can't express yet.
  • Tests (tests/domain/test_automation_draft.py, tests/api/test_automations.py), docs (docs/automations.md, docs/api.md) and the generated client (make openapi) updated.
  • Open standards; no new dependencies.
  • Result reported with evidence; "refine later" items written in docs/automations.md.

Checked locally: full backend suite (1328 passed), ruff, mypy, the threat model check, mkdocs build --strict and make openapi (no change).

🤖 Generated with Claude Code

https://claude.ai/code/session_01VCAZ9NEmBJNovqdzxvK3qi


Generated by Claude Code

POST /api/v1/automations/draft asks the model once to turn a sentence
into a draft automation, with the kinds of activity and their fields,
the match operators and the actions as its vocabulary. The reply is
checked piece by piece: a trigger, its where, the If or an action that
doesn't fit is dropped and said, and what the sentence asked for that
can't be expressed yet (schedules) is listed. Nothing is saved. The
call counts in the activity ledger and isn't made over budget.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VCAZ9NEmBJNovqdzxvK3qi
@adeelahmad adeelahmad self-assigned this Oct 16, 2026
@adeelahmad
adeelahmad merged commit 09de179 into main Oct 16, 2026
11 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-sxrerj branch October 16, 2026 03:46
adeelahmad added a commit that referenced this pull request Oct 16, 2026
Automations merged (#432 to #464): the stream now holds every kind of
activity, the Timeline page reviews it, and automations act on it with
triggers, conditions, actions, approvals, limits and budgets, made by
agents over MCP and in the assistant or drafted from a sentence. Say so
under Automate it, with the studio labelled planned as
docs/automations.md does; add the open RSS feeds (#453) and condition
operators (#434) to In progress; link the timeline from the docs index.


Claude-Session: https://claude.ai/code/session_01HDx7PPUauyjMn1LZs8JAsS

Co-authored-by: Adeel Ahmad <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0