Module: LLM::ActiveRecord::ActsAsAgent
- Included in:
- ActiveRecord::Base
- Defined in:
- lib/llm/active_record/acts_as_agent.rb
Overview
ActiveRecord integration for persisting LLM::Agent state.
This wrapper reuses the same record-backed runtime surface as ActsAsLLM, but builds an LLM::Agent instead of an LLM::Context. Agent defaults such as model, tools, schema, instructions, and concurrency are configured on the model class and forwarded to an internal agent subclass.
The model implements set_provider (required) and set_context
(optional), and the wrapper resolves them by name. A tracer is not one of
those callbacks: give it to acts_as_agent as tracer:, or set it on the
agent in the block with agent.tracer.
Defined Under Namespace
Modules: ClassMethods, Hooks, InstanceMethods
Instance Method Summary collapse
-
#acts_as_agent(options = EMPTY_HASH) {|agent| ... }
Installs the
acts_as_agentwrapper on an ActiveRecord model.
Instance Method Details
#acts_as_agent(options = EMPTY_HASH) {|agent| ... }
This method returns an undefined value.
Installs the acts_as_agent wrapper on an ActiveRecord model.
100 101 102 103 104 105 106 |
# File 'lib/llm/active_record/acts_as_agent.rb', line 100 def acts_as_agent( = EMPTY_HASH, &block) = DEFAULTS.merge() class_attribute :llm_plugin_options, instance_accessor: false, default: DEFAULTS unless respond_to?(:llm_plugin_options) self. = .freeze extend Hooks block_given? ? class_exec(agent, &block) : nil end |