Class: RubyLLM::Agents::Pipeline::Middleware::Base Abstract
- Inherits:
-
Object
- Object
- RubyLLM::Agents::Pipeline::Middleware::Base
- Defined in:
- lib/ruby_llm/agents/pipeline/middleware/base.rb
Overview
Subclass and implement #call
Base class for all middleware in the pipeline.
Middleware wraps the next handler in the chain and can:
-
Modify the context before passing it down
-
Short-circuit the chain (e.g., return cached result)
-
Handle errors from downstream
-
Modify the context after the response
Each middleware receives:
-
@app: The next handler in the chain (another middleware or the executor)
-
@agent_class: The agent class, for reading DSL configuration
Direct Known Subclasses
Constant Summary collapse
- LOG_TAG =
"[RubyLLM::Agents::Pipeline]"
Instance Method Summary collapse
-
#call(context) ⇒ Context
Process the context through this middleware.
-
#initialize(app, agent_class) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(app, agent_class) ⇒ Base
Returns a new instance of Base.
48 49 50 51 |
# File 'lib/ruby_llm/agents/pipeline/middleware/base.rb', line 48 def initialize(app, agent_class) @app = app @agent_class = agent_class end |
Instance Method Details
#call(context) ⇒ Context
Process the context through this middleware
Subclasses must implement this method. The typical pattern is:
-
Do pre-processing on context
-
Call @app.call(context) to continue the chain
-
Do post-processing on context
-
Return context
64 65 66 |
# File 'lib/ruby_llm/agents/pipeline/middleware/base.rb', line 64 def call(context) raise NotImplementedError, "#{self.class} must implement #call" end |