Automations phase 2: chaining, refinements, dry run

Chaining: spec gains calls:[ids] + calledOnly. On fire, a task calls its
same-owner callees in order; each callee evaluates its OWN condition and
may call onward. Safety: write-time cycle rejection (owner-graph DFS) plus
a runtime visited-set + depth cap (5); calledOnly tasks skip the schedule;
existing per-task fire caps and the owner daily email cap still apply
across the chain. The LLM never chooses calls — the user wires the graph.

Refinements: AgentTask.refinements jsonb (migration 026) stores added
constraints; the UI composes prompt+refinements into the compile text and
shows removable chips. Dry run: condition-check is split from fire() so
POST /api/agent/dry-run evaluates a spec without acting or recording —
the 'Extend → Try it' preview ('result would be false right now').

UI: detail view gains the 'If true, call' card (picker disables
loop-creating options), refinement chips + Extend/Try it/Add flow, called-by
breadcrumb, and a 'when called' frequency label.

Verified: full DB integration suite under -race (chaining fires callees,
cycle rejected at write + runtime guard terminates a DB-injected cycle,
calledOnly skips schedule, dry run records nothing, refinements capped),
db-converge + atomicity, web lint/SSR/build, browser regression extended
for chaining + refinement + dry run.
This commit is contained in:
Andrew S Erwin
2026-11-25 14:57:41 -06:00
parent 10d4c898d2
commit c84d694a03
10 changed files with 692 additions and 39 deletions
+11
View File
@@ -0,0 +1,11 @@
-- 026_agent_refinements.sql — Automations phase 2: stored refinements.
--
-- The original prompt lives in AgentTask.prompt (025); refinements are the
-- ordered list of added constraints ("also require a checked bag"). The UI
-- composes prompt + refinements into the compile text; this column stores
-- the list for display/removal. Chaining (spec.calls / spec.calledOnly)
-- needs no column — it lives inside the validated spec jsonb.
--
-- Additive and idempotent; schema.sql carries the identical column.
ALTER TABLE "AgentTask" ADD COLUMN IF NOT EXISTS refinements jsonb NOT NULL DEFAULT '[]';