Skip to content

v2.2.0 - Three-Role Prompt DSL

Choose a tag to compare

@adham90 adham90 released this 16 Feb 12:56
· 191 commits to main since this release

What's New in v2.2.0

Three-Role Prompt DSL

The prompt DSL now mirrors LLM API terminology with three explicit role methods:

class SearchAgent < ApplicationAgent
  model "gpt-4o"
  temperature 0.0

  system "You are a search intent analyzer."
  user "Extract search intent from: {query}"
  assistant '{"refined_query":'  # Force JSON output

  returns do
    string :refined_query
    array :filters, of: :string
  end
end

.ask for Conversational Agents

New class-level .ask method for one-off queries and conversational agents without a fixed user template:

class RubyExpert < ApplicationAgent
  model "claude-sonnet-4-5-20250929"
  system "You are a senior Ruby developer."
end

result = RubyExpert.ask("What's the difference between proc and lambda?")
puts result.content

# Streaming
RubyExpert.ask("Explain metaprogramming") { |chunk| print chunk.content }

Full Changelog

Added

  • user class-level DSL method for defining user prompts (replaces prompt)
  • assistant class-level DSL method for assistant prefill/priming
  • user_config and assistant_config for message-level options (e.g., cache_control)
  • .ask(message) class method for conversational agents
  • #assistant_prompt instance method (overridable for dynamic prefills)
  • System prompt now supports {placeholder} syntax with auto-registered params
  • Automatic parameter detection for system and assistant templates
  • resolved_assistant_prefill for assistant prefill resolution
  • execute_with_prefill for proper assistant message sequencing via RubyLLM

Changed

  • prompt is now a deprecated alias for user (backward-compatible)
  • prompt_config delegates to user_config
  • dry_run response now includes assistant_prompt
  • execution_options now includes assistant_prefill

Deprecated

  • prompt class-level DSL -- use user instead

Full Changelog: v2.1.0...v2.2.0