Skip to content
Changelog

ReaderFactory builds a fresh reader on every call

October 27, 20261 min read

Agno's ReaderFactory.create_reader() now constructs a new reader on every call and hands it the keyword arguments you pass. Earlier releases kept one cached reader per type, so the first call's options won for the rest of the process.

Knowledge picks readers by file extension through this factory, which meant two knowledge bases in one process shared the same reader object. Changing chunk_size on one quietly changed it for the other.

from agno.knowledge.reader.reader_factory import ReaderFactory
 
a = ReaderFactory.create_reader("text", chunk_size=200)
b = ReaderFactory.create_reader("text", chunk_size=1000)
print(a.chunk_size, b.chunk_size, a is b)
 
c = ReaderFactory.create_reader("text")
c.chunk_size = 50
print(ReaderFactory.create_reader("text").chunk_size)

Real output, earlier release and this release:

# Before
200 200 True
50
 
# Now
200 1000 False
5000

ReaderFactory.clear_cache() is now a no-op kept for backward compatibility.

Learn more about reader auto-selection in the documentation.

Frequently asked questions

Earlier releases cached one reader per type and returned it on every later call, so the options from the first call stuck. In this release each call constructs a new reader with the keyword arguments you pass.

No. Readers are no longer cached, and clear_cache() stays only so existing code keeps working.

Not through ReaderFactory anymore. Knowledge picks readers by file extension through the factory, and each pick is now a separate object, so setting an attribute on one leaves the others untouched.

Shipped around the same time