Module: Phronomy

Defined in:
lib/phronomy.rb,
lib/phronomy/eval.rb,
lib/phronomy/tool.rb,
lib/phronomy/agent.rb,
lib/phronomy/event.rb,
lib/phronomy/loader.rb,
lib/phronomy/context.rb,
lib/phronomy/version.rb,
lib/phronomy/runnable.rb,
lib/phronomy/splitter.rb,
lib/phronomy/workflow.rb,
lib/phronomy/agent/fsm.rb,
lib/phronomy/tool/base.rb,
lib/phronomy/agent/base.rb,
lib/phronomy/embeddings.rb,
lib/phronomy/event_loop.rb,
lib/phronomy/eval/runner.rb,
lib/phronomy/eval/scorer.rb,
lib/phronomy/fsm_session.rb,
lib/phronomy/loader/base.rb,
lib/phronomy/token_usage.rb,
lib/phronomy/agent/runner.rb,
lib/phronomy/eval/dataset.rb,
lib/phronomy/eval/metrics.rb,
lib/phronomy/tracing/base.rb,
lib/phronomy/vector_store.rb,
lib/phronomy/agent/handoff.rb,
lib/phronomy/configuration.rb,
lib/phronomy/output_parser.rb,
lib/phronomy/splitter/base.rb,
lib/phronomy/tool/mcp_tool.rb,
lib/phronomy/eval/eval_case.rb,
lib/phronomy/guardrail/base.rb,
lib/phronomy/embeddings/base.rb,
lib/phronomy/eval/comparison.rb,
lib/phronomy/prompt_template.rb,
lib/phronomy/tool/agent_tool.rb,
lib/phronomy/workflow_runner.rb,
lib/phronomy/agent/checkpoint.rb,
lib/phronomy/eval/eval_result.rb,
lib/phronomy/eval/scorer/base.rb,
lib/phronomy/knowledge_source.rb,
lib/phronomy/state_store/base.rb,
lib/phronomy/workflow_context.rb,
lib/phronomy/agent/react_agent.rb,
lib/phronomy/context/assembler.rb,
lib/phronomy/loader/csv_loader.rb,
lib/phronomy/vector_store/base.rb,
lib/phronomy/agent/orchestrator.rb,
lib/phronomy/agent/shared_state.rb,
lib/phronomy/cancellation_token.rb,
lib/phronomy/generator_verifier.rb,
lib/phronomy/output_parser/base.rb,
lib/phronomy/tracing/null_tracer.rb,
lib/phronomy/agent/suspend_signal.rb,
lib/phronomy/context/token_budget.rb,
lib/phronomy/context/trim_context.rb,
lib/phronomy/eval/scorer/llm_judge.rb,
lib/phronomy/knowledge_source/base.rb,
lib/phronomy/state_store/in_memory.rb,
lib/phronomy/vector_store/pgvector.rb,
lib/phronomy/agent/team_coordinator.rb,
lib/phronomy/loader/markdown_loader.rb,
lib/phronomy/vector_store/in_memory.rb,
lib/phronomy/context/token_estimator.rb,
lib/phronomy/context/trigger_context.rb,
lib/phronomy/eval/scorer/exact_match.rb,
lib/phronomy/tracing/langfuse_tracer.rb,
lib/phronomy/agent/concerns/retryable.rb,
lib/phronomy/agent/parallel_tool_chat.rb,
lib/phronomy/loader/plain_text_loader.rb,
lib/phronomy/guardrail/input_guardrail.rb,
lib/phronomy/output_parser/json_parser.rb,
lib/phronomy/vector_store/redis_search.rb,
lib/phronomy/agent/concerns/suspendable.rb,
lib/phronomy/context/compaction_context.rb,
lib/phronomy/guardrail/output_guardrail.rb,
lib/phronomy/eval/scorer/includes_scorer.rb,
lib/phronomy/splitter/recursive_splitter.rb,
lib/phronomy/agent/concerns/guardrailable.rb,
lib/phronomy/splitter/fixed_size_splitter.rb,
lib/phronomy/context/context_version_cache.rb,
lib/phronomy/tracing/open_telemetry_tracer.rb,
lib/phronomy/embeddings/ruby_llm_embeddings.rb,
lib/phronomy/knowledge_source/rag_knowledge.rb,
lib/phronomy/agent/before_completion_context.rb,
lib/phronomy/output_parser/structured_parser.rb,
lib/phronomy/agent/concerns/before_completion.rb,
lib/phronomy/agent/concerns/error_translation.rb,
lib/phronomy/knowledge_source/entity_knowledge.rb,
lib/phronomy/knowledge_source/static_knowledge.rb

Defined Under Namespace

Modules: Agent, Context, Embeddings, Eval, Guardrail, KnowledgeSource, Loader, OutputParser, Runnable, Splitter, StateStore, Tool, Tracing, VectorStore, WorkflowContext Classes: AuthenticationError, CancellationError, CancellationToken, Configuration, ConfigurationError, ContextLengthError, Error, Event, EventLoop, FSMSession, GeneratorVerifier, GuardrailError, HandoffError, LowConfidenceError, ParseError, PromptTemplate, RateLimitError, RecursionLimitError, TimeoutError, TokenUsage, ToolError, TransportError, Workflow, WorkflowRunner

Constant Summary collapse

VERSION =
"0.7.0"

Class Method Summary collapse

Class Method Details

.configurationObject



80
81
82
# File 'lib/phronomy.rb', line 80

def configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:



84
85
86
# File 'lib/phronomy.rb', line 84

def configure
  yield configuration
end

.reset_configuration!Object

Resets the global Phronomy configuration to defaults.

Intended for test suites only. Calling this in a production process will drop all runtime configuration (tracer, model, tokenizer, etc.) globally and immediately affect all subsequent agent and workflow calls.

Parallel test suites warning: When tests run in parallel (e.g. parallel_tests or parallel_rspec), +reset_configuration!+ in one worker will clear configuration shared with other workers in the same process. Prefer process-isolation strategies (forked workers) over thread-based parallelism when using this method.

Typical usage in a sequential test suite: after { Phronomy.reset_configuration! }



102
103
104
# File 'lib/phronomy.rb', line 102

def reset_configuration!
  @configuration = Configuration.new
end

.reset_runtime!Object

Resets all Phronomy runtime state: configuration and the EventLoop singleton (if running).

Intended for test suites only. Stops any running EventLoop thread, clears the EventLoop singleton, and resets configuration to defaults. Call once before/after each example to ensure test isolation.

Examples:

config.around { |ex| Phronomy.reset_runtime! ; ex.run ; Phronomy.reset_runtime! }


135
136
137
138
# File 'lib/phronomy.rb', line 135

def reset_runtime!
  Phronomy::EventLoop.reset!
  @configuration = Configuration.new
end

.with_configuration {|config| ... } ⇒ Object

Yields the current Configuration object, then restores the original configuration on exit (even if the block raises).

Intended for test helpers that need to temporarily override settings without permanently mutating the global configuration.

Examples:

Phronomy.with_configuration do |c|
  c.logger = Logger.new($stdout)
end

Yields:



118
119
120
121
122
123
# File 'lib/phronomy.rb', line 118

def with_configuration
  original = @configuration&.dup
  yield configuration
ensure
  @configuration = original
end