Skip to main content
Version: latest

History and decisions data model

ConversationHistory, DecisionTraces, and HistoryRetention return the models below. The models are defined in agrag/common/data_models/task.py, decision.py, write_result.py, and retention.py. The classes are in agrag/history/ and agrag/decisions.py. Conversation history and decisions explains the concepts behind these fields.

Tasks and events​

Task​

FieldTypeMeaning
idUUIDDerived from the project id and the task name.
project_idstrThe project that owns the task.
namestrThe task name, unique within the project.
goalstrThe goal given when the task was created.
statusTaskStatusThe lifecycle state.
event_seqintThe sequence number of the last event, or 0.
authorstrThe agent that created the task.
created_atdatetimeWhen the task was created.

Event​

FieldTypeDefaultMeaning
idUUIDnoneDerived from the task id and the sequence number.
task_idUUIDnoneThe task the event belongs to.
seqintnonePosition in the task, from 1 with no gaps.
kindEventKindnoneThe kind of event.
rolestr | NonenoneThe speaker role of a message, or None.
namestr | NonenoneThe tool or source name for a tool event, or None.
payloadstrnoneThe stored text. Cut to 32,000 characters when truncated is True. Replaced by [REDACTED] after a redaction.
payload_sha256strnoneSHA-256 of the full text, encoded as UTF-8, before any cut.
truncatedboolnoneWhether the stored payload is shorter than the full text.
authorstrnoneThe agent that recorded the event.
atdatetimenoneWhen the event was recorded.
redacted_atdatetime | NoneNoneWhen the payload was redacted.

Step​

FieldTypeDefaultMeaning
idUUIDnoneDerived from the task id and the step name.
task_idUUIDnoneThe task the step belongs to.
namestrnoneThe step name, unique within the task.
kindStepKindnoneThe broad category of the step.
stateStepStatenoneThe current state.
result_event_seqint | NonenoneThe sequence number of the event that holds the result.
updated_seqintnoneThe task's event sequence number when the step was last set.
result_basisStepResultBasisunknownWhether the result depends on evidence.
result_supportslist[Support][]The supports of the result.

StepSummary​

The step fields that a resume view shows.

FieldTypeDefaultMeaning
namestrnoneThe step name.
kindStepKindnoneThe broad category.
stateStepStatenoneThe current state.
result_event_seqint | NonenoneThe sequence number of the result event.
result_basisStepResultBasisunknownWhether the result depends on evidence.
result_validityStepResultValidityunknownWhether a completed result can be reused.
result_supportslist[Support][]The supports of the result.

StepPage​

FieldTypeDefaultMeaning
stepslist[StepSummary][]The steps in the page.
truncatedboolFalseWhether more steps follow.
next_after_namestr | NoneNoneThe after_name value that fetches the next page.

TaskView​

The bounded resume view. It never includes event bodies.

FieldTypeDefaultMeaning
task_namestrnoneThe task name.
goalstrnoneThe task goal.
statusTaskStatusnoneThe lifecycle state.
last_event_seqintnoneThe sequence number of the last event, or 0.
stepsdict[StepState, list[StepSummary]]noneShown steps grouped by state. Every state is a key.
step_countsdict[StepState, int]noneSteps in each state, including hidden steps. Every state is a key.
steps_truncatedboolnoneWhether some steps are hidden.
decisionslist[Decision][]Active decisions, newest first.
decision_countint0The number of active decisions, including hidden ones.
decisions_truncatedboolFalseWhether some active decisions are hidden.
review_decisionslist[Decision][]Active decisions that need review.
conflictslist[ConflictGroup][]Conflicting choices that include this task.
conflicts_truncatedboolFalseWhether some conflicts are hidden.

Lookups and pages​

ModelFieldsMeaning
TaskLookupfound: bool, view: TaskView | NoneThe result of get_task. view is None when found is False.
EventPagefound: bool, events: list[Event], truncated: bool, next_after_seq: int | NoneOne page of events in sequence order.
EventLookupfound: bool, event: Event | NoneThe result of fetch_event.

Write results​

Every history write returns one of these models. Each one has recorded: bool and error: WriteErrorCode \| None. The model that matches the write also has its result field.

ModelExtra fieldReturned by
CreateTaskResulttask: Task | Nonecreate_task
RecordEventResultevent: Event | Nonerecord_event
SetStepResultstep: Step | Noneset_step

Decisions​

Decision​

