Skip to main content

Overview

The finish() method marks a session as finished when its conversation is over. Finishing sets the session status to COMPLETED and closes it: the session accepts no more turns. Finishing also makes the session eligible for evaluation right away. A Monitor scores only closed sessions, so an explicit finish gets the session picked up on the next scan instead of waiting for the product’s inactivity auto-close window.

Parameters

string
required
The ID of the session to finish.
string
Free-text reason the conversation ended (for example GOAL_ACHIEVED). When omitted, the default FINISHED is sent, because the API requires a non-empty stopping reason.

Returns

Returns the finished Session object, with status COMPLETED.

Example

To send the default stopping reason, omit the argument:

Notes

Only call finish() when the conversation is truly over. A finished session is closed, so a later attempt to append an inference result follows the product’s closed-session policy: it is either rejected with an error or silently discarded (the default). See Session.
To mark a session as failed instead of completed, use Update Session with status="FAILED" (for example galtea.sessions.update(session_id=..., status="FAILED", error="...")). Setting error alone records the message but leaves the session open.