* Check if a chunk with the same (session_key, role, content_hash) already exists. * Uses indexed content_hash for O(1) lookup to prevent duplicate ingestion * when agent_end sends the full conversation history every turn.
(sessionKey: string, role: string, content: string)
| 1703 | * when agent_end sends the full conversation history every turn. |
| 1704 | */ |
| 1705 | chunkExistsByContent(sessionKey: string, role: string, content: string): boolean { |
| 1706 | const hash = contentHash(content); |
| 1707 | const row = this.db.prepare( |
| 1708 | "SELECT 1 FROM chunks WHERE session_key = ? AND role = ? AND content_hash = ? LIMIT 1", |
| 1709 | ).get(sessionKey, role, hash); |
| 1710 | return !!row; |
| 1711 | } |
| 1712 | |
| 1713 | /** |
| 1714 | * Find an active chunk with the same content_hash within the same owner (agent dimension). |
no test coverage detected