Clean multimodal tool results before storage (#911)
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
import { isSqliteAvailable, getDb } from '../index'
|
||||
import { SESSIONS_TABLE, MESSAGES_TABLE } from './schemas'
|
||||
import { normalizeMessageContentForStorageRole } from './message-content'
|
||||
|
||||
// Re-export types for compatibility with sessions-db.ts consumers
|
||||
export interface HermesSessionRow {
|
||||
@@ -377,7 +378,7 @@ export function addMessage(msg: {
|
||||
`INSERT INTO ${MESSAGES_TABLE} (session_id, role, content, tool_call_id, tool_calls, tool_name, timestamp, token_count, finish_reason, reasoning, reasoning_details, reasoning_content)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
).run(
|
||||
msg.session_id, msg.role, msg.content,
|
||||
msg.session_id, msg.role, normalizeMessageContentForStorageRole(msg.role, msg.content),
|
||||
msg.tool_call_id ?? null, toolCallsJson, msg.tool_name ?? null,
|
||||
msg.timestamp ?? Math.floor(Date.now() / 1000),
|
||||
msg.token_count ?? null, msg.finish_reason ?? null,
|
||||
@@ -412,7 +413,7 @@ export function addMessages(msgs: Array<{
|
||||
for (const msg of msgs) {
|
||||
const toolCallsJson = msg.tool_calls ? JSON.stringify(msg.tool_calls) : null
|
||||
insert.run(
|
||||
msg.session_id, msg.role, msg.content,
|
||||
msg.session_id, msg.role, normalizeMessageContentForStorageRole(msg.role, msg.content),
|
||||
msg.tool_call_id ?? null, toolCallsJson, msg.tool_name ?? null,
|
||||
msg.timestamp ?? Math.floor(Date.now() / 1000),
|
||||
msg.token_count ?? null, msg.finish_reason ?? null,
|
||||
|
||||
Reference in New Issue
Block a user