Module: ActiveAgent::Callbacks
- Extended by:
- ActiveSupport::Concern
- Included in:
- Base
- Defined in:
- lib/active_agent/concerns/callbacks.rb
Overview
Provides callback hooks for generation, prompting, and embedding lifecycles.
Enables agents to execute custom logic before, after, or around AI operations.
Callbacks support conditional execution via :if and :unless options, and
after callbacks are skipped when the chain is terminated with throw :abort.
Callback Types
Each lifecycle supports three timing hooks:
before_*- executes before the operationafter_*- executes after the operation (skipped if aborted)around_*- wraps the operation (must callyield)
Lifecycle Hierarchies
generation- wraps both prompting and embedding operationsprompting- specific to prompt executionembedding- specific to embedding operations
Use *_generation callbacks for cross-cutting concerns like rate limiting,
authentication, and logging that apply to all AI operations.
Callback Control
prepend_*- inserts callback at the beginning of the chainappend_*- adds callback at the end (same as base methods)skip_*- removes a previously defined callback
Defined Under Namespace
Modules: ClassMethods