audit_brief
Generate a budgeted session digest for auditors, preserving verbatim user turns and tool/file activity within a strict character limit.
Instructions
Token-lean, budgeted session digest for auditors — the audit_brief preset.
One call answers "what happened in this session, verbatim where it
matters", inside a hard character budget. A preset over the existing
core, not a second engine (project preset rule): ONE query scan over
the session's events supplies the user turns (VERBATIM — the auditor's
ground truth) and the tool/file footprint (folded by
aggregate(group_by="tool_kind") + the edit/write rows' existing
file refs); the plan/plan_feedback projections supply the
decision trail; :mod:ai_r.tokens (the same SSOT behind
session_stats(with_tokens) / read_session(with_tokens)) supplies
the token breakdown.
Deterministic budget algorithm: build the full digest, then tighten in a
FIXED ladder until the serialized JSON fits budget_chars (default
15000; 0 = unlimited) — (1) drop tool-call error details, (2) drop
the per-file edit list, (3) drop plan bodies + feedback quote/comment
texts (counts/references always stay; bodies on-demand via get_body).
User turns are NEVER truncated: if they alone exceed the budget the
response carries budget.over_budget: true + a note naming the
full projections — never a silently clipped ground truth.
session accepts the full uuid or a unique id prefix (e.g. the 8-hex
head), resolved through the SAME id-prefix matching locate uses —
the digest's session.uuid echoes the full resolved id; an ambiguous
prefix is invalid_argument naming the candidates (capped), zero
matches is not_found with closest-title suggestions. agent is
an optional hint (None = the id resolves across every parser, like
read_session). redact=true (default) masks secrets in the
emitted title / user texts / plan bodies / feedback pairs. The
response is section-structured (session / user_turns / plans
/ tools / files / tokens / component_tokens / budget);
the CLI mirror is ai-r audit-brief <uuid> (markdown, --json for
this dict).
Thin wrapper over :func:ai_r.audit_brief.audit_brief: a ValueError
becomes {"error": "invalid_argument"}, an unknown session id
{"error": "not_found"}.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agent | No | ||
| redact | No | ||
| session | Yes | ||
| budget_chars | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||