Coding Agents

Build coding agents that inspect repositories, edit files, run commands, and verify changes.

Coding agents handle repository work that starts with reading the project and ends with verified changes. Agno gives engineering teams scoped workspaces, command boundaries, approval gates, background runs, and a production API for these agents.

import tempfile
from pathlib import Path

from agno.agent import Agent
from agno.tools.coding import CodingTools

project = Path(tempfile.mkdtemp(prefix="coding-agent-"))

(project / "math_utils.py").write_text(
    "def factorial(n: int) -> int:\n"
    "    return 1 if n <= 1 else n * factorial(n - 1)\n"
)

(project / "test_math_utils.py").write_text(
    "import unittest\n\n"
    "from math_utils import factorial\n\n\n"
    "class TestFactorial(unittest.TestCase):\n"
    "    def test_factorial(self):\n"
    "        self.assertEqual(factorial(5), 120)\n\n\n"
    "if __name__ == '__main__':\n"
    "    unittest.main()\n"
)

coding_agent = Agent(
    name="Coding Agent",
    model="openai:gpt-5.5",
    tools=[
        CodingTools(
            base_dir=project,
            restrict_to_base_dir=True,
            all=True,
            allowed_commands=["python3"],
        )
    ],
    instructions=[
        "Read existing files before changing them.",
        "Make focused edits.",
        "Run the test suite after every change.",
        "Report the files changed and the final test result.",
    ],
)

coding_agent.print_response(
    "Update factorial() to reject negative inputs, add a regression test, "
    "then run python3 -m unittest -v.",
    stream=True,
)

Create a virtual environment, install the OpenAI integration, and set OPENAI_API_KEY before running the agent:

uv venv --python 3.12
uv pip install -U "agno[openai]"
export OPENAI_API_KEY="your_openai_api_key"
uv run python coding_agent.py

The example creates a fresh fixture on every run. base_dir scopes file operations to that directory. allowed_commands limits shell entry points to python3.

base_dir limits file paths. The process still inherits the host environment, network access, and operating-system permissions. Run untrusted code inside a dedicated container, virtual machine, or remote sandbox.

To give Codex, Claude Code, Cursor, or another client access to Agno documentation, see Connect your coding agent.

Common patterns

PatternAgent task
Repository onboardingMap the project and answer questions with file references.
Bug fixingReproduce a failure, make a focused change, and rerun the failing tests.
Code reviewInspect a diff, run targeted checks, and return prioritized findings.
Dependency upgradesUpdate a dependency, resolve compatibility failures, and run the project gates.
CI remediationRead failure logs, reproduce the failure, patch the cause, and verify the fix.
MigrationsApply repeatable changes across files and report unresolved cases.

Choose the execution boundary

RequirementUse
Compact tools for a trusted local projectCodingTools with a scoped base_dir and narrow allowed_commands.
Read-only repository analysisWorkspace with allowed=["read", "list", "search"].
Approval before edits or shell commandsWorkspace with its default confirmation policy and require_read_before_write=True.
Execute untrusted code remotelyDaytona or E2B.
Execute untrusted code on your infrastructureRun the agent inside a dedicated container or virtual machine.

Define the engineering loop

StageBoundary
UnderstandRead and search the relevant files before proposing a change.
ChangeKeep edits focused and require confirmation when the workspace is not disposable.
VerifyRun the repository's tests, lint, type checks, and build inside the execution environment.
ReviewReturn changed files, command results, and unresolved risks.
PublishKeep commits, pushes, pull requests, and deployments outside the default loop or expose them as separately gated tools.

Production path

NeedAgno capability
Serve coding tasks through an APIRegister the agent with AgentOS.
Continue after the client disconnectsUse background execution.
Pause before edits or shell commandsUse Workspace confirmation with AgentOS HITL.
Authenticate CI and machine callersMint a scoped service account.
Inspect model calls, tool arguments, and failuresConfigure a database and enable observability.
Catch behavioral regressionsRun coding tasks against fresh fixture repositories with an eval suite.

Evaluate coding agents

Quality layerCheck
Project gatesCompile the project and run its unit, integration, lint, and type checks inside the execution environment.
ReliabilityVerify required tool calls such as reading the target file and running the test command.
Agent as judgeScore whether the change follows the request, stays in scope, and explains its verification.
PerformanceTrack end-to-end runtime and memory use.

Restore the fixture before every eval case so one run cannot affect the next.

Next steps

TaskGuide
Configure the compact coding toolkitCodingTools
Add confirmation-gated workspace accessWorkspace
Isolate remote executionDaytona or E2B
Add behavioral regression casesAgent Evaluation
Serve the agent in productionAgent API