Search
Search docs, blog posts, and ecosystem packages with citations.
Enter a query to see grounded citations.
A real Jido agent that counts up and down using Actions, Signals, and signal routing. Demonstrates the core agent pattern: immutable state, validated actions, and LiveView integration.
defmodule AgentJido.Demos.CounterAgent do
@moduledoc """
A simple counter agent demonstrating core Jido concepts:
- Agent as immutable data structure
- Actions with validated params
- Signals and signal routing
- Direct strategy (synchronous execution)
"""
use Jido.Agent,
name: "counter_agent",
description: "Simple counter demonstration",
schema: [
count: [type: :integer, default: 0]
]
alias AgentJido.Demos.Counter.{IncrementAction, DecrementAction, ResetAction}
@impl true
def signal_routes(_ctx) do
[
{"counter.increment", IncrementAction},
{"counter.decrement", DecrementAction},
{"counter.reset", ResetAction}
]
end
end