Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 0 additions & 48 deletions lib/mars/agent.rb

This file was deleted.

15 changes: 15 additions & 0 deletions lib/mars/agent_step.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

module MARS
class AgentStep < Runnable
class << self
def agent(klass = nil)
klass ? @agent_class = klass : @agent_class
end
end

def run(input)
self.class.agent.new.ask(input).content
end
end
end
2 changes: 1 addition & 1 deletion lib/mars/rendering/graph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module MARS
module Rendering
module Graph
def self.include_extensions
MARS::Agent.include(Agent)
MARS::AgentStep.include(AgentStep)
MARS::Gate.include(Gate)
MARS::Workflows::Sequential.include(SequentialWorkflow)
MARS::Workflows::Parallel.include(ParallelWorkflow)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module MARS
module Rendering
module Graph
module Agent
module AgentStep
include Base

def to_graph(builder, parent_id: nil, value: nil)
Expand All @@ -12,10 +12,6 @@ def to_graph(builder, parent_id: nil, value: nil)

[node_id]
end

def name
self.class.name
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion mars.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Gem::Specification.new do |spec|

# Uncomment to register a new dependency of your gem
spec.add_dependency "async", "~> 2.34"
spec.add_dependency "ruby_llm", "~> 1.9"
spec.add_dependency "ruby_llm", "~> 1.12"
spec.add_dependency "zeitwerk", "~> 2.7"

# For more information and examples about making a new gem, check out our
Expand Down
64 changes: 0 additions & 64 deletions spec/mars/agent_spec.rb

This file was deleted.

61 changes: 61 additions & 0 deletions spec/mars/agent_step_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# frozen_string_literal: true

RSpec.describe MARS::AgentStep do
describe ".agent" do
it "stores and retrieves the agent class" do
agent_class = Class.new
step_class = Class.new(described_class) do
agent agent_class
end

expect(step_class.agent).to eq(agent_class)
end

it "returns nil when no agent class is set" do
step_class = Class.new(described_class)
expect(step_class.agent).to be_nil
end
end

describe "#run" do
let(:mock_agent_instance) do
instance_double("RubyLLM::Agent").tap do |mock|
allow(mock).to receive(:ask).and_return(instance_double("RubyLLM::Message", content: "agent response"))
end
end

let(:mock_agent_class) do
instance_double("Class").tap do |mock|
allow(mock).to receive(:new).and_return(mock_agent_instance)
end
end

let(:step_class) do
klass = mock_agent_class
Class.new(described_class) do
agent klass
end
end

it "creates a new agent instance and calls ask" do
step = step_class.new
result = step.run("hello")

expect(result).to eq("agent response")
expect(mock_agent_class).to have_received(:new)
expect(mock_agent_instance).to have_received(:ask).with("hello")
end
end

describe "inheritance" do
it "inherits from MARS::Runnable" do
expect(described_class.ancestors).to include(MARS::Runnable)
end

it "has access to name, formatter, and hooks from Runnable" do
step = described_class.new(name: "my_agent")
expect(step.name).to eq("my_agent")
expect(step.formatter).to be_a(MARS::Formatter)
end
end
end