Runnable examples for the phronomy gem.
bundle installAll examples load LLM settings from shared/llm_config.rb.
Edit that file to switch providers or models.
bundle exec ruby 01_basic_chain/run.rb| # | Directory | What it demonstrates |
|---|---|---|
| 01 | 01_basic_chain/ |
PromptTemplate → LLMChain pipeline |
| 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 guardrails |
| 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 + Phronomy::Memory (DB-backed conversation history) |
| 14 | 14_code_review/ |
Comprehensive pipeline — Guardrail, Splitter, Graph, ParallelNode, Interrupt/Resume, PromptTemplate, Agent (streaming), WindowMemory, OutputGuardrail, 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 |
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 the
phronomy:installgenerator (phronomy_messages/phronomy_checkpointstables,PhronomyMessage.phronomy_memory) MessagesController#createcallsChatAgent.new.invoke(content, config: { memory:, thread_id: })Phronomy::GuardrailErroris caught and returned as a 422 response- 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:
- InputGuardrail — rejects invalid/missing files before any LLM call
- Splitter — splits large files into chunks with
RecursiveSplitter - Graph + ParallelNode — runs Security / Performance / Readability agents concurrently
- 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
- WindowMemory — carries conversation context across repeat review sessions
- OutputGuardrail — 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.