> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Gateway Session Protocol • Rust AI Agent SDK

> GatewaySessionProtocol: Protocol for gateway session management. Sessions track conversations between clients and agents, maintaining state and message history.

# GatewaySessionProtocol

> Defined in the [**gateway**](../modules/gateway) module.

<Badge color="orange">Rust AI Agent SDK</Badge>

Protocol for gateway session management. Sessions track conversations between clients and agents, maintaining state and message history.

## Methods

### `session_id`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn session_id(&self) -> &str
```

Unique session identifier.

### `agent_id`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn agent_id(&self) -> Option<&str>
```

ID of the agent handling this session.

### `client_id`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn client_id(&self) -> Option<&str>
```

ID of the client in this session.

### `is_active`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn is_active(&self) -> bool
```

Whether the session is currently active.

### `created_at`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn created_at(&self) -> f64
```

Session creation timestamp.

### `last_activity`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn last_activity(&self) -> f64
```

Last activity timestamp.

### `get_state`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn get_state(&self) -> HashMap<String, serde_json::Value>
```

Get session state.

### `set_state`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn set_state(&mut self, key: &str, value: serde_json::Value) -> ()
```

Set a session state value.

**Parameters:**

| Name    | Type                |
| ------- | ------------------- |
| `key`   | `&str`              |
| `value` | `serde_json::Value` |

### `add_message`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn add_message(&mut self, message: GatewayMessage) -> ()
```

Add a message to the session history.

**Parameters:**

| Name      | Type             |
| --------- | ---------------- |
| `message` | `GatewayMessage` |

### `get_messages`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn get_messages(&self, limit: Option<usize>) -> Vec<GatewayMessage>
```

Get session message history.

**Parameters:**

| Name    | Type                  |
| ------- | --------------------- |
| `limit` | `Option&lt;usize&gt;` |

### `close`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn close(&mut self) -> ()
```

Close the session.

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-rust/praisonai/src/gateway/mod.rs">
  `praisonai/src/gateway/mod.rs` at line 0
</Card>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Rust Sessions" icon="clock" href="/docs/rust/sessions" />

  <Card title="Rust Memory" icon="database" href="/docs/rust/memory" />

  <Card title="Rust Gateway" icon="tower-broadcast" href="/docs/rust/gateway" />
</CardGroup>
