Class: ComposableAgents::AiAgents::Agent
- Inherits:
-
PromptDrivenAgent
- Object
- ComposableAgents::Agent
- PromptDrivenAgent
- ComposableAgents::AiAgents::Agent
- Defined in:
- lib/composable_agents/ai_agents/agent.rb
Overview
Agent implementation that uses an ai-agent's AgentRunner.
Instance Attribute Summary
Attributes inherited from PromptDrivenAgent
#constraints, #conversation, #objective, #role, #system_instructions
Attributes inherited from ComposableAgents::Agent
Public API collapse
-
#full_name ⇒ String
Return the full name of the agent.
-
#initialize(*args, model: Agents.configuration.default_model, params: {}, handoff_agents: [], **kwargs) ⇒ Agent
constructor
Initialize a new agent with a list of ai-agents' Agents to be used with an AgentRunner.
Methods inherited from PromptDrivenAgent
Methods included from Mixins::Logger
Internal collapse
-
#export_state ⇒ Object
Export the agent state for persistence.
-
#import_state(state) ⇒ Object
Import the agent state from persistence.
Methods inherited from PromptDrivenAgent
#input_artifacts_contracts, #output_artifacts_contracts, #report_error_for_output_artifact, #save_output_artifact
Methods inherited from ComposableAgents::Agent
Constructor Details
#initialize(*args, model: Agents.configuration.default_model, params: {}, handoff_agents: [], **kwargs) ⇒ Agent
Initialize a new agent with a list of ai-agents' Agents to be used with an AgentRunner
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/composable_agents/ai_agents/agent.rb', line 16 def initialize( *args, model: Agents.configuration.default_model, params: {}, handoff_agents: [], **kwargs ) super(*args, **kwargs) @model = model @params = params @handoff_agents = handoff_agents @context = {} end |
Instance Method Details
#export_state ⇒ Object
Export the agent state for persistence
44 45 46 |
# File 'lib/composable_agents/ai_agents/agent.rb', line 44 def export_state super.merge(deep_transform_keys(context: Base64.encode64(Marshal.dump(@context)), &:to_s)) end |
#full_name ⇒ String
Return the full name of the agent. This method is intended to be overridden by subclasses to give better full names, tailored to the kind of agent. The full name can be used in logs and traces to better identify the agent.
35 36 37 |
# File 'lib/composable_agents/ai_agents/agent.rb', line 35 def full_name "#{name || 'Unnamed'} (AiAgent #{@model})" end |
#import_state(state) ⇒ Object
Import the agent state from persistence
51 52 53 54 |
# File 'lib/composable_agents/ai_agents/agent.rb', line 51 def import_state(state) super @context = Marshal.load(Base64.decode64(deep_transform_keys(state, &:to_sym)[:context])) end |