Models and structured outcomes
Pydantic models and the structured-outcome/entity-reference types for ReasoningMemory API reference.
Models
These are Pydantic models, not dataclasses. Inherited fields include UUID IDs and created_at; there is no timestamp alias. ReasoningStep uses step_number, and ToolCall uses status rather than success.
ReasoningTrace
Pydantic model; inherited memory-entry fields are included.
| Field | Type | Default | Description |
|---|---|---|---|
|
|
|
Unique identifier. |
|
|
|
Creation time. |
|
|
|
Last update time, if updated. |
|
|
|
Embedding vector, if one was generated. |
|
|
|
Arbitrary key-value metadata, stored as JSON. |
|
|
|
Session identifier |
|
|
|
Task description |
|
|
|
Task embedding |
|
|
|
Reasoning steps |
|
|
|
Final outcome |
|
|
|
Whether task succeeded |
|
|
|
Start time |
|
|
|
Completion time |
ReasoningStep
Pydantic model; inherited memory-entry fields are included.
| Field | Type | Default | Description |
|---|---|---|---|
|
|
|
Unique identifier. |
|
|
|
Creation time. |
|
|
|
Last update time, if updated. |
|
|
|
Embedding vector, if one was generated. |
|
|
|
Arbitrary key-value metadata, stored as JSON. |
|
|
|
Parent trace ID |
|
|
|
Step number in sequence |
|
|
|
Agent’s thought/reasoning |
|
|
|
Action taken |
|
|
|
Observation from action |
|
|
|
Tool calls in this step |
ToolCall
Pydantic model; inherited memory-entry fields are included.
| Field | Type | Default | Description |
|---|---|---|---|
|
|
|
Unique identifier. |
|
|
|
Creation time. |
|
|
|
Last update time, if updated. |
|
|
|
Embedding vector, if one was generated. |
|
|
|
Arbitrary key-value metadata. |
|
|
|
Name of the tool |
|
|
|
Tool arguments |
|
|
|
Tool result |
|
|
|
Call status |
|
|
|
Duration in milliseconds |
|
|
|
Error message if failed |
|
|
|
Parent reasoning step ID |
ToolStats
Fields and defaults:
| Field | Type | Default | Description |
|---|---|---|---|
|
|
|
Tool name |
|
|
|
Tool description |
|
|
|
Total number of calls |
|
|
|
Number of successful calls |
|
|
|
Number of failed calls (error/timeout) |
|
|
|
Success rate (0.0 to 1.0) |
|
|
|
Average duration in ms |
|
|
|
Last time tool was used |
ReasoningStepWithContext
Fields and defaults:
| Field | Type | Default | Description |
|---|---|---|---|
|
|
|
The matching reasoning step |
|
|
|
Cosine similarity to the query (0-1) |
|
|
|
Task of the parent ReasoningTrace |
|
|
|
Outcome of the parent ReasoningTrace, if completed |
|
|
|
Success flag of the parent ReasoningTrace |
Structured outcomes and entity references (bolt)
Import TraceOutcome and EntityRef from neo4j_agent_memory.schema.models. A structured outcome overrides a separate success= argument. EntityRef requires at least a name or ID; the operation using the reference determines how it resolves identity. NAMS does not persist these trace outcome fields through its compatibility lifecycle.
from neo4j_agent_memory.schema.models import EntityRef, TraceOutcome
outcome = TraceOutcome(
success=True,
summary="Recommended La Trattoria",
related_entities=[EntityRef(name="La Trattoria", type="ORGANIZATION")],
metrics={"latency_ms": 812.0, "tools_called": 1},
)
await client.reasoning.complete_trace(trace.id, outcome=outcome)
EntityRef
Fields and defaults:
| Field | Type | Default | Description |
|---|---|---|---|
|
|
|
Optional source domain label (e.g. 'Client'). Used when adopting an existing graph and the caller wants to disambiguate by label. |
|
|
|
Entity display name (matches Entity.name) |
|
|
|
POLE+O or custom entity type (matches Entity.type) |
|
|
|
Optional explicit entity id. When set, the reference identifies exactly one entity regardless of name/type. |
TraceOutcome
Fields and defaults:
| Field | Type | Default | Description |
|---|---|---|---|
|
|
|
Whether the task succeeded |
|
|
|
Human-readable outcome summary |
|
|
|
Indexed error category, e.g. 'timeout', 'no_results', 'user_aborted'. Stored on the ReasoningTrace for fast filtering. |
|
|
|
Entities the trace touched (for case-based retrieval) |
|
|
|
Arbitrary numeric metrics keyed by name (e.g. 'latency_ms', 'tools_called') |