Class: Silas::AgentLoopJob
- Inherits:
-
ActiveJob::Base
- Object
- ActiveJob::Base
- Silas::AgentLoopJob
- Includes:
- ActiveJob::Continuable
- Defined in:
- app/jobs/silas/agent_loop_job.rb
Overview
One durable turn. Step-name sequence: :prepare, :step_0, :step_1, …, :finalize. Every between-step loop-control read hits write-once persisted state (Step#terminal, invocation approval state at-or-after the cursor), so a resumed continuation regenerates the IDENTICAL sequence — the spike's hard-won determinism constraint, owned by the framework so users can't violate it.
Parking (approval / in-doubt) is a NORMAL job exit at zero compute; resume is a fresh job enqueued by approve!/decline!, replaying completed steps from rows (no model calls, no re-effects — StepRunner's replay path).
Instance Method Summary collapse
Instance Method Details
#perform(turn_id) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/jobs/silas/agent_loop_job.rb', line 19 def perform(turn_id) turn = Turn.find(turn_id) return if turn.completed? || %w[failed canceled].include?(turn.status) # Named-agent / subagent sessions run EVERY turn under their own scope # (tools, skills, instructions, digest) — including resumes: a rescued # turn re-enters here and re-establishes the same scope, so a crashed # staff member never wakes up holding the root agent's tools. scope = Silas.scope_for_session(turn.session) if scope Silas.with_agent_scope(scope) { drive(turn) } else drive(turn) end end |