Stop War Room A2A loops and unlock full chat history with dates.
Detect repeating topics and pause A2A, load older messages beyond the old ~120 cap, and show clear date/time stamps on every bubble.
This commit is contained in:
@@ -572,16 +572,36 @@ async def warroom_open_dm(agent_key: str) -> dict[str, Any]:
|
||||
|
||||
|
||||
@router.get("/warroom/rooms/{room_id}/messages")
|
||||
async def warroom_list_messages(room_id: int, limit: int = 100, after_id: int | None = None) -> dict[str, Any]:
|
||||
async def warroom_list_messages(
|
||||
room_id: int,
|
||||
limit: int = 500,
|
||||
after_id: int | None = None,
|
||||
before_id: int | None = None,
|
||||
) -> dict[str, Any]:
|
||||
from app.services import agent_chat
|
||||
|
||||
agent_chat.ensure_warroom()
|
||||
room = agent_chat.get_room(room_id)
|
||||
if not room:
|
||||
raise HTTPException(404, "Room niet gevonden")
|
||||
items = agent_chat.list_messages(room_id, limit=min(limit, 300), after_id=after_id)
|
||||
lim = min(max(1, limit), 5000)
|
||||
items = agent_chat.list_messages(
|
||||
room_id, limit=lim, after_id=after_id, before_id=before_id
|
||||
)
|
||||
deleted_ids = agent_chat.list_deleted_ids(room_id) if after_id else []
|
||||
return {"ok": True, "room": room, "items": items, "deleted_ids": deleted_ids}
|
||||
total = agent_chat.count_messages(room_id)
|
||||
oldest = agent_chat.oldest_message_id(room_id)
|
||||
first_id = int(items[0]["id"]) if items else None
|
||||
has_more = bool(oldest is not None and first_id is not None and first_id > oldest)
|
||||
return {
|
||||
"ok": True,
|
||||
"room": room,
|
||||
"items": items,
|
||||
"deleted_ids": deleted_ids,
|
||||
"total": total,
|
||||
"has_more": has_more,
|
||||
"oldest_id": oldest,
|
||||
}
|
||||
|
||||
|
||||
@router.post("/warroom/rooms/{room_id}/messages")
|
||||
|
||||
Reference in New Issue
Block a user