Module engine

Module engine 

Source
Expand description

High-performance async reasoning engine with streaming support.

The engine module provides ReasoningLoop for orchestrating ThinkTool execution with memory integration and concurrent processing.

§ReasonKit Engine Module

High-performance async reasoning engine that orchestrates ThinkTool execution with memory integration, streaming support, and concurrent processing.

§Core Components

  • ReasoningLoop: Main async engine for structured reasoning
  • ReasoningSession: Stateful session with context accumulation
  • StreamingOutput: Real-time reasoning step streaming

§Architecture

+------------------+     +------------------+     +------------------+
|   User Prompt    | --> |  ReasoningLoop   | --> |  Decision Output |
+------------------+     +------------------+     +------------------+
                                 |
                   +-------------+-------------+
                   |             |             |
              +----v----+  +-----v-----+  +----v----+
              | Memory  |  | ThinkTool |  | Profile |
              | Query   |  | Executor  |  | System  |
              +---------+  +-----------+  +---------+

§Usage

use reasonkit::engine::{ReasoningLoop, ReasoningConfig, Profile};

#[tokio::main]
async fn main() -> Result<()> {
    let loop_engine = ReasoningLoop::builder()
        .with_profile(Profile::Balanced)
        .with_memory(memory_client)
        .build()?;

    // Streaming execution
    let mut stream = loop_engine.reason_stream("Should we adopt microservices?").await?;
    while let Some(step) = stream.next().await {
        println!("Step: {:?}", step);
    }

    // Blocking execution
    let decision = loop_engine.reason("Should we adopt microservices?").await?;
    println!("Decision: {}", decision.conclusion);

    Ok(())
}

Re-exports§

pub use reasoning_loop::Decision;
pub use reasoning_loop::MemoryContext;
pub use reasoning_loop::Profile;
pub use reasoning_loop::ReasoningConfig;
pub use reasoning_loop::ReasoningError;
pub use reasoning_loop::ReasoningEvent;
pub use reasoning_loop::ReasoningLoop;
pub use reasoning_loop::ReasoningLoopBuilder;
pub use reasoning_loop::ReasoningSession;
pub use reasoning_loop::ReasoningStep;
pub use reasoning_loop::StepKind;
pub use reasoning_loop::StreamHandle;
pub use reasoning_loop::ThinkToolResult;

Modules§

reasoning_loop
Async ReasoningLoop Engine