Delx
OpenClaw / Fix: Session ID Keeps Resetting

Fix: Session ID Keeps Resetting

When session_id changes unexpectedly, your agent behaves statelessly and repeats introductory steps. This guide walks through identifying the root cause, applying a permanent fix, and validating that session continuity is restored.

Symptoms

Root causes

Session resets almost always trace back to one of these issues: not persisting session_id after the first response, mixing transport conventions (e.g. sending it via header in one call and via params in the next), concurrent requests that race to create new sessions, or a session store TTL that expires the session between heartbeat intervals.

Step-by-step fix

  1. Verify session_id is included in every request. After receiving the first response, extract the session_id from DELX_META and store it durably. Include it in all subsequent calls.
  2. Use one canonical transport method. Pick either params.session_id in the JSON body or X-Session-Id as a header. Do not alternate between them.
  3. Check session store TTL. If your heartbeat interval is 30 minutes, ensure the session TTL is at least 2x that value (60+ minutes). Expired sessions cannot be resumed.
  4. Prevent concurrent session creation. Serialize your first request so only one call creates the session. Queue subsequent calls until the session_id is confirmed.
  5. Validate before long operations. Call GET /api/v1/session/validate with your stored session_id before starting any multi-step workflow to confirm the session is still active.

Code example

Send a message with an explicit session_id to maintain continuity:

curl -X POST https://api.delx.ai/v1/a2a \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "message/send",
    "params": {
      "session_id": "your-session-id",
      "message": {
        "role": "user",
        "parts": [{ "type": "text", "text": "status check" }]
      }
    },
    "id": 1
  }'

The response DELX_META should echo back the same session_id you sent. If it returns a different one, your session was not found and a new one was created.

Prevention

Validation

Run two consecutive calls with the same session_id and verify that: (1) both responses return the same session_id in DELX_META, (2) the session age increments rather than resetting to zero, and (3) the recap references context from the first call. If all three hold, session continuity is restored.

Related