You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
expires_in=expires_in_hours(12), # optional — default is 24 h (Agora max)
44
+
)
45
+
46
+
# start() returns a session ID unique to this agent session
47
+
agent_session_id = session.start()
48
+
49
+
# In production, stop is typically called when your client signals the session has ended.
50
+
# Your server receives that request and calls session.stop().
51
+
session.stop()
52
+
```
53
+
54
+
For async usage, use `AsyncAgora` and `await session.start()`, etc. See [Quick Start](docs/getting-started/quick-start.md).
55
+
56
+
### Session lifecycle
57
+
58
+
`start()` joins the agent to the channel and returns a **session ID** — a unique identifier for this agent session. The session stays active until `stop()` is called.
59
+
60
+
There are two ways to stop a session depending on how your server is structured:
61
+
62
+
**Option 1 — Hold the session in memory:**
63
+
64
+
```python
65
+
# start-session handler
66
+
agent_session_id = session.start() # unique ID for this session
67
+
# stop-session handler (same process, session still in scope)
39
68
session.stop()
40
69
```
41
70
42
-
For async usage, use `AsyncAgora` and `await session.start()`, `await session.say()`, etc. See [Quick Start](docs/getting-started/quick-start.md).
71
+
**Option 2 — Store the session ID and stop by ID (stateless servers):**
72
+
73
+
```python
74
+
# start-session handler: return session ID to your client app
75
+
agent_session_id = session.start()
76
+
# ... return agent_session_id to client ...
77
+
78
+
# stop-session handler: client sends back agent_session_id
0 commit comments