Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

866 B
Raw Blame
import { AgentRunSource } from '@activepieces/shared'
import { FastifyBaseLogger } from 'fastify'
import { repoFactory } from '../../core/db/repo-factory'
import { executionDataRetention } from '../../helper/retention/execution-data-retention'
import { AgentConversationEntity } from './agent-conversation-entity'

const conversationRepo = repoFactory(AgentConversationEntity)

export const agentRetention = (log: FastifyBaseLogger) => ({
    async deleteStaleFlowStepConversations(): Promise<void> {
        await executionDataRetention.sweep({
            repo: conversationRepo,
            alias: 'conversation',
            scopeCondition: {
                condition: 'conversation.source = :source',
                parameters: { source: AgentRunSource.FLOW_STEP },
            },
            logLabel: 'agentRetention',
            log,
        })
    },
})