Ruby SDK

Harness

Create the Ruby harness, start a run for a task and guard your agent's tool calls.

Scute::Harness puts guards in front of each tool call your agent makes. Every guard answers, and the strictest enforced answer wins. For what each guard does, the decision kinds and the human steps, see Harness. This page shows the Ruby API.

Create the harness#

harness = Scute::Harness.new(  agent: "support-bot",  guards: [    Scute::Guards.permissions,    Scute::Guards.approval(when: { tier: :high }),    Scute::Guards.grounding,    Scute::Guards.args(refund_invoice: { amount: { max: 500 } }),    Scute::Guards.budget(calls: 20, per_hour: { high: 5 }),    Scute::Guards.content(pii: %i[card ssn])  ],  tools: { refund_invoice: { tier: :high } },  store: Scute::Harness::CacheStore.new(Rails.cache))
agentStringrequired
The agent's slug in Scute (see Agents). Missing raises Scute::ConfigurationError.
guardsArray
Default [Scute::Guards.permissions].
toolsHash
Per-tool settings: permission: (a string, or false for none), tier:, key:, attributes:, resource:. false instead of a Hash means the tool needs no permission.
modeSymbol
:enforce (default), :monitor or :observe, for guards that set no mode of their own.
default_tierSymbol
Default :low.
storeObject
Where run state lives. Default Scute::Harness::MemoryStore.new (one process). Use Scute::Harness::CacheStore.new(Rails.cache) with more than one process. Any object with get(key) and set(key, value, ttl) works.
clientScute::Client
Default Scute::Client.new with any extra keyword arguments.
on_decisionProc
Called with every decision (run, agent, tool, call_id, phase, kind, guard, reason, message, results, ms).
on_alertProc
Called when a :monitor guard would have blocked.

Tool names map to permissions: refund_invoice needs invoice:refund on the invoice named by invoice_id (or invoiceId, or id). The arguments reach the engine as context.args.

Guards#

FactoryKeyword arguments
Scute::Guards.permissionsfile_requests: true, context: nil, mode:
Scute::Guards.verify_personwhen:, methods:, max_age: 900, message:, mode:
Scute::Guards.approvalwhen: (default { tier: :high }), message:, mode:
Scute::Guards.requester_onlyarg: :email, when:, mode:
Scute::Guards.groundingargs:, min_length: 3, when:, mode:
Scute::Guards.args(rules)rules per tool and field: min, max, max_length, pattern, one_of, or a lambda; mode:
Scute::Guards.budgetcalls:, per_hour: (a number or a Hash per tier), usd_per_run:, mode:
Scute::Guards.contentpii: (:card, :ssn, :email, :phone), secrets: true, injection: :block (or :flag, false), providers: [], mode:
Scute::Guards.decoy(tools)report: true, mode:
Scute::Guards.define(name) with a block that takes the callmode:, after: (a proc that takes the call and the result)

when: is { tier: ..., tools: [...] } or a proc that takes the call.

A custom guard answers with call.proceed, call.deny(message), call.guide(message), call.verify, call.approve, call.transform(args) or call.redirect(tool). nil means proceed. A guard that raises counts as deny.

Scute::Guards.define("no-weekend-refunds") do |call|  call.guide("Refunds wait until Monday.") if call.tool == "refund_invoice" && [0, 6].include?(Time.now.utc.wday)end

Start a run#

run = harness.run(id: conversation.id, acts_for: user.scute_id, task: { actions: %w[invoice:read invoice:refund] })

harness.run takes id: (reuse it to resume), acts_for:, task: (actions:, resources:, ttl:, ref:), requester:, parent:, token: (a task token your backend minted), session: and context:. The run starts the task on first use with SCUTE_SECRET. Without a secret, pass token:.

Guard a tool#

refund = run.wrap("refund_invoice") { |args| Billing.refund(**args) }refund.call(invoice_id: "INV-1", amount: 90)  # the result, or a message for the model

For other loops, call run.check(tool, args) and, when verdict.runs?, run the tool and pass its result through run.after(tool, verdict.args, result).

RubyLLM#

chat = RubyLLM.chatchat.with_tool(run.ruby_llm(RefundInvoice, chat: chat))chat.with_tools(*run.ruby_llm_human_tools)

See RubyLLM adapter.

Other run methods#

MethodDoes
start_verification(method:), submit_code(code), verification_statusVerify the person with the task token.
confirm(tool, args)The person confirmed this exact call in your UI.
approval_status(id)Where a reviewer approval stands.
request_plan(calls, reason:), plan_statusOne review for several calls.
preview(tool, args)A dry run; uses nothing up. Returns a Scute::Authz::Decision.
report_tools(definitions)Reports a hash of each tool definition so Scute notices drift.
property(name), sign(name, claims:) or sign(name, data:)Read an app secret or sign with an app key pair, inside a tool.
ground(*values), identify(*values)Values known to be true, and who is asking.
whoami, task_id, snapshotThe task, and what the run remembers (tokens masked).
complete!, revoke!End the task.