The state endpoints give you a structured, queryable view of everything Spectron has learned within a given scope. Rather than replaying the conversation history, you query the current knowledge graph directly – grouped by category and filtered by scope – and receive a clean, structured representation of what the agent knows.
The /state endpoint
The scope parameters filter the state to the specified dimensional intersection. Omitting a dimension broadens the query – scope[org]=acme without a user returns the union of all user-level knowledge for that organisation.
Response:
Response structure
| Field | Description |
|---|---|
identity | Named entities and their current attributes within this scope. |
knowledge | Extracted facts and relations that are not directly tied to the scoped entity. |
context | Conversational context: recent topics, open threads, pending questions. |
instructions | Persistent behavioural directives extracted from the conversation. |
unknowns | Statements flagged as uncertain or unverified. |
corrections | Attributes that were corrected, with their previous and current values. |
The state endpoint always returns the current, canonical view. Superseded attributes are not present in identity.attributes – they appear only in corrections as the previous side of a correction record.
The /state/diff endpoint
The diff endpoint returns only what changed since a given turn. This is more efficient than polling the full state on every message.
Response:
Pass the turn_id returned from a previous session.turn() call as the since parameter. The response contains only records that were added, updated, or superseded after that turn.
Use this endpoint to drive incremental UI updates. After each message, fetch the diff since the previous turn and apply only the changed records rather than re-rendering the entire state.
Python SDK
The scope parameter is optional. If omitted, the SDK uses the scope from the active session.
JavaScript SDK
Profile endpoint
The profile endpoint returns a richer, opinionated view of a single user's memory – pre-formatted for prompt injection or display in account or preferences UIs.
Python SDK
JavaScript SDK
Response shape:
| Field | Description |
|---|---|
static | Stable identity facts: name, role, organisation, contact details. |
dynamic | Frequently-updated attributes: location, status, current project, mood. |
preferences | Extracted preferences and stated likes or dislikes. |
instructions | Active behavioural directives applicable to this user. |
The profile view does not include raw turn references. It is a synthesised snapshot intended for injection into system prompts or display in a "what does the AI know about me?" UI.
Using diffs for real-time UI updates
A common pattern is to store the turn_id returned from each session.turn() call and use it to fetch incremental diffs immediately after the model responds:
The corrections format in detail
Corrections are produced during reconciliation whenever a newly extracted attribute contradicts an existing one. Each correction record contains both sides of the change and the turn references that establish provenance:
valid_until on the previous record is set to just before the correction timestamp, preserving a temporally accurate record of when the prior value was valid. This allows historical queries – "what did the agent know about Alice's location in March 2026?" – to return the correct answer.
Corrections accumulate and are never deleted. The full supersession chain for any attribute is always queryable, which means the audit trail for any fact is complete and irrevocable. See Temporal validity and Reconciliation and supersession for the detailed model.