Skip to main content

Module

Trait Module 

Source
pub trait Module: Send + Sync {
    // Required methods
    fn prompt_components(&self) -> Vec<Arc<dyn PromptComponent>>;
    fn context_components(&self) -> Vec<Arc<dyn ContextComponent>>;
    fn tools(&self) -> Vec<Arc<dyn ToolExecutor>>;

    // Provided methods
    fn session_state(&self) -> Option<Arc<dyn SessionStateComponent>> { ... }
    fn slash_commands(&self) -> Vec<Arc<dyn SlashCommand>> { ... }
    fn settings_namespace(&self) -> Option<&'static str> { ... }
    fn settings_json_schema(&self) -> Option<RootSchema> { ... }
}
Expand description

A Module bundles related prompt components, context components, and tools.

Modules represent cohesive functionality that spans multiple systems:

  • Prompts: Instructions for how the agent should behave
  • Context: Runtime state included in each request
  • Tools: Actions the agent can take

Example: TaskListModule provides task tracking across all three:

  • Prompt instructions for managing tasks
  • Context showing current task status
  • Tools to create and update tasks

Required Methods§

Provided Methods§

Source

fn session_state(&self) -> Option<Arc<dyn SessionStateComponent>>

Returns a session state component if this module has persistent state. Return None if this module has no state to persist across sessions.

Source

fn slash_commands(&self) -> Vec<Arc<dyn SlashCommand>>

Returns slash commands provided by this module. Default implementation returns an empty vec (no commands).

Source

fn settings_namespace(&self) -> Option<&'static str>

Option allows modules without configuration to opt-out, avoiding empty entries.

Source

fn settings_json_schema(&self) -> Option<RootSchema>

Returns JSON Schema for this module’s settings configuration. Used for auto-generating settings UI.

Implementors§