Skip to content

Pipelines

Pipeline documentation explains linear runtime execution paths: what starts them, what each stage receives, what each produces, and where side effects occur.

TomoriBot organizes conversation turn handling into five interconnected pipelines:

flowchart TD
msg["Incoming Message"] --> chat["Chat Pipeline<br/>1. Admission & Channel Lock<br/>2. Persona Turn Planning<br/>3. Per-Turn Execution"]
chat --> ctx["Context-Build Pipeline<br/>- Persona & Server Metadata<br/>- Participant Profile Hydration<br/>- Dialogue History & Tail Directives"]
ctx --> gen["Generation Turn<br/>Model Fallback Chain & Key Rotation"]
gen --> tool["Tool-Loop Pipeline<br/>- Tool Call Validation & Dispatch<br/>- Enhanced Context Restarts<br/>- Memory Tool Writes"]
tool --> prov["Provider Pipeline<br/>- Native Request Serialization<br/>- Chunk Normalization & Reasoning<br/>- Markdown Buffer Management<br/>- Discord Stream Delivery"]
prov --> post["4. Post-Turn Effects"]
post --> mem["Memory Pipeline<br/>- Passive Short-Term Memory Capture"]
  • Chat Pipeline: Orchestrates Discord event ingress, message admission, channel queue locking, persona turn planning, and post-turn accounting.
  • Context-Build Pipeline: Assembles ordered prompt items, evaluates SillyTavern preset routing, hydrates participant profiles, and prepares conversation history for model consumption.
  • Tool-Loop Pipeline: Coordinates repeated model generation passes, tool call execution, argument validation, error suppression, and enhanced context restarts.
  • Provider Pipeline: Manages provider-specific streaming requests, SSE chunk parsing, reasoning block stripping, markdown segment buffering, and Discord message delivery.
  • Memory Pipeline: Connects passive capture of recent dialogue with tool-driven durable summaries and persona-lineage-scoped long-term memories.
  1. Ingress to planning: An admitted Discord message in the Chat Pipeline acquires a channel lock and plans persona turns.
  2. Planning to context assembly: For each turn, the chat coordinator calls the Context-Build Pipeline to assemble static system instructions, dynamic participant profiles, and recent dialogue history.
  3. Context to generation loop: The turn coordinator invokes the Tool-Loop Pipeline, passing the prepared context closure.
  4. Generation to provider streaming: The tool loop initiates streaming passes through the Provider Pipeline, which negotiates wire protocols, extracts reasoning, flushes markdown buffers, and delivers text to Discord.
  5. Tool calls to execution: Tool invocations emitted during provider streaming route back to the tool loop for execution. Tools may return direct responses or trigger enhanced context restarts.
  6. Generation to memory: Memory tools write summaries or long-term facts during the tool loop. After generation settles, result-dependent post-turn effects record recent dialogue and advance memory cadence counters. The Memory Pipeline owns both write paths.