scute.harness runs guards on each tool call your agent makes, backed by Scute's engine for what the agent, the person it works for and the task allow. This page shows the Python setup. For guards, verdicts, runs and people in the loop, see Harness.
from scute.harness import Harness, guardsharness = Harness( agent="support-bot", guards=[ guards.permissions(), guards.approval(when={"tier": "high"}), guards.budget(calls=20), ], tools={"refund_invoice": {"tier": "high"}},)run = harness.run(id=conversation_id, acts_for=user_id, actions=["invoice:read", "invoice:refund"])verdict = run.check("refund_invoice", {"invoice_id": "INV-1", "amount": 90})if verdict.runs: result = run.after("refund_invoice", verdict.args, billing.refund(**verdict.args))else: result = verdict.message # for the model; verdict.say is for the personHarness#
Harness(agent, *, guards=None, tools=None, mode="enforce", default_tier="low", store=None, scute=None, app_id=None, secret=None, base_url=None, timeout=10.0, transport=None, on_decision=None, on_alert=None)- agent is the agent's slug in Scute. Empty raises ConfigurationError.
- guards defaults to [guards.permissions()].
- tools maps tool names to settings, for example {"refund_invoice": {"tier": "high"}, "get_weather": False}. Tools without a tier get default_tier.
- mode is enforce, monitor or observe for every guard that does not set its own.
- store keeps run state and budget counters. The default MemoryStore lives in one process. Pass any object with get(key) and set(key, value, ttl=None) (Redis, a cache, a table) to resume runs across requests and processes.
- Credentials: pass a Scute client as scute, or app_id / secret / base_url, else SCUTE_APP_ID, SCUTE_SECRET, SCUTE_BASE_URL.
- on_decision(event) sees every decision; on_alert(event) fires when a guard in monitor mode would have blocked. Neither receives a token.
Guards#
Factories in scute.harness.guards: permissions, verify_person, approval, requester_only, grounding, args, budget, content, and define for your own.
Runs#
harness.run(*, id=None, acts_for=None, actions=None, resources=None, ttl=None, ref=None, requester=None, parent=None, token=None, session=None, context=None) -> RunThe task is minted with the secret on first use. An agent process without the secret runs on a token your backend minted with scute.agents.start_task:
run = harness.run(token=task["token"])run.check(tool, args, messages=...) returns a Verdict; verdict.runs is True for proceed and transform. run.after(tool, args, result) returns what the model should see. run.wrap(tool) guards a function, as a decorator or a call. run.complete() and run.revoke() end the run.
@run.wrap("refund_invoice")def refund(invoice_id: str, amount: float) -> str: ...