foobara-agent-backed-command 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44612bf50517981f612d5cc6da7ebf23149455f80ed3ff523c5c9453b2e9168e
4
- data.tar.gz: 294abdb6334158e2544eeb171ce8405194544c461c83df6e0e57d6b78a540734
3
+ metadata.gz: dc71a16e925bc371058a8fa67197ffbb4628fc5b9a7201a41a19e9bb86b661b6
4
+ data.tar.gz: 1274e53472b00432601ad7ca1c9db89716e82d804816c2b6b35383d9f1dbffb4
5
5
  SHA512:
6
- metadata.gz: 9d94e43106f216cb08b4a6378fe571882656bb0526b9a340084f8a60c9090136d0f6cb0ccfb0e661417e87fb62f2294547643b7b516c6f19a0f66eb30b5e8e0d
7
- data.tar.gz: 0cd7d6926331e9f8c0fa1665336291fa552fadd4ce8af8ccaffa3708b4135fda0c136edfdba01f87429651b99d0aeb0578adedd9019f57406783e0639633b1ed
6
+ metadata.gz: 74a9526f5b9e09496b5a0c0e162181af418d8a2aa9efecdaffe5bb9c6e0e2f04222dbcba84ceded5d7c14d3a0a2b24fefb3b54c8986d23832aa95ed6f3ec5686
7
+ data.tar.gz: 6c442453cec558c796c836ab9a24b74d0106307dda2cb51689611df1b86e28201adc158e8f3c18cede0b10c3ed662606152074fc2b70c6e2afc491d2460f2d3e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [0.0.7] - 2025-07-23
2
+
3
+ - Do not let ABCs use the #agent_options input of other ABCs
4
+
5
+ ## [0.0.6] - 2025-07-21
6
+
7
+ - Make sure foobara-ai gem is properly loaded
8
+
1
9
  ## [0.0.5] - 2025-07-12
2
10
 
3
11
  - Allow agent_options input to be removed
@@ -1,3 +1,4 @@
1
1
  require "foobara/all"
2
+ require "foobara/ai"
2
3
 
3
4
  Foobara::Util.require_directory "#{__dir__}/../../src"
@@ -30,8 +30,8 @@ module Foobara
30
30
  [
31
31
  :agent_name,
32
32
  :llm_model,
33
- :max_llm_calls_per_minute,
34
- :result_entity_depth
33
+ :result_entity_depth,
34
+ :maximum_command_calls
35
35
  ].each do |method_name|
36
36
  define_method method_name do |*args|
37
37
  case args.size
@@ -60,8 +60,11 @@ module Foobara
60
60
  one_of: Ai::AnswerBot::Types::ModelEnum,
61
61
  default: Ai.default_llm_model,
62
62
  description: "The model to use for the LLM"
63
- max_llm_calls_per_minute :integer, :allow_nil
64
63
  pass_aggregates_to_llm :boolean, :allow_nil
64
+ maximum_command_calls :integer,
65
+ :allow_nil,
66
+ default: 25,
67
+ description: "Maximum number of commands to run before giving up"
65
68
  result_entity_depth :symbol, :allow_nil, one_of: Foobara::AssociationDepth
66
69
  end
67
70
  end
@@ -123,13 +126,12 @@ module Foobara
123
126
  end
124
127
  end
125
128
 
126
- agent_name = agent_options&.[](:agent_name) || self.class.agent_name || "#{self.class.scoped_short_name}Agent"
129
+ agent_name = agent_options&.[](:agent_name) || self.class.agent_name || self.class.scoped_short_name
127
130
 
128
131
  verbose = agent_options&.[](:verbose)
129
132
  verbose = self.class.verbose? if verbose.nil?
130
133
 
131
134
  opts = {
132
- command_classes:,
133
135
  include_message_to_user_in_result:,
134
136
  result_type: agent_result_type,
135
137
  verbose:,
@@ -137,9 +139,7 @@ module Foobara
137
139
  io_err: agent_options&.[](:io_err) || self.class.io_err,
138
140
  agent_name:,
139
141
  context: agent_options&.[](:context) || self.class.context,
140
- llm_model: agent_options&.[](:llm_model) || self.class.llm_model,
141
- # TODO: eliminate this now that we have backoffs for 529s and 429s
142
- max_llm_calls_per_minute: agent_options&.[](:max_llm_calls_per_minute) || self.class.max_llm_calls_per_minute
142
+ llm_model: agent_options&.[](:llm_model) || self.class.llm_model
143
143
  }
144
144
 
145
145
  if agent_options&.[](:result_entity_depth).nil?
@@ -156,7 +156,34 @@ module Foobara
156
156
  agent_options[:pass_aggregates_to_llm]
157
157
  end
158
158
 
159
+ maximum_command_calls = agent_options&.[](:maximum_command_calls) || self.class.maximum_command_calls
160
+
161
+ if maximum_command_calls
162
+ opts[:maximum_command_calls] = maximum_command_calls
163
+ end
164
+
159
165
  self.agent = Foobara::Agent.new(**opts)
166
+
167
+ command_classes.each do |klass|
168
+ if klass.is_a?(::Symbol)
169
+ real_class = Namespace.global.foobara_lookup_command(
170
+ klass,
171
+ mode: Namespace::LookupMode::ABSOLUTE
172
+ )
173
+
174
+ if real_class
175
+ klass = real_class
176
+ end
177
+ end
178
+
179
+ opts = if klass.is_a?(Class) && klass < AgentBackedCommand
180
+ { inputs: { reject: [:agent_options] } }
181
+ else
182
+ {}
183
+ end
184
+
185
+ agent.connect(klass, **opts)
186
+ end
160
187
  end
161
188
 
162
189
  def agent_options
@@ -177,10 +204,9 @@ module Foobara
177
204
  goal = Util.underscore(goal)
178
205
  goal = Util.humanize(goal)
179
206
 
180
- goal = "You are an agent backed command named #{self.class.scoped_short_name}. Your goal is: #{goal}."
181
-
182
207
  if self.class.description
183
- goal += " The command description is: #{self.class.description}."
208
+ goal += "\n\nYour behavior has been described to the person or agent that chose to run you as: "
209
+ goal += self.class.description
184
210
  end
185
211
 
186
212
  inputs_type = self.class.inputs_type
@@ -202,7 +228,7 @@ module Foobara
202
228
  inputs_type,
203
229
  association_depth:
204
230
  )
205
- goal += " The inputs to this command have the following type:\n\n#{json_inputs_type}\n\n"
231
+ goal += "\n\nYour inputs to this command have the following type:\n\n#{json_inputs_type}\n\n"
206
232
 
207
233
  serializer = if pass_aggregates_to_llm?
208
234
  CommandConnectors::Serializers::AggregateSerializer
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara-agent-backed-command
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi