About Dspy.Rb
DSPy.rb is a Ruby framework for building typed AI agents on the programming model of DSPy. Developers define a task contract as a signature with Sorbet types for inputs and outputs, hand the model narrow typed tools written in Ruby, and run a bounded loop such as ReAct in which the model chooses tools while Ruby executes them and enforces permissions, errors, side effects and iteration limits. The answer comes back in the declared type, and the run history records each tool choice and result.
It is aimed at Ruby and Rails teams that want LLM features with explicit contracts rather than loose prompt strings. It works with OpenAI, Anthropic, Gemini and Ollama models. Beyond agents, it supports evaluation of complete runs against examples and metrics, and optimizers that search for better instructions and demonstrations. A production guide covers typed runtime events, module lifecycle callbacks, concurrent predictions, Rails integration, storage and a registry for versioned optimized programs, OpenTelemetry observability and typed score reporting to Langfuse. The repository ships runnable examples, including a read only GitHub assistant agent.
DSPy.rb is free and open source under the MIT license, with the current release at version 1.0.2. There is no paid plan; the only costs are the language model provider fees an application incurs.
The project is maintained by Vicente Services SL and is a Ruby native implementation of DSPy's ideas, not an official port maintained by the original Python DSPy team.