Repository navigation
Description
Follows #20.
Problem
When SafeAgents blocks a call, the harness never runs it, so hook-based recorders and audit tools never see the attempt. The record exists only in calls.jsonl.
Now that the journal format is documented, a tool can tail that file, but that has limits. It has to poll, it reads a file that can hold secrets, and it gets nothing under --no-journal. There is also no supported way to react to a verdict as it happens.
This affects anyone who wants SafeAgents' decisions in a SIEM or an audit trail.
Proposal
Add an optional, repeatable --sink MODULE:FACTORY (or path/to/file.py:FACTORY), with the same convention as --plugin. FACTORY() returns a callable that receives one dict per call:
# my_sink.py
def sink():
def handle(entry: dict) -> None:
... # send it wherever you need
return handlesafeagents start URL --sink my_sink:sink
Suggested behaviour:
- Called for every verdict other than
passed, at the point whereGuard.allowwrites the journal. entryhas the fields indocs/journal.md, so there is one format to keep stable.idisnullunder--no-journal. A session ID would be added here if Documented journal schema or event sink, so blocked calls can reach audit trails #20's second point lands.- A sink must never delay a response or change a verdict. It runs off the event loop with a short timeout, and exceptions are logged and ignored.
- Off by default, with no new dependencies. SafeAgents does no network delivery itself, so it holds no sink URLs or tokens.
argumentsandtaskcan hold secrets, as the journal notes, so the docs should say a sink receives them and is responsible for what it does with them.
From Python, this could be Config(sinks=[...]).
Alternatives
- Tail
calls.jsonl. Needs no change and works today, with the limits above. An adapter can start here either way. - A built-in webhook. Simple to use, but SafeAgents would take on URLs, credentials, retries and a payload contract.
- Run a command per event. Language-neutral, but it starts a process for each call and passes potentially secret data to it.
- OTLP or OCSF output. Useful for some users, but it picks one schema for everyone, and could be built as a sink later.
If this direction works for you, I'm happy to send a branch following the process in CONTRIBUTING.md. If you would rather keep the proxy minimal, the journal alone is enough for a first adapter.
Activity
younesbelkada commentedon Nov 11, 2026
Hi @blitzcrieg1
Thanks for the RFC - the proposed plan sounds great. Could you share a minimal PR on your fork to demostrate how the integration will look like? Also if you could document some potential usecases (maybe by combining it with Agentmetrics) in
docs/(maybe create a new filesink.md). Thank you!blitzcrieg1 commentedon Nov 11, 2026
Thanks for the feedback. The minimal sink prototype is on this fork branch:
https://github.com/blitzcrieg1/safeagents/tree/feature/optional-event-sinks
It adds repeatable
--sink MODULE:FACTORYloading andConfig(sinks=[...]), using the journal-shaped observation for non-passed calls, including with--no-journal. Delivery is off the response loop and bounded per sink. The deadline is explicit about Python's inability to cancel a running callback; callbacks need their own I/O timeouts, and notifications can be dropped.docs/sink.mdcovers the raw-payload privacy boundary, a metadata-only output example and possible Agentmetry/SIEM uses. It does not claim a live Agentmetry adapter or infer tool execution from an allowed proposal. The branch includes guard, CLI, journal and scripted proxy regression cases.Please let me know whether this is the right shape before adding any destination-specific adapter.
blitzcrieg1 commentedon Nov 12, 2026
Here is the minimal PR on my fork, as you asked: blitzcrieg1#1
It is one commit on top of current
main. It adds a repeatable--sink MODULE:FACTORYandConfig(sinks=[...]), delivers off the response path with a bounded queue per sink, and addsdocs/sink.mdwith use cases, including recording blocked calls in Agentmetry. Delivery is best effort: a full queue, a failing callback or shutdown can drop a notification, and the doc says so.Happy to change anything. If it looks right, the branch is ready for you to open upstream.
feat: add opt-in sinks for guard observations (#30)
younesbelkada commentedon Nov 15, 2026
Thanks @blitzcrieg1 ! Reviewed and tested your changes, all is good !
blitzcrieg1 commentedon Nov 15, 2026
Thanks for reviewing, testing and merging it, and for keeping the boundaries in the doc. I'll close my fork PR. If anyone wants to record denied attempts in Agentmetry through a sink, I'm happy to help.