mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
fix: Replace Event ID generation with UUID4 to prevent SQLite integrity constraint failures
Fixes #719 where duplicate Event IDs caused database constraint violations during streaming responses. Replaces 8-character random string generation with UUID4 to ensure globally unique identifiers. Changes: - Replace Event.new_id() random string approach with uuid.uuid4() - Remove unused random and string imports - Add uuid import Eliminates SQLite UNIQUE constraint failures in streaming scenarios.
This commit is contained in:
@@ -14,9 +14,8 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
import random
|
||||
import string
|
||||
from typing import Optional
|
||||
import uuid
|
||||
|
||||
from google.genai import types
|
||||
from pydantic import alias_generators
|
||||
@@ -132,5 +131,4 @@ class Event(LlmResponse):
|
||||
|
||||
@staticmethod
|
||||
def new_id():
|
||||
characters = string.ascii_letters + string.digits
|
||||
return ''.join(random.choice(characters) for _ in range(8))
|
||||
return str(uuid.uuid4())
|
||||
|
||||
Reference in New Issue
Block a user