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
The client-supplied context entries, as frozen hashes.
The canonical digest of the accepted input, for run identity.
Application-specific values passed through untouched.
The parsed conversation, as AgUiProtocol::Core::Types message models.
The run that spawned this one, when the client sets one.
The AG-UI protocol version the client declared, or nil when absent.
The resume entries answering a previous run’s interrupts.
Identifies this run.
The state the run starts from.
The conversation this run belongs to.
The client-supplied tool definitions, as frozen hashes. Never used to authorize a host tool.
Non-fatal observations made while parsing (unknown members stripped).
Public Class Methods
# 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
# 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
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
Whether this run answers a previous run’s interrupts.
# File lib/ruby_llm/ag_ui/input.rb, line 108 def resume? !@resume.empty? end
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
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
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