Class: AgUiProtocol::Core::Events::ToolCallChunkEvent

Inherits:
BaseEvent show all
Defined in:
lib/ag_ui_protocol/core/events.rb

Overview

Convenience event for tool calls without manually emitting ‘ToolCallStartEvent`/`ToolCallEndEvent`.

“‘ruby

event = AgUiProtocol::Core::Events::ToolCallChunkEvent.new(

tool_call_id: "tc1",
tool_call_name: "search",
delta: "{\"q\":\"AG-UI\"}"

)

“‘

Behavior:

  • Convenience: Consumers may expand chunk sequences into the standard start/args/end triad (the JS/TS client does this automatically).

  • First chunk requirements: Include both ‘tool_call_id` and `tool_call_name` on the first chunk.

  • Streaming: Subsequent chunks with the same ‘tool_call_id` correspond to args pieces; completion triggers an implied end in clients that perform expansion.

Instance Attribute Summary collapse

Attributes inherited from BaseEvent

#raw_event, #timestamp, #type

Instance Method Summary collapse

Methods inherited from Types::Model

#as_json, #to_json

Constructor Details

#initialize(tool_call_id: nil, tool_call_name: nil, parent_message_id: nil, delta: nil, timestamp: nil, raw_event: nil) ⇒ ToolCallChunkEvent

Returns a new instance of ToolCallChunkEvent.



487
488
489
490
491
492
493
# File 'lib/ag_ui_protocol/core/events.rb', line 487

def initialize(tool_call_id: nil, tool_call_name: nil, parent_message_id: nil, delta: nil, timestamp: nil, raw_event: nil)
  super(type: EventType::TOOL_CALL_CHUNK, timestamp: timestamp, raw_event: raw_event)
  @tool_call_id = tool_call_id
  @tool_call_name = tool_call_name
  @parent_message_id = parent_message_id
  @delta = delta
end

Instance Attribute Details

#deltaObject (readonly)

Returns the value of attribute delta.



469
470
471
# File 'lib/ag_ui_protocol/core/events.rb', line 469

def delta
  @delta
end

#parent_message_idObject (readonly)

Returns the value of attribute parent_message_id.



466
467
468
# File 'lib/ag_ui_protocol/core/events.rb', line 466

def parent_message_id
  @parent_message_id
end

#tool_call_idObject (readonly)

Returns the value of attribute tool_call_id.



460
461
462
# File 'lib/ag_ui_protocol/core/events.rb', line 460

def tool_call_id
  @tool_call_id
end

#tool_call_nameObject (readonly)

Returns the value of attribute tool_call_name.



463
464
465
# File 'lib/ag_ui_protocol/core/events.rb', line 463

def tool_call_name
  @tool_call_name
end

Instance Method Details

#to_hObject



496
497
498
499
500
501
502
503
# File 'lib/ag_ui_protocol/core/events.rb', line 496

def to_h
  super.merge(
    tool_call_id: @tool_call_id,
    tool_call_name: @tool_call_name,
    parent_message_id: @parent_message_id,
    delta: @delta
  )
end