Examples / Getting Started / Simple Logic

Simple Logic

Has Specs

A pure logic example that demonstrates Tactus procedures without using any AI agents. This example shows: - How to define procedures with input and output schemas using field definitions - State management with the `state` primitive - Multiple BDD specifications testing different aspects of the procedure - Basic Lua control flow (loops, conditionals)

Source Code

-- Simple Tactus procedure without agents for BDD testing
-- This example uses only state primitives, no LLM calls required

-- Procedure with input, output, and state defined inline
Procedure {
    input = {
        target_count = field.number{
            required = false,
            description = "Target counter value",
            default = 5,
        },
    },
    output = {
        final_count = field.number{required = true, description = "Final counter value"},
        message = field.string{required = true, description = "Status message"},
    },
    function(input)
        local target = input.target_count or 5
        for i = 1, target do
            state.counter = i
        end

        state.message = "complete"
        return {final_count = state.counter, message = state.message}
    end
}

-- BDD Specifications
Specification([[
Feature: Simple State Management
  Test basic state functionality without agents

  Scenario: State updates correctly
    Given the procedure has started
    When the procedure runs
    Then the state counter should be 5
    And the state message should be complete
    And the procedure should complete successfully

  Scenario: Outputs are returned
    Given the procedure has started
    When the procedure runs
    Then the output should exist
    And the output final_count should be 5
    And the output message should be complete

  Scenario: Iterations are tracked
    Given the procedure has started
    When the procedure runs
    Then the total iterations should be less than 10
]])

-- Custom steps can be added here if needed
-- step("custom assertion", function(input)
--   assert(state.counter > 0)
-- end)

Quick Start

Run the example:

$tactus run 01-getting-started/02-simple-logic.tac

Test with mocks:

$tactus test 01-getting-started/02-simple-logic.tac --mock

View source on GitHub →

Explore more examples

Learn Tactus through practical, runnable examples organized by topic.

Part of the Anthus Platform
Tactus icon

Tactus

Tactus is a programming language and runtime for durable AI agent procedures with checkpointing, sandboxing, and built-in human-in-the-loop controls.

PART OF

The Anthus Platform

Solve complex business problems with AI and ML using a proven, reusable technology stack. These interoperable building blocks give our solutions a stronger operational foundation: durable procedures, MLOps control loops, workload orchestration, knowledge systems, observability, and programmable media workflows.

Plexus

MLOps platform for agent evaluation and iteration.

Tactus

Durable runtime for agent procedures.

Korporus

Agent operating system and federated shell.

Biblicus

Corpus analysis for extraction and retrieval.

Babulus

Marketing automation built around VideoML.

Kanbus

Durable multi-agent task management.

Caducus

Monitoring, alerts, and operator support.

Free and open-source softwareDesigned cybernetically by Ryan Porter
Contact us

How can we help?

GitHub

Browse the code.

LinkedIn

Company updates.

Discord

Join the chat.