Architecture
Tirea runtime is organized as three layers:
Application -> AgentOs (orchestration + execution engine) -> Thread/State Engine
1. Application Layer
Your application defines tools, agent definitions, and integration endpoints.
Primary call path:
- Build
AgentOsviaAgentOsBuilder - Submit
RunRequest - Consume streamed
AgentEvent
2. AgentOs (Orchestration + Execution)
AgentOs handles both pre-run orchestration and loop execution:
Orchestration (composition/, runtime/):
- Resolve agent/model/plugin wiring (plugins implement the
AgentBehaviortrait) - Load or create thread
- Deduplicate incoming messages
- Persist pre-run checkpoint
- Construct
RunContext
Execution engine (engine/, runtime/loop_runner/):
Loop is phase-driven:
RunStartStepStart -> BeforeInference -> AfterInference -> BeforeToolExecute -> AfterToolExecute -> StepEndRunEnd
Termination is explicit in RunFinish.termination.
3. Thread + State Engine
State mutation is patch-based:
State' = apply_patch(State, Patch)Threadstores base state + patch history + messagesRunContextaccumulates run delta and emitstake_delta()for persistence
Design Intent
- Deterministic state transitions
- Append-style persistence with version checks
- Transport-independent runtime (
AgentEventas core stream)