FieldTypeDefaultMeaning
idUUIDnoneDerived from the task id, the choice key, and the revision.
task_idUUIDnoneThe task the decision belongs to.
task_namestrnoneThe name of that task.
choice_keystrnoneThe choice inside the task that the decision settles.
revisionintnone1 for the first decision of a choice, then one more for each supersession.
conclusionstrnoneThe conclusion. Never changed after recording.
rationalestrnoneThe stated reasoning.
assumptionslist[str]noneThe assumptions the decision relies on.
open_questionslist[str]noneThe questions left open.
authorstrnoneThe agent that recorded the decision.
statusDecisionStatusnoneThe lifecycle state.
review_stateReviewStatenoneWhether the supports still hold.
review_reasonReviewReason | NoneNoneWhy the decision needs review.
rejection_reasonstr | NoneNoneThe reason given when the decision was rejected.
rejected_bystr | NoneNoneWho rejected the decision.
created_atdatetimenoneWhen the decision was recorded.
supportslist[Support][]The stored supports, in the order given.

Supports​

A stored support is one of three models. The kind field selects the model.

DocumentSupport​

FieldTypeDefaultMeaning
kind"document"noneAlways document.
evidence_idstrnoneThe evidence id the caller cited.
document_keystrnoneThe stable key of the cited document.
document_node_idUUIDnoneThe id of the Document node.
content_hash_prefixstrnoneThe first 16 hex characters of the cited version.
content_hashstrnoneThe full content hash of the cited version.
reference_kindEvidenceKindnoneWhether the id names a span or a chunk.
char_startint | NoneNoneStart offset of a span, or None for a chunk.
char_endint | NoneNoneEnd offset of a span, or None for a chunk.
chunk_idUUID | NoneNoneThe chunk id of a chunk reference, or None for a span.
recorded_activation_seqint | NoneNoneThe document's activation sequence when the decision was recorded.
currentboolTrueWhether the support is the current one.
reviewed_bystr | NoneNoneWho reviewed the support.
reviewed_atdatetime | NoneNoneWhen the support was reviewed.
review_explanationstr | NoneNoneThe explanation given during review.

EventSupport​

FieldTypeDefaultMeaning
kind"event"noneAlways event.
event_idUUIDnoneThe id of the event node.
task_namestrnoneThe task that holds the event.
seqintnoneThe sequence number of the event in that task.
current, reviewed_by, reviewed_at, review_explanationas in DocumentSupportTrue, None, None, NoneReview fields.

DecisionSupport​

FieldTypeDefaultMeaning
kind"decision"noneAlways decision.
decision_idUUIDnoneThe id of the decision depended on.
current, reviewed_by, reviewed_at, review_explanationas in DocumentSupportTrue, None, None, NoneReview fields.

Support inputs​

These models are the arguments that a write accepts.

ModelFieldsMeaning
DocumentSupportInputevidence_id: strA passage fetched in full with status ok.
EventSupportInputtask_name: str, seq: intAn existing event in the project.
DecisionSupportInputdecision_id: strAn active decision in the project.

Pages and lookups​

ModelFieldsMeaning
DecisionPagedecisions: list[Decision], count: int, truncated: boolDecisions of a list call. count includes hidden decisions.
DecisionPageLookupfound: bool, page: DecisionPageThe result of list_decisions.
DecisionLookupfound: bool, decision: Decision | NoneThe result of get_decision.
DecisionReviewListdecisions: list[Decision], count: int, truncated: boolThe result of list_decisions_for_review.
SupportHistoryPagesupports: list[Support], truncated: bool, next_after_ordinal: int | NoneThe result of list_support_history.
DecisionHitdecision: Decision, task_goal: str, marker: "precedent"One result of search_decisions.
ConflictGroupchoice_key: str, decisions: list[Decision], truncated: boolActive decisions of one choice that disagree across tasks.
ConflictListgroups: list[ConflictGroup], truncated: boolThe result of list_conflicts.

Decision write results​

ModelExtra fieldsReturned by
RecordDecisionResultdecision: Decision | None, warnings: list[str]record_decision and supersede_decision. warnings holds source_changed_during_recording when a cited source changed.
RejectDecisionResultdecision: Decision | Nonereject_decision
ReaffirmDecisionResultdecision: Decision | Nonereaffirm_decision

Retention​

ModelFieldsReturned by
RetentionResultrecorded: bool, error: RetentionErrorCode | None, affected_decision_ids: list[str]redact_event and delete_task. affected_decision_ids lists the decisions flagged by the call, sorted.

Methods, defaults, and limits​

Each method clamps its page size to the maximum shown.

MethodParameterDefaultLimit
ConversationHistory.list_eventsafter_seq, limit0, 50limit is 1 to 200.
ConversationHistory.list_stepsafter_name, limitNone, 50limit is 1 to 200.
ConversationHistory.record_eventpayloadnoneAt most 32,000 characters are stored. Longer text is cut.
ConversationHistory.get_tasknonenoneShows at most 50 steps, 20 active decisions, 20 review decisions, and 10 conflict groups.
DecisionTraces.record_decisionsupportsnoneAt least 1 support and at most 20.
DecisionTraces.supersede_decisionexplanationnoneMust not be blank.
DecisionTraces.reaffirm_decisionexplanation"Reaffirmed after review."Stored with the review.
DecisionTraces.list_decisionsinclude_historyTrueAt most 20 decisions per call.
DecisionTraces.list_decisions_for_reviewtask_name, limitNone, 20At most 20 decisions per call.
DecisionTraces.search_decisionstask_name, limitNone, 20At most 100 results.
DecisionTraces.list_support_historyafter_ordinal, limit-1, 20At most 100 per call.
DecisionTraces.continue_decision_reviewlimit100At most 100 queued decisions per call.
DecisionTraces.list_conflictsnonenoneAt most 50 groups, with at most 50 decisions shown per group.
HistoryRetention.delete_taskinclude_decisionsTruenone
All writesrequest_idNone1 to 64 characters when set.

Enums and states​

Each value is the string that is stored and returned.

Task and step states​

EnumValueMeaning
TaskStatusopenThe task was created. Every task starts in this state.
TaskStatusdoneDefined in the model. No method in this version sets it.
EventKindmessageA message from a speaker. Set role to name the speaker.
EventKindtool_callA call to a tool. Set name to the tool.
EventKindtool_resultThe result of a tool call. Set name to the tool.
EventKindnoteA free-form note from the agent.
StepStatenot_startedThe step is planned and has not begun.
StepStatein_progressThe step has begun, and no outcome is recorded yet.
StepStatecompletedThe step finished. Resume does not rerun it.
StepStatefailedThe step finished with a failure. Resume reruns it.
StepStateunknownThe outcome is not known, for example after an interrupted run. Resume reruns it.
StepKindreadA step that reads sources.
StepKindanalysisA step that analyzes gathered material.
StepKindotherAny other step. This is the default.
StepResultBasisindependentThe result does not depend on evidence.
StepResultBasissupportedThe result depends on supports.
StepResultBasisunknownThe basis is not known. This is the default.
StepResultValidityreusableThe supports still match, so the result can be reused.
StepResultValidityneeds_reviewA support changed, or a supporting decision is not clear or active.
StepResultValidityunavailableA support is gone, redacted, truncated, or was not found.
StepResultValidityunknownValidity was not established. This is the default.

Decision states​

EnumValueMeaning
DecisionStatusactiveThe decision is the current one for its choice. Only active decisions are reused.
DecisionStatusrejectedA reviewer rejected the decision. The record and its supports are kept.
DecisionStatussupersededA later revision of the same choice replaced the decision.
ReviewStateclearThe supports still hold.
ReviewStateneeds_reviewA support changed or was removed, or a decision it depends on is flagged. A flag does not mean the decision is false.
ReviewStateunknownThe state could not be established, for example while review is incomplete. The decision is treated as needing review.
ReviewReasonsource_changedA cited document version was replaced. Set by the document update path.
ReviewReasonsource_removedA cited document was deleted or purged, a cited event was redacted, or a task with cited records was deleted.
ReviewReasonsource_changed_during_recordingA cited document changed while the decision was recorded. The result carries a warning.
ReviewReasondependency_reviewA decision the record depends on was flagged. Set by review propagation, which continue_decision_review runs.
SupportKinddocumentA DocumentSupport.
SupportKindeventAn EventSupport.
SupportKinddecisionA DecisionSupport.

Verdicts and source states​

