Class: Brute::Middleware::SessionPersistence
- Defined in:
- lib/brute/middleware/session_persistence.rb
Overview
Saves the conversation to disk after each LLM call.
Runs POST-call: delegates to Session#save. Failures are non-fatal —a broken session save should never crash the agent loop.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, session:) ⇒ SessionPersistence
constructor
A new instance of SessionPersistence.
Constructor Details
#initialize(app, session:) ⇒ SessionPersistence
Returns a new instance of SessionPersistence.
16 17 18 19 |
# File 'lib/brute/middleware/session_persistence.rb', line 16 def initialize(app, session:) super(app) @session = session end |
Instance Method Details
#call(env) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/brute/middleware/session_persistence.rb', line 21 def call(env) response = @app.call(env) begin @session.save(env[:context]) rescue => e warn "[brute] Session save failed: #{e.}" end response end |