Steps to reproduce:
  1. Add a pdf as knowledge to a custom agent.
  2. Then go to media tab and delete that file.
  3. Then go back to the custom agent and the media file still remains as knowledge for the custom agent.
  4. Now ask the custom agent about specific knowledge.
  5. Custom agent will tell you that it has no knowledge even though the file reference is still in the knowledge.
This is quite confusing and misleading. We should either preserve a copy of the media file in the agent, separate from the media tab OR we should not allow deleting of the media file if it is being used by a custom agent. If we go with the 2nd option, we should list the custom agents that are currently using the media files as knowledge. User will be allowed to delete the media file only when no agents have references to it. I prefer the 2nd option since it preserves storage space and keep things tidy but you might have other reasons for the first option.