criogenai

IBM agent types

Simple reflex agent

If this, then that: rules on the current reading only.

A simple reflex agent maps what it senses right now to an action with fixed condition-action rules. It keeps no memory and has no goal beyond its rules: the same reading always gives the same action.

A thermostat is the classic example. Change the target with the slider and run it again.

Use it when
The current reading is enough to act
Rules are known and stable
Speed and predictability matter most
Skip it when
The world is only partly visible (it cannot remember)
Situations the rules do not cover

Run it

No model needed · CriogenAI engine in your browser
Ready
reading< target − 1> target + 1SensorRulesHeatIdleCool
The run
  1. Press Run to watch the pattern work, step by step.

This run is the TypeScript code below, running on the CriogenAI engine in your browser (WebAssembly). Without a key, a scripted model stands in for MODEL; with your key, your provider answers, called from this tab. The tools return made-up data.

Build it with CriogenAI

Built from primitives: Workflow.route (a router is a rule)
target = 21.0

def rule(state: Dict[str, Any]) -> str:  # the condition-action rules
    t = state["temperature"]
    return "heat" if t < target - 1 else "cool" if t > target + 1 else "idle"

def act(action: str) -> Callable[[Dict[str, Any]], Dict[str, Any]]:
    return lambda state: {"action": action}

wf = Workflow()
wf.add_node("sense", lambda state: None)
for action in ("heat", "cool", "idle"):
    wf.add_node(action, act(action))
    wf.edge(action, END)
wf.start("sense").route("sense", rule, {a: a for a in ("heat", "cool", "idle")})
app = wf.compile()
for reading in (17.5, 21.0, 23.6):
    print(reading, (await app.run({"temperature": reading})).state["action"])
const target = settings.target; // the thermostat's set point
const rule = (state: State) => (state.temperature < target - 1 ? "heat" : state.temperature > target + 1 ? "cool" : "idle");

const wf = new Workflow().node("sense", () => undefined).start("sense");
for (const action of ["heat", "cool", "idle"]) wf.node(action, () => ({ action })).edge(action, END);
wf.route("sense", rule, { heat: "heat", cool: "cool", idle: "idle" }); // the condition-action rules
const app = wf.compile();
const readings: string[] = [];
for (const temperature of [17.5, 21, 23.6]) readings.push(`${temperature} °C → ${(await app.run({ temperature })).state.action}`);
console.log(readings);