Class: SolidLoop::Pipeline::ToolContext
- Inherits:
-
Object
- Object
- SolidLoop::Pipeline::ToolContext
- Defined in:
- lib/solid_loop/pipeline/tool_context.rb
Instance Attribute Summary collapse
-
#agent ⇒ Object
Returns the value of attribute agent.
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#exception ⇒ Object
Returns the value of attribute exception.
-
#execution_token ⇒ Object
Returns the value of attribute execution_token.
-
#is_success ⇒ Object
Returns the value of attribute is_success.
-
#lease_token ⇒ Object
The per-tool_call lease token this worker claimed.
-
#loop ⇒ Object
Returns the value of attribute loop.
-
#message ⇒ Object
Returns the value of attribute message.
-
#metadata ⇒ Object
Hash for middlewares to share custom state.
-
#result ⇒ Object
Working State.
-
#tool_call ⇒ Object
Loaded Context.
-
#tool_call_id ⇒ Object
Inputs.
Instance Method Summary collapse
-
#initialize(tool_call_id:) ⇒ ToolContext
constructor
A new instance of ToolContext.
- #loop_active? ⇒ Boolean
- #loop_active_fresh? ⇒ Boolean
- #skip_execution!(result:, success: false, duration: 0.0) ⇒ Object
- #skip_execution? ⇒ Boolean
Constructor Details
#initialize(tool_call_id:) ⇒ ToolContext
Returns a new instance of ToolContext.
25 26 27 28 |
# File 'lib/solid_loop/pipeline/tool_context.rb', line 25 def initialize(tool_call_id:) @tool_call_id = tool_call_id @metadata = {} end |
Instance Attribute Details
#agent ⇒ Object
Returns the value of attribute agent.
11 12 13 |
# File 'lib/solid_loop/pipeline/tool_context.rb', line 11 def agent @agent end |
#duration ⇒ Object
Returns the value of attribute duration.
14 15 16 |
# File 'lib/solid_loop/pipeline/tool_context.rb', line 14 def duration @duration end |
#exception ⇒ Object
Returns the value of attribute exception.
16 17 18 |
# File 'lib/solid_loop/pipeline/tool_context.rb', line 16 def exception @exception end |
#execution_token ⇒ Object
Returns the value of attribute execution_token.
18 19 20 |
# File 'lib/solid_loop/pipeline/tool_context.rb', line 18 def execution_token @execution_token end |
#is_success ⇒ Object
Returns the value of attribute is_success.
15 16 17 |
# File 'lib/solid_loop/pipeline/tool_context.rb', line 15 def is_success @is_success end |
#lease_token ⇒ Object
The per-tool_call lease token this worker claimed. The SECOND fence, alongside execution_token: the canonical completion write re-validates BOTH under the row lock, so a stale worker whose tool lease was revoked by pause/reclaim writes nothing.
23 24 25 |
# File 'lib/solid_loop/pipeline/tool_context.rb', line 23 def lease_token @lease_token end |
#loop ⇒ Object
Returns the value of attribute loop.
10 11 12 |
# File 'lib/solid_loop/pipeline/tool_context.rb', line 10 def loop @loop end |
#message ⇒ Object
Returns the value of attribute message.
9 10 11 |
# File 'lib/solid_loop/pipeline/tool_context.rb', line 9 def @message end |
#metadata ⇒ Object
Hash for middlewares to share custom state
17 18 19 |
# File 'lib/solid_loop/pipeline/tool_context.rb', line 17 def @metadata end |
#result ⇒ Object
Working State
13 14 15 |
# File 'lib/solid_loop/pipeline/tool_context.rb', line 13 def result @result end |
#tool_call ⇒ Object
Loaded Context
8 9 10 |
# File 'lib/solid_loop/pipeline/tool_context.rb', line 8 def tool_call @tool_call end |
#tool_call_id ⇒ Object
Inputs
5 6 7 |
# File 'lib/solid_loop/pipeline/tool_context.rb', line 5 def tool_call_id @tool_call_id end |
Instance Method Details
#loop_active? ⇒ Boolean
30 31 32 33 34 |
# File 'lib/solid_loop/pipeline/tool_context.rb', line 30 def loop_active? return true unless @loop # Fail closed: a context without a generation token never owns the loop. @loop.running? && @execution_token.present? && @loop.execution_token == @execution_token end |
#loop_active_fresh? ⇒ Boolean
36 37 38 39 |
# File 'lib/solid_loop/pipeline/tool_context.rb', line 36 def loop_active_fresh? @loop.reload loop_active? end |
#skip_execution!(result:, success: false, duration: 0.0) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/solid_loop/pipeline/tool_context.rb', line 41 def skip_execution!(result:, success: false, duration: 0.0) @skip_execution = true @result = result @is_success = success @duration = duration end |
#skip_execution? ⇒ Boolean
48 49 50 |
# File 'lib/solid_loop/pipeline/tool_context.rb', line 48 def skip_execution? @skip_execution == true end |