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))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#
| Factory | Keyword arguments |
|---|---|
| Scute::Guards.permissions | file_requests: true, context: nil, mode: |
| Scute::Guards.verify_person | when:, methods:, max_age: 900, message:, mode: |
| Scute::Guards.approval | when: (default { tier: :high }), message:, mode: |
| Scute::Guards.requester_only | arg: :email, when:, mode: |
| Scute::Guards.grounding | args:, 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.budget | calls:, per_hour: (a number or a Hash per tier), usd_per_run:, mode: |
| Scute::Guards.content | pii: (: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 call | mode:, 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)endStart 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 modelFor 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#
| Method | Does |
|---|---|
| start_verification(method:), submit_code(code), verification_status | Verify 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_status | One 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, snapshot | The task, and what the run remembers (tokens masked). |
| complete!, revoke! | End the task. |