Skip to content

Add example for defining new agent provider#784

Open
dersam wants to merge 1 commit into02-12-move_agent_providers_into_shared_registryfrom
02-12-add_example_for_defining_new_agent_provider
Open

Add example for defining new agent provider#784
dersam wants to merge 1 commit into02-12-move_agent_providers_into_shared_registryfrom
02-12-add_example_for_defining_new_agent_provider

Conversation

@dersam
Copy link
Contributor

@dersam dersam commented Feb 12, 2026

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.

Copy link
Contributor Author

dersam commented Feb 12, 2026

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.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@dersam dersam force-pushed the 02-12-add_example_for_defining_new_agent_provider branch from 373be46 to df57af6 Compare February 12, 2026 22:01
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.
Comment on lines -151 to -153
formatted_message = message.format(@context)
puts formatted_message if formatted_message.present? && @show_progress

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where does progress get displayed now if we remove these lines?


if from
# Load gem - no special requires, gem must handle everything
require from
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's already a require from if from on line 101

Comment on lines +109 to +110
loadables.each do |cog_name|
require @workflow_path.realdirpath.dirname.join("cogs/#{cog_name}").to_s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this raise?

and shouldn't InvalidCogReference be completely replaced InvalidLoadableReference now?

Comment on lines +39 to +43
attr_accessor :timeout

def initialize
@timeout = 30
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work with config merging. With our architecture, config values must be stored in the @values hash.

Suggested change
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

Comment on lines +266 to +267
raise "City is required" if city.nil? || city.empty?
true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
raise "City is required" if city.nil? || city.empty?
true
raise "City is required" if city.blank?

end

execute do
weather do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
weather do
weather(:my_weather) do

Comment on lines +313 to +316
<<~PROMPT
The weather in #{weather!.city} is #{weather!.temperature}°F and #{weather!.conditions}.
Should I bring an umbrella?
PROMPT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the correct way to access cog output

Suggested change
<<~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

Comment on lines +330 to +332
def validate!
true
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def validate!
true
end
def validate!
end

end

def execute(input)
puts "I'm a namespaced cog!"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
puts "I'm a namespaced cog!"
puts "I'm a namespaced cog!"
Cog::Output.new

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants