agrag.history.retention.HistoryRetention
HistoryRetention(store:GraphStore, project_id:str, agent_id:str) -> None
Apply retention actions to conversation history in one project.
Functions:
- delete_task – Delete a task and its events and steps, and optionally its decisions.
- redact_event – Replace an event body while keeping its identity and payload hash.
delete_task
delete_task(name:str, include_decisions:bool = True, request_id:str | None = None, *, expected_task_id:str | None = None, expected_created_at:datetime | None = None) -> RetentionResult
Delete a task and its events and steps, and optionally its decisions.
Decisions in other tasks that cite deleted events or decisions are
directly flagged needs_review. Their ids are returned; no
transitive review propagation or queueing is performed here. When an
approved task id or creation time is supplied, the task is locked and
the delete is refused unless the stored task still matches it. A task
deleted and recreated under the same name is refused.
redact_event
redact_event(event_id:str, request_id:str | None = None, *, expected_revision:str | None = None) -> RetentionResult
Replace an event body while keeping its identity and payload hash.
The event remains in sequence and receives a redacted_at timestamp.
A retry with the same request id replays the first result. When an
approved revision is supplied, it is checked against the event inside
the write transaction, so a changed event cannot be redacted under a
stale approval.