Skip to main content

Crate bob_runtime

Crate bob_runtime 

Source
Expand description

§Bob Runtime

Runtime orchestration layer for the Bob Agent Framework.

§Overview

This crate provides the orchestration layer that coordinates agent execution:

  • Scheduler: Finite state machine for agent turn execution
  • Action Parser: Parses LLM responses into structured actions
  • Prompt Builder: Constructs prompts with tool definitions and context
  • Composite Tool Port: Aggregates multiple tool sources

This crate depends only on bob_core port traits — never on concrete adapters.

§Architecture

┌─────────────────────────────────────────┐
│         AgentRuntime (trait)            │
├─────────────────────────────────────────┤
│  ┌──────────┐  ┌──────────┐  ┌───────┐ │
│  │Scheduler │→ │Prompt    │→ │Action │ │
│  │  FSM     │  │Builder   │  │Parser │ │
│  └──────────┘  └──────────┘  └───────┘ │
└─────────────────────────────────────────┘
         ↓ uses ports from bob_core

§Example

use bob_runtime::{AgentBootstrap, AgentRuntime, RuntimeBuilder};
use bob_core::{
    ports::{LlmPort, ToolPort, SessionStore, EventSink},
    types::TurnPolicy,
};
use std::sync::Arc;

fn create_runtime(
    llm: Arc<dyn LlmPort>,
    tools: Arc<dyn ToolPort>,
    store: Arc<dyn SessionStore>,
    events: Arc<dyn EventSink>,
) -> Result<Arc<dyn AgentRuntime>, bob_core::error::AgentError> {
    RuntimeBuilder::new()
        .with_llm(llm)
        .with_tools(tools)
        .with_store(store)
        .with_events(events)
        .with_default_model("openai:gpt-4o-mini")
        .with_policy(TurnPolicy::default())
        .build()
}

§Features

  • Finite State Machine: Robust turn execution with state tracking
  • Streaming Support: Real-time event streaming via run_stream()
  • Tool Composition: Aggregate multiple MCP servers or tool sources
  • Turn Policies: Configurable limits for steps, timeouts, and retries
  • Health Monitoring: Built-in health check endpoints

§Modules

  • scheduler - Core FSM implementation for agent execution
  • action - Action types and parser for LLM responses
  • prompt - Prompt construction and tool definition formatting
  • composite - Multi-source tool aggregation

Re-exports§

pub use tooling::NoOpToolPort;
pub use tooling::TimeoutToolLayer;
pub use tooling::ToolLayer;
pub use bob_core as core;

Modules§

action
Action Parser
agent_loop
Agent Loop
composite
Composite Tool Port
progressive_tools
Progressive Tool View
prompt
Prompt Builder
router
Slash Command Router
scheduler
Scheduler
tooling
Tooling helpers for runtime composition.

Structs§

DefaultAgentRuntime
Default runtime that composes the 4 port traits via Arc<dyn ...>.
RuntimeBuilder
Trait-first runtime builder used by composition roots.

Enums§

DispatchMode
Action dispatch mode for model responses.

Traits§

AgentBootstrap
Bootstrap contract for producing an AgentRuntime.
AgentRuntime
The primary API for running agent turns.