summaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/init.lua b/init.lua
index 6058c9d..5597dd2 100644
--- a/init.lua
+++ b/init.lua
@@ -156,6 +156,25 @@ return subagents.workflow(function(ctx)
end)
```
+**Program, don't transcribe.** `source` is a program, not a transcript: write each piece of text once and let code produce the variations. Templates are the one mechanism: a `[[long string]]` with `{name}` placeholders, filled by `template:gsub("{([%w_]+)}", vars)` where `vars` is a table. Do not use `string.format`, `..` chains, or any other placeholder style. Near-identical prompts come from a loop over a data table, never copy-pasted per child; a shared system prompt goes in `agents` once, not in every `ctx:agent`. Children share your workspace, so a prompt can name a file to read instead of quoting its contents. If `source` is mostly quoted text, that is the signal to factor it.
+
+```lua
+local brief = [[
+Audit the {area} module under {root} for unchecked errors. Read-only.
+Report as a bullet list; end with RESULT={"issues":<count>}
+]]
+return subagents.workflow(function(ctx)
+ local workers = {}
+ for _, area in ipairs({"auth", "billing", "search"}) do
+ workers[#workers + 1] = ctx:agent{name=area, agent="auditor",
+ prompt=brief:gsub("{([%w_]+)}", {area=area, root="src/"})}
+ end
+ local out = {}
+ for _, r in ipairs(ctx:await(workers, "all")) do out[#out + 1] = r.output end
+ return table.concat(out, "\n\n")
+end)
+```
+
**Deterministic code drives; agents advise.** A workflow is code you control wrapped around judgment you cannot. Put every decision that can be nailed down into Lua — loops, counts, ordering, retries, pass/fail gates — and spend agents only on discovery and judgment. When Lua needs a fact an agent found (a list to fan out over, a verdict, a chosen option), tell that agent to end its report with one machine-parseable line, parse it, and let the parsed value shape the rest of the graph. The sandbox has `json.encode(value)` and `json.decode(text)`, which returns the value or `nil, message`.
```lua