class RubyLLM::AgUI::Input

A validated AG-UI 1.0 RunAgentInput.

The community Ruby SDK models RunAgentInput but has no JSON to model parser, so hosts parse and authorize the body by hand. This class does that once: it bounds the body size, decodes it, strips members the pinned schema does not define, validates the shapes the schema requires, and hands the run typed values and a stable digest for run identity.

input = RubyLLM::AgUI::Input.parse(request_body, max_bytes: 256_000)
input.thread_id   # => "thread-1"
input.resume      # => [#<RubyLLM::AgUI::ResumeEntry ...>]
input.digest      # => "9f2c..."

Nothing here grants trust. Client messages, state, tools, context and forwardedProps are accepted as data only; the host decides which tools and model a run may use, and client history is reconciled by id against host-stored history rather than appended as trusted system or tool turns.

Constants

SUPPORTED_PROTOCOL_VERSIONS

The protocol versions this gem can act on.

TOP_LEVEL_KEYS

Members the pinned RunAgentInput schema defines. Anything else is not part of the contract and is stripped (or rejected with strict: true).

Attributes

context[R]

The client-supplied context entries, as frozen hashes.

digest[R]

The canonical digest of the accepted input, for run identity.

forwarded_props[R]

Application-specific values passed through untouched.

messages[R]

The parsed conversation, as AgUiProtocol::Core::Types message models.

parent_run_id[R]

The run that spawned this one, when the client sets one.

protocol_version[R]

The AG-UI protocol version the client declared, or nil when absent.

resume[R]

The resume entries answering a previous run’s interrupts.

run_id[R]

Identifies this run.

state[R]

The state the run starts from.

thread_id[R]

The conversation this run belongs to.

tools[R]

The client-supplied tool definitions, as frozen hashes. Never used to authorize a host tool.

warnings[R]

Non-fatal observations made while parsing (unknown members stripped).

Public Class Methods

new(attributes) click to toggle source
# File lib/ruby_llm/ag_ui/input.rb, line 73
def initialize(attributes)
  @thread_id = attributes[:thread_id]
  @run_id = attributes[:run_id]
  @parent_run_id = attributes[:parent_run_id]
  @protocol_version = attributes[:protocol_version]
  @state = attributes[:state]
  @messages = attributes[:messages]
  @tools = attributes[:tools]
  @context = attributes[:context]
  @forwarded_props = attributes[:forwarded_props]
  @resume = attributes[:resume]
  @digest = attributes[:digest]
  @normalized = attributes[:normalized]
  @warnings = attributes[:warnings]
  freeze
end
parse(raw, max_bytes: nil, strict: false, logger: nil) click to toggle source
# File lib/ruby_llm/ag_ui/input.rb, line 69
def self.parse(raw, max_bytes: nil, strict: false, logger: nil)
  Parser.new(raw, max_bytes: max_bytes, strict: strict, logger: logger).parse
end

Public Instance Methods

client_tools?() click to toggle source

Whether the client supplied tool definitions. The first release never grants them; a run reports them and stops.

# File lib/ruby_llm/ag_ui/input.rb, line 103
def client_tools?
  !@tools.empty?
end
resume?() click to toggle source

Whether this run answers a previous run’s interrupts.

# File lib/ruby_llm/ag_ui/input.rb, line 108
def resume?
  !@resume.empty?
end
resume_entry(interrupt_id) click to toggle source

The resume entry for interrupt_id, or nil.

# File lib/ruby_llm/ag_ui/input.rb, line 113
def resume_entry(interrupt_id)
  @resume.find { |entry| entry.interrupt_id == interrupt_id }
end
to_h() click to toggle source

The accepted input as a plain hash with camelCase keys and the members the schema defines. Suitable for echoing as RUN_STARTED.input.

# File lib/ruby_llm/ag_ui/input.rb, line 92
def to_h
  @normalized
end
tool_names() click to toggle source

The names of the client-supplied tools. Informational only.

# File lib/ruby_llm/ag_ui/input.rb, line 97
def tool_names
  @tools.filter_map { |tool| tool['name'] }
end