Engineering notes on typed LLM programs, agents, evaluation, and Ruby.
Why field-level descriptions help Ruby LLM apps avoid valid-but-wrong structured extraction.
DSPy.rb 1.0.0 follows revisions that added TOON/BAML, RubyLLM, Anthropic structured outputs, Langfuse tracing, JSON coercion changes, and multimodal document support.
Apply familiar software disciplines to LLM programs: typed contracts, tests, traces, and repeatable evaluation.
How MIPROv2 compiles instructions and demonstrations from examples, metrics, and measured program behavior in DSPy.rb.
Does 'think step by step' help a simple summarization task? Compare two DSPy.rb modules against the same examples and judge.
Build a CodeAct research agent that chooses and executes Ruby code inside a bounded loop, with an explicit warning about process isolation.
Build a bounded generator-evaluator workflow in Ruby, with typed feedback, a token budget, and traces for each model call.
Route support tickets through typed DSPy.rb modules while Ruby keeps control of every branch, model, and fallback.
How TOON represents nested Sorbet structs and arrays that require flattening or extra conventions in CSV.
Use BAML for compact schema guidance and TOON for compact structured payloads in DSPy.rb's prompt-based path.
How BAML reduces schema guidance in DSPy.rb's prompt-based structured-response path.
A dated benchmark of prompt-based JSON and provider-native structured outputs across eight models.
How to run independent DSPy.rb calls concurrently inside one Sidekiq job, with explicit limits and accurate worker-thread semantics.
Define and calibrate an LLM judge for prospect relevance, personalization, professional tone, and sales-email review.
How DSPy.rb combines application-owned Async tasks, fiber-local context, synchronous events, and background OpenTelemetry export.
Configure DSPy.rb's optional Langfuse integration and inspect module, LM, and evaluation spans.
How DSPy.rb uses Ruby's Async runtime, where automatic retries existed, and which concurrency decisions remain with the application
Use Module#save or ProgramStorage to persist serializable program state and optimization metadata.
Configure the Gemini adapter, define typed predictions, pass inline images, and inspect provider metadata.
DSPy.with_lm applies a temporary language model override to the current fiber, with explicit precedence and exception-safe restoration.
DSPy.rb v0.20.0 added Google Gemini support, fiber-local LM overrides, and storage for serializable optimized programs.
Use a single union-typed output when an LM must choose among several structured actions.
Connect DSPy.rb to Ollama's OpenAI-compatible endpoint and validate local model output against Ruby signatures.
Use DSPy.rb's raw_chat API for direct provider conversations, instrumentation, and staged migration to typed modules.
How DSPy.rb converts model output into Sorbet structs, enums, arrays, and scalar values at runtime.
Program of Thought delegates computation to generated code. Here is how it differs from ChainOfThought and CodeAct, and why execution isolation matters.
CodeAct is a tool-using agent loop that generates and executes Ruby code. It ships in the optional dspy-code_act gem.
Build a bounded ReAct agent whose model chooses among typed Ruby tools while DSPy.rb records each action and observation.
How signatures, modules, blocks, tool objects, and ordinary Ruby control flow shape DSPy.rb's API.
Build a sentiment evaluation that distinguishes label accuracy, confidence calibration, and execution failures.
Define acceptable program behavior with examples and metrics, inspect failures, and use the same evidence to optimize DSPy.rb programs.
How DSPy.rb selects provider-native structured output, extracts JSON candidates, and constructs typed prediction values.
How provider-native structured outputs, prompt-based JSON, extraction, and runtime validation fit together in DSPy.rb.
Run independent DSPy.rb calls in sibling Async tasks, measure the result, and check whether the provider transport yields cooperatively.