Module: ComposableAgents::Mixins::UserInteraction

Defined in:
lib/composable_agents/mixins/user_interaction.rb

Overview

Mixin that adds user interaction capabilities to PromptDrivenAgent agents. This defines the following methods:

  • #ask(question) -> answer Calls the #answer_to method to get the answer to a question and logs the conversation. An agent using this Mixin should define the private method `#answer_to`` to handle the question. Default handling is asking the question on the terminal.

Public API collapse

Instance Method Details

#ask(question) ⇒ String

Answer an agent's question

Parameters:

  • question (String)

    The agent's question

Returns:

  • (String)

    The answer that should be sent back to the agent



15
16
17
18
19
20
# File 'lib/composable_agents/mixins/user_interaction.rb', line 15

def ask(question)
  track_message(message: question, author: "Agent #{full_name}", question: true)
  answer = answer_to(question)
  track_message(message: answer, author: 'User')
  answer
end