{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/lexifina/json-schema/lexifina-session-schema.json",
  "title": "Session",
  "description": "An agent session: a conversation that holds one or more runs.",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/lexifina-openapi.json#/components/schemas/Session",
  "properties": {
    "id": {
      "description": "The session id; pass it as session_id to continue the conversation.",
      "title": "Id",
      "type": "string"
    },
    "object": {
      "const": "session",
      "default": "session",
      "title": "Object",
      "type": "string"
    },
    "session_id": {
      "title": "Session Id",
      "type": "string"
    },
    "document_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Document Id"
    },
    "document_title": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Document Title"
    },
    "document_filename": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Document Filename"
    },
    "matter_ids": {
      "default": [],
      "items": {
        "type": "string"
      },
      "title": "Matter Ids",
      "type": "array"
    },
    "user_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The session's owner.",
      "title": "User Id"
    },
    "agent_type": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Agent Type"
    },
    "title": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Title"
    },
    "conversation_tag": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Conversation Tag"
    },
    "preview": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Preview"
    },
    "status": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "idle or running.",
      "title": "Status"
    },
    "last_run_status": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Last Run Status"
    },
    "last_run_at": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Last Run At"
    },
    "run_count": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Run Count"
    },
    "tool_call_count": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Tool Call Count"
    },
    "skill_count": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Skill Count"
    },
    "total_token_count": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Total Token Count"
    },
    "research_policy": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Research Policy"
    },
    "active_attachments": {
      "default": [],
      "items": {},
      "title": "Active Attachments",
      "type": "array"
    },
    "active_folder_scopes": {
      "default": [],
      "items": {},
      "title": "Active Folder Scopes",
      "type": "array"
    },
    "collaboration_mode": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Collaboration Mode"
    },
    "initiator_type": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Initiator Type"
    },
    "execution_mode": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Execution Mode"
    },
    "session_kind": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "root, or child for a sub-agent's session.",
      "title": "Session Kind"
    },
    "root_session_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Root Session Id"
    },
    "parent_session_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Parent Session Id"
    },
    "depth": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Depth"
    },
    "model_target_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Model Target Id"
    },
    "model_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Model Id"
    },
    "live_summary": {
      "anyOf": [
        {
          "$ref": "#/$defs/SessionLiveSummary"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "access": {
      "anyOf": [
        {
          "$ref": "#/$defs/SessionAccess"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "created_at": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Created At"
    },
    "updated_at": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Updated At"
    },
    "archived_at": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Archived At"
    }
  },
  "required": [
    "id",
    "object",
    "session_id",
    "document_id",
    "document_title",
    "document_filename",
    "matter_ids",
    "user_id",
    "agent_type",
    "title",
    "conversation_tag",
    "preview",
    "status",
    "last_run_status",
    "last_run_at",
    "run_count",
    "tool_call_count",
    "skill_count",
    "total_token_count",
    "research_policy",
    "active_attachments",
    "active_folder_scopes",
    "collaboration_mode",
    "initiator_type",
    "execution_mode",
    "session_kind",
    "root_session_id",
    "parent_session_id",
    "depth",
    "model_target_id",
    "model_id",
    "live_summary",
    "access",
    "created_at",
    "updated_at",
    "archived_at"
  ],
  "type": "object",
  "$defs": {
    "SessionAccess": {
      "properties": {
        "role": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Role"
        },
        "read_only": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Read Only"
        },
        "can_write": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Can Write"
        },
        "can_submit": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Can Submit"
        },
        "can_answer_user_input": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Can Answer User Input"
        },
        "can_manage_session": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Can Manage Session"
        },
        "can_manage_sharing": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Can Manage Sharing"
        }
      },
      "title": "SessionAccess",
      "type": "object",
      "required": [
        "role",
        "read_only",
        "can_write",
        "can_submit",
        "can_answer_user_input",
        "can_manage_session",
        "can_manage_sharing"
      ]
    },
    "SessionLiveSummary": {
      "properties": {
        "status": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Status"
        },
        "current_stage": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Current Stage"
        },
        "current_stage_label": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Current Stage Label"
        },
        "overall_progress": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Overall Progress"
        },
        "current_stage_progress": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Current Stage Progress"
        },
        "elapsed_seconds": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Elapsed Seconds"
        },
        "tool_use_count": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Tool Use Count"
        },
        "last_activity_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Last Activity At"
        }
      },
      "title": "SessionLiveSummary",
      "type": "object",
      "required": [
        "status",
        "current_stage",
        "current_stage_label",
        "overall_progress",
        "current_stage_progress",
        "elapsed_seconds",
        "tool_use_count",
        "last_activity_at"
      ]
    }
  }
}