fix(chat): audit fixes — retention, rag_project_id, cleanup scheduler, tool rounds
- cleanup_old_conversations now excludes briefing conversations (was silently deleting briefing history after the retention window) - list_conversations response now includes rag_project_id, matching the shape returned by the single-conversation GET endpoint - create_conversation_from_article: removed duplicate async_session import (_session2 was a copy of the same import); consolidated into one - MAX_TOOL_ROUNDS fixed from 5→6 to match the actual range(6) loop; loop updated to range(MAX_TOOL_ROUNDS) so the constant is accurate - Chat retention cleanup moved from per-request (every GET /conversations) to a daily scheduled job in event_scheduler.py; route no longer runs a DB write on every read Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -81,6 +81,7 @@ async def list_conversations(
|
||||
"model": conv.model,
|
||||
"conversation_type": conv.conversation_type,
|
||||
"briefing_date": conv.briefing_date.isoformat() if conv.briefing_date else None,
|
||||
"rag_project_id": conv.rag_project_id,
|
||||
"message_count": row[1],
|
||||
"created_at": conv.created_at.isoformat(),
|
||||
"updated_at": conv.updated_at.isoformat(),
|
||||
@@ -131,8 +132,9 @@ async def cleanup_old_conversations(user_id: int, days: int) -> int:
|
||||
.where(
|
||||
Conversation.user_id == user_id,
|
||||
Conversation.updated_at < cutoff,
|
||||
Conversation.conversation_type != "mcp", # preserve MCP audit trail
|
||||
Conversation.conversation_type != "voice", # voice convs managed separately
|
||||
Conversation.conversation_type != "mcp", # preserve MCP audit trail
|
||||
Conversation.conversation_type != "voice", # voice convs managed separately
|
||||
Conversation.conversation_type != "briefing", # briefing history managed by briefing system
|
||||
)
|
||||
.returning(Conversation.id)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user