Aidarb - AI Ruby Agent SDK

Note: This SDK is currently under active development and not ready for production use. Star and watch the repo to stay updated on our progress!

Gem Version Build Status Maintainability License: MIT

An elegant Ruby SDK for building AI agents that interact with both LLMs and system tools. The SDK follows a minimalist philosophy focusing on three core components:

  • 🌍 Environment: File-based agent communication and queueing
  • 🛠️ Tools: A unified registry for various capabilities (browser control, file operations, etc.)
  • 💬 Prompt: ERB templates for natural Ruby-style prompt interpolation

Philosophy

Not every problem needs an agent. Use agents when tasks are:

  • Complex with multiple steps
  • Valuable enough to justify LLM costs
  • Ambiguous requiring intelligence

Keep agents simple and focused - this enables faster iteration and better understanding of their behavior.

Installation

Install the gem and add to the application's Gemfile by executing:

bundle add aidarb

If bundler is not being used to manage dependencies, install the gem by executing:

gem install aidarb

Usage

require 'aira'

# Create a web content extractor agent
agent :web_extractor do
  description "Extract main content from a webpage and save as markdown"

  input :url
  output :markdown_file

  tools :web_browser, :markdown_converter

  prompt "    Given the URL <%= url %>, extract the main content.\n    Return the result as a markdown document.\n  ERB\n\n  # Optional validation loop\n  loop do |context|\n    File.exist?(context[:markdown_file])\n  end\nend\n\n# Create a summarization agent\nagent :summarizer do\n  description \"Create a concise summary of markdown content\"\n\n  input :markdown_file\n  output :summary\n\n  tools :file_ops\n\n  prompt <<-ERB\n    Read the markdown from <%= markdown_file %>\n    Create a concise summary focusing on key points.\n  ERB\nend\n\n# Run the agents in sequence\ncontext = {url: \"https://example.com/article\"}\nweb_extractor.run(context)\nsummarizer.run(context)\n"

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/cs3b/ai-ruby-agent-sdk.

License

The gem is available as open source under the terms of the MIT License.