Expand description
Cascading multi-turn inference engine.
Enables multi-turn reasoning loops where a model’s output can trigger additional pipeline passes — tool calls, function execution, chain-of-thought continuation — until a termination condition is met.
§Architecture
PromptRequest
│
▼
┌─────────────────────────────────────────┐
│ CascadeEngine │
│ │
│ Turn 1: infer → parse tools │
│ Turn 2: execute tools → infer again │
│ Turn N: model returns DONE / no tools │
└─────────────────────────────────────────┘
│
▼
CascadeResult (all turns + final answer)§Termination Conditions
The loop exits when ANY of the following is true:
- The model output contains no tool calls (
ToolCallParserfinds nothing) - The output text contains the DONE sentinel string
max_turnsis reached (default: 10)- A pipeline error occurs (propagated to caller)
§Tool Call Format
The engine recognises tool calls in this JSON block format:
<tool_call>
{"name": "search", "arguments": {"query": "rust tokio"}}
</tool_call>Custom parsers can be registered via CascadeEngine::with_tool_parser.
Structs§
- Cascade
Config - Configuration for a cascade run.
- Cascade
Engine - Multi-turn cascading inference engine.
- Cascade
Monitor - A thread-safe store of active cascade sessions for introspection.
- Cascade
Result - Final output of a complete cascade run.
- Cascade
Turn - The result of a single cascade turn.
- Noop
Tool Executor - Stub executor that returns a placeholder result without doing real work.
- Tool
Call - A single parsed tool call extracted from a model response.
- Tool
Result - The result of a tool execution.
- XmlStyle
Tool Parser - Default parser: finds
<tool_call>…</tool_call>JSON blocks.
Enums§
- Termination
Reason - Why a cascade loop exited.
Constants§
- DEFAULT_
MAX_ TURNS - Default maximum number of cascade turns before halting.
- DONE_
SENTINEL - Sentinel string that signals the model is done cascading.
Traits§
- Tool
Call Parser - Trait for parsing tool calls out of a raw model response.
- Tool
Executor - Trait for executing tool calls and returning results.
Type Aliases§
- InferFn
- Infer function type: takes a prompt string, returns the model response.