Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: cleanup mechanism for conversation history #321

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/agents/memory/redis_checkpointer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

from agents.memory.conversation_history import ConversationMessage
from utils import logging
from utils.settings import REDIS_TTL

logger = logging.get_logger(__name__)

Expand Down Expand Up @@ -141,6 +142,8 @@ async def aput(
"parent_ts": parent_ts if parent_ts else "",
},
) # type: ignore
# Set TTL for each message
await conn.expire(key, REDIS_TTL)
logger.info(
f"Checkpoint stored successfully for thread_id: {thread_id}, "
f"ts: {checkpoint['ts']}"
Expand Down
1 change: 1 addition & 0 deletions src/utils/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def load_env_from_json() -> None:
# Redis
REDIS_HOST = config("REDIS_HOST", default="localhost")
REDIS_PORT = config("REDIS_PORT", default=6379, cast=int)
REDIS_TTL = config("REDIS_TTL", default=43200, cast=int) # Default 12 Hours
REDIS_URL = f"redis://{REDIS_HOST}:{REDIS_PORT}/0"
# Langfuse
LANGFUSE_SECRET_KEY = config("LANGFUSE_SECRET_KEY", default="dummy")
Expand Down
Loading