# Cached tools now release agent state after each run

> On Python 3.13, Agno's cached tool wrappers now drop the frame that built them, so the Agent, session and run state are freed when a run finishes.

- Published: 2026-09-08
- Author: Bas Nijholt
- Categories: Changelog
- Canonical: https://www.agno.com/articles/cached-tools-now-release-agent-state-after-each-run
- Markdown: https://www.agno.com/articles/cached-tools-now-release-agent-state-after-each-run.md

On Python 3.13, a long-running Agno process held on to Agent, session and run state for as long as it lived. The leak came from Agno's cached tool wrappers.

Pydantic's `validate_call` stores the caller's local variables on each wrapper it builds, and Agno caches those tool wrappers for the life of the process. On Python 3.13, every cached tool kept alive its building frame, which held the Agent, session and run state from the stack.

Agno now clears the frame reference once the validators are built.

![Two reference chains compared. Before, the tool cache, which lives as long as the process, held the validate_call wrapper, which held the caller's frame, which held the Agent, session and run state, so none of it was ever freed. Now the link from the wrapper to the frame is cut, and the frame and the state are released after the run.](https://www.agno.com/images/v3-0-7-cached-tool-references.png)

Learn more about [Python functions as tools](https://docs.agno.com/tools/creating-tools/python-functions) in the documentation.