Enum or typeValueMeaning
SourceState (source_status)currentThe committed version is complete and no job is pending.
SourceState (source_status)pendingA cutover job holds an unexpired lease.
SourceState (source_status)failedAn incomplete job has an expired lease, or the last write did not complete.
SourceState (source_status)deletedThe last committed change was a delete or purge.
SourceState (source_status)unknownThe document key is not in the graph, and no job exists for it.
FetchStatusokThe text is returned in full. This is the only status that can back a document support.
FetchStatuspartialPart of the requested range has no chunk. Only the covered part is returned.
FetchStatustruncatedThe text was cut at the requested maximum length.
FetchStatusunavailableThe id names no evidence the caller can read. Missing and out-of-scope ids look the same.
FetchStatusmalformedThe id does not decode.
FetchStatusindex_not_readyAn index the operation needs is not ready.
FetchStatusfailedThe store failed while reading the evidence.
VersionStatuscurrentThe text is from the document's current version.
VersionStatussupersededThe document changed after the text was written. The text is returned but is not searchable.
CitationVerdictvalidThe id decodes, is in scope, and was fetched, or lies inside a fetched span.
CitationVerdictnot_fetchedThe id is in scope but was not fetched, or it extends past every fetched span.
CitationVerdictunavailableThe id names a document outside the scope.
CitationVerdictmalformedThe id does not decode.
VerificationResult.statusPASSEvery sub-question has supporting evidence, and nothing contradicts it.
VerificationResult.statusINSUFFICIENTOne or more sub-questions lack supporting evidence.
VerificationResult.statusCONTRADICTORYCited evidence conflicts, so further research cannot settle it.
CandidateState (Literal)pendingA candidate waits for review.
CandidateState (Literal)approvedA reviewer approved the candidate.
CandidateState (Literal)rejectedA reviewer rejected the candidate.

Agent result status​

AgentRunResult.status has six values. The built-in agent sets the first value that applies, in this order.

OrderValueSet when
1recording_failedA task write did not complete.
2budget_exhaustedThe run used its tool or time budget.
3partial_retrievalA retrieval call failed.
4partialAn invalid citation exists, or no structured answer was produced.
5insufficient_evidenceThe answer's support status is insufficient_evidence.
6answeredNone of the above applies.

Write error codes​

Each write returns one of these codes in its error field. The WriteErrorCode enum has two sets of values, one for conversation history writes and one for decision writes.

Conversation history writes​

agrag/common/data_models/task.py, returned by ConversationHistory.

CodeMeaning
task_existsThe task name is used with a different goal.
task_not_foundThe task does not exist in the project.
event_not_foundresult_event_seq names no event in the task.
support_requiredA supported result has no supports.
support_invalidA support does not match an event or document in the project.
request_id_reusedThe request id was used with different arguments.
invalid_request_idThe request id is empty or longer than 64 characters.

Decision writes​

agrag/common/data_models/write_result.py, returned by DecisionTraces.

CodeMeaning
task_existsDefined in the enum. Decision writes do not return it in this version.
task_not_foundThe task does not exist in the project.
event_not_foundDefined in the enum. Decision writes return support_event_not_found instead.
request_id_reusedThe request id was used with different arguments.
invalid_request_idThe request id is empty or longer than 64 characters.
choice_existsThe choice already has a decision. Use supersede_decision.
supersede_target_invalidThe decision to supersede does not exist or is not active.
explanation_requiredsupersede_decision received a blank explanation.
support_requiredThe write has no supports, or more than 20.
support_malformedA support or evidence id does not decode or has an invalid form.
support_not_fetchedA document support has no fetch outcome with status ok.
support_out_of_scopeDefined in the enum. Decision writes do not return it in this version.
support_document_not_foundThe cited document is not in the graph.
support_event_not_foundThe cited event is not in the project.
support_decision_not_foundThe cited decision is not in the project.
decision_not_foundThe decision id does not exist in the project.
decision_not_activeThe decision is rejected or superseded, so the operation does not apply.
support_decision_not_activeA decision support names a decision that is not active.
cannot_revalidatereaffirm_decision cannot confirm the decision, because a cited text changed, the review is incomplete, or a dependency is not clear.

Retention error codes​

agrag/common/data_models/retention.py, returned by HistoryRetention.

CodeMeaning
event_not_foundThe event id names no event in the project.
task_not_foundThe task does not exist in the project.
request_id_reusedThe request id was used with different arguments.
invalid_request_idThe request id is empty or longer than 64 characters.

Exceptions​

The history, decision, and retention writes return the error codes above for a refused write and do not raise. The _WriteRefusedError, _DecisionRefusedError, and _RetentionRefusedError classes are private and not part of the public API.

