Multi-agent
Agents run concurrently on real threads, each in its own isolated interpreter. They coordinate through a shared blackboard and signals — not direct calls. (This is the concurrency layer; for a model that picks tools, see Tool calling.)
-- Doc example: the blackboard (share / observe) — thread-safe shared state.
-- spawn / signal / wait_for run real threads (non-deterministic), shown in the prose.
intent: "doc example: blackboard"
share 42 as "demo_key"
observe "demo_key" as demo_v
print("blackboard: demo_key → " + text(demo_v))
test "the blackboard is shared, synchronous state (share publishes, observe reads)"
share 42 as "answer"
observe "answer" as a
assert_eq(a, 42)
share "hi" as "result_1"
observe "result_1" as g
assert_eq(g, "hi")
Define & spawn
Defining an agent registers it; the body runs only when spawned (in a new thread). The parent continues immediately.
agent Researcher
require net("*.wikipedia.org")
let data be fetch("https://en.wikipedia.org/api/...")
share data as "research"
signal "done"
spawn Researcher with query = "AI safety"
Top-level tasks/values are snapshotted (a copy) into the agent. A failing agent is contained (state ERROR); synsema run joins agents before exiting and exits non-zero if any ended in ERROR.
Blackboard — share / observe
share value as "key" publishes; observe "key" as var reads. Thread-safe and versioned; the key is an expression ("result_" + text(id)).
Signals — signal / wait_for
signal "done" -- emit (a consumable queue, not a latch)
signal "done" with data -- emit with a payload
wait_for "done" as result -- blocks until a signal arrives (default 30s), CONSUMES it
wait_for "done" timeout 2 as r -- bound the wait; returns nothing on timeout
Bound wait_for with timeout inside a route handler so a request can't hang. The channel is an expression — use "cancel:" + text(job_id) for a per-job push channel.
Inspecting a run
synsema conform --swarm program.syn -- JSON dump: blackboard + per-agent states