Skip to content

Privacy-safe event logs for AI agents, tools, and governance

PyPI Python CI License Runtime dependencies Status

Capture model calls, tool calls, retrieval, policy checks, approvals, decisions, and errors as redacted JSONL — without adopting a new agent framework or observability platform.

agentlogsafe is vendor-neutral, framework-neutral, JSONL-first, and implemented entirely with the Python standard library at runtime. Redaction is enabled by default. Use it for AI governance, debugging, audit trails, and internal platform observability.

Install and start Review the schema

Project status

agentlogsafe is early-stage software. It is suitable for prototypes, internal evaluation, lightweight audit trails, and developer-facing governance workflows. Review carefully before using it in regulated production systems.

It is not a replacement for a security, DLP, SIEM, compliance, or enterprise observability platform.

Install

python -m pip install agentlogsafe

Python 3.10 or newer is required. Runtime dependencies: zero.

Quickstart

from agentlogsafe import AgentLogger

log = AgentLogger(
    agent_name="pricing-agent",
    workflow_name="margin-risk-review",
    sink="agent_events.jsonl",
)

with log.run(input={"request": "Find margin risks in this forecast"}):
    log.user_message("Find margin risks in this forecast")
    log.model_call(
        provider="azure_openai",
        model="gpt-4.1",
        input_tokens=812,
        output_tokens=132,
        payload={"prompt": "Find margin risks in this forecast"},
    )
    log.tool_call(
        tool_name="snowflake.query",
        args={
            "sql": "select * from customer_margin where email = 'person@example.com'",
            "authorization": "Bearer abc.def.ghi",
        },
    )
    log.tool_result(
        tool_name="snowflake.query",
        result={"rows": 20, "sample_email": "person@example.com"},
    )
    log.policy_check(
        policy_name="pii-redaction",
        status="success",
        payload={"contains_pii": True},
    )
    log.decision(
        decision="Escalated because margin impact exceeded threshold",
        requires_human_review=True,
    )

Sensitive values are redacted before an event reaches its sink:

{"schema_version":"1.0","event_type":"tool_call","tool_name":"snowflake.query","payload":{"args":{"sql":"select * from customer_margin where email = '[REDACTED]'","authorization":"[REDACTED]"}}}

Why agentlogsafe

  • Safe defaults. Payload, risk, and metadata dictionaries are recursively redacted before sink delivery.
  • Stable audit records. UUID event and run identifiers, UTC timestamps, parent relationships, workflow metadata, and a versioned schema support correlation.
  • Portable JSONL. Records work with files, notebooks, batch jobs, log shippers, object storage, and existing enterprise data platforms.
  • No framework adoption. Instrument the workflow you already have.
  • No runtime dependency tree. The implementation is standard-library-only.

Enterprise AI governance use case

Teams can produce consistent records for model calls, tool calls, retrieval queries and results, policy checks, human approvals, decisions, errors, and redacted payloads. Stable run IDs and workflow metadata provide workflow-level traceability without coupling applications to one provider or platform.

Redaction is not a complete security boundary

Sensitive systems should still use defense-in-depth, access controls, secure storage, retention controls, monitoring, and review. Pattern detection can produce false positives and false negatives.