A class is public when its module name does not start with an underscore. CutoverJobLeaseError in agrag/ingestion/_cutover.py is therefore not listed. The base classes with no raise site in agrag are marked as bases. Catch a base class to handle every subclass.

Graph store​

ClassBaseRaised when
GraphStoreErrorExceptionThe base class. A query or transaction failed in the backend.
GraphStoreMissingExtraErrorGraphStoreErrorThe Neo4j or FalkorDB client package is not installed.
GraphStoreWriteConflictErrorGraphStoreErrorA write reaches a row that an in-flight job owns, and the write cannot defer it. The transaction rolls back.
GraphStoreConstraintViolationErrorGraphStoreErrorThe backend reports a uniqueness violation. History writes retry it up to three times.
GraphStoreAliasConflictErrorGraphStoreConstraintViolationErrorA merge key alias is already owned by another entity. Raised by the entity merge step. Attribute: conflicts.

Embeddings and vector stores​

ClassBaseRaised when
EmbeddingErrorExceptionThe base class for embedding errors. No raise site in agrag uses it directly.
EmbeddingMissingExtraErrorEmbeddingErrorThe local sentence-transformers embedder or the reranker needs an extra that is not installed. Attribute: extra.
EmbeddingDimensionMismatchErrorEmbeddingErrorThe embedder produces a dimension that differs from the stored index. Attributes: expected, actual.
VectorStoreErrorExceptionAn external vector index operation failed.
VectorStoreMissingExtraErrorVectorStoreErrorThe client for the selected vector store is not installed. Attribute: extra.
CollectionMismatchErrorVectorStoreErrorAn existing collection has incompatible dimensions, distance, or metadata.
VectorPlacementErrorVectorStoreErrorThe requested vector placement differs from the placement recorded in the graph.

Ingestion and loaders​

ClassBaseRaised when
IngestionErrorExceptionThe base class for ingestion errors. Ingestion code catches it to skip a source. No raise site uses it directly.
UnsupportedFormatErrorIngestionErrorNo registered loader reads the file extension. Attribute: extension.
MissingExtraErrorUnsupportedFormatErrorA loader exists for the format, but its extra is not installed. An error policy treats it like an unsupported format. Attributes: extension, extra.
DecodeErrorIngestionErrorThe source bytes do not decode under the forced encoding, or detection fails and the fallback is unavailable.
MalformedRecordErrorIngestionErrorA record in a record-family source, such as a chat export or a table, does not parse.
DocumentTooLargeErrorIngestionErrorA prose source is larger than the configured byte limit.
DocumentConversionErrorIngestionErrorThe Docling loader cannot parse or convert the source.
ChunkingErrorExceptionThe chunker cannot split a document without changing its text, or a text chunk has no offsets.

Extraction and communities​

ClassBaseRaised when
ExtractorMissingExtraErrorIngestionErrorThe GLiNER or BAML extractor needs an extra that is not installed. Attributes: component, extra.
UnparsableExtractionErrorIngestionErrorThe LLM reply holds no JSON answer. An empty result from a model that found nothing is not this error.
CommunityDetectionMissingExtraErrorExceptionThe community detection package is not installed.

Schema​

ClassBaseRaised when
SchemaErrorExceptionThe base class for schema loader errors. No raise site uses it directly.
SchemaLoadErrorSchemaError, ValueErrorA schema source is invalid. The message lists every issue with its path. Attributes: issues, source.
SchemaFormatErrorValueErrorAn input cannot be imported as a supported schema format, for example an invalid OWL or Turtle document.
SchemaFormatMissingExtraErrorSchemaFormatErrorThe optional package for a schema format is not installed. Attributes: component, extra.

Evidence, candidates, and agents​

ClassBaseRaised when
MalformedEvidenceIdErrorValueErrorAn evidence id is not in the canonical form, or it names an empty or reversed range. History and decision writes convert it to support_malformed.
PatchNotAppliedErrorValueErrorThe active schema does not contain every item of a candidate patch. Attribute: missing.
AgentMissingExtraErrorExceptionThe agent extra is not installed, or agent tracing needs the observability extra. Attribute: extra.
UnsupportedAgentProviderErrorExceptionThe configured model provider has no agent mapping.
McpServerMissingExtraErrorExceptionThe MCP server is started without the mcp extra. Attribute: extra.

The agrag package defines no class whose name ends in Exception.