fix(consolidation): pass parsed agentUUID to ExistsBySourceID (#809, #824)

Line 52 parses agent_id into agentUUID but line 59 passed the raw
event.AgentID string to ExistsBySourceID. PR #826 fixed the emission
side (loop_finalize.go) so event.AgentID is now always a valid UUID,
but the consumption side kept the inconsistent parse-then-discard
pattern.

Use agentUUID.String() to keep the parse-once-use-parsed invariant,
matching the tenantUUID pattern two lines above. Fixes the
"invalid input syntax for type uuid" error reported in #809 and the
downstream "..." Telegram symptom in #824 where episodic failure
cascaded into empty agent replies.
This commit is contained in:
viettranx
2026-04-18 14:52:18 +07:00
parent 91d79ce120
commit 564997cfae
+1 -1
View File
@@ -56,7 +56,7 @@ func (w *episodicWorker) Handle(ctx context.Context, event eventbus.DomainEvent)
// Build source_id for idempotency
sourceID := fmt.Sprintf("%s:%d", payload.SessionKey, payload.CompactionCount)
exists, err := w.store.ExistsBySourceID(ctx, event.AgentID, event.UserID, sourceID)
exists, err := w.store.ExistsBySourceID(ctx, agentUUID.String(), event.UserID, sourceID)
if err != nil {
return fmt.Errorf("episodic: check source_id: %w", err)
}