Skip to main content

Message Processing Flow - Detailed Breakdown

This document provides a step-by-step breakdown of how messages flow through the plugin-bootstrap system.

Complete Message Flow Diagram

Detailed Step Descriptions

1. Initial Message Reception

2. Self-Check

3. Response ID Generation

4. Run Tracking

5. Memory Storage

6. Attachment Processing

7. Agent State Check

8. Should Respond Evaluation

Bypass Conditions

LLM Evaluation

9. Response Generation

State Composition with Providers

LLM Response

10. Response Validation

11. Action Processing

Simple Response

Complex Response

12. Evaluator Execution

Reflection Evaluator

Key Decision Points

1. Should Respond Decision Tree

2. Response Type Decision

3. Evaluator Trigger Conditions

Performance Optimizations

1. Response ID Tracking

  • Prevents duplicate responses when multiple messages arrive quickly
  • Only processes the latest message per room

2. Parallel Operations

3. Timeout Protection

Error Handling

1. Run Lifecycle Events

2. Graceful Degradation

  • Missing attachments → Continue without them
  • Provider errors → Use default values
  • LLM failures → Retry with backoff
  • Database errors → Log and continue

Platform-Specific Handling

Discord

  • Channels → Rooms with ChannelType
  • Servers → Worlds
  • Users → Entities

Telegram

  • Chats → Rooms
  • Groups → Worlds
  • Users → Entities

Message Bus

  • Topics → Rooms
  • Namespaces → Worlds
  • Publishers → Entities

Summary

The message flow through plugin-bootstrap is designed to be:
  1. Platform-agnostic - Works with any message source
  2. Intelligent - Makes context-aware response decisions
  3. Extensible - Supports custom actions, providers, evaluators
  4. Resilient - Handles errors gracefully
  5. Performant - Uses parallel operations and caching
This flow ensures that every message is processed consistently, responses are contextual and appropriate, and the agent learns from each interaction.

Template Usage in Message Flow

Understanding where templates are used helps you customize the right parts of the flow:

1. shouldRespondTemplate - Decision Point

Used at step 8 in the flow when evaluating whether to respond:
This template controls:
  • When your agent engages in conversations
  • What triggers a response
  • When to stay silent

2. messageHandlerTemplate - Response Generation

Used at step 9 when generating the actual response:
This template controls:
  • How responses are formulated
  • Which actions are selected
  • The agent’s personality and tone
  • Which providers to use for context

3. reflectionTemplate - Post-Interaction Analysis

Used at step 12 during evaluator execution:
This template controls:
  • What the agent learns from interactions
  • How facts are extracted
  • Relationship tracking logic
  • Self-improvement mechanisms

4. postCreationTemplate - Social Media Posts

Used when POST_GENERATED event is triggered:
This template controls:
  • Post style and tone
  • Content generation approach
  • Image prompt generation

Template Processing Pipeline

  1. Template Selection: System picks the appropriate template
  2. Variable Replacement: {{agentName}}, {{providers}}, etc. are replaced
  3. Provider Injection: Provider data is formatted and inserted
  4. Prompt Assembly: Complete prompt is constructed
  5. LLM Processing: Sent to language model
  6. Response Parsing: XML/JSON response is parsed
  7. Execution: Actions are executed, callbacks are called

Customization Impact

When you customize templates, you’re modifying these key decision points:
  • shouldRespond: Change engagement patterns
  • messageHandler: Alter personality and response style
  • reflection: Modify learning and memory formation
  • postCreation: Adjust social media presence
Each template change cascades through the entire interaction flow, allowing deep customization of agent behavior while maintaining the robust message processing infrastructure.