Add example for defining new agent provider#784
Add example for defining new agent provider#784dersam wants to merge 1 commit into02-12-move_agent_providers_into_shared_registryfrom
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
373be46 to
df57af6
Compare
This is the most minimal possible agent. This one always responds with the same thing and always succeeds. This should make it easier to understand how to implement providers, as the Claude version is quite complex. Also we decided we don't care about duplicated agent responses in Claude and removed some special casing.
df57af6 to
530dc39
Compare
| formatted_message = message.format(@context) | ||
| puts formatted_message if formatted_message.present? && @show_progress | ||
|
|
There was a problem hiding this comment.
where does progress get displayed now if we remove these lines?
|
|
||
| if from | ||
| # Load gem - no special requires, gem must handle everything | ||
| require from |
There was a problem hiding this comment.
there's already a require from if from on line 101
| loadables.each do |cog_name| | ||
| require @workflow_path.realdirpath.dirname.join("cogs/#{cog_name}").to_s |
There was a problem hiding this comment.
shouldn't this be something more generic that cog_name here?
| require path.to_s if from.nil? | ||
| loadables.each do |name| | ||
| class_name_string = name.camelize | ||
| raise InvalidCogReference, "#{name} class not found" unless Object.const_defined?(class_name_string) |
There was a problem hiding this comment.
why do we need this raise?
and shouldn't InvalidCogReference be completely replaced InvalidLoadableReference now?
| attr_accessor :timeout | ||
|
|
||
| def initialize | ||
| @timeout = 30 | ||
| end |
There was a problem hiding this comment.
This won't work with config merging. With our architecture, config values must be stored in the @values hash.
| attr_accessor :timeout | |
| def initialize | |
| @timeout = 30 | |
| end | |
| def timeout(seconds) | |
| @values[:timeout] = seconds | |
| end | |
| # by convention, we use `valid_<attibute>` method as accessors used by the cog, to distinguish them from setters used in the workflow definition | |
| def valid_timeout | |
| @values.fetch(:timeout, 30) | |
| end |
| raise "City is required" if city.nil? || city.empty? | ||
| true |
There was a problem hiding this comment.
| raise "City is required" if city.nil? || city.empty? | |
| true | |
| raise "City is required" if city.blank? |
| end | ||
|
|
||
| execute do | ||
| weather do |
There was a problem hiding this comment.
| weather do | |
| weather(:my_weather) do |
| <<~PROMPT | ||
| The weather in #{weather!.city} is #{weather!.temperature}°F and #{weather!.conditions}. | ||
| Should I bring an umbrella? | ||
| PROMPT |
There was a problem hiding this comment.
This is not the correct way to access cog output
| <<~PROMPT | |
| The weather in #{weather!.city} is #{weather!.temperature}°F and #{weather!.conditions}. | |
| Should I bring an umbrella? | |
| PROMPT | |
| city, temperature, conditions = weather!(:my_weather).values_at(:city, :temperature, :conditions) | |
| <<~PROMPT | |
| The weather in #{city} is #{temperature}°F and #{conditions}. | |
| Should I bring an umbrella? | |
| PROMPT |
| def validate! | ||
| true | ||
| end |
There was a problem hiding this comment.
| def validate! | |
| true | |
| end | |
| def validate! | |
| end |
| end | ||
|
|
||
| def execute(input) | ||
| puts "I'm a namespaced cog!" |
There was a problem hiding this comment.
| puts "I'm a namespaced cog!" | |
| puts "I'm a namespaced cog!" | |
| Cog::Output.new |

This is the most minimal possible agent. This one always responds with
the same thing and always succeeds. This should make it easier to
understand how to implement providers, as the Claude version is quite
complex.
Also we decided we don't care about duplicated agent responses in Claude
and removed some special casing.