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:
2026-04-04 12:30:41 -04:00
parent edfed6b5bb
commit 738245af5c
4 changed files with 59 additions and 19 deletions
@@ -217,7 +217,7 @@ async def run_generation(
voice_mode: bool = False,
) -> None:
"""Stream LLM response into buffer with periodic DB flushes."""
MAX_TOOL_ROUNDS = 5
MAX_TOOL_ROUNDS = 6
msg_id = buf.assistant_message_id
buf.append_event("status", {"status": "Building context..."})
@@ -294,7 +294,7 @@ async def run_generation(
cancelled = False
research_completed = False
for _round in range(MAX_TOOL_ROUNDS + 1):
for _round in range(MAX_TOOL_ROUNDS):
timing["rounds"] = _round + 1
round_tool_calls: list[dict] = []
logger.info("Generation round %d started for conv %d (model=%s)", _round, conv_id, model)