API Documentation
Low-latency key-value state plane for ephemeral workflow context, checkpoints, and task-scoped execution memory.
Overview
Agent State provides short-term, task-scoped storage for agentic workflows. Unlike memories (long-term facts), state tracks the agent's current working context: task progress, pending actions, and session variables.
Use cases: Multi-step task automation, workflow position tracking, pending tool call results, session variables, and resumable conversations.
PUT /state/:key
Create or update agent state for a given key.
X-Subject-IDrequiredX-Session-IDvaluerequiredttl_secondscurl -X PUT "https://www.mnexium.com/api/v1/state/current_task" \
-H "x-mnexium-key: $MNX_KEY" \
-H "Content-Type: application/json" \
-H "X-Subject-ID: user_123" \
-d '{
"value": {
"status": "in_progress",
"task": "Plan trip to Tokyo",
"steps_completed": ["research", "book_flights"],
"next_step": "book_hotels"
},
"ttl_seconds": 3600
}'GET /state/:key
Retrieve agent state for a given key.
X-Subject-IDrequiredcurl "https://www.mnexium.com/api/v1/state/current_task" \
-H "x-mnexium-key: $MNX_KEY" \
-H "X-Subject-ID: user_123"// Response
{
"key": "current_task",
"value": {
"status": "in_progress",
"task": "Plan trip to Tokyo",
"next_step": "book_hotels"
},
"ttl": "2025-01-01T12:00:00Z",
"updated_at": "2025-01-01T11:00:00Z"
}DELETE /state/:key
Delete agent state (soft delete via TTL expiration).
X-Subject-IDrequiredState Injection in Proxy
Load and inject agent state into LLM context via the mnx.state config:
curl -X POST "https://www.mnexium.com/api/v1/chat/completions" \ -H "x-mnexium-key: $MNX_KEY" \ -H "x-openai-key: $OPENAI_KEY" \ -d '{ "model": "gpt-4o-mini", "messages": [{ "role": "user", "content": "What should I do next?" }], "mnx": { "subject_id": "user_123", "state": { "load": true, "key": "current_task" } } }'When state.load: true, the agent's current state is injected as a system message, allowing the LLM to resume tasks and avoid repeating completed work.
Key Naming Conventions
Recommended patterns for state keys:
current_taskDefault key for general task statetask:onboardingNamed workflow statetool:weather:tc_123Pending tool call resultflow:checkoutMulti-step flow position