Engine Endpoints¶
The engine endpoints process observations and produce execution contracts. These are the core of Identity OS.
Process Observation¶
POST /instances/{id}/process
Process a single behavioral observation and get the execution contract.
Path Parameters¶
| Parameter | Type | Notes |
|---|---|---|
id | string | Instance ID (e.g., inst_xxx) |
Request¶
{
"mode_target": "EXPLORATION",
"signal_strength": 0.8,
"confidence": 0.9,
"context": {
"task": "research",
"tool_failed": false
}
}
Fields¶
| Field | Type | Required | Default | Notes |
|---|---|---|---|---|
mode_target | string | Yes | — | Target mode (see modes) |
signal_strength | float | Yes | — | 0.0–1.0, intensity |
confidence | float | No | 1.0 | 0.0–1.0, certainty |
context | object | No | {} | Metadata (arbitrary) |
Modes¶
Valid values for mode_target:
Response¶
{
"data": {
"snapshot": {
"instance_id": "inst_xxx",
"cycle": 42,
"mode_strengths": {
"perception": 0.50,
"exploration": 0.50,
"order": 0.50,
"assertion": 0.50,
"connection": 0.50,
"identity": 0.50,
"stress_response": 0.50
},
"energy_level": 0.50,
"stress_state": "LOW",
"stability_index": 0.50
},
"contract": {
"dominant_modes": ["Order", "Identity"],
"suppressed_modes": ["Exploration"],
"allowed_actions": ["execute", "clarify", "suggest"],
"forbidden_actions": ["pivot", "explore"],
"decision_style": {
"tempo": "decisive",
"risk": "bounded",
"expressiveness": "medium",
"commitment_threshold": "medium"
},
"energy_level": 0.50,
"stress_state": "LOW",
"recovery_profile": {
"preferred_path": "gradual",
"support_required": false,
"cooldown_required": false
}
},
"drift": {
"level": "D0",
"deviation": "..."
}
}
}
Examples¶
Batch Process¶
POST /instances/{id}/process/batch
Process multiple observations in sequence and get the final contract.
Path Parameters¶
| Parameter | Type | Notes |
|---|---|---|
id | string | Instance ID |
Request¶
{
"observations": [
{
"mode_target": "EXPLORATION",
"signal_strength": 0.8,
"confidence": 0.9
},
{
"mode_target": "ORDER",
"signal_strength": 0.7,
"confidence": 0.85
},
{
"mode_target": "ASSERTION",
"signal_strength": 0.6,
"confidence": 0.8
}
],
"include_intermediate": false
}
Fields¶
| Field | Type | Required | Default | Notes |
|---|---|---|---|---|
observations | array | Yes | — | List of observations |
include_intermediate | bool | No | false | Return all intermediate states |
Response (include_intermediate=false)¶
{
"data": {
"snapshot": { /* final state after all 3 observations */ },
"contract": { /* final contract */ },
"drift": { /* final drift classification */ },
"processed_count": 3
}
}
Response (include_intermediate=true)¶
{
"data": {
"states": [
{
"snapshot": { /* after observation 1 */ },
"contract": { /* contract 1 */ },
"drift": { /* drift 1 */ }
},
{
"snapshot": { /* after observation 2 */ },
"contract": { /* contract 2 */ },
"drift": { /* drift 2 */ }
},
{
"snapshot": { /* after observation 3 */ },
"contract": { /* contract 3 */ },
"drift": { /* drift 3 */ }
}
],
"processed_count": 3
}
}
Examples¶
from identity_os_sdk import Mode
result = client.engine.process_batch(
instance_id="inst_xxx",
observations=[
{"mode_target": Mode.EXPLORATION, "signal_strength": 0.8},
{"mode_target": Mode.ORDER, "signal_strength": 0.7},
{"mode_target": Mode.ASSERTION, "signal_strength": 0.6}
],
include_intermediate=False
)
print(f"Processed {result.processed_count} observations")
print(f"Final stress: {result.contract.stress_state}")
Get Snapshot¶
GET /instances/{id}/snapshot
Get the current identity state without processing a new observation.
Path Parameters¶
| Parameter | Type | Notes |
|---|---|---|
id | string | Instance ID |
Response¶
{
"data": {
"instance_id": "inst_xxx",
"cycle": 42,
"mode_strengths": {
"perception": 0.50,
"exploration": 0.50,
"order": 0.50,
"assertion": 0.50,
"connection": 0.50,
"identity": 0.50,
"stress_response": 0.50
},
"energy_level": 0.50,
"stress_state": "LOW",
"stability_index": 0.50,
"cycle_count": 42,
"created_at": "2026-03-24T10:15:30Z",
"updated_at": "2026-03-24T10:45:00Z"
}
}
Examples¶
Get Contract¶
GET /instances/{id}/contract
Get the current execution contract without processing a new observation.
Path Parameters¶
| Parameter | Type | Notes |
|---|---|---|
id | string | Instance ID |
Response¶
{
"data": {
"dominant_modes": ["Order", "Identity"],
"suppressed_modes": ["Exploration"],
"allowed_actions": ["execute", "clarify", "suggest"],
"forbidden_actions": ["pivot", "explore"],
"decision_style": {
"tempo": "decisive",
"risk": "bounded",
"expressiveness": "medium",
"commitment_threshold": "medium"
},
"energy_level": 0.50,
"stress_state": "LOW",
"recovery_profile": {
"preferred_path": "gradual",
"support_required": false,
"cooldown_required": false
}
}
}
Examples¶
Get History¶
GET /instances/{id}/history
Get observation history for an instance.
Path Parameters¶
| Parameter | Type | Notes |
|---|---|---|
id | string | Instance ID |
Query Parameters¶
| Parameter | Type | Default | Notes |
|---|---|---|---|
limit | int | 100 | Max 1000 |
offset | int | 0 | For pagination |
Response¶
{
"data": [
{
"cycle": 42,
"mode_target": "EXPLORATION",
"signal_strength": 0.8,
"confidence": 0.9,
"context": {},
"timestamp": "2026-03-24T10:45:00Z"
},
{
"cycle": 41,
"mode_target": "ORDER",
"signal_strength": 0.7,
"confidence": 0.85,
"context": {},
"timestamp": "2026-03-24T10:44:30Z"
}
],
"pagination": {
"limit": 100,
"offset": 0,
"total": 42,
"has_more": false
}
}
Examples¶
Get Drift Events¶
GET /instances/{id}/drift
Get drift events and classifications for an instance.
Path Parameters¶
| Parameter | Type | Notes |
|---|---|---|
id | string | Instance ID |
Response¶
{
"data": [
{
"cycle": 47,
"drift_level": "D3",
"deviation": "...",
"affected_modes": ["identity", "connection"],
"rolled_back": true,
"timestamp": "2026-03-24T10:50:00Z"
},
{
"cycle": 23,
"drift_level": "D1",
"deviation": "...",
"affected_modes": ["assertion"],
"rolled_back": false,
"timestamp": "2026-03-24T09:45:12Z"
}
],
"pagination": {
"total": 2
}
}
Examples¶
Reset Instance¶
POST /instances/{id}/reset
Reset instance to a previous state.
Path Parameters¶
| Parameter | Type | Notes |
|---|---|---|
id | string | Instance ID |
Request¶
Fields¶
| Field | Type | Required | Options | Notes |
|---|---|---|---|---|
mode | string | Yes | "initial", "default" | Which state to restore |
Response¶
{
"data": {
"id": "inst_xxx",
"reset_to": "initial",
"cycle": 0,
"energy_level": 0.8,
"stress_state": "LOW"
}
}
Examples¶
Throttling¶
The engine enforces a minimum cycle interval to prevent rapid-fire observations:
- Minimum interval: 1.0 second between observations
- Violation: Returns
200 OKwith the previous snapshot unchanged (no new cycle is billed)
Solution: Batch multiple observations with /process/batch or wait 1+ second between calls.
Related Endpoints¶
- Create instance — Create before processing
- Get instance — Instance metadata
- Personas — Reference persona definitions