Tactus in a Nutshell

Migration Guide

From Python Scripts

Before (Python)

import openai

def run_agent(prompt):
    messages = [{"role": "user", "content": prompt}]
    while True:
        response = openai.chat.completions.create(
            model="gpt-4",
            messages=messages,
            tools=[search_tool, done_tool]
        )
        if done_called(response):
            return extract_result(response)
        messages.append(response.choices[0].message)

After (Tactus)

local done = require("tactus.tools.done")
search = Tool { ... }

worker = Agent {
  model = "openai/gpt-4o",
  system_prompt = "...",
  tools = {search, done}
}

Procedure {
  input = {prompt = field.string{required = true}},
  output = {result = field.string{required = true}},
  function(input)
    worker({message = input.prompt})
    repeat worker() until done.called() or Iterations.exceeded(20)
    return {result = done.last_result() or ""}
  end
}

Benefits:

From LangChain/LangGraph

Before (LangGraph)

class State(TypedDict):
    messages: list
    done: bool

graph = StateGraph(State)
graph.add_node("agent", agent_node)
graph.add_node("tools", tool_node)
graph.add_conditional_edges(...)
app = graph.compile(checkpointer=memory)

After (Tactus)

local done = require("tactus.tools.done")
worker = Agent { model = "openai/gpt-4o-mini", tools = {search, done} }

Procedure {
  function(input)
    repeat worker() until done.called()
    return {result = done.last_result() or ""}
  end
}

Benefits:

From Large MCP Tool Catalogs

When an MCP server has many related operations, consider replacing the catalog with one programmable Tactus gateway. The host exposes an application module, and the model writes a short snippet that composes those APIs for the current task.

Before

MCP server exposes:
- score_info
- score_predict
- feedback_find
- evaluation_run
- report_run
- procedure_run
- ...

After

local score = plexus.score.info({ id = "compliance-score" })
local docs = plexus.docs.get({ key = "overview" })

return {
  score_name = score.scoreName,
  docs = docs.content,
}

Generic hosts usually expose this shape through require("your_app"); Plexus hides that bootstrap by injecting plexus as a global inside execute_tactus.

Benefits:

Key Differences

Python/LangChain Tactus
Classes and decorators Assignment-based declarations
Manual state management Durable state + checkpoints
Graph-based flow Imperative loops
Separate test files Embedded Specifications([[]])
Multiple files Single .tac file

From Older Tactus Syntax

Older examples often use “named blocks” (e.g., Agent "worker" { ... }). In v5, declarations are assignment-based and referenced as variables:

worker = Agent { ... }
repeat worker() until done.called()

Script Mode (Zero-Wrapper)

Script mode lets Tactus wrap simple Lua scripts as a procedure automatically. It’s useful when migrating a quick script into a full Procedure { ... } file.