Class: RobotLab::A2A::NetworkAdapter

Inherits:
A2A::Server::AgentExecutor
  • Object
show all
Defined in:
lib/robot_lab/a2a/network_adapter.rb

Overview

Wraps a RobotLab::Network as an A2A AgentExecutor.

Only :none interactive mode is supported — interactive flows require per-robot queue injection across all network robots, planned for a future release. Wrap individual robots with RobotAdapter for interactive flows.

Instance Method Summary collapse

Constructor Details

#initialize(network, interactive: :none) ⇒ NetworkAdapter

Returns a new instance of NetworkAdapter.



11
12
13
14
15
16
17
18
19
20
# File 'lib/robot_lab/a2a/network_adapter.rb', line 11

def initialize(network, interactive: :none)
  super()
  if interactive != :none
    raise ArgumentError,
          'NetworkAdapter only supports interactive: :none. ' \
          'For interactive network flows, wrap individual robots with RobotAdapter.'
  end

  @network = network
end

Instance Method Details

#call(context) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/robot_lab/a2a/network_adapter.rb', line 22

def call(context)
  context.task.start!
  context.emit_status

  input_text = context.message.text_content
  reply      = @network.run(message: input_text).last_text_content

  artifact = ::A2A::Models::Artifact.new(
    parts: [::A2A::Models::Part.text(reply.to_s)],
    name: 'reply'
  )
  context.task.complete!(artifacts: [artifact])
  context.emit_status(final: true)
end