Skip to content
Changelog

CodeMode lets an agent write Python that calls your tools directly

ContributorAshpreet BediFounder & CEO

August 24, 20261 min read

CodeMode is a new toolkit that gives an agent a persistent Python kernel in place of a long list of individual tool calls. The model gets two tools, execute and restart. It writes Python in execute and calls your tools as awaitable handles, composing them with variables, loops, and helper functions in a single cell.

Previously, an agent with many tools worked one call at a time, round-tripping each result through the transcript and filling the context window with intermediate output. Now that composition happens in the kernel, and anything the model set up, from a variable to a parsed tool result, stays available across turns. Writing real code also lets the model use actual control flow instead of approximating it call by call.

CodeMode needs extra dependencies that aren't in base Agno. Install them with pip install 'agno[code]', which pulls in ipykernel, jupyter_client, and dill. Without them, importing the toolkit raises an ImportError.

It is also not a sandbox and does not pretend to be one. It runs Python and shell with the same permissions as the process running your agent, and it restores session snapshots by unpickling them, so resuming a session also executes code. Run it with a trusted operator or inside an isolated container, and keep untrusted input away from it.

# pip install 'agno[code]'
from agno.agent import Agent
from agno.tools.code.code_mode import CodeMode
 
agent = Agent(tools=[CodeMode(tools=[...])])

See the cookbook for reference.

Shipped around the same time