Skip to content

[Feature]: Add metadata-only audit records for agent runs and tool actions #98521

Description

@steipete

Summary

Add a small, metadata-only audit ledger for agent runs and tool actions so operators can answer who acted, what action ran, when it happened, and how it ended without reading transcripts or enabling raw-content telemetry.

Problem to solve

OpenClaw already has the right source signals, but they serve different jobs:

  • session transcripts preserve conversation artifacts;
  • the agent event stream carries sequenced run and tool lifecycle updates;
  • task and cron records cover detached/background work;
  • diagnostics and hooks support live observation and optional export.

There is no single durable, bounded query path for interactive agent runs and their tool actions. Reconstructing that history from transcripts or logs risks exposing prompt, argument, result, and error content, while task records intentionally do not cover every interactive run.

Proposed solution

Add one canonical shared-SQLite audit event table and a typed read contract with:

  • stable event identity and global ordering;
  • agent, session, actor, run, and tool-call provenance;
  • closed action, status, and error-code fields;
  • metadata-only redaction as an invariant: no prompt, message, tool argument, tool result, command output, or raw error text;
  • bounded pagination plus filters for time, agent, session, run, action kind, and status;
  • a read-only Gateway RPC and CLI JSON output for bounded export.

Project records from the existing sequenced agent run/tool lifecycle rather than creating another conversation or transcript store. Use the shared state database and Kysely. Keep retention fixed and bounded; do not add configuration in this foundation.

Initial scope:

  • agent run started and terminal records;
  • tool action started and terminal records, including failure/timeout/denial codes when the existing lifecycle proves them;
  • read-only query/export surface;
  • persistence, ordering, filter, redaction, and terminal-path tests;
  • operator documentation.

Non-goals:

  • Control UI work;
  • prompt/body/tool payload capture;
  • replacement of transcripts, task records, hooks, or diagnostics exporters;
  • broad policy, approval, or workflow modeling;
  • new audit configuration.

Alternatives considered

  • Parse transcripts or logs on demand: content-heavy, difficult to bound, and duplicates existing artifact semantics.
  • Add a JSON/JSONL audit file: conflicts with the shared SQLite state boundary and creates another lifecycle/retention owner.
  • Depend only on diagnostics export: useful for telemetry, but optional exporters are not the canonical local operator record.
  • Extend background task records to every interaction: changes the task ledger's detached-work contract and still does not model individual tool actions cleanly.

Impact

Operators gain a privacy-preserving local history for run and tool accountability. The main risks are write amplification, unbounded retention, accidental content capture, and ambiguous terminal classification; the implementation should address those with selective lifecycle projection, fixed pruning, a column-only metadata schema, and tests against failure/cancellation/timeout paths.

Evidence/examples

Related requests and current candidates:

Current source provides sequenced lifecycle events with run/session context, normalized run terminal outcomes, sanitized tool result handling, and a shared Kysely-backed state database. Those seams are sufficient for a bounded first implementation without a new dependency.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🌊 off-meta tidepoolIssue quality rating does not apply to this item.maintainerMaintainer-authored PRmaturity:stableIssue affects a taxonomy feature currently scored M4/M5.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions