Tactus in a Nutshell

Templates and Prompting

Tactus supports {...} templates in prompts. They’re designed for:

Template Namespaces

Namespace Source Example
input procedure inputs {input.topic}
state durable mutable state {state.items_processed}
prepared agent prepare() output {prepared.file_contents}
context runtime context from caller {context.parent_id}
env environment variables {env.API_KEY}
output final outputs (in return_prompt) {output.findings}

Templates are re-evaluated before each agent turn.

Where Templates Appear

Most commonly:

worker = Agent {
  model = "openai/gpt-4o-mini",
  prepare = function()
    return {now = os.date(), cwd = context.cwd}
  end,
  system_prompt = [[
Time: {prepared.now}
Working directory: {prepared.cwd}
Task: {input.task}
  ]]
}

“Prepared Context” Pattern

Use prepare() for deterministic data-loading and preprocessing, then template it into prompts.

worker = Agent {
  prepare = function()
    local readme = File.read("README.md")
    return {readme = readme}
  end,
  system_prompt = "Use this context:\n\n{prepared.readme}"
}

Prompt Components (Procedure-Level)

Procedures can provide standardized prompts that frame the run:

Procedure {
  return_prompt = "Return JSON for {output.result} only.",
  error_prompt = "Explain what failed and what to do next.",
  status_prompt = "Return a short status update.",
  function(input) ... end
}

Prompt Hygiene (Nutshell Rules)