Purpose
Define how a single openboa agent actually runs at turn level. This document specifies runtime responsibilities, state transitions, and reliability guarantees.Runtime Boundary
boa-runtime is responsible for execution.
It is not responsible for:
- transport protocol ownership (gateway owns)
- external infra operation (connectors are optional)
- organization-level governance policy authoring
- turn lifecycle control
- system prompt/context assembly
- tool/skill invocation pipeline
- terminal result contract (
completed | failed | denied) - session append + checkpoint writeback
Runtime Components
-
Turn Executor
- runs one turn from input event to terminal report
-
Context Assembler
- loads runtime context from workspace + recent session history
- applies token/window budget policy
-
Prompt Builder
- composes final system prompt from openboa contracts
- ensures policy/system clauses are first-priority
-
Tool & Skill Bridge
- resolves tool definitions
- validates schema + permission before execution
-
Pi Adapter Client (
runtime-adapter-pi)- open/reuse session
- stream model events
- normalize runtime outputs to openboa event model
-
State Writer
- append JSONL events
- update cursor/checkpoint files
- emit audit lines
Runtime Input Contract
Runtime consumes normalized chat events from gateway. Minimum input fields:eventIdchatIdseqsender.agentIdtypepayloadtraceIdcorrelationId
agentId identities.
No human/agent branch at runtime path.
Session Model
Session Key
Default key basis:agentIdchatId
Turn Concurrency
Default:- one active turn per session key
- new events during active turn are queued by gateway/runtime queue policy
Persistence Paths
- session append:
.openboa/agents/<agentId>/sessions/<sessionId>.jsonl - state checkpoint:
.openboa/agents/<agentId>/state/<sessionId>.json - runtime audit:
.openboa/audit/runtime/YYYY-MM-DD.jsonl
Storage Role Split (critical)
- Chat SOT:
.openboa/chat/chats/<chatId>.jsonl- canonical chat message stream (1:1 and group)
- Session log:
.openboa/agents/<agentId>/sessions/<sessionId>.jsonl- runtime turn metadata, tool/results references, recovery breadcrumbs
Turn Lifecycle
Step details
-
preparing
- load context
- build system prompt
- resolve tools/skills
-
running
- execute prompt via pi adapter
- stream deltas/events
-
waiting_tool
- validate and execute tool calls
- return tool result events back to runtime
-
committing
- finalize assistant output
- emit terminal status payload
- persist journal/checkpoint/audit
Tool & Skill Execution Rules
- All tool calls pass policy gate before execution.
- Input schema validation failure returns structured error; no blind execution.
- Tool runtime exceptions are captured as
tool_runtime_errorterminal or intermediate errors. - Skills are runtime hints/recipes; execution authority remains in runtime policy + tool contracts.
Reliability Contract
For every turn, runtime must emit exactly one terminal status:completedfaileddenied
statusreason(for failed/denied)nextAction(recovery hint)traceIdcorrelationId
report_missing incident.
Error Classes
invalid_inputpolicy_deniedtool_runtime_errortimeoutauth_errorprovider_errorreport_missing
Local-First Runtime Guarantee
Runtime must boot and execute with local defaults only:- local file-backed journal/state/audit
- embedded pi adapter
- no required external DB or broker
Acceptance Criteria
- Runtime executes one turn end-to-end through pi adapter
- Tool pipeline enforces validation + policy gates
- One terminal report is always emitted
- Session recovery works from local checkpoint + JSONL append
- Agent↔Human and Agent↔Agent events share same runtime path