Class: Phronomy::Agent::Checkpoint
- Inherits:
-
Object
- Object
- Phronomy::Agent::Checkpoint
- Defined in:
- lib/phronomy/agent/checkpoint.rb
Overview
Encapsulates the suspended state of an agent invocation.
A Checkpoint is returned as the +:checkpoint+ key of the result hash when an approval-required tool is encountered and no synchronous on_approval_required handler has been registered.
Pass the checkpoint to Agent::Base#resume to continue execution after obtaining an approval decision from the user or an external system.
Instance Attribute Summary collapse
-
#messages ⇒ Array<RubyLLM::Message>
readonly
Conversation messages up to and including the assistant message that requested the pending tool call.
-
#pending_tool_args ⇒ Hash
readonly
The arguments the LLM passed to the pending tool.
-
#pending_tool_call_id ⇒ String
readonly
The tool_call_id from the LLM response (required to inject the tool result message on resume).
-
#pending_tool_name ⇒ String
readonly
The name of the tool awaiting approval.
-
#thread_id ⇒ String?
readonly
The thread_id from the invocation config.
Instance Method Summary collapse
-
#initialize(thread_id:, messages:, pending_tool_name:, pending_tool_args:, pending_tool_call_id:) ⇒ Checkpoint
constructor
A new instance of Checkpoint.
Constructor Details
#initialize(thread_id:, messages:, pending_tool_name:, pending_tool_args:, pending_tool_call_id:) ⇒ Checkpoint
Returns a new instance of Checkpoint.
44 45 46 47 48 49 50 |
# File 'lib/phronomy/agent/checkpoint.rb', line 44 def initialize(thread_id:, messages:, pending_tool_name:, pending_tool_args:, pending_tool_call_id:) @thread_id = thread_id @messages = .dup.freeze @pending_tool_name = pending_tool_name @pending_tool_args = pending_tool_args @pending_tool_call_id = pending_tool_call_id end |
Instance Attribute Details
#messages ⇒ Array<RubyLLM::Message> (readonly)
Returns conversation messages up to and including the assistant message that requested the pending tool call.
27 28 29 |
# File 'lib/phronomy/agent/checkpoint.rb', line 27 def @messages end |
#pending_tool_args ⇒ Hash (readonly)
Returns the arguments the LLM passed to the pending tool.
33 34 35 |
# File 'lib/phronomy/agent/checkpoint.rb', line 33 def pending_tool_args @pending_tool_args end |
#pending_tool_call_id ⇒ String (readonly)
Returns the tool_call_id from the LLM response (required to inject the tool result message on resume).
37 38 39 |
# File 'lib/phronomy/agent/checkpoint.rb', line 37 def pending_tool_call_id @pending_tool_call_id end |
#pending_tool_name ⇒ String (readonly)
Returns the name of the tool awaiting approval.
30 31 32 |
# File 'lib/phronomy/agent/checkpoint.rb', line 30 def pending_tool_name @pending_tool_name end |
#thread_id ⇒ String? (readonly)
Returns the thread_id from the invocation config.
23 24 25 |
# File 'lib/phronomy/agent/checkpoint.rb', line 23 def thread_id @thread_id end |