Examples / Getting Started / Parameters

Parameters

Has Specs

Demonstrates how to work with procedure parameters (inputs) and use them throughout your workflow. This example shows: - Defining input schemas with descriptions and default values - Accessing input parameters within the procedure function - Using parameters in loops and logic - Logging with the Log utility - State management with `State.increment()` - Returning structured output that references input parameters

Source Code

-- Parameters Example
-- Demonstrates accessing parameters and using them in procedure logic

-- No agents are needed for this example.

-- Procedure with input and output defined inline
Procedure {
    input = {
        task = field.string{description = "The task name to process", default = "default task"},
        count = field.number{description = "Number of iterations to perform", default = 3},
    },
    output = {
        result = field.string{required = true, description = "Summary of the completed work"},
    },
    function(input)
        -- Access input
        local task = input.task
        local count = input.count

        Log.info("Running task", {task = task, count = count})

        -- Use parameters in workflow
        state.iterations = 0
        for i = 1, count do
          State.increment("iterations")
          Log.info("Iteration", {number = i, task = task})
        end

        local final_iterations = state.iterations

        return {
          result = "Completed " .. task .. " with " .. final_iterations .. " iterations"
        }
    end
}

-- BDD Specifications
Specification([[
Feature: Parameter Usage
  Demonstrate parameter access and usage in workflows

  Scenario: Parameters are used correctly
    Given the procedure has started
    When the procedure runs
    Then the procedure should complete successfully
    And the state iterations should be 3
    And the output result should exist
]])

Quick Start

Run the example:

$tactus run 01-getting-started/03-parameters.tac

Test with mocks:

$tactus test 01-getting-started/03-parameters.tac --mock

View source on GitHub →

Explore more examples

Learn Tactus through practical, runnable examples organized by topic.