Skip to main content

sessions

Creates, updates, deletes, gets or lists a sessions resource.

Overview​

Namesessions
TypeResource
Iddatabricks_workspace.agentkit.sessions

Fields​

The following fields are returned by SELECT queries:

NameDatatypeDescription
namestringResource name in the form ``session-stores/{session_store_id}/sessions/{session_id}``.
actor_idstringOpaque caller-provided identifier for the application actor associated with the session. This is application data and has no Databricks authentication or authorization semantics. Use the same value as the Managed Memory Entry ``actor_id`` when storing memories associated with this actor. Every session must set it. A child session must use the same value as its parent.
parent_session_idstringImmediate parent session ID. Set only at creation for child sessions, immutable thereafter, and restricted to the same store.
root_session_idstringTop-level session ID in the spawn tree. This equals ``session_id`` for a root or fork and is inherited transitively by child sessions.
session_idstringUnique session ID. The service generates a UUID unless the caller supplies ``CreateSessionRequest.session_id``.
create_timestring (date-time)Time when the session was created.
last_activity_timestring (date-time)Time when the session's item history was last mutated.
metadataobjectMutable caller-defined string labels.
update_timestring (date-time)Time when session resource fields last changed.

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectsession_store_id, session_id, deployment_name, workspace_domainGets a session by resource name.
listselectsession_store_id, deployment_name, workspace_domainfilter, order_by, page_size, page_tokenLists sessions within a session store.
createinsertsession_store_id, deployment_name, workspace_domain, actor_idsession_idCreates a session within a session store.
updateupdatesession_store_id, session_id, update_mask, deployment_name, workspace_domain, actor_idUpdates a session's mutable fields.
deletedeletesession_store_id, session_id, deployment_name, workspace_domainDeletes a session, its items, and any descendant sessions recursively. Independently retained memory
extract_memoriesexecsession_store_id, session_id, deployment_name, workspace_domain, memory_storeSynchronously extracts memories from a single session into the given memory store, returning the
forkexecsession_store_id, deployment_name, workspace_domain, source_session_id, actor_idForks a session into an independent top-level copy.

Parameters​

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
deployment_namestringThe Databricks workspace deployment name: the host prefix of the workspace URL (dbc-abcd0123-a1bc on AWS, adb-1234567890123456.7 on Azure, 1234567890123456.7 on GCP). Set DATABRICKS_DEPLOYMENT_NAME to default it for the session. (default: dbc-abcd0123-a1bc, x-stackQL-envVar: DATABRICKS_DEPLOYMENT_NAME)
session_idstringIdentifier of the session whose transcript is distilled into memories.
session_store_idstringThe session_store_id segment of the parent resource name (session-stores/{session_store_id}). Resource name of the containing session store, in the form session-stores/{session_store_id}.
update_maskobjectFields to update. Only metadata is mutable; any other path returns INVALID_PARAMETER_VALUE.
workspace_domainstringThe Databricks workspace domain suffix for the cloud. Selected by DATABRICKS_CLOUD (aws, azure or gcp; default aws). (default: cloud.databricks.com, x-stackQL-envVarSelector: {"envVar":"DATABRICKS_CLOUD","default":"aws","values":{"aws":"cloud.databricks.com","azure":"azuredatabricks.net","gcp":"gcp.databricks.com"}})
filterstringFilter expression. Supported fields include actor_id and metadata; for example, actor_id = "support-customer-123".
order_bystringSort order. Defaults to last_activity_time desc. Page-token continuation is exactly-once when ordering by create_time (immutable); ordering by last_activity_time is best-effort, because that value changes as a session gains activity, so a session updated between page requests may be repeated or skipped. To enumerate every session exactly once, order by create_time.
page_sizeintegerMaximum number of sessions to return. Defaults to 10; must be between 1 and 100.
page_tokenstringToken returned by a previous list request.
session_idstringOptional caller-selected session ID. The service generates a UUID when this field is omitted. The ID must be unique; a collision returns ALREADY_EXISTS.

SELECT examples​

Gets a session by resource name.

SELECT
name,
actor_id,
parent_session_id,
root_session_id,
session_id,
create_time,
last_activity_time,
metadata,
update_time
FROM databricks_workspace.agentkit.sessions
WHERE session_store_id = '{{ session_store_id }}' -- required
AND session_id = '{{ session_id }}' -- required
AND deployment_name = '{{ deployment_name }}' -- required
AND workspace_domain = '{{ workspace_domain }}' -- required
;

INSERT examples​

Creates a session within a session store.

INSERT INTO databricks_workspace.agentkit.sessions (
actor_id,
create_time,
last_activity_time,
metadata,
name,
parent_session_id,
root_session_id,
session_id,
update_time,
session_store_id,
deployment_name,
workspace_domain,
session_id
)
SELECT
'{{ actor_id }}' /* required */,
'{{ create_time }}',
'{{ last_activity_time }}',
'{{ metadata }}',
'{{ name }}',
'{{ parent_session_id }}',
'{{ root_session_id }}',
'{{ session_id }}',
'{{ update_time }}',
'{{ session_store_id }}',
'{{ deployment_name }}',
'{{ workspace_domain }}',
'{{ session_id }}'
RETURNING
name,
actor_id,
parent_session_id,
root_session_id,
session_id,
create_time,
last_activity_time,
metadata,
update_time
;

UPDATE examples​

Updates a session's mutable fields.

UPDATE databricks_workspace.agentkit.sessions
SET
actor_id = '{{ actor_id }}',
create_time = '{{ create_time }}',
last_activity_time = '{{ last_activity_time }}',
metadata = '{{ metadata }}',
name = '{{ name }}',
parent_session_id = '{{ parent_session_id }}',
root_session_id = '{{ root_session_id }}',
session_id = '{{ session_id }}',
update_time = '{{ update_time }}'
WHERE
session_store_id = '{{ session_store_id }}' --required
AND session_id = '{{ session_id }}' --required
AND update_mask = '{{ update_mask }}' --required
AND deployment_name = '{{ deployment_name }}' --required
AND workspace_domain = '{{ workspace_domain }}' --required
AND actor_id = '{{ actor_id }}' --required
RETURNING
name,
actor_id,
parent_session_id,
root_session_id,
session_id,
create_time,
last_activity_time,
metadata,
update_time;

DELETE examples​

Deletes a session, its items, and any descendant sessions recursively. Independently retained memory

DELETE FROM databricks_workspace.agentkit.sessions
WHERE session_store_id = '{{ session_store_id }}' --required
AND session_id = '{{ session_id }}' --required
AND deployment_name = '{{ deployment_name }}' --required
AND workspace_domain = '{{ workspace_domain }}' --required
;

Lifecycle Methods​

Synchronously extracts memories from a single session into the given memory store, returning the

EXEC databricks_workspace.agentkit.sessions.extract_memories
@session_store_id='{{ session_store_id }}' --required,
@session_id='{{ session_id }}' --required,
@deployment_name='{{ deployment_name }}' --required,
@workspace_domain='{{ workspace_domain }}' --required
@@json=
'{
"memory_store": "{{ memory_store }}",
"dry_run": {{ dry_run }},
"instructions": "{{ instructions }}"
}'
;