feat: add retention policy for agent chats#4039
feat: add retention policy for agent chats#40390vertake wants to merge 23 commits intosuperplanehq:mainfrom
Conversation
|
👋 Commands for maintainers:
|
|
@0vertake now that the agent service is talking with the usage service, I think the retention policy configuration should be based on the limit for retention policy for the organization. @forestileao can you help here? |
I will need to add a retention policy limit to agent chats on usage service. Then he will only need to grab this value to cleanup stuff. |
|
@forestileao can't we just use the same retention policy we have there for everything else already? |
We can, no problem. Unless we want to make different policies, but I don't think we need |
e398aae to
0c9823c
Compare
Remove agent chats from the database based on each organization's retention window from the usage service, falling back to a configurable default (AGENT_CHAT_RETENTION_DAYS, default 14 days, 0 to disable). - Add per-org delete_expired_chats_for_org to SessionStore with batched DELETEs and a race-safe outer WHERE clause for READ COMMITTED isolation - Query each org's retention_window_days via the usage service gRPC; fall back to the env var default when the service is unavailable - Add background async task (chat_retention.py) wired into the FastAPI lifespan, checking once per hour - Add updated_at index on agent_chats for query performance - Fix missing await on UsageLimitChecker.close() - Add unit tests for the store method and the retention loop Closes superplanehq#3818 Signed-off-by: Milos Jovanovic <milosjovanovic519@gmail.com> Made-with: Cursor
0c9823c to
8e6974d
Compare
Signed-off-by: Milos Jovanovic <milosjovanovic519@gmail.com>
Signed-off-by: Milos Jovanovic <milosjovanovic519@gmail.com>
Signed-off-by: Milos Jovanovic <milosjovanovic519@gmail.com>
Signed-off-by: Milos Jovanovic <milosjovanovic519@gmail.com>
Signed-off-by: Milos Jovanovic <milosjovanovic519@gmail.com>
Signed-off-by: Milos Jovanovic <milosjovanovic519@gmail.com>
Signed-off-by: Milos Jovanovic <milosjovanovic519@gmail.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 2feebfb. Configure here.
Signed-off-by: Milos Jovanovic <milosjovanovic519@gmail.com>
Signed-off-by: Milos Jovanovic <milosjovanovic519@gmail.com>

Summary
Closes #3818