Skip to main content
CogOS supports optional plugins via .use(...). Plugins add behavior without modifying core code.

Plugin Protocol

A plugin is any Python class implementing optional methods (no base class required):
HookTriggeredPurpose
on_register(cogos)On .use()Plugin initialization
before_build(state, registry)Before build()Pre-processing
after_build(state, registry, result)After build()Post-processing
before_chat(state, registry)Before chat()Pre-processing
after_chat(state, registry, result, answer)After chat()Post-processing
chat_prompt_vars(message, *, session_id, state, registry, recalled)During chatbot prompt generationInject custom prompt variables
Plugins use best-effort isolation: any plugin exception will never crash the core pipeline.

Registering Plugins

Example: External RAG Plugin

A complete example that retrieves context from an external service and injects it into the chatbot prompt:

Common Use Cases

  • External RAG retrieval — call your own service, inject retrieved context
  • Logging / metrics — track build and chat operations
  • Safety filters / policy checks — validate inputs and outputs