Skip to main content

Overview

The update() method allows you to modify an existing session after it has been created. This is useful when you need to update session metadata, status, or other properties.

Parameters

session_id
string
The ID of the session to update.
custom_id
string
The custom ID associated with the session.
context
string
The context provided to the AI product during the session or ground-truth related context.
metadata
object
Additional metadata to associate with the session.
error
string
Any error message associated with the session. This is useful for tracking failed sessions or sessions that encountered issues.

Returns

Returns the updated Session object.

Example

updated_session = galtea.sessions.update(
    session_id=session_id,
    custom_id=custom_session_id + "_" + run_identifier,
    metadata={"updated_at": run_identifier},
)

Use Cases

Recording Session Errors

Store error information when a session encounters issues:
try:
    # Your agent logic that might fail
    raise Exception("Connection timeout")
except Exception as e:
    # Record the error in the session
    galtea.sessions.update(
        session_id=session.id,
        error=str(e),
    )

Adding Session Metadata

Update a session with additional metadata:
galtea.sessions.update(
    session_id=session.id,
    metadata={
        "user_tier": "premium",
        "source": "mobile_app",
        "language": "en",
    },
)

Notes

Only include fields you want to update. Fields not specified will remain unchanged.
  • Pass None explicitly to clear a field’s value