QoderSDKClient starts a brand new session with each connection. Through several fields in QoderAgentOptions, you can specify a session ID, resume a historical session, or fork from an existing session.
Concepts
A session corresponds to a persisted conversation history on the CLI side (including context, tool call records, compaction boundaries, etc.), identified by a UUID. Theinit system message contains the current session_id, which also serves as the anchor point for subsequent resume / fork_session operations.
Creating New Sessions
Default
Without passing any session-related fields, a new session is created each time:Specifying a Session ID
Let the caller determine the session UUID (suitable when the host manages its own session index):Resuming Sessions
Resume by ID
Resume the Most Recent
When you don’t know the session ID, usecontinue_conversation=True to pick up the most recently modified session:
resume and continue_conversation simultaneously.
Forking Sessions
Derive a new session from an existing one, preserving the original context but obtaining a new session ID. The original session is unaffected:Field Reference
| Field | Type | Behavior |
|---|---|---|
session_id | str | Used alone: creates with this ID; with fork_session: ID of the new forked session |
resume | str | Session ID to resume |
continue_conversation | bool | True resumes the most recent session |
fork_session | bool | Used with resume; forks rather than continues |
Getting the Current Session ID
Thedata dict of the init system message carries session_id; ResultMessage carries it too. Either can be used for bookkeeping: