Runnable examples for the phronomy gem.
bundle installAll examples load LLM settings from shared/llm_config.rb, which reads from
environment variables. No source file editing is required.
| Variable | Default | Description |
|---|---|---|
PHRONOMY_MODEL |
gpt-4o-mini |
Model identifier (e.g. gpt-4o, claude-3-5-sonnet-20241022) |
PHRONOMY_PROVIDER |
(auto-inferred) | Provider symbol (e.g. openai, anthropic). Leave unset for standard models. |
PHRONOMY_BASE_URL |
(provider default) | Base URL for local/custom endpoints (LM Studio, Ollama, vLLM, etc.) |
PHRONOMY_API_KEY |
(from OPENAI_API_KEY) |
API key. Falls back to OPENAI_API_KEY for OpenAI. |
PHRONOMY_CONTEXT_WINDOW |
(auto-detected or 8192) | Override context window size in tokens. |
export OPENAI_API_KEY="sk-..."
bundle exec ruby 01_basic_chain/run.rbexport PHRONOMY_MODEL="openai/gpt-oss-20b"
export PHRONOMY_BASE_URL="http://127.0.0.1:1234/v1"
export PHRONOMY_API_KEY="lm-studio"
bundle exec ruby 01_basic_chain/run.rbbundle exec ruby 01_basic_chain/run.rb| # | Directory | What it demonstrates |
|---|---|---|
| 01 | 01_basic_chain/ |
Minimal Workflow pipeline using WorkflowContext and Workflow.define |
| 02 | 02_react_agent/ |
ReAct Agent with custom tools |
| 03 | 03_state_graph/ |
Stateful branching graph |
| 04 | 04_interrupt_resume/ |
Human-in-the-loop with interrupt/resume |
| 05 | 05_multi_agent/ |
Multi-Agent LLM-driven coordination (Agent-as-Tool) |
| 06 | 06_guardrails/ |
Input and output blocking filters |
| 07 | 07_tracing/ |
Custom span-based tracer |
| 08 | 08_mcp_tool/ |
MCP server tool integration |
| 09 | 09_rails_chat/ |
Rails web chat app using Phronomy::Agent with manually persisted conversation history (DB-backed via PhronomyMessage) |
| 14 | 14_code_review/ |
Comprehensive pipeline — BlockingFilter, Splitter, Graph, Parallel branches, Interrupt/Resume, PromptTemplate, Agent (streaming), OutputFilter, Eval (LLMJudge), Tracing |
| 16 | 16_before_completion_hook/ |
Global / class / instance before_completion hooks — logging, param overrides |
| 17 | 17_multi_agent_handoff/ |
Hub-and-spoke routing with Phronomy::Agent::Runner — triage → specialist handoff |
| 18 | 18_rails_agent_job/ |
Rails 8 + ActionCable real-time streaming via Phronomy::Rails::AgentJob |
| 19 | 19_trust_pipeline/ |
Trustworthy output via Citation Tracking + Self-Review Loop + Confidence Gate |
| 20 | 20_cve_scanner/ |
Rails 8 Web UI — CVE vulnerability scanning + remediation with CHECK LOOP / REMEDIATION LOOP, interrupt/approve gates, ActionCable real-time streaming |
| 27 | 27_issue_analyzer/ |
Batch GitHub Issue classifier — two-axis (WHAT × WHERE) LLM classification, 2D histogram, CSV export; demonstrates Agent::Base for structured-output batch processing |
A full Rails web app that integrates phronomy as the conversation engine.
ChatAgent < Phronomy::Agent::Basewith aCurrentTimeTool < Phronomy::Tool::Base- DB-backed conversation history via
PhronomyMessage(application-managed persistence) MessagesController#createloads history withPhronomyMessage.load_messages(thread_id), callsChatAgent.new.invoke(content, messages: messages, thread_id: thread_id), then saves the result withPhronomyMessage.save_messages(thread_id, result[:messages])- Configured in
config/initializers/phronomy.rb
cd 09_rails_chat
bundle install
bin/rails db:prepare
bin/rails server -p 4567Then open http://localhost:4567/.
A comprehensive example that exercises the majority of phronomy's features in a single CLI pipeline. Supply a Ruby source file and the pipeline:
- InputFilter — rejects invalid/missing files before any LLM call
- Splitter — splits large files into chunks with
RecursiveSplitter - Graph + Parallel branches — runs Security / Performance / Readability / Abstraction agents concurrently via
Runtimenamed pools andBlockingAdapterPool - Interrupt/Resume — pauses after reviews so you can choose which area to fix
- PromptTemplate — formats the improvement prompt from variables
- Agent (streaming) — generates improved code with real-time token output
- OutputFilter — validates that the improved code contains a code block
- Eval (LLMJudge) — scores review quality and improvement quality out of 10
- Tracing — measures and prints elapsed time for every pipeline stage
bundle exec ruby 14_code_review/run.rb
# When prompted, enter: 14_code_review/sample.rbsample.rb is a demo file with intentional Security, Performance, and Readability issues.