Skip to main content

Crate behest_runtime

Crate behest_runtime 

Source
Expand description

Async runtime glue connecting the sans-IO state machine to real I/O.

The Runtime struct orchestrates the full agent execution loop:

  1. Receives a user message
  2. Builds context (system prompt + history)
  3. Drives the sans-IO state machine via transition
  4. Executes actions: model calls, tool execution, memory compaction, approval
  5. Emits events through the hook stack
  6. Returns when the run finishes or is aborted

§Architecture

User Message
    │
    ▼
Runtime::run()
    │
    ├─► build context (system prompt + history + RAG)
    ├─► transition(state, input) → (new_state, actions)
    │       │
    │       ├─► RequestModel  → provider.stream() → events → ModelCompleted
    │       ├─► ExecuteTool   → tool_registry.execute() → ToolResultReceived
    │       ├─► RequestToolApproval → approval_gate.request() → await decision
    │       ├─► CompactMemory → memory compaction → MemoryCompactionCompleted
    │       ├─► FinishRun     → return RunOutput
    │       └─► AbortRun      → return error
    │
    └─► emit events → HookStack.dispatch() → EventActions

Structs§

RunOutput
Output from a completed run.
Runtime
The central runtime orchestrator.
RuntimeConfig
Configuration for the runtime.

Enums§

RuntimeError
Errors produced by the runtime layer.

Type Aliases§

RuntimeResult
Result type for runtime operations.