Retrieves the content of the most recent assistant message from a client's session history.
This function fetches the raw history for a specified client using getRawHistory and finds the last entry where the role is "assistant".
It is wrapped in beginContext for a clean execution environment and logs the operation if enabled via GLOBAL_CONFIG. The result is the content
of the last assistant message as a string, or null if no assistant message exists in the history.
Parameters
clientId: string
The unique identifier of the client session whose last assistant message is to be retrieved.
Returns Promise<string>
A promise that resolves to the content of the last assistant message, or null if none is found.
Throws
If getRawHistory fails due to session validation or history retrieval issues.
Example
constlastMessage = awaitgetLastAssistantMessage("client-123"); console.log(lastMessage); // Outputs the last assistant message or null
Retrieves the content of the most recent assistant message from a client's session history.
This function fetches the raw history for a specified client using
getRawHistory
and finds the last entry where the role is "assistant". It is wrapped inbeginContext
for a clean execution environment and logs the operation if enabled viaGLOBAL_CONFIG
. The result is the content of the last assistant message as a string, ornull
if no assistant message exists in the history.