Class: Mistri::ToolCall
- Inherits:
-
Data
- Object
- Data
- Mistri::ToolCall
- Defined in:
- lib/mistri/tool_call.rb
Overview
One immutable tool invocation requested by the model. Completed arguments are deeply owned JSON; arguments_error records why an unsafe value became nil instead of letting it cross the execution boundary. Signature carries opaque replay state; provider_call_id distinguishes an optional wire ID from Mistri's always-present session correlation ID.
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#arguments_error ⇒ Object
readonly
Returns the value of attribute arguments_error.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#provider_call_id ⇒ Object
readonly
Returns the value of attribute provider_call_id.
-
#signature ⇒ Object
readonly
Returns the value of attribute signature.
Instance Method Summary collapse
- #arguments_error? ⇒ Boolean
- #arguments_owned? ⇒ Boolean
-
#initialize(id:, name:, arguments: {}, signature: nil, arguments_error: nil, provider_call_id: nil, canonicalize: true) ⇒ ToolCall
constructor
A new instance of ToolCall.
- #to_h ⇒ Object
- #type ⇒ Object
-
#with(id: self.id, name: self.name, arguments: self.arguments, signature: self.signature, arguments_error: self.arguments_error, provider_call_id: self.provider_call_id) ⇒ Object
Data#with bypasses custom initializers; this value must re-enter the ownership boundary whenever a normalizer replaces its arguments.
Constructor Details
#initialize(id:, name:, arguments: {}, signature: nil, arguments_error: nil, provider_call_id: nil, canonicalize: true) ⇒ ToolCall
Returns a new instance of ToolCall.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/mistri/tool_call.rb', line 13 def initialize(id:, name:, arguments: {}, signature: nil, arguments_error: nil, provider_call_id: nil, canonicalize: true) id = id.dup.freeze if id.is_a?(String) name = name.dup.freeze if name.is_a?(String) signature = signature.dup.freeze if signature.is_a?(String) provider_call_id = provider_call_id.dup.freeze if provider_call_id.is_a?(String) @arguments_owned = canonicalize || !arguments_error.nil? if arguments_error.nil? arguments, arguments_error = ToolArguments.canonicalize(arguments) if canonicalize else arguments = nil arguments_error = ToolArguments.normalize_error(arguments_error) end super(id:, name:, arguments:, signature:, arguments_error:, provider_call_id:) end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments
11 12 13 |
# File 'lib/mistri/tool_call.rb', line 11 def arguments @arguments end |
#arguments_error ⇒ Object (readonly)
Returns the value of attribute arguments_error
11 12 13 |
# File 'lib/mistri/tool_call.rb', line 11 def arguments_error @arguments_error end |
#id ⇒ Object (readonly)
Returns the value of attribute id
11 12 13 |
# File 'lib/mistri/tool_call.rb', line 11 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name
11 12 13 |
# File 'lib/mistri/tool_call.rb', line 11 def name @name end |
#provider_call_id ⇒ Object (readonly)
Returns the value of attribute provider_call_id
11 12 13 |
# File 'lib/mistri/tool_call.rb', line 11 def provider_call_id @provider_call_id end |
#signature ⇒ Object (readonly)
Returns the value of attribute signature
11 12 13 |
# File 'lib/mistri/tool_call.rb', line 11 def signature @signature end |
Instance Method Details
#arguments_error? ⇒ Boolean
31 |
# File 'lib/mistri/tool_call.rb', line 31 def arguments_error? = !arguments_error.nil? |
#arguments_owned? ⇒ Boolean
33 |
# File 'lib/mistri/tool_call.rb', line 33 def arguments_owned? = @arguments_owned |
#to_h ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/mistri/tool_call.rb', line 43 def to_h hash = { type: :tool_call, id:, name: }.compact hash[:arguments] = arguments hash[:signature] = signature unless signature.nil? hash[:arguments_error] = arguments_error unless arguments_error.nil? hash[:provider_call_id] = provider_call_id unless provider_call_id.nil? hash end |
#type ⇒ Object
29 |
# File 'lib/mistri/tool_call.rb', line 29 def type = :tool_call |
#with(id: self.id, name: self.name, arguments: self.arguments, signature: self.signature, arguments_error: self.arguments_error, provider_call_id: self.provider_call_id) ⇒ Object
Data#with bypasses custom initializers; this value must re-enter the ownership boundary whenever a normalizer replaces its arguments.
37 38 39 40 41 |
# File 'lib/mistri/tool_call.rb', line 37 def with(id: self.id, name: self.name, arguments: self.arguments, signature: self.signature, arguments_error: self.arguments_error, provider_call_id: self.provider_call_id) self.class.new(id:, name:, arguments:, signature:, arguments_error:, provider_call_id:) end |