Skip to content

Core Classes

The fundamental classes that power RobotLab.

Overview

classDiagram
    class Robot {
        +name: String
        +description: String
        +model: String
        +template: String
        +tools: Array~Tool~
        +run(state, network)
    }

    class Network {
        +name: String
        +robots: Hash
        +router: Proc
        +run(state)
    }

    class State {
        +data: StateProxy
        +results: Array
        +messages: Array
        +memory: Memory
    }

    class Tool {
        +name: String
        +description: String
        +parameters: Hash
        +handler: Proc
    }

    class Memory {
        +remember(key, value)
        +recall(key)
        +forget(key)
        +scoped(namespace)
    }

    Network --> Robot : contains
    Robot --> Tool : has
    State --> Memory : has
    Network --> State : uses

Classes

Class Purpose
Robot LLM agent with personality, tools, and model configuration
Network Container for robots with routing and orchestration
State Conversation state with data, results, and memory
Tool Callable function with parameters and handler
Memory Namespaced key-value store for sharing data

Quick Examples

Robot

robot = RobotLab.build do
  name "assistant"
  model "claude-sonnet-4"
  template "You are helpful."

  tool :greet do
    parameter :name, type: :string
    handler { |name:, **_| "Hello, #{name}!" }
  end
end

Network

network = RobotLab.create_network do
  name "my_network"
  add_robot robot
  router ->(args) { args.call_count.zero? ? :assistant : nil }
end

State

state = RobotLab.create_state(
  message: "Hello",
  data: { user_id: "123" }
)

Tool

tool = RobotLab::Tool.new(
  name: "get_time",
  description: "Get current time",
  handler: ->(**, _) { Time.now.to_s }
)

Memory

state.memory.remember("key", "value")
value = state.memory.recall("key")