Execution Model
This page defines Toolang runtime execution semantics.
Two orthogonal axes
Toolang keeps two concepts separate:
runtime loopa long-lived trigger sourceexecution strategythe strategy used to complete one turn
Rules:
- runtime loops decide when a turn starts
- execution strategies decide how that turn completes
- these concepts must not be merged
Message model
Toolang uses one Message shape as the semantic input for one turn.
Minimal fields:
originchannelsenderthread_idtextmeta
origin values:
invokechattaskchorewill
Rules:
origin == chatrequires a non-nullchannelorigin in {invoke, task, chore, will}requireschannel = nulltask,chore, andwillusesender = selfrunandstartare process surfaces, not message origins
Runtime loops
Toolang defines four runtime loops:
serveraccepts local API requestspollpolls external channelshookaccepts hook deliveriespulseemits internaltask,chore, andwill
Rules:
- runtime loops create turn requests
- runtime loops do not execute turns directly
toolang invokestarts no runtime loopstoolang runstarts a foreground runtime-loop settoolang startstarts a background runtime-loop set
Execution strategies
Execution strategy is a turn-local concern.
Examples:
directreactplan_execute
Rules:
- one turn uses one execution strategy
- one strategy may produce many internal steps
- strategy selection is independent from runtime-loop selection
Core execution objects
Toolang execution is organized around:
runthread_groupthreadturnstep
The local execution truth layer lives in ${AGENT_ROOM}/execution.db.
${AGENT_ROOM}/agent.run remains a current-running summary, not the historical
truth.
Runs, threads, turns, and steps
runone continuous active interval of agent executionthreadone durable execution contextturnone complete handling attempt inside a threadstepone internal part of one turn
Important rules:
- one thread may span many turns
- one thread may span many runs
- every turn belongs to exactly one run
- at most one turn may run at a time for the same
thread_id
Scheduling
The scheduler should enforce:
- thread serialization
- thread-group budget limits
Suggested built-in thread groups:
chattaskchorewill
Default intent:
chathighest prioritytaskmoderate concurrencychorelow priority with coalescingwilllowest priority with aggressive coalescing
Truth layer and projections
Execution uses three layers:
- agent-local execution truth
- shared bus projection
- outbound side effects
Rules:
- local execution state is written first
- shared bus projection is written second
- external delivery happens last
The truth layer should preserve enough raw data to derive later projections and
statistics without depending on bus/events.db.
Loop-owned sources
Recommended source files:
channels.tomlhooks.tomltasks/chores/will.md
Recommended runtime state:
poll/hooks/pulse.json
The pulse loop is responsible for turning local task, chore, and will state into schedulable turn requests.
Read next
- Read Task Model for task-origin turns.
- Read Collaboration Model for inbox and scheduler mental models.
- Read Control Surfaces for the public entry points into this runtime model.