This is a submission for the is a tiny Python harness that wraps a Hermes Agent call with four governance layers:
- A budget cap that stops the agent when it would spend past a dollar amount or a call count.
- An egress allowlist that blocks any outbound HTTP fetch the agent did not declare up front.
- An audit trace that writes every call, denial, and exception to a JSONL file.
- A structured output check that pulls JSON out of the model reply, validates it against a schema, and retries once if the first reply does not parse.
Each layer fails closed. The audit trail captures the failure before it propagates. The whole thing is a single HermesAgent you wrap around a Hermes call.
I wrote a companion piece for the Write prompt:
The interesting part is the agent class. Every Hermes call goes through the same path: reserve a call slot, emit a pre-event, call the model, record the spend, cast the output, emit a post-event. Any step can raise and the audit trail catches it.
class HermesAgent:
def chat(self, messages):
self.budget.reserve_call()
self._trace("hermes.call", {...})
try:
resp = self.client.complete(messages)
except Exception as exc:
self._trace("hermes.error", {...})
raise
try:
self.budget.record_spend(resp.usd_cost)
except BudgetExceeded as exc:
self._trace("budget.exceeded", {...})
raise
self._trace("hermes.ok", {...})
return resp
run_structured is the cast layer on top of chat. It tries to parse JSON out of the reply, and if the parse or schema check fails, it sends one repair prompt and tries again. Mirrors the pattern in . Issues and PRs welcome.
Thanks to the DEV team and Nous Research for running the challenge. The four-layer pattern was waiting for an excuse to land in one place, and Hermes was a good excuse.
SOCIAL SHARE CARD GENERATOR