sdac-get-conversation-history
Purpose
Retrieves the most recent conversation turns for a session from SDAC.fact_ConversationHistory. Use this to reconstruct context at the start of a multi-turn chat or after a page reload so the agent can refer to prior messages.
Tool type
Deterministic (read-only)
Tool ID
sdac-get-conversation-history
Inputs
conversationId(string, required) -- Session ID returned bysdac-start-conversationmaxTurns(number, optional, default: 10) -- Maximum number of recent turns to retrieve (1-50)
Outputs
turns(array) -- Conversation turns in chronological orderturnNumber(number)role(user|assistant|system)content(string)timestamp(string) -- ISO 8601personnelId(number | null) -- Set if the turn relates to a specific personnel recordruleId(string | null) -- Set if the turn relates to a specific validation rule
totalTurns(number) -- Total turn count for the conversation (may exceedmaxTurns)reportId(string) -- Cost report ID associated with the conversationisExpired(boolean) -- True if the conversation is 90+ days old
Example output
{
"turns": [
{
"turnNumber": 1,
"role": "user",
"content": "Provide the fringe analysis.",
"timestamp": "2026-05-08T14:20:00.000Z",
"personnelId": null,
"ruleId": null
},
{
"turnNumber": 2,
"role": "assistant",
"content": "The fringe increase appears proportional to salary.",
"timestamp": "2026-05-08T14:20:02.000Z",
"personnelId": null,
"ruleId": "FRINGE_VARIANCE"
}
],
"totalTurns": 2,
"reportId": "SDAC-2024-Q2-001",
"isExpired": false
}
Functional details
- Returns an empty
turnsarray (not an error) when the conversation is not found or has expired. - Also exported as
historyToMessages()helper to convert turns into the{ role, content }message format expected by agentgenerate()calls. - Expired conversations return
isExpired: truewithturns: []and the last knownreportId.
Usage notes
- Call at the start of a chat handler to hydrate agent context from prior turns.
- Filter out
role: systemturns before passing history to the LLM (the exported helper does this automatically). - Part of the session management trio:
sdac-start-conversation→sdac-get-conversation-history→sdac-log-conversation-turn.
Implementation details
- Reads from
SDAC.fact_ConversationHistoryviagetConversationHistoryandgetConversationMetadataDB helpers.
Code Location: packages/domain-sdac/src/tools/session/get-conversation-history.tool.ts